loki-mode 6.69.0 → 6.69.2
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.
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/dashboard/__init__.py +1 -1
- package/docs/INSTALLATION.md +1 -1
- package/mcp/__init__.py +1 -1
- package/package.json +1 -1
- package/web-app/dist/assets/{Badge-CeqwGFM0.js → Badge-BxiA-JDb.js} +1 -1
- package/web-app/dist/assets/{Button-qiaMm3tV.js → Button-58BwlzCq.js} +1 -1
- package/web-app/dist/assets/{Card-Uav6bI4v.js → Card-C2cxpFNl.js} +1 -1
- package/web-app/dist/assets/{HomePage-CnHzys9u.js → HomePage-DpMzy3Sz.js} +1 -1
- package/web-app/dist/assets/{LoginPage-C5TN24fk.js → LoginPage-DYghO6Uc.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-CRF3pccO.js → NotFoundPage-Dv9wsoCN.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-reLTN0xY.js → ProjectPage-n7r_pWr2.js} +80 -50
- package/web-app/dist/assets/{ProjectsPage-BxvFm4PV.js → ProjectsPage-tZLnZmDW.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-B-_VC6hV.js → SettingsPage-vzIL8d7R.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-3h_qn6Ag.js → TemplatesPage-BpPc7MmM.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-Blk-nLSd.js → TerminalOutput-DW1Q6elC.js} +1 -1
- package/web-app/dist/assets/{arrow-left-oowTfEm_.js → arrow-left-CVP50JWU.js} +1 -1
- package/web-app/dist/assets/{clock-DREWjyYa.js → clock-KWo-YzsE.js} +1 -1
- package/web-app/dist/assets/{external-link-C6nfCPLP.js → external-link-BGj_qdwC.js} +1 -1
- package/web-app/dist/assets/index-MWlxNCt7.css +1 -0
- package/web-app/dist/assets/{index-B79IKKoY.js → index-UD3Q__HZ.js} +2 -2
- package/web-app/dist/index.html +2 -2
- package/web-app/dist/assets/index-BChSxZgM.css +0 -1
|
@@ -1,115 +1,145 @@
|
|
|
1
|
-
var
|
|
1
|
+
var yn=e=>{throw TypeError(e)};var wn=(e,t,i)=>t.has(e)||yn("Cannot "+i);var li=(e,t,i)=>(wn(e,t,"read from private field"),i?i.call(e):t.get(e)),xn=(e,t,i)=>t.has(e)?yn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),Cn=(e,t,i,s)=>(wn(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i);import{c as oe,r as g,W as Gt,j as c,a as ee,M as Jo,T as $r,X as Di,b as Hl,E as mi,B as kn,P as Fl,S as Wl,F as Zo,d as Kl,A as Ul,e as Ls,f as ql,u as Vl}from"./index-UD3Q__HZ.js";import{S as us,T as Yl,P as Bs,a as Xl,E as ss,R as Gl,C as Jl,b as Zl,c as Ql}from"./TerminalOutput-DW1Q6elC.js";import{B as qt,T as Qo,F as Js,P as eh}from"./Button-58BwlzCq.js";import{C as th,a as ih}from"./clock-KWo-YzsE.js";import{A as sh}from"./arrow-left-CVP50JWU.js";import{E as En}from"./external-link-BGj_qdwC.js";/**
|
|
2
2
|
* @license lucide-react v0.577.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const rh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],nh=oe("bot",rh);/**
|
|
7
7
|
* @license lucide-react v0.577.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const oh=[["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"}]],ah=oe("code-xml",oh);/**
|
|
12
12
|
* @license lucide-react v0.577.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const lh=[["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"}]],hh=oe("eye-off",lh);/**
|
|
17
17
|
* @license lucide-react v0.577.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/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:"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"}]],dh=oe("file-braces",ch);/**
|
|
22
22
|
* @license lucide-react v0.577.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const uh=[["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"}]],Ke=oe("file-code-corner",uh);/**
|
|
27
27
|
* @license lucide-react v0.577.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const fh=[["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"}]],_h=oe("file-code",fh);/**
|
|
32
32
|
* @license lucide-react v0.577.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const ph=[["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"}]],mh=oe("file-plus",ph);/**
|
|
37
37
|
* @license lucide-react v0.577.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const gh=[["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"}]],vh=oe("file-type",gh);/**
|
|
42
42
|
* @license lucide-react v0.577.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Sh=[["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"}]],bh=oe("file",Sh);/**
|
|
47
47
|
* @license lucide-react v0.577.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const yh=[["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"}]],wh=oe("folder-plus",yh);/**
|
|
52
52
|
* @license lucide-react v0.577.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const xh=[["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"}]],Ch=oe("folder",xh);/**
|
|
57
57
|
* @license lucide-react v0.577.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const kh=[["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"}]],Eh=oe("key-round",kh);/**
|
|
62
62
|
* @license lucide-react v0.577.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const Mh=[["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"}]],Dh=oe("keyboard",Mh);/**
|
|
67
67
|
* @license lucide-react v0.577.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const Rh=[["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"}]],Mn=oe("layout-dashboard",Rh);/**
|
|
72
72
|
* @license lucide-react v0.577.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const Ph=[["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"}]],Lh=oe("maximize-2",Ph);/**
|
|
77
77
|
* @license lucide-react v0.577.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const Bh=[["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"}]],Nh=oe("minimize-2",Bh);/**
|
|
82
82
|
* @license lucide-react v0.577.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const Th=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Ah=oe("package",Th);/**
|
|
87
87
|
* @license lucide-react v0.577.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const zh=[["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"}]],Oh=oe("panel-bottom-close",zh);/**
|
|
92
92
|
* @license lucide-react v0.577.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
96
|
+
*/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"}]],Ih=oe("panel-bottom-open",jh);/**
|
|
97
97
|
* @license lucide-react v0.577.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const $h=[["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"}]],Hh=oe("panel-left-open",$h);/**
|
|
102
102
|
* @license lucide-react v0.577.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const Fh=[["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"}]],Wh=oe("refresh-cw",Fh);/**
|
|
107
107
|
* @license lucide-react v0.577.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
112
|
-
|
|
111
|
+
*/const Kh=[["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"}]],Uh=oe("scroll-text",Kh);/**
|
|
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 qh=[["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"}]],Vh=oe("send",qh);/**
|
|
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 Yh=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Xh=oe("server",Yh);/**
|
|
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 Gh=[["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"}]],ea=oe("shield-check",Gh);/**
|
|
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 Jh=[["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"}]],Ns=oe("test-tube-diagonal",Jh);/**
|
|
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 Zh=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Qh=oe("users",Zh);/**
|
|
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 ec=[["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"}]],tc=oe("wrench",ec);function Dn(e,t){(t==null||t>e.length)&&(t=e.length);for(var i=0,s=Array(t);i<t;i++)s[i]=e[i];return s}function ic(e){if(Array.isArray(e))return e}function sc(e,t,i){return(t=cc(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function rc(e,t){var i=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(i!=null){var s,r,n,o,a=[],h=!0,l=!1;try{if(n=(i=i.call(e)).next,t!==0)for(;!(h=(s=n.call(i)).done)&&(a.push(s.value),a.length!==t);h=!0);}catch(d){l=!0,r=d}finally{try{if(!h&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(l)throw r}}return a}}function nc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
142
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rn(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function Pn(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?Rn(Object(i),!0).forEach(function(s){sc(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Rn(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function oc(e,t){if(e==null)return{};var i,s,r=ac(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)===-1&&{}.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function ac(e,t){if(e==null)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.indexOf(s)!==-1)continue;i[s]=e[s]}return i}function lc(e,t){return ic(e)||rc(e,t)||dc(e,t)||nc()}function hc(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var s=i.call(e,t);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function cc(e){var t=hc(e,"string");return typeof t=="symbol"?t:t+""}function dc(e,t){if(e){if(typeof e=="string")return Dn(e,t);var i={}.toString.call(e).slice(8,-1);return i==="Object"&&e.constructor&&(i=e.constructor.name),i==="Map"||i==="Set"?Array.from(e):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Dn(e,t):void 0}}function uc(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Ln(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),i.push.apply(i,s)}return i}function Bn(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?Ln(Object(i),!0).forEach(function(s){uc(e,s,i[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Ln(Object(i)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(i,s))})}return e}function fc(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return function(s){return t.reduceRight(function(r,n){return n(r)},s)}}function gi(e){return function t(){for(var i=this,s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];return r.length>=e.length?e.apply(this,r):function(){for(var o=arguments.length,a=new Array(o),h=0;h<o;h++)a[h]=arguments[h];return t.apply(i,[].concat(r,a))}}}function fs(e){return{}.toString.call(e).includes("Object")}function _c(e){return!Object.keys(e).length}function Ri(e){return typeof e=="function"}function pc(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function mc(e,t){return fs(t)||vt("changeType"),Object.keys(t).some(function(i){return!pc(e,i)})&&vt("changeField"),t}function gc(e){Ri(e)||vt("selectorType")}function vc(e){Ri(e)||fs(e)||vt("handlerType"),fs(e)&&Object.values(e).some(function(t){return!Ri(t)})&&vt("handlersType")}function Sc(e){e||vt("initialIsRequired"),fs(e)||vt("initialType"),_c(e)&&vt("initialContent")}function bc(e,t){throw new Error(e[t]||e.default)}var yc={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"},vt=gi(bc)(yc),Vi={changes:mc,selector:gc,handler:vc,initial:Sc};function wc(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Vi.initial(e),Vi.handler(t);var i={current:e},s=gi(kc)(i,t),r=gi(Cc)(i),n=gi(Vi.changes)(e),o=gi(xc)(i);function a(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return Vi.selector(l),l(i.current)}function h(l){fc(s,r,n,o)(l)}return[a,h]}function xc(e,t){return Ri(t)?t(e.current):t}function Cc(e,t){return e.current=Bn(Bn({},e.current),t),t}function kc(e,t,i){return Ri(t)?t(e.current):Object.keys(i).forEach(function(s){var r;return(r=t[s])===null||r===void 0?void 0:r.call(t,e.current[s])}),i}var Ec={create:wc},Mc={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Dc(e){return function t(){for(var i=this,s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];return r.length>=e.length?e.apply(this,r):function(){for(var o=arguments.length,a=new Array(o),h=0;h<o;h++)a[h]=arguments[h];return t.apply(i,[].concat(r,a))}}}function Rc(e){return{}.toString.call(e).includes("Object")}function Pc(e){return e||Nn("configIsRequired"),Rc(e)||Nn("configType"),e.urls?(Lc(),{paths:{vs:e.urls.monacoBase}}):e}function Lc(){console.warn(ta.deprecation)}function Bc(e,t){throw new Error(e[t]||e.default)}var ta={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!
|
|
113
143
|
You are using deprecated way of configuration.
|
|
114
144
|
|
|
115
145
|
Instead of using
|
|
@@ -118,7 +148,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
118
148
|
monaco.config({ paths: { vs: '...' } })
|
|
119
149
|
|
|
120
150
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
121
|
-
`},yn=sc(ac)(Wo),lc={config:nc},hc=function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return function(r){return i.reduceRight(function(n,o){return o(n)},r)}};function Ko(e,t){return Object.keys(t).forEach(function(i){t[i]instanceof Object&&e[i]&&Object.assign(t[i],Ko(e[i],t[i]))}),vn(vn({},e),t)}var cc={type:"cancelation",msg:"operation is manually canceled"};function Es(e){var t=!1,i=new Promise(function(s,r){e.then(function(n){return t?r(cc):s(n)}),e.catch(r)});return i.cancel=function(){return t=!0},i}var dc=["monaco"],uc=tc.create({config:ic,isInitialized:!1,resolve:null,reject:null,monaco:null}),Uo=Oh(uc,2),Pi=Uo[0],_s=Uo[1];function fc(e){var t=lc.config(e),i=t.monaco,s=Ah(t,dc);_s(function(r){return{config:Ko(r.config,s),monaco:i}})}function _c(){var e=Pi(function(t){var i=t.monaco,s=t.isInitialized,r=t.resolve;return{monaco:i,isInitialized:s,resolve:r}});if(!e.isInitialized){if(_s({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Es(Ms);if(window.monaco&&window.monaco.editor)return qo(window.monaco),e.resolve(window.monaco),Es(Ms);hc(pc,gc)(vc)}return Es(Ms)}function pc(e){return document.body.appendChild(e)}function mc(e){var t=document.createElement("script");return e&&(t.src=e),t}function gc(e){var t=Pi(function(s){var r=s.config,n=s.reject;return{config:r,reject:n}}),i=mc("".concat(t.config.paths.vs,"/loader.js"));return i.onload=function(){return e()},i.onerror=t.reject,i}function vc(){var e=Pi(function(i){var s=i.config,r=i.resolve,n=i.reject;return{config:s,resolve:r,reject:n}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(i){var s=i.m||i;qo(s),e.resolve(s)},function(i){e.reject(i)})}function qo(e){Pi().monaco||_s({monaco:e})}function Sc(){return Pi(function(e){var t=e.monaco;return t})}var Ms=new Promise(function(e,t){return _s({resolve:e,reject:t})}),Vo={config:fc,init:_c,__getMonacoInstance:Sc},bc={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ds=bc,yc={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},wc=yc;function xc({children:e}){return Yt.createElement("div",{style:wc.container},e)}var Cc=xc,kc=Cc;function Ec({width:e,height:t,isEditorReady:i,loading:s,_ref:r,className:n,wrapperProps:o}){return Yt.createElement("section",{style:{...Ds.wrapper,width:e,height:t},...o},!i&&Yt.createElement(kc,null,s),Yt.createElement("div",{ref:r,style:{...Ds.fullWidth,...!i&&Ds.hide},className:n}))}var Mc=Ec,Yo=g.memo(Mc);function Dc(e){g.useEffect(e,[])}var Xo=Dc;function Rc(e,t,i=!0){let s=g.useRef(!0);g.useEffect(s.current||!i?()=>{s.current=!1}:e,t)}var je=Rc;function yi(){}function Ut(e,t,i,s){return Pc(e,s)||Bc(e,t,i,s)}function Pc(e,t){return e.editor.getModel(Go(e,t))}function Bc(e,t,i,s){return e.editor.createModel(t,i,s?Go(e,s):void 0)}function Go(e,t){return e.Uri.parse(t)}function Lc({original:e,modified:t,language:i,originalLanguage:s,modifiedLanguage:r,originalModelPath:n,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:h=!1,theme:l="light",loading:d="Loading...",options:u={},height:f="100%",width:m="100%",className:p,wrapperProps:_={},beforeMount:y=yi,onMount:S=yi}){let[b,P]=g.useState(!1),[k,C]=g.useState(!0),A=g.useRef(null),D=g.useRef(null),U=g.useRef(null),q=g.useRef(S),$=g.useRef(y),L=g.useRef(!1);Xo(()=>{let x=Vo.init();return x.then(B=>(D.current=B)&&C(!1)).catch(B=>(B==null?void 0:B.type)!=="cancelation"&&console.error("Monaco initialization: error:",B)),()=>A.current?R():x.cancel()}),je(()=>{if(A.current&&D.current){let x=A.current.getOriginalEditor(),B=Ut(D.current,e||"",s||i||"text",n||"");B!==x.getModel()&&x.setModel(B)}},[n],b),je(()=>{if(A.current&&D.current){let x=A.current.getModifiedEditor(),B=Ut(D.current,t||"",r||i||"text",o||"");B!==x.getModel()&&x.setModel(B)}},[o],b),je(()=>{let x=A.current.getModifiedEditor();x.getOption(D.current.editor.EditorOption.readOnly)?x.setValue(t||""):t!==x.getValue()&&(x.executeEdits("",[{range:x.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),x.pushUndoStop())},[t],b),je(()=>{var x,B;(B=(x=A.current)==null?void 0:x.getModel())==null||B.original.setValue(e||"")},[e],b),je(()=>{let{original:x,modified:B}=A.current.getModel();D.current.editor.setModelLanguage(x,s||i||"text"),D.current.editor.setModelLanguage(B,r||i||"text")},[i,s,r],b),je(()=>{var x;(x=D.current)==null||x.editor.setTheme(l)},[l],b),je(()=>{var x;(x=A.current)==null||x.updateOptions(u)},[u],b);let M=g.useCallback(()=>{var j;if(!D.current)return;$.current(D.current);let x=Ut(D.current,e||"",s||i||"text",n||""),B=Ut(D.current,t||"",r||i||"text",o||"");(j=A.current)==null||j.setModel({original:x,modified:B})},[i,t,r,e,s,n,o]),w=g.useCallback(()=>{var x;!L.current&&U.current&&(A.current=D.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...u}),M(),(x=D.current)==null||x.editor.setTheme(l),P(!0),L.current=!0)},[u,l,M]);g.useEffect(()=>{b&&q.current(A.current,D.current)},[b]),g.useEffect(()=>{!k&&!b&&w()},[k,b,w]);function R(){var B,j,N,G;let x=(B=A.current)==null?void 0:B.getModel();a||((j=x==null?void 0:x.original)==null||j.dispose()),h||((N=x==null?void 0:x.modified)==null||N.dispose()),(G=A.current)==null||G.dispose()}return Yt.createElement(Yo,{width:m,height:f,isEditorReady:b,loading:d,_ref:U,className:p,wrapperProps:_})}var Nc=Lc;g.memo(Nc);function Tc(e){let t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}var Ac=Tc,Hi=new Map;function zc({defaultValue:e,defaultLanguage:t,defaultPath:i,value:s,language:r,path:n,theme:o="light",line:a,loading:h="Loading...",options:l={},overrideServices:d={},saveViewState:u=!0,keepCurrentModel:f=!1,width:m="100%",height:p="100%",className:_,wrapperProps:y={},beforeMount:S=yi,onMount:b=yi,onChange:P,onValidate:k=yi}){let[C,A]=g.useState(!1),[D,U]=g.useState(!0),q=g.useRef(null),$=g.useRef(null),L=g.useRef(null),M=g.useRef(b),w=g.useRef(S),R=g.useRef(),x=g.useRef(s),B=Ac(n),j=g.useRef(!1),N=g.useRef(!1);Xo(()=>{let W=Vo.init();return W.then(H=>(q.current=H)&&U(!1)).catch(H=>(H==null?void 0:H.type)!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>$.current?ie():W.cancel()}),je(()=>{var H,F,Y,ne;let W=Ut(q.current,e||s||"",t||r||"",n||i||"");W!==((H=$.current)==null?void 0:H.getModel())&&(u&&Hi.set(B,(F=$.current)==null?void 0:F.saveViewState()),(Y=$.current)==null||Y.setModel(W),u&&((ne=$.current)==null||ne.restoreViewState(Hi.get(n))))},[n],C),je(()=>{var W;(W=$.current)==null||W.updateOptions(l)},[l],C),je(()=>{!$.current||s===void 0||($.current.getOption(q.current.editor.EditorOption.readOnly)?$.current.setValue(s):s!==$.current.getValue()&&(N.current=!0,$.current.executeEdits("",[{range:$.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),$.current.pushUndoStop(),N.current=!1))},[s],C),je(()=>{var H,F;let W=(H=$.current)==null?void 0:H.getModel();W&&r&&((F=q.current)==null||F.editor.setModelLanguage(W,r))},[r],C),je(()=>{var W;a!==void 0&&((W=$.current)==null||W.revealLine(a))},[a],C),je(()=>{var W;(W=q.current)==null||W.editor.setTheme(o)},[o],C);let G=g.useCallback(()=>{var W;if(!(!L.current||!q.current)&&!j.current){w.current(q.current);let H=n||i,F=Ut(q.current,s||e||"",t||r||"",H||"");$.current=(W=q.current)==null?void 0:W.editor.create(L.current,{model:F,automaticLayout:!0,...l},d),u&&$.current.restoreViewState(Hi.get(H)),q.current.editor.setTheme(o),a!==void 0&&$.current.revealLine(a),A(!0),j.current=!0}},[e,t,i,s,r,n,l,d,u,o,a]);g.useEffect(()=>{C&&M.current($.current,q.current)},[C]),g.useEffect(()=>{!D&&!C&&G()},[D,C,G]),x.current=s,g.useEffect(()=>{var W,H;C&&P&&((W=R.current)==null||W.dispose(),R.current=(H=$.current)==null?void 0:H.onDidChangeModelContent(F=>{N.current||P($.current.getValue(),F)}))},[C,P]),g.useEffect(()=>{if(C){let W=q.current.editor.onDidChangeMarkers(H=>{var Y;let F=(Y=$.current.getModel())==null?void 0:Y.uri;if(F&&H.find(ne=>ne.path===F.path)){let ne=q.current.editor.getModelMarkers({resource:F});k==null||k(ne)}});return()=>{W==null||W.dispose()}}return()=>{}},[C,k]);function ie(){var W,H;(W=R.current)==null||W.dispose(),f?u&&Hi.set(n,$.current.saveViewState()):(H=$.current.getModel())==null||H.dispose(),$.current.dispose()}return Yt.createElement(Yo,{width:m,height:p,isEditorReady:C,loading:h,_ref:L,className:_,wrapperProps:y})}var Oc=zc,jc=g.memo(Oc),Ic=jc;function $c(e,t){const i=getComputedStyle(e),s=parseFloat(i.fontSize);return t*s}function Fc(e,t){const i=getComputedStyle(e.ownerDocument.body),s=parseFloat(i.fontSize);return t*s}function Hc(e){return e/100*window.innerHeight}function Wc(e){return e/100*window.innerWidth}function Kc(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 _i({groupSize:e,panelElement:t,styleProp:i}){let s;const[r,n]=Kc(i);switch(n){case"%":{s=r/100*e;break}case"px":{s=r;break}case"rem":{s=Fc(t,r);break}case"em":{s=$c(t,r);break}case"vh":{s=Hc(r);break}case"vw":{s=Wc(r);break}}return s}function Ne(e){return parseFloat(e.toFixed(3))}function Jt({group:e}){const{orientation:t,panels:i}=e;return i.reduce((s,r)=>(s+=t==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,s),0)}function Ks(e){const{panels:t}=e,i=Jt({group:e});return i===0?t.map(s=>({groupResizeBehavior:s.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:s.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:s.panelConstraints.disabled,minSize:0,maxSize:100,panelId:s.id})):t.map(s=>{const{element:r,panelConstraints:n}=s;let o=0;if(n.collapsedSize!==void 0){const d=_i({groupSize:i,panelElement:r,styleProp:n.collapsedSize});o=Ne(d/i*100)}let a;if(n.defaultSize!==void 0){const d=_i({groupSize:i,panelElement:r,styleProp:n.defaultSize});a=Ne(d/i*100)}let h=0;if(n.minSize!==void 0){const d=_i({groupSize:i,panelElement:r,styleProp:n.minSize});h=Ne(d/i*100)}let l=100;if(n.maxSize!==void 0){const d=_i({groupSize:i,panelElement:r,styleProp:n.maxSize});l=Ne(d/i*100)}return{groupResizeBehavior:n.groupResizeBehavior,collapsedSize:o,collapsible:n.collapsible===!0,defaultSize:a,disabled:n.disabled,minSize:h,maxSize:l,panelId:s.id}})}function re(e,t="Assertion error"){if(!e)throw Error(t)}function Us(e,t){return Array.from(t).sort(e==="horizontal"?Uc:qc)}function Uc(e,t){const i=e.element.offsetLeft-t.element.offsetLeft;return i!==0?i:e.element.offsetWidth-t.element.offsetWidth}function qc(e,t){const i=e.element.offsetTop-t.element.offsetTop;return i!==0?i:e.element.offsetHeight-t.element.offsetHeight}function Jo(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Zo(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 Vc({orientation:e,rects:t,targetRect:i}){const s={x:i.x+i.width/2,y:i.y+i.height/2};let r,n=Number.MAX_VALUE;for(const o of t){const{x:a,y:h}=Zo(s,o),l=e==="horizontal"?a:h;l<n&&(n=l,r=o)}return re(r,"No rect found"),r}let Wi;function Yc(){return Wi===void 0&&(typeof matchMedia=="function"?Wi=!!matchMedia("(pointer:coarse)").matches:Wi=!1),Wi}function Qo(e){const{element:t,orientation:i,panels:s,separators:r}=e,n=Us(i,Array.from(t.children).filter(Jo).map(p=>({element:p}))).map(({element:p})=>p),o=[];let a=!1,h=!1,l=-1,d=-1,u=0,f,m=[];{let p=-1;for(const _ of n)_.hasAttribute("data-panel")&&(p++,_.ariaDisabled===null&&(u++,l===-1&&(l=p),d=p))}if(u>1){let p=-1;for(const _ of n)if(_.hasAttribute("data-panel")){p++;const y=s.find(S=>S.element===_);if(y){if(f){const S=f.element.getBoundingClientRect(),b=_.getBoundingClientRect();let P;if(h){const k=i==="horizontal"?new DOMRect(S.right,S.top,0,S.height):new DOMRect(S.left,S.bottom,S.width,0),C=i==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(m.length){case 0:{P=[k,C];break}case 1:{const A=m[0],D=Vc({orientation:i,rects:[S,b],targetRect:A.element.getBoundingClientRect()});P=[A,D===S?C:k];break}default:{P=m;break}}}else m.length?P=m:P=[i==="horizontal"?new DOMRect(S.right,b.top,b.left-S.right,b.height):new DOMRect(b.left,S.bottom,b.width,b.top-S.bottom)];for(const k of P){let C="width"in k?k:k.element.getBoundingClientRect();const A=Yc()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<A){const U=A-C.width;C=new DOMRect(C.x-U/2,C.y,C.width+U,C.height)}if(C.height<A){const U=A-C.height;C=new DOMRect(C.x,C.y-U/2,C.width,C.height+U)}const D=p<=l||p>d;!a&&!D&&o.push({group:e,groupSize:Jt({group:e}),panels:[f,y],separator:"width"in k?void 0:k,rect:C}),a=!1}}h=!1,f=y,m=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(a=!0);const y=r.find(S=>S.element===_);y?m.push(y):(f=void 0,m=[])}else h=!0}return o}var pt,Ao;let ea=(Ao=class{constructor(){fn(this,pt,{})}addListener(t,i){const s=ri(this,pt)[t];return s===void 0?ri(this,pt)[t]=[i]:s.includes(i)||s.push(i),()=>{this.removeListener(t,i)}}emit(t,i){const s=ri(this,pt)[t];if(s!==void 0)if(s.length===1)s[0].call(null,i);else{let r=!1,n=null;const o=Array.from(s);for(let a=0;a<o.length;a++){const h=o[a];try{h.call(null,i)}catch(l){n===null&&(r=!0,n=l)}}if(r)throw n}}removeAllListeners(){_n(this,pt,{})}removeListener(t,i){const s=ri(this,pt)[t];if(s!==void 0){const r=s.indexOf(i);r>=0&&s.splice(r,1)}}},pt=new WeakMap,Ao),Qe=new Map;const ta=new ea;function Xc(e){Qe=new Map(Qe),Qe.delete(e)}function wn(e,t){for(const[i]of Qe)if(i.id===e)return i}function vt(e,t){for(const[i,s]of Qe)if(i.id===e)return s;if(t)throw Error(`Could not find data for Group with id ${e}`)}function At(){return Qe}function Nr(e,t){return ta.addListener("groupChange",i=>{i.group.id===e&&t(i)})}function ot(e,t){const i=Qe.get(e);Qe=new Map(Qe),Qe.set(e,t),ta.emit("groupChange",{group:e,prev:i,next:t})}function Gc(e,t,i){let s,r={x:1/0,y:1/0};for(const n of t){const o=Zo(i,n.rect);switch(e){case"horizontal":{o.x<=r.x&&(s=n,r=o);break}case"vertical":{o.y<=r.y&&(s=n,r=o);break}}}return s?{distance:r,hitRegion:s}:void 0}function Jc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Zc(e,t){if(e===t)throw new Error("Cannot compare node with itself");const i={a:kn(e),b:kn(t)};let s;for(;i.a.at(-1)===i.b.at(-1);)s=i.a.pop(),i.b.pop();re(s,"Stacking order can only be calculated for elements with a common ancestor");const r={a:Cn(xn(i.a)),b:Cn(xn(i.b))};if(r.a===r.b){const n=s.childNodes,o={a:i.a.at(-1),b:i.b.at(-1)};let a=n.length;for(;a--;){const h=n[a];if(h===o.a)return 1;if(h===o.b)return-1}}return Math.sign(r.a-r.b)}const Qc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ed(e){const t=getComputedStyle(ia(e)??e).display;return t==="flex"||t==="inline-flex"}function td(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ed(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"||Qc.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function xn(e){let t=e.length;for(;t--;){const i=e[t];if(re(i,"Missing node"),td(i))return i}return null}function Cn(e){return e&&Number(getComputedStyle(e).zIndex)||0}function kn(e){const t=[];for(;e;)t.push(e),e=ia(e);return t}function ia(e){const{parentNode:t}=e;return Jc(t)?t.host:t}function id(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 sd({groupElement:e,hitRegion:t,pointerEventTarget:i}){if(!Jo(i)||i.contains(e)||e.contains(i))return!0;if(Zc(i,e)>0){let s=i;for(;s;){if(s.contains(e))return!0;if(id(s.getBoundingClientRect(),t))return!1;s=s.parentElement}}return!0}function Tr(e,t){const i=[];return t.forEach((s,r)=>{if(r.disabled)return;const n=Qo(r),o=Gc(r.orientation,n,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&sd({groupElement:r.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&i.push(o.hitRegion)}),i}function rd(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i])return!1;return!0}function Re(e,t,i=0){return Math.abs(Ne(e)-Ne(t))<=i}function Ze(e,t){return Re(e,t)?0:e>t?1:-1}function qt({overrideDisabledPanels:e,panelConstraints:t,prevSize:i,size:s}){const{collapsedSize:r=0,collapsible:n,disabled:o,maxSize:a=100,minSize:h=0}=t;if(o&&!e)return i;if(Ze(s,h)<0)if(n){const l=(r+h)/2;Ze(s,l)<0?s=r:s=h}else s=h;return s=Math.min(a,s),s=Ne(s),s}function Ei({delta:e,initialLayout:t,panelConstraints:i,pivotIndices:s,prevLayout:r,trigger:n}){if(Re(e,0))return t;const o=n==="imperative-api",a=Object.values(t),h=Object.values(r),l=[...a],[d,u]=s;re(d!=null,"Invalid first pivot index"),re(u!=null,"Invalid second pivot index");let f=0;switch(n){case"keyboard":{{const _=e<0?u:d,y=i[_];re(y,`Panel constraints not found for index ${_}`);const{collapsedSize:S=0,collapsible:b,minSize:P=0}=y;if(b){const k=a[_];if(re(k!=null,`Previous layout not found for panel index ${_}`),Re(k,S)){const C=P-k;Ze(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const _=e<0?d:u,y=i[_];re(y,`No panel constraints found for index ${_}`);const{collapsedSize:S=0,collapsible:b,minSize:P=0}=y;if(b){const k=a[_];if(re(k!=null,`Previous layout not found for panel index ${_}`),Re(k,P)){const C=k-S;Ze(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const _=e<0?u:d,y=i[_];re(y,`Panel constraints not found for index ${_}`);const S=a[_],{collapsible:b,collapsedSize:P,minSize:k}=y;if(b&&Ze(S,k)<0)if(e>0){const C=k-P,A=C/2,D=S+e;Ze(D,k)<0&&(e=Ze(e,A)<=0?0:C)}else{const C=k-P,A=100-C/2,D=S-e;Ze(D,k)<0&&(e=Ze(100+e,A)>0?0:-C)}break}}{const _=e<0?1:-1;let y=e<0?u:d,S=0;for(;;){const P=a[y];re(P!=null,`Previous layout not found for panel index ${y}`);const k=qt({overrideDisabledPanels:o,panelConstraints:i[y],prevSize:P,size:100})-P;if(S+=k,y+=_,y<0||y>=i.length)break}const b=Math.min(Math.abs(e),Math.abs(S));e=e<0?0-b:b}{let _=e<0?d:u;for(;_>=0&&_<i.length;){const y=Math.abs(e)-Math.abs(f),S=a[_];re(S!=null,`Previous layout not found for panel index ${_}`);const b=S-y,P=qt({overrideDisabledPanels:o,panelConstraints:i[_],prevSize:S,size:b});if(!Re(S,P)&&(f+=S-P,l[_]=P,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(rd(h,l))return r;{const _=e<0?u:d,y=a[_];re(y!=null,`Previous layout not found for panel index ${_}`);const S=y+f,b=qt({overrideDisabledPanels:o,panelConstraints:i[_],prevSize:y,size:S});if(l[_]=b,!Re(b,S)){let P=S-b,k=e<0?u:d;for(;k>=0&&k<i.length;){const C=l[k];re(C!=null,`Previous layout not found for panel index ${k}`);const A=C+P,D=qt({overrideDisabledPanels:o,panelConstraints:i[k],prevSize:C,size:A});if(Re(C,D)||(P-=D-C,l[k]=D),Re(P,0))break;e>0?k--:k++}}}const m=Object.values(l).reduce((_,y)=>y+_,0);if(!Re(m,100,.1))return r;const p=Object.keys(r);return l.reduce((_,y,S)=>(_[p[S]]=y,_),{})}function Pt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(t[i]===void 0||Ze(e[i],t[i])!==0)return!1;return!0}function Bt({layout:e,panelConstraints:t}){const i=Object.values(e),s=[...i],r=s.reduce((a,h)=>a+h,0);if(s.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${s.map(a=>`${a}%`).join(", ")}`);if(!Re(r,100)&&s.length>0)for(let a=0;a<t.length;a++){const h=s[a];re(h!=null,`No layout data found for index ${a}`);const l=100/r*h;s[a]=l}let n=0;for(let a=0;a<t.length;a++){const h=i[a];re(h!=null,`No layout data found for index ${a}`);const l=s[a];re(l!=null,`No layout data found for index ${a}`);const d=qt({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:h,size:l});l!=d&&(n+=l-d,s[a]=d)}if(!Re(n,0))for(let a=0;a<t.length;a++){const h=s[a];re(h!=null,`No layout data found for index ${a}`);const l=h+n,d=qt({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:h,size:l});if(h!==d&&(n-=d-h,s[a]=d,Re(n,0)))break}const o=Object.keys(e);return s.reduce((a,h,l)=>(a[o[l]]=h,a),{})}function sa({groupId:e,panelId:t}){const i=()=>{const a=At();for(const[h,{defaultLayoutDeferred:l,derivedPanelConstraints:d,layout:u,groupSize:f,separatorToPanels:m}]of a)if(h.id===e)return{defaultLayoutDeferred:l,derivedPanelConstraints:d,group:h,groupSize:f,layout:u,separatorToPanels:m};throw Error(`Group ${e} not found`)},s=()=>{const a=i().derivedPanelConstraints.find(h=>h.panelId===t);if(a!==void 0)return a;throw Error(`Panel constraints not found for Panel ${t}`)},r=()=>{const a=i().group.panels.find(h=>h.id===t);if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},n=()=>{const a=i().layout[t];if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},o=a=>{const h=n();if(a===h)return;const{defaultLayoutDeferred:l,derivedPanelConstraints:d,group:u,groupSize:f,layout:m,separatorToPanels:p}=i(),_=u.panels.findIndex(P=>P.id===t),y=_===u.panels.length-1,S=Ei({delta:y?h-a:a-h,initialLayout:m,panelConstraints:d,pivotIndices:y?[_-1,_]:[_,_+1],prevLayout:m,trigger:"imperative-api"}),b=Bt({layout:S,panelConstraints:d});Pt(m,b)||ot(u,{defaultLayoutDeferred:l,derivedPanelConstraints:d,groupSize:f,layout:b,separatorToPanels:p})};return{collapse:()=>{const{collapsible:a,collapsedSize:h}=s(),{mutableValues:l}=r(),d=n();a&&d!==h&&(l.expandToSize=d,o(h))},expand:()=>{const{collapsible:a,collapsedSize:h,minSize:l}=s(),{mutableValues:d}=r(),u=n();if(a&&u===h){let f=d.expandToSize??l;f===0&&(f=1),o(f)}},getSize:()=>{const{group:a}=i(),h=n(),{element:l}=r(),d=a.orientation==="horizontal"?l.offsetWidth:l.offsetHeight;return{asPercentage:h,inPixels:d}},isCollapsed:()=>{const{collapsible:a,collapsedSize:h}=s(),l=n();return a&&Re(h,l)},resize:a=>{const{group:h}=i(),{element:l}=r(),d=Jt({group:h}),u=_i({groupSize:d,panelElement:l,styleProp:a}),f=Ne(u/d*100);o(f)}}}function En(e){if(e.defaultPrevented)return;const t=At();Tr(e,t).forEach(i=>{if(i.separator){const s=i.panels.find(r=>r.panelConstraints.defaultSize!==void 0);if(s){const r=s.panelConstraints.defaultSize,n=sa({groupId:i.group.id,panelId:s.id});n&&r!==void 0&&(n.resize(r),e.preventDefault())}}})}function Zi(e){const t=At();for(const[i]of t)if(i.separators.some(s=>s.element===e))return i;throw Error("Could not find parent Group for separator element")}function ra({groupId:e}){const t=()=>{const i=At();for(const[s,r]of i)if(s.id===e)return{group:s,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:i,layout:s}=t();return i?{}:s},setLayout(i){const{defaultLayoutDeferred:s,derivedPanelConstraints:r,group:n,groupSize:o,layout:a,separatorToPanels:h}=t(),l=Bt({layout:i,panelConstraints:r});return s?a:(Pt(a,l)||ot(n,{defaultLayoutDeferred:s,derivedPanelConstraints:r,groupSize:o,layout:l,separatorToPanels:h}),l)}}}function xt(e,t){const i=Zi(e),s=vt(i.id,!0),r=i.separators.find(d=>d.element===e);re(r,"Matching separator not found");const n=s.separatorToPanels.get(r);re(n,"Matching panels not found");const o=n.map(d=>i.panels.indexOf(d)),a=ra({groupId:i.id}).getLayout(),h=Ei({delta:t,initialLayout:a,panelConstraints:s.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),l=Bt({layout:h,panelConstraints:s.derivedPanelConstraints});Pt(a,l)||ot(i,{defaultLayoutDeferred:s.defaultLayoutDeferred,derivedPanelConstraints:s.derivedPanelConstraints,groupSize:s.groupSize,layout:l,separatorToPanels:s.separatorToPanels})}function Mn(e){if(e.defaultPrevented)return;const t=e.currentTarget,i=Zi(t);if(!i.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),i.orientation==="vertical"&&xt(t,5);break}case"ArrowLeft":{e.preventDefault(),i.orientation==="horizontal"&&xt(t,-5);break}case"ArrowRight":{e.preventDefault(),i.orientation==="horizontal"&&xt(t,5);break}case"ArrowUp":{e.preventDefault(),i.orientation==="vertical"&&xt(t,-5);break}case"End":{e.preventDefault(),xt(t,100);break}case"Enter":{e.preventDefault();const s=Zi(t),r=vt(s.id,!0),{derivedPanelConstraints:n,layout:o,separatorToPanels:a}=r,h=s.separators.find(f=>f.element===t);re(h,"Matching separator not found");const l=a.get(h);re(l,"Matching panels not found");const d=l[0],u=n.find(f=>f.panelId===d.id);if(re(u,"Panel metadata not found"),u.collapsible){const f=o[d.id],m=u.collapsedSize===f?s.mutableState.expandedPanelSizes[d.id]??u.minSize:u.collapsedSize;xt(t,m-f)}break}case"F6":{e.preventDefault();const s=Zi(t).separators.map(o=>o.element),r=Array.from(s).findIndex(o=>o===e.currentTarget);re(r!==null,"Index not found");const n=e.shiftKey?r>0?r-1:s.length-1:r+1<s.length?r+1:0;s[n].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),xt(t,-100);break}}}let Xt={cursorFlags:0,state:"inactive"};const Ar=new ea;function Lt(){return Xt}function nd(e){return Ar.addListener("change",e)}function od(e){const t=Xt,i={...Xt};i.cursorFlags=e,Xt=i,Ar.emit("change",{prev:t,next:i})}function Gt(e){const t=Xt;Xt=e,Ar.emit("change",{prev:t,next:e})}function Dn(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=At(),i=Tr(e,t),s=new Map;let r=!1;i.forEach(n=>{n.separator&&(r||(r=!0,n.separator.element.focus({preventScroll:!0})));const o=t.get(n.group);o&&s.set(n.group,o.layout)}),Gt({cursorFlags:0,hitRegions:i,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),i.length&&e.preventDefault()}const ad=e=>e,Rs=()=>{},na=1,oa=2,aa=4,la=8,Rn=3,Pn=12;let Ki;function Bn(){return Ki===void 0&&(Ki=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ki=!0)),Ki}function ld({cursorFlags:e,groups:t,state:i}){let s=0,r=0;switch(i){case"active":case"hover":t.forEach(n=>{if(!n.mutableState.disableCursor)switch(n.orientation){case"horizontal":{s++;break}case"vertical":{r++;break}}})}if(!(s===0&&r===0)){switch(i){case"active":{if(e&&Bn()){const n=(e&na)!==0,o=(e&oa)!==0,a=(e&aa)!==0,h=(e&la)!==0;if(n)return a?"se-resize":h?"ne-resize":"e-resize";if(o)return a?"sw-resize":h?"nw-resize":"w-resize";if(a)return"s-resize";if(h)return"n-resize"}break}}return Bn()?s>0&&r>0?"move":s>0?"ew-resize":"ns-resize":s>0&&r>0?"grab":s>0?"col-resize":"row-resize"}}const Ln=new WeakMap;function zr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:i}=Ln.get(e)??{};i===void 0&&(i=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(i));const s=Lt();switch(s.state){case"active":case"hover":{const r=ld({cursorFlags:s.cursorFlags,groups:s.hitRegions.map(o=>o.group),state:s.state}),n=`*, *:hover {cursor: ${r} !important; }`;if(t===n)return;t=n,r?i.cssRules.length===0?i.insertRule(n):i.replaceSync(n):i.cssRules.length===1&&i.deleteRule(0);break}case"inactive":{t=void 0,i.cssRules.length===1&&i.deleteRule(0);break}}Ln.set(e,{prevStyle:t,styleSheet:i})}function ha({document:e,event:t,hitRegions:i,initialLayoutMap:s,mountedGroups:r,pointerDownAtPoint:n,prevCursorFlags:o}){let a=0;i.forEach(l=>{const{group:d,groupSize:u}=l,{orientation:f,panels:m}=d,{disableCursor:p}=d.mutableState;let _=0;n?f==="horizontal"?_=(t.clientX-n.x)/u*100:_=(t.clientY-n.y)/u*100:f==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const y=s.get(d),S=r.get(d);if(!y||!S)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:P,groupSize:k,layout:C,separatorToPanels:A}=S;if(P&&C&&A){const D=Ei({delta:_,initialLayout:y,panelConstraints:P,pivotIndices:l.panels.map(U=>m.indexOf(U)),prevLayout:C,trigger:"mouse-or-touch"});if(Pt(D,C)){if(_!==0&&!p)switch(f){case"horizontal":{a|=_<0?na:oa;break}case"vertical":{a|=_<0?aa:la;break}}}else ot(l.group,{defaultLayoutDeferred:b,derivedPanelConstraints:P,groupSize:k,layout:D,separatorToPanels:A})}});let h=0;t.movementX===0?h|=o&Rn:h|=a&Rn,t.movementY===0?h|=o&Pn:h|=a&Pn,od(h),zr(e)}function Nn(e){const t=At(),i=Lt();switch(i.state){case"active":ha({document:e.currentTarget,event:e,hitRegions:i.hitRegions,initialLayoutMap:i.initialLayoutMap,mountedGroups:t,prevCursorFlags:i.cursorFlags})}}function Tn(e){if(e.defaultPrevented)return;const t=Lt(),i=At();switch(t.state){case"active":{if(e.buttons===0){Gt({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const r=vt(s.group.id,!0);ot(s.group,r)});return}ha({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:i,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Tr(e,i);s.length===0?t.state!=="inactive"&&Gt({cursorFlags:0,state:"inactive"}):Gt({cursorFlags:0,hitRegions:s,state:"hover"}),zr(e.currentTarget);break}}}function An(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Lt().state){case"hover":Gt({cursorFlags:0,state:"inactive"})}}function zn(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Lt();switch(t.state){case"active":Gt({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(zr(e.currentTarget),t.hitRegions.forEach(i=>{const s=vt(i.group.id,!0);ot(i.group,s)}),e.preventDefault())}}function On(e){let t=0,i=0;const s={};for(const n of e)if(n.defaultSize!==void 0){t++;const o=Ne(n.defaultSize);i+=o,s[n.panelId]=o}else s[n.panelId]=void 0;const r=e.length-t;if(r!==0){const n=Ne((100-i)/r);for(const o of e)o.defaultSize===void 0&&(s[o.panelId]=n)}return s}function hd(e,t,i){if(!i[0])return;const s=e.panels.find(h=>h.element===t);if(!s||!s.onResize)return;const r=Jt({group:e}),n=e.orientation==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,o=s.mutableValues.prevSize,a={asPercentage:Ne(n/r*100),inPixels:n};s.mutableValues.prevSize=a,s.onResize(a,s.id,o)}function cd(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}function dd({group:e,nextGroupSize:t,prevGroupSize:i,prevLayout:s}){if(i<=0||t<=0||i===t)return s;let r=0,n=0,o=!1;const a=new Map,h=[];for(const u of e.panels){const f=s[u.id]??0;switch(u.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const m=f/100*i,p=Ne(m/t*100);a.set(u.id,p),r+=p;break}case"preserve-relative-size":default:{h.push(u.id),n+=f;break}}}if(!o||h.length===0)return s;const l=100-r,d={...s};if(a.forEach((u,f)=>{d[f]=u}),n>0)for(const u of h){const f=s[u]??0;d[u]=Ne(f/n*l)}else{const u=Ne(l/h.length);for(const f of h)d[f]=u}return d}function ud(e,t){const i=e.map(r=>r.id),s=Object.keys(t);if(i.length!==s.length)return!1;for(const r of i)if(!s.includes(r))return!1;return!0}const Ft=new Map;function fd(e){let t=!0;re(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const i=e.element.ownerDocument.defaultView.ResizeObserver,s=new Set,r=new Set,n=new i(p=>{for(const _ of p){const{borderBoxSize:y,target:S}=_;if(S===e.element){if(t){const b=Jt({group:e});if(b===0)return;const P=vt(e.id);if(!P)return;const k=Ks(e),C=P.defaultLayoutDeferred?On(k):P.layout,A=dd({group:e,nextGroupSize:b,prevGroupSize:P.groupSize,prevLayout:C}),D=Bt({layout:A,panelConstraints:k});if(!P.defaultLayoutDeferred&&Pt(P.layout,D)&&cd(P.derivedPanelConstraints,k)&&P.groupSize===b)return;ot(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:k,groupSize:b,layout:D,separatorToPanels:P.separatorToPanels})}}else hd(e,S,y)}});n.observe(e.element),e.panels.forEach(p=>{re(!s.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),s.add(p.id),p.onResize&&n.observe(p.element)});const o=Jt({group:e}),a=Ks(e),h=e.panels.map(({id:p})=>p).join(",");let l=e.mutableState.defaultLayout;l&&(ud(e.panels,l)||(l=void 0));const d=e.mutableState.layouts[h]??l??On(a),u=Bt({layout:d,panelConstraints:a}),f=e.element.ownerDocument;Ft.set(f,(Ft.get(f)??0)+1);const m=new Map;return Qo(e).forEach(p=>{p.separator&&m.set(p.separator,p.panels)}),ot(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:u,separatorToPanels:m}),e.separators.forEach(p=>{re(!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",Mn)}),Ft.get(f)===1&&(f.addEventListener("dblclick",En,!0),f.addEventListener("pointerdown",Dn,!0),f.addEventListener("pointerleave",Nn),f.addEventListener("pointermove",Tn),f.addEventListener("pointerout",An),f.addEventListener("pointerup",zn,!0)),function(){t=!1,Ft.set(f,Math.max(0,(Ft.get(f)??0)-1)),Xc(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",Mn)}),Ft.get(f)||(f.removeEventListener("dblclick",En,!0),f.removeEventListener("pointerdown",Dn,!0),f.removeEventListener("pointerleave",Nn),f.removeEventListener("pointermove",Tn),f.removeEventListener("pointerout",An),f.removeEventListener("pointerup",zn,!0)),n.disconnect()}}function _d(){const[e,t]=g.useState({}),i=g.useCallback(()=>t({}),[]);return[e,i]}function Or(e){const t=g.useId();return`${e??t}`}const zt=typeof window<"u"?g.useLayoutEffect:g.useEffect;function wi(e){const t=g.useRef(e);return zt(()=>{t.current=e},[e]),g.useCallback((...i)=>{var s;return(s=t.current)==null?void 0:s.call(t,...i)},[t])}function jr(...e){return wi(t=>{e.forEach(i=>{if(i)switch(typeof i){case"function":{i(t);break}case"object":{i.current=t;break}}})})}function Ir(e){const t=g.useRef({...e});return zt(()=>{for(const i in e)t.current[i]=e[i]},[e]),t.current}const ca=g.createContext(null);function pd(e,t){const i=g.useRef({getLayout:()=>({}),setLayout:ad});g.useImperativeHandle(t,()=>i.current,[]),zt(()=>{Object.assign(i.current,ra({groupId:e}))})}function qs({children:e,className:t,defaultLayout:i,disableCursor:s,disabled:r,elementRef:n,groupRef:o,id:a,onLayoutChange:h,onLayoutChanged:l,orientation:d="horizontal",resizeTargetMinimumSize:u={coarse:20,fine:10},style:f,...m}){const p=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=wi(L=>{Pt(p.current.onLayoutChange,L)||(p.current.onLayoutChange=L,h==null||h(L))}),y=wi(L=>{Pt(p.current.onLayoutChanged,L)||(p.current.onLayoutChanged=L,l==null||l(L))}),S=Or(a),b=g.useRef(null),[P,k]=_d(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:u,separators:[]}),A=jr(b,n);pd(S,o);const D=wi((L,M)=>{const w=Lt(),R=wn(L),x=vt(L);if(x){let B=!1;switch(w.state){case"active":{B=w.hitRegions.some(j=>j.group===R);break}}return{flexGrow:x.layout[M]??1,pointerEvents:B?"none":void 0}}return{flexGrow:(i==null?void 0:i[M])??1}}),U=Ir({defaultLayout:i,disableCursor:s}),q=g.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:D,id:S,orientation:d,registerPanel:L=>{const M=C.current;return M.panels=Us(d,[...M.panels,L]),k(),()=>{M.panels=M.panels.filter(w=>w!==L),k()}},registerSeparator:L=>{const M=C.current;return M.separators=Us(d,[...M.separators,L]),k(),()=>{M.separators=M.separators.filter(w=>w!==L),k()}},togglePanelDisabled:(L,M)=>{const w=C.current.panels.find(B=>B.id===L);w&&(w.panelConstraints.disabled=M);const R=wn(S),x=vt(S);R&&x&&ot(R,{...x,derivedPanelConstraints:Ks(R)})},toggleSeparatorDisabled:(L,M)=>{const w=C.current.separators.find(R=>R.id===L);w&&(w.disabled=M)}}),[D,S,k,d,U]),$=g.useRef(null);return zt(()=>{const L=b.current;if(L===null)return;const M=C.current;let w;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===M.panels.length){w={};for(const ie of M.panels){const W=U.defaultLayout[ie.id];W!==void 0&&(w[ie.id]=W)}}const R={disabled:!!r,element:L,id:S,mutableState:{defaultLayout:w,disableCursor:!!U.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:d,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};$.current=R;const x=fd(R),{defaultLayoutDeferred:B,derivedPanelConstraints:j,layout:N}=vt(R.id,!0);!B&&j.length>0&&(_(N),y(N));const G=Nr(S,ie=>{const{defaultLayoutDeferred:W,derivedPanelConstraints:H,layout:F}=ie.next;if(W||H.length===0)return;const Y=R.panels.map(({id:oe})=>oe).join(",");R.mutableState.layouts[Y]=F,H.forEach(oe=>{if(oe.collapsible){const{layout:Te}=ie.prev??{};if(Te){const Ye=Re(oe.collapsedSize,F[oe.panelId]),Ie=Re(oe.collapsedSize,Te[oe.panelId]);Ye&&!Ie&&(R.mutableState.expandedPanelSizes[oe.panelId]=Te[oe.panelId])}}});const ne=Lt().state!=="active";_(F),ne&&y(F)});return()=>{$.current=null,x(),G()}},[r,S,y,_,d,P,U]),g.useEffect(()=>{const L=$.current;L&&(L.mutableState.defaultLayout=i,L.mutableState.disableCursor=!!s)}),c.jsx(ca.Provider,{value:q,children:c.jsx("div",{...m,className:t,"data-group":!0,"data-testid":S,id:S,ref:A,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:d==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:d==="horizontal"?"pan-y":"pan-x"},children:e})})}qs.displayName="Group";function $r(){const e=g.useContext(ca);return re(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function md(e,t){const{id:i}=$r(),s=g.useRef({collapse:Rs,expand:Rs,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Rs});g.useImperativeHandle(t,()=>s.current,[]),zt(()=>{Object.assign(s.current,sa({groupId:i,panelId:e}))})}function pi({children:e,className:t,collapsedSize:i="0%",collapsible:s=!1,defaultSize:r,disabled:n,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:h,maxSize:l="100%",minSize:d="0%",onResize:u,panelRef:f,style:m,...p}){const _=!!h,y=Or(h),S=Ir({disabled:n}),b=g.useRef(null),P=jr(b,o),{getPanelStyles:k,id:C,orientation:A,registerPanel:D,togglePanelDisabled:U}=$r(),q=u!==null,$=wi((M,w,R)=>{u==null||u(M,h,R)});zt(()=>{const M=b.current;if(M!==null){const w={element:M,id:y,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:q?$:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:i,collapsible:s,defaultSize:r,disabled:S.disabled,maxSize:l,minSize:d}};return D(w)}},[a,i,s,r,q,y,_,l,d,$,D,S]),g.useEffect(()=>{U(y,!!n)},[n,y,U]),md(y,f);const L=g.useSyncExternalStore(M=>Nr(C,M),()=>JSON.stringify(k(C,y)),()=>JSON.stringify(k(C,y)));return c.jsx("div",{...p,"aria-disabled":n||void 0,"data-panel":!0,"data-testid":y,id:y,ref:P,style:{...gd,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(L)},children:c.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:A==="horizontal"?"pan-y":"pan-x"},children:e})})}pi.displayName="Panel";const gd={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function vd({layout:e,panelConstraints:t,panelId:i,panelIndex:s}){let r,n;const o=e[i],a=t.find(h=>h.panelId===i);if(a){const h=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,d=[s,s+1];n=Bt({layout:Ei({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[i],r=Bt({layout:Ei({delta:h-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[i]}return{valueControls:i,valueMax:r,valueMin:n,valueNow:o}}function Vs({children:e,className:t,disabled:i,elementRef:s,id:r,style:n,...o}){const a=Or(r),h=Ir({disabled:i}),[l,d]=g.useState({}),[u,f]=g.useState("inactive"),m=g.useRef(null),p=jr(m,s),{disableCursor:_,id:y,orientation:S,registerSeparator:b,toggleSeparatorDisabled:P}=$r(),k=S==="horizontal"?"vertical":"horizontal";zt(()=>{const A=m.current;if(A!==null){const D={disabled:h.disabled,element:A,id:a},U=b(D),q=nd(L=>{f(L.next.state!=="inactive"&&L.next.hitRegions.some(M=>M.separator===D)?L.next.state:"inactive")}),$=Nr(y,L=>{const{derivedPanelConstraints:M,layout:w,separatorToPanels:R}=L.next,x=R.get(D);if(x){const B=x[0],j=x.indexOf(B);d(vd({layout:w,panelConstraints:M,panelId:B.id,panelIndex:j}))}});return()=>{q(),$(),U()}}},[y,a,b,h]),g.useEffect(()=>{P(a,!!i)},[i,a,P]);let C;return i&&!_&&(C="not-allowed"),c.jsx("div",{...o,"aria-controls":l.valueControls,"aria-disabled":i||void 0,"aria-orientation":k,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":i?"disabled":u,"data-testid":a,id:a,ref:p,role:"separator",style:{flexBasis:"auto",cursor:C,...n,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:i?void 0:0})}Vs.displayName="Separator";const Sd={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},bd={sm:"w-7 h-7",md:"w-8 h-8"},yd={sm:14,md:16};function ct({icon:e,label:t,size:i="md",variant:s="ghost",onClick:r,className:n="",disabled:o=!1,title:a}){return c.jsx("button",{type:"button","aria-label":t,title:a??t,disabled:o,onClick:r,className:["inline-flex items-center justify-center rounded-btn transition-colors",Sd[s],bd[i],o?"opacity-40 cursor-not-allowed":"",n].filter(Boolean).join(" "),children:c.jsx(e,{size:yd[i]})})}function wd({x:e,y:t,items:i,onClose:s}){const[r,n]=g.useState(0),o=g.useRef(null),a=g.useRef([]);g.useEffect(()=>{var l;(l=a.current[0])==null||l.focus()},[]),g.useEffect(()=>{const l=d=>{o.current&&!o.current.contains(d.target)&&s()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]);const h=g.useCallback(l=>{var d,u;switch(l.key){case"Escape":l.preventDefault(),s();break;case"ArrowDown":l.preventDefault(),n(f=>{var p;const m=(f+1)%i.length;return(p=a.current[m])==null||p.focus(),m});break;case"ArrowUp":l.preventDefault(),n(f=>{var p;const m=(f-1+i.length)%i.length;return(p=a.current[m])==null||p.focus(),m});break;case"Home":l.preventDefault(),n(0),(d=a.current[0])==null||d.focus();break;case"End":l.preventDefault(),n(i.length-1),(u=a.current[i.length-1])==null||u.focus();break}},[i.length,s]);return c.jsx("div",{ref:o,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:i.map((l,d)=>{const u=l.icon,f=l.variant==="danger";return c.jsxs("button",{ref:m=>{a.current[d]=m},role:"menuitem",tabIndex:r===d?0:-1,onClick:()=>{l.onClick(),s()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[c.jsx(u,{size:14}),l.label]},l.label)})})}/**
|
|
151
|
+
`},Nn=Dc(Bc)(ta),Nc={config:Pc},Tc=function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return function(r){return i.reduceRight(function(n,o){return o(n)},r)}};function ia(e,t){return Object.keys(t).forEach(function(i){t[i]instanceof Object&&e[i]&&Object.assign(t[i],ia(e[i],t[i]))}),Pn(Pn({},e),t)}var Ac={type:"cancelation",msg:"operation is manually canceled"};function Ts(e){var t=!1,i=new Promise(function(s,r){e.then(function(n){return t?r(Ac):s(n)}),e.catch(r)});return i.cancel=function(){return t=!0},i}var zc=["monaco"],Oc=Ec.create({config:Mc,isInitialized:!1,resolve:null,reject:null,monaco:null}),sa=lc(Oc,2),Ti=sa[0],bs=sa[1];function jc(e){var t=Nc.config(e),i=t.monaco,s=oc(t,zc);bs(function(r){return{config:ia(r.config,s),monaco:i}})}function Ic(){var e=Ti(function(t){var i=t.monaco,s=t.isInitialized,r=t.resolve;return{monaco:i,isInitialized:s,resolve:r}});if(!e.isInitialized){if(bs({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Ts(As);if(window.monaco&&window.monaco.editor)return ra(window.monaco),e.resolve(window.monaco),Ts(As);Tc($c,Fc)(Wc)}return Ts(As)}function $c(e){return document.body.appendChild(e)}function Hc(e){var t=document.createElement("script");return e&&(t.src=e),t}function Fc(e){var t=Ti(function(s){var r=s.config,n=s.reject;return{config:r,reject:n}}),i=Hc("".concat(t.config.paths.vs,"/loader.js"));return i.onload=function(){return e()},i.onerror=t.reject,i}function Wc(){var e=Ti(function(i){var s=i.config,r=i.resolve,n=i.reject;return{config:s,resolve:r,reject:n}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(i){var s=i.m||i;ra(s),e.resolve(s)},function(i){e.reject(i)})}function ra(e){Ti().monaco||bs({monaco:e})}function Kc(){return Ti(function(e){var t=e.monaco;return t})}var As=new Promise(function(e,t){return bs({resolve:e,reject:t})}),na={config:jc,init:Ic,__getMonacoInstance:Kc},Uc={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},zs=Uc,qc={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Vc=qc;function Yc({children:e}){return Gt.createElement("div",{style:Vc.container},e)}var Xc=Yc,Gc=Xc;function Jc({width:e,height:t,isEditorReady:i,loading:s,_ref:r,className:n,wrapperProps:o}){return Gt.createElement("section",{style:{...zs.wrapper,width:e,height:t},...o},!i&&Gt.createElement(Gc,null,s),Gt.createElement("div",{ref:r,style:{...zs.fullWidth,...!i&&zs.hide},className:n}))}var Zc=Jc,oa=g.memo(Zc);function Qc(e){g.useEffect(e,[])}var aa=Qc;function ed(e,t,i=!0){let s=g.useRef(!0);g.useEffect(s.current||!i?()=>{s.current=!1}:e,t)}var $e=ed;function ki(){}function Vt(e,t,i,s){return td(e,s)||id(e,t,i,s)}function td(e,t){return e.editor.getModel(la(e,t))}function id(e,t,i,s){return e.editor.createModel(t,i,s?la(e,s):void 0)}function la(e,t){return e.Uri.parse(t)}function sd({original:e,modified:t,language:i,originalLanguage:s,modifiedLanguage:r,originalModelPath:n,modifiedModelPath:o,keepCurrentOriginalModel:a=!1,keepCurrentModifiedModel:h=!1,theme:l="light",loading:d="Loading...",options:u={},height:f="100%",width:m="100%",className:p,wrapperProps:_={},beforeMount:y=ki,onMount:S=ki}){let[b,P]=g.useState(!1),[k,C]=g.useState(!0),A=g.useRef(null),D=g.useRef(null),W=g.useRef(null),U=g.useRef(S),$=g.useRef(y),N=g.useRef(!1);aa(()=>{let x=na.init();return x.then(L=>(D.current=L)&&C(!1)).catch(L=>(L==null?void 0:L.type)!=="cancelation"&&console.error("Monaco initialization: error:",L)),()=>A.current?R():x.cancel()}),$e(()=>{if(A.current&&D.current){let x=A.current.getOriginalEditor(),L=Vt(D.current,e||"",s||i||"text",n||"");L!==x.getModel()&&x.setModel(L)}},[n],b),$e(()=>{if(A.current&&D.current){let x=A.current.getModifiedEditor(),L=Vt(D.current,t||"",r||i||"text",o||"");L!==x.getModel()&&x.setModel(L)}},[o],b),$e(()=>{let x=A.current.getModifiedEditor();x.getOption(D.current.editor.EditorOption.readOnly)?x.setValue(t||""):t!==x.getValue()&&(x.executeEdits("",[{range:x.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),x.pushUndoStop())},[t],b),$e(()=>{var x,L;(L=(x=A.current)==null?void 0:x.getModel())==null||L.original.setValue(e||"")},[e],b),$e(()=>{let{original:x,modified:L}=A.current.getModel();D.current.editor.setModelLanguage(x,s||i||"text"),D.current.editor.setModelLanguage(L,r||i||"text")},[i,s,r],b),$e(()=>{var x;(x=D.current)==null||x.editor.setTheme(l)},[l],b),$e(()=>{var x;(x=A.current)==null||x.updateOptions(u)},[u],b);let M=g.useCallback(()=>{var I;if(!D.current)return;$.current(D.current);let x=Vt(D.current,e||"",s||i||"text",n||""),L=Vt(D.current,t||"",r||i||"text",o||"");(I=A.current)==null||I.setModel({original:x,modified:L})},[i,t,r,e,s,n,o]),w=g.useCallback(()=>{var x;!N.current&&W.current&&(A.current=D.current.editor.createDiffEditor(W.current,{automaticLayout:!0,...u}),M(),(x=D.current)==null||x.editor.setTheme(l),P(!0),N.current=!0)},[u,l,M]);g.useEffect(()=>{b&&U.current(A.current,D.current)},[b]),g.useEffect(()=>{!k&&!b&&w()},[k,b,w]);function R(){var L,I,B,Y;let x=(L=A.current)==null?void 0:L.getModel();a||((I=x==null?void 0:x.original)==null||I.dispose()),h||((B=x==null?void 0:x.modified)==null||B.dispose()),(Y=A.current)==null||Y.dispose()}return Gt.createElement(oa,{width:m,height:f,isEditorReady:b,loading:d,_ref:W,className:p,wrapperProps:_})}var rd=sd;g.memo(rd);function nd(e){let t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}var od=nd,Yi=new Map;function ad({defaultValue:e,defaultLanguage:t,defaultPath:i,value:s,language:r,path:n,theme:o="light",line:a,loading:h="Loading...",options:l={},overrideServices:d={},saveViewState:u=!0,keepCurrentModel:f=!1,width:m="100%",height:p="100%",className:_,wrapperProps:y={},beforeMount:S=ki,onMount:b=ki,onChange:P,onValidate:k=ki}){let[C,A]=g.useState(!1),[D,W]=g.useState(!0),U=g.useRef(null),$=g.useRef(null),N=g.useRef(null),M=g.useRef(b),w=g.useRef(S),R=g.useRef(),x=g.useRef(s),L=od(n),I=g.useRef(!1),B=g.useRef(!1);aa(()=>{let H=na.init();return H.then(K=>(U.current=K)&&W(!1)).catch(K=>(K==null?void 0:K.type)!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>$.current?te():H.cancel()}),$e(()=>{var K,V,Z,se;let H=Vt(U.current,e||s||"",t||r||"",n||i||"");H!==((K=$.current)==null?void 0:K.getModel())&&(u&&Yi.set(L,(V=$.current)==null?void 0:V.saveViewState()),(Z=$.current)==null||Z.setModel(H),u&&((se=$.current)==null||se.restoreViewState(Yi.get(n))))},[n],C),$e(()=>{var H;(H=$.current)==null||H.updateOptions(l)},[l],C),$e(()=>{!$.current||s===void 0||($.current.getOption(U.current.editor.EditorOption.readOnly)?$.current.setValue(s):s!==$.current.getValue()&&(B.current=!0,$.current.executeEdits("",[{range:$.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),$.current.pushUndoStop(),B.current=!1))},[s],C),$e(()=>{var K,V;let H=(K=$.current)==null?void 0:K.getModel();H&&r&&((V=U.current)==null||V.editor.setModelLanguage(H,r))},[r],C),$e(()=>{var H;a!==void 0&&((H=$.current)==null||H.revealLine(a))},[a],C),$e(()=>{var H;(H=U.current)==null||H.editor.setTheme(o)},[o],C);let Y=g.useCallback(()=>{var H;if(!(!N.current||!U.current)&&!I.current){w.current(U.current);let K=n||i,V=Vt(U.current,s||e||"",t||r||"",K||"");$.current=(H=U.current)==null?void 0:H.editor.create(N.current,{model:V,automaticLayout:!0,...l},d),u&&$.current.restoreViewState(Yi.get(K)),U.current.editor.setTheme(o),a!==void 0&&$.current.revealLine(a),A(!0),I.current=!0}},[e,t,i,s,r,n,l,d,u,o,a]);g.useEffect(()=>{C&&M.current($.current,U.current)},[C]),g.useEffect(()=>{!D&&!C&&Y()},[D,C,Y]),x.current=s,g.useEffect(()=>{var H,K;C&&P&&((H=R.current)==null||H.dispose(),R.current=(K=$.current)==null?void 0:K.onDidChangeModelContent(V=>{B.current||P($.current.getValue(),V)}))},[C,P]),g.useEffect(()=>{if(C){let H=U.current.editor.onDidChangeMarkers(K=>{var Z;let V=(Z=$.current.getModel())==null?void 0:Z.uri;if(V&&K.find(se=>se.path===V.path)){let se=U.current.editor.getModelMarkers({resource:V});k==null||k(se)}});return()=>{H==null||H.dispose()}}return()=>{}},[C,k]);function te(){var H,K;(H=R.current)==null||H.dispose(),f?u&&Yi.set(n,$.current.saveViewState()):(K=$.current.getModel())==null||K.dispose(),$.current.dispose()}return Gt.createElement(oa,{width:m,height:p,isEditorReady:C,loading:h,_ref:N,className:_,wrapperProps:y})}var ld=ad,hd=g.memo(ld),cd=hd;function dd(e,t){const i=getComputedStyle(e),s=parseFloat(i.fontSize);return t*s}function ud(e,t){const i=getComputedStyle(e.ownerDocument.body),s=parseFloat(i.fontSize);return t*s}function fd(e){return e/100*window.innerHeight}function _d(e){return e/100*window.innerWidth}function pd(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 vi({groupSize:e,panelElement:t,styleProp:i}){let s;const[r,n]=pd(i);switch(n){case"%":{s=r/100*e;break}case"px":{s=r;break}case"rem":{s=ud(t,r);break}case"em":{s=dd(t,r);break}case"vh":{s=fd(r);break}case"vw":{s=_d(r);break}}return s}function ze(e){return parseFloat(e.toFixed(3))}function Qt({group:e}){const{orientation:t,panels:i}=e;return i.reduce((s,r)=>(s+=t==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,s),0)}function Zs(e){const{panels:t}=e,i=Qt({group:e});return i===0?t.map(s=>({groupResizeBehavior:s.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:s.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:s.panelConstraints.disabled,minSize:0,maxSize:100,panelId:s.id})):t.map(s=>{const{element:r,panelConstraints:n}=s;let o=0;if(n.collapsedSize!==void 0){const d=vi({groupSize:i,panelElement:r,styleProp:n.collapsedSize});o=ze(d/i*100)}let a;if(n.defaultSize!==void 0){const d=vi({groupSize:i,panelElement:r,styleProp:n.defaultSize});a=ze(d/i*100)}let h=0;if(n.minSize!==void 0){const d=vi({groupSize:i,panelElement:r,styleProp:n.minSize});h=ze(d/i*100)}let l=100;if(n.maxSize!==void 0){const d=vi({groupSize:i,panelElement:r,styleProp:n.maxSize});l=ze(d/i*100)}return{groupResizeBehavior:n.groupResizeBehavior,collapsedSize:o,collapsible:n.collapsible===!0,defaultSize:a,disabled:n.disabled,minSize:h,maxSize:l,panelId:s.id}})}function ne(e,t="Assertion error"){if(!e)throw Error(t)}function Qs(e,t){return Array.from(t).sort(e==="horizontal"?md:gd)}function md(e,t){const i=e.element.offsetLeft-t.element.offsetLeft;return i!==0?i:e.element.offsetWidth-t.element.offsetWidth}function gd(e,t){const i=e.element.offsetTop-t.element.offsetTop;return i!==0?i:e.element.offsetHeight-t.element.offsetHeight}function ha(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function ca(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 vd({orientation:e,rects:t,targetRect:i}){const s={x:i.x+i.width/2,y:i.y+i.height/2};let r,n=Number.MAX_VALUE;for(const o of t){const{x:a,y:h}=ca(s,o),l=e==="horizontal"?a:h;l<n&&(n=l,r=o)}return ne(r,"No rect found"),r}let Xi;function Sd(){return Xi===void 0&&(typeof matchMedia=="function"?Xi=!!matchMedia("(pointer:coarse)").matches:Xi=!1),Xi}function da(e){const{element:t,orientation:i,panels:s,separators:r}=e,n=Qs(i,Array.from(t.children).filter(ha).map(p=>({element:p}))).map(({element:p})=>p),o=[];let a=!1,h=!1,l=-1,d=-1,u=0,f,m=[];{let p=-1;for(const _ of n)_.hasAttribute("data-panel")&&(p++,_.ariaDisabled===null&&(u++,l===-1&&(l=p),d=p))}if(u>1){let p=-1;for(const _ of n)if(_.hasAttribute("data-panel")){p++;const y=s.find(S=>S.element===_);if(y){if(f){const S=f.element.getBoundingClientRect(),b=_.getBoundingClientRect();let P;if(h){const k=i==="horizontal"?new DOMRect(S.right,S.top,0,S.height):new DOMRect(S.left,S.bottom,S.width,0),C=i==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(m.length){case 0:{P=[k,C];break}case 1:{const A=m[0],D=vd({orientation:i,rects:[S,b],targetRect:A.element.getBoundingClientRect()});P=[A,D===S?C:k];break}default:{P=m;break}}}else m.length?P=m:P=[i==="horizontal"?new DOMRect(S.right,b.top,b.left-S.right,b.height):new DOMRect(b.left,S.bottom,b.width,b.top-S.bottom)];for(const k of P){let C="width"in k?k:k.element.getBoundingClientRect();const A=Sd()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<A){const W=A-C.width;C=new DOMRect(C.x-W/2,C.y,C.width+W,C.height)}if(C.height<A){const W=A-C.height;C=new DOMRect(C.x,C.y-W/2,C.width,C.height+W)}const D=p<=l||p>d;!a&&!D&&o.push({group:e,groupSize:Qt({group:e}),panels:[f,y],separator:"width"in k?void 0:k,rect:C}),a=!1}}h=!1,f=y,m=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(a=!0);const y=r.find(S=>S.element===_);y?m.push(y):(f=void 0,m=[])}else h=!0}return o}var mt,Vo;let ua=(Vo=class{constructor(){xn(this,mt,{})}addListener(t,i){const s=li(this,mt)[t];return s===void 0?li(this,mt)[t]=[i]:s.includes(i)||s.push(i),()=>{this.removeListener(t,i)}}emit(t,i){const s=li(this,mt)[t];if(s!==void 0)if(s.length===1)s[0].call(null,i);else{let r=!1,n=null;const o=Array.from(s);for(let a=0;a<o.length;a++){const h=o[a];try{h.call(null,i)}catch(l){n===null&&(r=!0,n=l)}}if(r)throw n}}removeAllListeners(){Cn(this,mt,{})}removeListener(t,i){const s=li(this,mt)[t];if(s!==void 0){const r=s.indexOf(i);r>=0&&s.splice(r,1)}}},mt=new WeakMap,Vo),Qe=new Map;const fa=new ua;function bd(e){Qe=new Map(Qe),Qe.delete(e)}function Tn(e,t){for(const[i]of Qe)if(i.id===e)return i}function St(e,t){for(const[i,s]of Qe)if(i.id===e)return s;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Ot(){return Qe}function Hr(e,t){return fa.addListener("groupChange",i=>{i.group.id===e&&t(i)})}function at(e,t){const i=Qe.get(e);Qe=new Map(Qe),Qe.set(e,t),fa.emit("groupChange",{group:e,prev:i,next:t})}function yd(e,t,i){let s,r={x:1/0,y:1/0};for(const n of t){const o=ca(i,n.rect);switch(e){case"horizontal":{o.x<=r.x&&(s=n,r=o);break}case"vertical":{o.y<=r.y&&(s=n,r=o);break}}}return s?{distance:r,hitRegion:s}:void 0}function wd(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function xd(e,t){if(e===t)throw new Error("Cannot compare node with itself");const i={a:On(e),b:On(t)};let s;for(;i.a.at(-1)===i.b.at(-1);)s=i.a.pop(),i.b.pop();ne(s,"Stacking order can only be calculated for elements with a common ancestor");const r={a:zn(An(i.a)),b:zn(An(i.b))};if(r.a===r.b){const n=s.childNodes,o={a:i.a.at(-1),b:i.b.at(-1)};let a=n.length;for(;a--;){const h=n[a];if(h===o.a)return 1;if(h===o.b)return-1}}return Math.sign(r.a-r.b)}const Cd=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kd(e){const t=getComputedStyle(_a(e)??e).display;return t==="flex"||t==="inline-flex"}function Ed(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||kd(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"||Cd.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function An(e){let t=e.length;for(;t--;){const i=e[t];if(ne(i,"Missing node"),Ed(i))return i}return null}function zn(e){return e&&Number(getComputedStyle(e).zIndex)||0}function On(e){const t=[];for(;e;)t.push(e),e=_a(e);return t}function _a(e){const{parentNode:t}=e;return wd(t)?t.host:t}function Md(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 Dd({groupElement:e,hitRegion:t,pointerEventTarget:i}){if(!ha(i)||i.contains(e)||e.contains(i))return!0;if(xd(i,e)>0){let s=i;for(;s;){if(s.contains(e))return!0;if(Md(s.getBoundingClientRect(),t))return!1;s=s.parentElement}}return!0}function Fr(e,t){const i=[];return t.forEach((s,r)=>{if(r.disabled)return;const n=da(r),o=yd(r.orientation,n,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&Dd({groupElement:r.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&i.push(o.hitRegion)}),i}function Rd(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i])return!1;return!0}function Le(e,t,i=0){return Math.abs(ze(e)-ze(t))<=i}function Ze(e,t){return Le(e,t)?0:e>t?1:-1}function Yt({overrideDisabledPanels:e,panelConstraints:t,prevSize:i,size:s}){const{collapsedSize:r=0,collapsible:n,disabled:o,maxSize:a=100,minSize:h=0}=t;if(o&&!e)return i;if(Ze(s,h)<0)if(n){const l=(r+h)/2;Ze(s,l)<0?s=r:s=h}else s=h;return s=Math.min(a,s),s=ze(s),s}function Pi({delta:e,initialLayout:t,panelConstraints:i,pivotIndices:s,prevLayout:r,trigger:n}){if(Le(e,0))return t;const o=n==="imperative-api",a=Object.values(t),h=Object.values(r),l=[...a],[d,u]=s;ne(d!=null,"Invalid first pivot index"),ne(u!=null,"Invalid second pivot index");let f=0;switch(n){case"keyboard":{{const _=e<0?u:d,y=i[_];ne(y,`Panel constraints not found for index ${_}`);const{collapsedSize:S=0,collapsible:b,minSize:P=0}=y;if(b){const k=a[_];if(ne(k!=null,`Previous layout not found for panel index ${_}`),Le(k,S)){const C=P-k;Ze(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const _=e<0?d:u,y=i[_];ne(y,`No panel constraints found for index ${_}`);const{collapsedSize:S=0,collapsible:b,minSize:P=0}=y;if(b){const k=a[_];if(ne(k!=null,`Previous layout not found for panel index ${_}`),Le(k,P)){const C=k-S;Ze(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const _=e<0?u:d,y=i[_];ne(y,`Panel constraints not found for index ${_}`);const S=a[_],{collapsible:b,collapsedSize:P,minSize:k}=y;if(b&&Ze(S,k)<0)if(e>0){const C=k-P,A=C/2,D=S+e;Ze(D,k)<0&&(e=Ze(e,A)<=0?0:C)}else{const C=k-P,A=100-C/2,D=S-e;Ze(D,k)<0&&(e=Ze(100+e,A)>0?0:-C)}break}}{const _=e<0?1:-1;let y=e<0?u:d,S=0;for(;;){const P=a[y];ne(P!=null,`Previous layout not found for panel index ${y}`);const k=Yt({overrideDisabledPanels:o,panelConstraints:i[y],prevSize:P,size:100})-P;if(S+=k,y+=_,y<0||y>=i.length)break}const b=Math.min(Math.abs(e),Math.abs(S));e=e<0?0-b:b}{let _=e<0?d:u;for(;_>=0&&_<i.length;){const y=Math.abs(e)-Math.abs(f),S=a[_];ne(S!=null,`Previous layout not found for panel index ${_}`);const b=S-y,P=Yt({overrideDisabledPanels:o,panelConstraints:i[_],prevSize:S,size:b});if(!Le(S,P)&&(f+=S-P,l[_]=P,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(Rd(h,l))return r;{const _=e<0?u:d,y=a[_];ne(y!=null,`Previous layout not found for panel index ${_}`);const S=y+f,b=Yt({overrideDisabledPanels:o,panelConstraints:i[_],prevSize:y,size:S});if(l[_]=b,!Le(b,S)){let P=S-b,k=e<0?u:d;for(;k>=0&&k<i.length;){const C=l[k];ne(C!=null,`Previous layout not found for panel index ${k}`);const A=C+P,D=Yt({overrideDisabledPanels:o,panelConstraints:i[k],prevSize:C,size:A});if(Le(C,D)||(P-=D-C,l[k]=D),Le(P,0))break;e>0?k--:k++}}}const m=Object.values(l).reduce((_,y)=>y+_,0);if(!Le(m,100,.1))return r;const p=Object.keys(r);return l.reduce((_,y,S)=>(_[p[S]]=y,_),{})}function Bt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(t[i]===void 0||Ze(e[i],t[i])!==0)return!1;return!0}function Nt({layout:e,panelConstraints:t}){const i=Object.values(e),s=[...i],r=s.reduce((a,h)=>a+h,0);if(s.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${s.map(a=>`${a}%`).join(", ")}`);if(!Le(r,100)&&s.length>0)for(let a=0;a<t.length;a++){const h=s[a];ne(h!=null,`No layout data found for index ${a}`);const l=100/r*h;s[a]=l}let n=0;for(let a=0;a<t.length;a++){const h=i[a];ne(h!=null,`No layout data found for index ${a}`);const l=s[a];ne(l!=null,`No layout data found for index ${a}`);const d=Yt({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:h,size:l});l!=d&&(n+=l-d,s[a]=d)}if(!Le(n,0))for(let a=0;a<t.length;a++){const h=s[a];ne(h!=null,`No layout data found for index ${a}`);const l=h+n,d=Yt({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:h,size:l});if(h!==d&&(n-=d-h,s[a]=d,Le(n,0)))break}const o=Object.keys(e);return s.reduce((a,h,l)=>(a[o[l]]=h,a),{})}function pa({groupId:e,panelId:t}){const i=()=>{const a=Ot();for(const[h,{defaultLayoutDeferred:l,derivedPanelConstraints:d,layout:u,groupSize:f,separatorToPanels:m}]of a)if(h.id===e)return{defaultLayoutDeferred:l,derivedPanelConstraints:d,group:h,groupSize:f,layout:u,separatorToPanels:m};throw Error(`Group ${e} not found`)},s=()=>{const a=i().derivedPanelConstraints.find(h=>h.panelId===t);if(a!==void 0)return a;throw Error(`Panel constraints not found for Panel ${t}`)},r=()=>{const a=i().group.panels.find(h=>h.id===t);if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},n=()=>{const a=i().layout[t];if(a!==void 0)return a;throw Error(`Layout not found for Panel ${t}`)},o=a=>{const h=n();if(a===h)return;const{defaultLayoutDeferred:l,derivedPanelConstraints:d,group:u,groupSize:f,layout:m,separatorToPanels:p}=i(),_=u.panels.findIndex(P=>P.id===t),y=_===u.panels.length-1,S=Pi({delta:y?h-a:a-h,initialLayout:m,panelConstraints:d,pivotIndices:y?[_-1,_]:[_,_+1],prevLayout:m,trigger:"imperative-api"}),b=Nt({layout:S,panelConstraints:d});Bt(m,b)||at(u,{defaultLayoutDeferred:l,derivedPanelConstraints:d,groupSize:f,layout:b,separatorToPanels:p})};return{collapse:()=>{const{collapsible:a,collapsedSize:h}=s(),{mutableValues:l}=r(),d=n();a&&d!==h&&(l.expandToSize=d,o(h))},expand:()=>{const{collapsible:a,collapsedSize:h,minSize:l}=s(),{mutableValues:d}=r(),u=n();if(a&&u===h){let f=d.expandToSize??l;f===0&&(f=1),o(f)}},getSize:()=>{const{group:a}=i(),h=n(),{element:l}=r(),d=a.orientation==="horizontal"?l.offsetWidth:l.offsetHeight;return{asPercentage:h,inPixels:d}},isCollapsed:()=>{const{collapsible:a,collapsedSize:h}=s(),l=n();return a&&Le(h,l)},resize:a=>{const{group:h}=i(),{element:l}=r(),d=Qt({group:h}),u=vi({groupSize:d,panelElement:l,styleProp:a}),f=ze(u/d*100);o(f)}}}function jn(e){if(e.defaultPrevented)return;const t=Ot();Fr(e,t).forEach(i=>{if(i.separator){const s=i.panels.find(r=>r.panelConstraints.defaultSize!==void 0);if(s){const r=s.panelConstraints.defaultSize,n=pa({groupId:i.group.id,panelId:s.id});n&&r!==void 0&&(n.resize(r),e.preventDefault())}}})}function rs(e){const t=Ot();for(const[i]of t)if(i.separators.some(s=>s.element===e))return i;throw Error("Could not find parent Group for separator element")}function ma({groupId:e}){const t=()=>{const i=Ot();for(const[s,r]of i)if(s.id===e)return{group:s,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:i,layout:s}=t();return i?{}:s},setLayout(i){const{defaultLayoutDeferred:s,derivedPanelConstraints:r,group:n,groupSize:o,layout:a,separatorToPanels:h}=t(),l=Nt({layout:i,panelConstraints:r});return s?a:(Bt(a,l)||at(n,{defaultLayoutDeferred:s,derivedPanelConstraints:r,groupSize:o,layout:l,separatorToPanels:h}),l)}}}function kt(e,t){const i=rs(e),s=St(i.id,!0),r=i.separators.find(d=>d.element===e);ne(r,"Matching separator not found");const n=s.separatorToPanels.get(r);ne(n,"Matching panels not found");const o=n.map(d=>i.panels.indexOf(d)),a=ma({groupId:i.id}).getLayout(),h=Pi({delta:t,initialLayout:a,panelConstraints:s.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),l=Nt({layout:h,panelConstraints:s.derivedPanelConstraints});Bt(a,l)||at(i,{defaultLayoutDeferred:s.defaultLayoutDeferred,derivedPanelConstraints:s.derivedPanelConstraints,groupSize:s.groupSize,layout:l,separatorToPanels:s.separatorToPanels})}function In(e){if(e.defaultPrevented)return;const t=e.currentTarget,i=rs(t);if(!i.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),i.orientation==="vertical"&&kt(t,5);break}case"ArrowLeft":{e.preventDefault(),i.orientation==="horizontal"&&kt(t,-5);break}case"ArrowRight":{e.preventDefault(),i.orientation==="horizontal"&&kt(t,5);break}case"ArrowUp":{e.preventDefault(),i.orientation==="vertical"&&kt(t,-5);break}case"End":{e.preventDefault(),kt(t,100);break}case"Enter":{e.preventDefault();const s=rs(t),r=St(s.id,!0),{derivedPanelConstraints:n,layout:o,separatorToPanels:a}=r,h=s.separators.find(f=>f.element===t);ne(h,"Matching separator not found");const l=a.get(h);ne(l,"Matching panels not found");const d=l[0],u=n.find(f=>f.panelId===d.id);if(ne(u,"Panel metadata not found"),u.collapsible){const f=o[d.id],m=u.collapsedSize===f?s.mutableState.expandedPanelSizes[d.id]??u.minSize:u.collapsedSize;kt(t,m-f)}break}case"F6":{e.preventDefault();const s=rs(t).separators.map(o=>o.element),r=Array.from(s).findIndex(o=>o===e.currentTarget);ne(r!==null,"Index not found");const n=e.shiftKey?r>0?r-1:s.length-1:r+1<s.length?r+1:0;s[n].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),kt(t,-100);break}}}let Jt={cursorFlags:0,state:"inactive"};const Wr=new ua;function Tt(){return Jt}function Pd(e){return Wr.addListener("change",e)}function Ld(e){const t=Jt,i={...Jt};i.cursorFlags=e,Jt=i,Wr.emit("change",{prev:t,next:i})}function Zt(e){const t=Jt;Jt=e,Wr.emit("change",{prev:t,next:e})}function $n(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Ot(),i=Fr(e,t),s=new Map;let r=!1;i.forEach(n=>{n.separator&&(r||(r=!0,n.separator.element.focus({preventScroll:!0})));const o=t.get(n.group);o&&s.set(n.group,o.layout)}),Zt({cursorFlags:0,hitRegions:i,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),i.length&&e.preventDefault()}const Bd=e=>e,Os=()=>{},ga=1,va=2,Sa=4,ba=8,Hn=3,Fn=12;let Gi;function Wn(){return Gi===void 0&&(Gi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Gi=!0)),Gi}function Nd({cursorFlags:e,groups:t,state:i}){let s=0,r=0;switch(i){case"active":case"hover":t.forEach(n=>{if(!n.mutableState.disableCursor)switch(n.orientation){case"horizontal":{s++;break}case"vertical":{r++;break}}})}if(!(s===0&&r===0)){switch(i){case"active":{if(e&&Wn()){const n=(e&ga)!==0,o=(e&va)!==0,a=(e&Sa)!==0,h=(e&ba)!==0;if(n)return a?"se-resize":h?"ne-resize":"e-resize";if(o)return a?"sw-resize":h?"nw-resize":"w-resize";if(a)return"s-resize";if(h)return"n-resize"}break}}return Wn()?s>0&&r>0?"move":s>0?"ew-resize":"ns-resize":s>0&&r>0?"grab":s>0?"col-resize":"row-resize"}}const Kn=new WeakMap;function Kr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:i}=Kn.get(e)??{};i===void 0&&(i=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(i));const s=Tt();switch(s.state){case"active":case"hover":{const r=Nd({cursorFlags:s.cursorFlags,groups:s.hitRegions.map(o=>o.group),state:s.state}),n=`*, *:hover {cursor: ${r} !important; }`;if(t===n)return;t=n,r?i.cssRules.length===0?i.insertRule(n):i.replaceSync(n):i.cssRules.length===1&&i.deleteRule(0);break}case"inactive":{t=void 0,i.cssRules.length===1&&i.deleteRule(0);break}}Kn.set(e,{prevStyle:t,styleSheet:i})}function ya({document:e,event:t,hitRegions:i,initialLayoutMap:s,mountedGroups:r,pointerDownAtPoint:n,prevCursorFlags:o}){let a=0;i.forEach(l=>{const{group:d,groupSize:u}=l,{orientation:f,panels:m}=d,{disableCursor:p}=d.mutableState;let _=0;n?f==="horizontal"?_=(t.clientX-n.x)/u*100:_=(t.clientY-n.y)/u*100:f==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const y=s.get(d),S=r.get(d);if(!y||!S)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:P,groupSize:k,layout:C,separatorToPanels:A}=S;if(P&&C&&A){const D=Pi({delta:_,initialLayout:y,panelConstraints:P,pivotIndices:l.panels.map(W=>m.indexOf(W)),prevLayout:C,trigger:"mouse-or-touch"});if(Bt(D,C)){if(_!==0&&!p)switch(f){case"horizontal":{a|=_<0?ga:va;break}case"vertical":{a|=_<0?Sa:ba;break}}}else at(l.group,{defaultLayoutDeferred:b,derivedPanelConstraints:P,groupSize:k,layout:D,separatorToPanels:A})}});let h=0;t.movementX===0?h|=o&Hn:h|=a&Hn,t.movementY===0?h|=o&Fn:h|=a&Fn,Ld(h),Kr(e)}function Un(e){const t=Ot(),i=Tt();switch(i.state){case"active":ya({document:e.currentTarget,event:e,hitRegions:i.hitRegions,initialLayoutMap:i.initialLayoutMap,mountedGroups:t,prevCursorFlags:i.cursorFlags})}}function qn(e){if(e.defaultPrevented)return;const t=Tt(),i=Ot();switch(t.state){case"active":{if(e.buttons===0){Zt({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const r=St(s.group.id,!0);at(s.group,r)});return}ya({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:i,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Fr(e,i);s.length===0?t.state!=="inactive"&&Zt({cursorFlags:0,state:"inactive"}):Zt({cursorFlags:0,hitRegions:s,state:"hover"}),Kr(e.currentTarget);break}}}function Vn(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(Tt().state){case"hover":Zt({cursorFlags:0,state:"inactive"})}}function Yn(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Tt();switch(t.state){case"active":Zt({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Kr(e.currentTarget),t.hitRegions.forEach(i=>{const s=St(i.group.id,!0);at(i.group,s)}),e.preventDefault())}}function Xn(e){let t=0,i=0;const s={};for(const n of e)if(n.defaultSize!==void 0){t++;const o=ze(n.defaultSize);i+=o,s[n.panelId]=o}else s[n.panelId]=void 0;const r=e.length-t;if(r!==0){const n=ze((100-i)/r);for(const o of e)o.defaultSize===void 0&&(s[o.panelId]=n)}return s}function Td(e,t,i){if(!i[0])return;const s=e.panels.find(h=>h.element===t);if(!s||!s.onResize)return;const r=Qt({group:e}),n=e.orientation==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,o=s.mutableValues.prevSize,a={asPercentage:ze(n/r*100),inPixels:n};s.mutableValues.prevSize=a,s.onResize(a,s.id,o)}function Ad(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}function zd({group:e,nextGroupSize:t,prevGroupSize:i,prevLayout:s}){if(i<=0||t<=0||i===t)return s;let r=0,n=0,o=!1;const a=new Map,h=[];for(const u of e.panels){const f=s[u.id]??0;switch(u.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const m=f/100*i,p=ze(m/t*100);a.set(u.id,p),r+=p;break}case"preserve-relative-size":default:{h.push(u.id),n+=f;break}}}if(!o||h.length===0)return s;const l=100-r,d={...s};if(a.forEach((u,f)=>{d[f]=u}),n>0)for(const u of h){const f=s[u]??0;d[u]=ze(f/n*l)}else{const u=ze(l/h.length);for(const f of h)d[f]=u}return d}function Od(e,t){const i=e.map(r=>r.id),s=Object.keys(t);if(i.length!==s.length)return!1;for(const r of i)if(!s.includes(r))return!1;return!0}const Wt=new Map;function jd(e){let t=!0;ne(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const i=e.element.ownerDocument.defaultView.ResizeObserver,s=new Set,r=new Set,n=new i(p=>{for(const _ of p){const{borderBoxSize:y,target:S}=_;if(S===e.element){if(t){const b=Qt({group:e});if(b===0)return;const P=St(e.id);if(!P)return;const k=Zs(e),C=P.defaultLayoutDeferred?Xn(k):P.layout,A=zd({group:e,nextGroupSize:b,prevGroupSize:P.groupSize,prevLayout:C}),D=Nt({layout:A,panelConstraints:k});if(!P.defaultLayoutDeferred&&Bt(P.layout,D)&&Ad(P.derivedPanelConstraints,k)&&P.groupSize===b)return;at(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:k,groupSize:b,layout:D,separatorToPanels:P.separatorToPanels})}}else Td(e,S,y)}});n.observe(e.element),e.panels.forEach(p=>{ne(!s.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),s.add(p.id),p.onResize&&n.observe(p.element)});const o=Qt({group:e}),a=Zs(e),h=e.panels.map(({id:p})=>p).join(",");let l=e.mutableState.defaultLayout;l&&(Od(e.panels,l)||(l=void 0));const d=e.mutableState.layouts[h]??l??Xn(a),u=Nt({layout:d,panelConstraints:a}),f=e.element.ownerDocument;Wt.set(f,(Wt.get(f)??0)+1);const m=new Map;return da(e).forEach(p=>{p.separator&&m.set(p.separator,p.panels)}),at(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:u,separatorToPanels:m}),e.separators.forEach(p=>{ne(!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",In)}),Wt.get(f)===1&&(f.addEventListener("dblclick",jn,!0),f.addEventListener("pointerdown",$n,!0),f.addEventListener("pointerleave",Un),f.addEventListener("pointermove",qn),f.addEventListener("pointerout",Vn),f.addEventListener("pointerup",Yn,!0)),function(){t=!1,Wt.set(f,Math.max(0,(Wt.get(f)??0)-1)),bd(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",In)}),Wt.get(f)||(f.removeEventListener("dblclick",jn,!0),f.removeEventListener("pointerdown",$n,!0),f.removeEventListener("pointerleave",Un),f.removeEventListener("pointermove",qn),f.removeEventListener("pointerout",Vn),f.removeEventListener("pointerup",Yn,!0)),n.disconnect()}}function Id(){const[e,t]=g.useState({}),i=g.useCallback(()=>t({}),[]);return[e,i]}function Ur(e){const t=g.useId();return`${e??t}`}const jt=typeof window<"u"?g.useLayoutEffect:g.useEffect;function Ei(e){const t=g.useRef(e);return jt(()=>{t.current=e},[e]),g.useCallback((...i)=>{var s;return(s=t.current)==null?void 0:s.call(t,...i)},[t])}function qr(...e){return Ei(t=>{e.forEach(i=>{if(i)switch(typeof i){case"function":{i(t);break}case"object":{i.current=t;break}}})})}function Vr(e){const t=g.useRef({...e});return jt(()=>{for(const i in e)t.current[i]=e[i]},[e]),t.current}const wa=g.createContext(null);function $d(e,t){const i=g.useRef({getLayout:()=>({}),setLayout:Bd});g.useImperativeHandle(t,()=>i.current,[]),jt(()=>{Object.assign(i.current,ma({groupId:e}))})}function er({children:e,className:t,defaultLayout:i,disableCursor:s,disabled:r,elementRef:n,groupRef:o,id:a,onLayoutChange:h,onLayoutChanged:l,orientation:d="horizontal",resizeTargetMinimumSize:u={coarse:20,fine:10},style:f,...m}){const p=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=Ei(N=>{Bt(p.current.onLayoutChange,N)||(p.current.onLayoutChange=N,h==null||h(N))}),y=Ei(N=>{Bt(p.current.onLayoutChanged,N)||(p.current.onLayoutChanged=N,l==null||l(N))}),S=Ur(a),b=g.useRef(null),[P,k]=Id(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:u,separators:[]}),A=qr(b,n);$d(S,o);const D=Ei((N,M)=>{const w=Tt(),R=Tn(N),x=St(N);if(x){let L=!1;switch(w.state){case"active":{L=w.hitRegions.some(I=>I.group===R);break}}return{flexGrow:x.layout[M]??1,pointerEvents:L?"none":void 0}}return{flexGrow:(i==null?void 0:i[M])??1}}),W=Vr({defaultLayout:i,disableCursor:s}),U=g.useMemo(()=>({get disableCursor(){return!!W.disableCursor},getPanelStyles:D,id:S,orientation:d,registerPanel:N=>{const M=C.current;return M.panels=Qs(d,[...M.panels,N]),k(),()=>{M.panels=M.panels.filter(w=>w!==N),k()}},registerSeparator:N=>{const M=C.current;return M.separators=Qs(d,[...M.separators,N]),k(),()=>{M.separators=M.separators.filter(w=>w!==N),k()}},togglePanelDisabled:(N,M)=>{const w=C.current.panels.find(L=>L.id===N);w&&(w.panelConstraints.disabled=M);const R=Tn(S),x=St(S);R&&x&&at(R,{...x,derivedPanelConstraints:Zs(R)})},toggleSeparatorDisabled:(N,M)=>{const w=C.current.separators.find(R=>R.id===N);w&&(w.disabled=M)}}),[D,S,k,d,W]),$=g.useRef(null);return jt(()=>{const N=b.current;if(N===null)return;const M=C.current;let w;if(W.defaultLayout!==void 0&&Object.keys(W.defaultLayout).length===M.panels.length){w={};for(const te of M.panels){const H=W.defaultLayout[te.id];H!==void 0&&(w[te.id]=H)}}const R={disabled:!!r,element:N,id:S,mutableState:{defaultLayout:w,disableCursor:!!W.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:d,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};$.current=R;const x=jd(R),{defaultLayoutDeferred:L,derivedPanelConstraints:I,layout:B}=St(R.id,!0);!L&&I.length>0&&(_(B),y(B));const Y=Hr(S,te=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:K,layout:V}=te.next;if(H||K.length===0)return;const Z=R.panels.map(({id:le})=>le).join(",");R.mutableState.layouts[Z]=V,K.forEach(le=>{if(le.collapsible){const{layout:Ee}=te.prev??{};if(Ee){const yt=Le(le.collapsedSize,V[le.panelId]),Oe=Le(le.collapsedSize,Ee[le.panelId]);yt&&!Oe&&(R.mutableState.expandedPanelSizes[le.panelId]=Ee[le.panelId])}}});const se=Tt().state!=="active";_(V),se&&y(V)});return()=>{$.current=null,x(),Y()}},[r,S,y,_,d,P,W]),g.useEffect(()=>{const N=$.current;N&&(N.mutableState.defaultLayout=i,N.mutableState.disableCursor=!!s)}),c.jsx(wa.Provider,{value:U,children:c.jsx("div",{...m,className:t,"data-group":!0,"data-testid":S,id:S,ref:A,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:d==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:d==="horizontal"?"pan-y":"pan-x"},children:e})})}er.displayName="Group";function Yr(){const e=g.useContext(wa);return ne(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Hd(e,t){const{id:i}=Yr(),s=g.useRef({collapse:Os,expand:Os,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Os});g.useImperativeHandle(t,()=>s.current,[]),jt(()=>{Object.assign(s.current,pa({groupId:i,panelId:e}))})}function Si({children:e,className:t,collapsedSize:i="0%",collapsible:s=!1,defaultSize:r,disabled:n,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:h,maxSize:l="100%",minSize:d="0%",onResize:u,panelRef:f,style:m,...p}){const _=!!h,y=Ur(h),S=Vr({disabled:n}),b=g.useRef(null),P=qr(b,o),{getPanelStyles:k,id:C,orientation:A,registerPanel:D,togglePanelDisabled:W}=Yr(),U=u!==null,$=Ei((M,w,R)=>{u==null||u(M,h,R)});jt(()=>{const M=b.current;if(M!==null){const w={element:M,id:y,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:U?$:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:i,collapsible:s,defaultSize:r,disabled:S.disabled,maxSize:l,minSize:d}};return D(w)}},[a,i,s,r,U,y,_,l,d,$,D,S]),g.useEffect(()=>{W(y,!!n)},[n,y,W]),Hd(y,f);const N=g.useSyncExternalStore(M=>Hr(C,M),()=>JSON.stringify(k(C,y)),()=>JSON.stringify(k(C,y)));return c.jsx("div",{...p,"aria-disabled":n||void 0,"data-panel":!0,"data-testid":y,id:y,ref:P,style:{...Fd,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(N)},children:c.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...m,touchAction:A==="horizontal"?"pan-y":"pan-x"},children:e})})}Si.displayName="Panel";const Fd={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Wd({layout:e,panelConstraints:t,panelId:i,panelIndex:s}){let r,n;const o=e[i],a=t.find(h=>h.panelId===i);if(a){const h=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,d=[s,s+1];n=Nt({layout:Pi({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[i],r=Nt({layout:Pi({delta:h-o,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[i]}return{valueControls:i,valueMax:r,valueMin:n,valueNow:o}}function tr({children:e,className:t,disabled:i,elementRef:s,id:r,style:n,...o}){const a=Ur(r),h=Vr({disabled:i}),[l,d]=g.useState({}),[u,f]=g.useState("inactive"),m=g.useRef(null),p=qr(m,s),{disableCursor:_,id:y,orientation:S,registerSeparator:b,toggleSeparatorDisabled:P}=Yr(),k=S==="horizontal"?"vertical":"horizontal";jt(()=>{const A=m.current;if(A!==null){const D={disabled:h.disabled,element:A,id:a},W=b(D),U=Pd(N=>{f(N.next.state!=="inactive"&&N.next.hitRegions.some(M=>M.separator===D)?N.next.state:"inactive")}),$=Hr(y,N=>{const{derivedPanelConstraints:M,layout:w,separatorToPanels:R}=N.next,x=R.get(D);if(x){const L=x[0],I=x.indexOf(L);d(Wd({layout:w,panelConstraints:M,panelId:L.id,panelIndex:I}))}});return()=>{U(),$(),W()}}},[y,a,b,h]),g.useEffect(()=>{P(a,!!i)},[i,a,P]);let C;return i&&!_&&(C="not-allowed"),c.jsx("div",{...o,"aria-controls":l.valueControls,"aria-disabled":i||void 0,"aria-orientation":k,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":i?"disabled":u,"data-testid":a,id:a,ref:p,role:"separator",style:{flexBasis:"auto",cursor:C,...n,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:i?void 0:0})}tr.displayName="Separator";const Kd={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Ud={sm:"w-7 h-7",md:"w-8 h-8"},qd={sm:14,md:16};function dt({icon:e,label:t,size:i="md",variant:s="ghost",onClick:r,className:n="",disabled:o=!1,title:a}){return c.jsx("button",{type:"button","aria-label":t,title:a??t,disabled:o,onClick:r,className:["inline-flex items-center justify-center rounded-btn transition-colors",Kd[s],Ud[i],o?"opacity-40 cursor-not-allowed":"",n].filter(Boolean).join(" "),children:c.jsx(e,{size:qd[i]})})}function Vd({x:e,y:t,items:i,onClose:s}){const[r,n]=g.useState(0),o=g.useRef(null),a=g.useRef([]);g.useEffect(()=>{var l;(l=a.current[0])==null||l.focus()},[]),g.useEffect(()=>{const l=d=>{o.current&&!o.current.contains(d.target)&&s()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]);const h=g.useCallback(l=>{var d,u;switch(l.key){case"Escape":l.preventDefault(),s();break;case"ArrowDown":l.preventDefault(),n(f=>{var p;const m=(f+1)%i.length;return(p=a.current[m])==null||p.focus(),m});break;case"ArrowUp":l.preventDefault(),n(f=>{var p;const m=(f-1+i.length)%i.length;return(p=a.current[m])==null||p.focus(),m});break;case"Home":l.preventDefault(),n(0),(d=a.current[0])==null||d.focus();break;case"End":l.preventDefault(),n(i.length-1),(u=a.current[i.length-1])==null||u.focus();break}},[i.length,s]);return c.jsx("div",{ref:o,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:i.map((l,d)=>{const u=l.icon,f=l.variant==="danger";return c.jsxs("button",{ref:m=>{a.current[d]=m},role:"menuitem",tabIndex:r===d?0:-1,onClick:()=>{l.onClick(),s()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[c.jsx(u,{size:14}),l.label]},l.label)})})}/**
|
|
122
152
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
123
153
|
* @license MIT
|
|
124
154
|
*
|
|
@@ -129,22 +159,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
129
159
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
130
160
|
* http://bellard.org/jslinux/
|
|
131
161
|
* Copyright (c) 2011 Fabrice Bellard
|
|
132
|
-
*/var
|
|
162
|
+
*/var xa=Object.defineProperty,Yd=Object.getOwnPropertyDescriptor,Xd=(e,t)=>{for(var i in t)xa(e,i,{get:t[i],enumerable:!0})},fe=(e,t,i,s)=>{for(var r=s>1?void 0:s?Yd(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&xa(t,i,r),r},O=(e,t)=>(i,s)=>t(i,s,e),Gn="Terminal input",ir={get:()=>Gn,set:e=>Gn=e},Jn="Too much output to announce, navigate to rows manually to read",sr={get:()=>Jn,set:e=>Jn=e};function Gd(e){return e.replace(/\r?\n/g,"\r")}function Jd(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Zd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Qd(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Ca(r,t,i,s)}}function Ca(e,t,i,s){e=Gd(e),e=Jd(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function ka(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.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 Zn(e,t,i,s,r){ka(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function pt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ys(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var eu=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},tu=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let f=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)m<<=6,m|=_;let y=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=y-p;for(;l<S;){if(l>=i)return 0;if(_=e[l++],(_&192)!==128){l--,f=!0;break}else this.interim[p++]=_,m<<=6,m|=_&63}f||(y===2?m<128?l--:t[s++]=m:y===3?m<2048||m>=55296&&m<=57343||m===65279||(t[s++]=m):m<65536||m>1114111||(t[s++]=m)),this.interim.fill(0)}let d=i-4,u=l;for(;u<i;){for(;u<d&&!((r=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((a=e[u+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,u+=4;if(r=e[u++],r<128)t[s++]=r;else if((r&224)===192){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(h=(r&31)<<6|n&63,h<128){u--;continue}t[s++]=h}else if((r&240)===224){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[u++],(a&192)!==128){u--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Ea="",gt=" ",Ai=class Ma{constructor(){this.fg=0,this.bg=0,this.extended=new _s}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 Ma;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}},_s=class Da{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 Da(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},qe=class Ra extends Ai{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _s,this.combinedData=""}static fromCharData(t){let i=new Ra;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?pt(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Qn="di$target",rr="di$dependencies",js=new Map;function iu(e){return e[rr]||[]}function ke(e){if(js.has(e))return js.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");su(t,i,r)};return t._id=e,js.set(e,t),t}function su(e,t,i){t[Qn]===t?t[rr].push({id:e,index:i}):(t[rr]=[{id:e,index:i}],t[Qn]=t)}var Be=ke("BufferService"),Pa=ke("CoreMouseService"),It=ke("CoreService"),ru=ke("CharsetService"),Xr=ke("InstantiationService"),La=ke("LogService"),Ne=ke("OptionsService"),Ba=ke("OscLinkService"),nu=ke("UnicodeService"),zi=ke("DecorationService"),nr=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new qe,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let u=0;u<o;u++)if(!(h===-1&&!i.hasContent(u))){if(i.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=u,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&u===o-1){let f=(d=this._oscLinkService.getLinkData(a))==null?void 0:d.uri;if(f){let m={start:{x:h+1,y:e},end:{x:u+(!l&&u===o-1?1:0),y:e}},p=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let _=new URL(f);["http:","https:"].includes(_.protocol)||(p=!0)}catch{p=!0}p||s.push({text:f,range:m,activate:(_,y)=>r?r.activate(_,y,m):ou(_,y),hover:(_,y)=>{var S;return(S=r==null?void 0:r.hover)==null?void 0:S.call(r,_,y,m)},leave:(_,y)=>{var S;return(S=r==null?void 0:r.leave)==null?void 0:S.call(r,_,y,m)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=u,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};nr=fe([O(0,Be),O(1,Ne),O(2,Ba)],nr);function ou(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
133
163
|
|
|
134
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var
|
|
164
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ws=ke("CharSizeService"),lt=ke("CoreBrowserService"),Gr=ke("MouseService"),ht=ke("RenderService"),au=ke("SelectionService"),Na=ke("CharacterJoinerService"),ti=ke("ThemeService"),Ta=ke("LinkProviderService"),lu=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?eo.isErrorNoTelemetry(e)?new eo(e.message+`
|
|
135
165
|
|
|
136
166
|
`+e.stack):new Error(e.message+`
|
|
137
167
|
|
|
138
|
-
`+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)}},jd=new Od;function Qi(e){Id(e)||jd.onUnexpectedError(e)}var Zs="Canceled";function Id(e){return e instanceof $d?!0:e instanceof Error&&e.name===Zs&&e.message===Zs}var $d=class extends Error{constructor(){super(Zs),this.name=this.message}};function Fd(e){return new Error(`Illegal argument: ${e}`)}var Hn=class Qs extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Qs)return t;let i=new Qs;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},er=class xa extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,xa.prototype)}};function ze(e,t=0){return e[e.length-(1+t)]}var Hd;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Hd||(Hd={}));function Wd(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Ca;(e=>{function t(k){return k&&typeof k=="object"&&typeof k[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(k){yield k}e.single=r;function n(k){return t(k)?k:r(k)}e.wrap=n;function o(k){return k||i}e.from=o;function*a(k){for(let C=k.length-1;C>=0;C--)yield k[C]}e.reverse=a;function h(k){return!k||k[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(k){return k[Symbol.iterator]().next().value}e.first=l;function d(k,C){let A=0;for(let D of k)if(C(D,A++))return!0;return!1}e.some=d;function u(k,C){for(let A of k)if(C(A))return A}e.find=u;function*f(k,C){for(let A of k)C(A)&&(yield A)}e.filter=f;function*m(k,C){let A=0;for(let D of k)yield C(D,A++)}e.map=m;function*p(k,C){let A=0;for(let D of k)yield*C(D,A++)}e.flatMap=p;function*_(...k){for(let C of k)yield*C}e.concat=_;function y(k,C,A){let D=A;for(let U of k)D=C(D,U);return D}e.reduce=y;function*S(k,C,A=k.length){for(C<0&&(C+=k.length),A<0?A+=k.length:A>k.length&&(A=k.length);C<A;C++)yield k[C]}e.slice=S;function b(k,C=Number.POSITIVE_INFINITY){let A=[];if(C===0)return[A,k];let D=k[Symbol.iterator]();for(let U=0;U<C;U++){let q=D.next();if(q.done)return[A,e.empty()];A.push(q.value)}return[A,{[Symbol.iterator](){return D}}]}e.consume=b;async function P(k){let C=[];for await(let A of k)C.push(A);return Promise.resolve(C)}e.asyncToArray=P})(Ca||(Ca={}));function Nt(e){if(Ca.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 Kd(...e){return le(()=>Nt(e))}function le(e){return{dispose:Wd(()=>{e()})}}var ka=class Ea{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{Nt(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?Ea.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)}};ka.DISABLE_DISPOSED_WARNING=!1;var St=ka,Z=class{constructor(){this._store=new St,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)}};Z.None=Object.freeze({dispose(){}});var Zt=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}},nt=typeof window=="object"?window:globalThis,tr=class ir{constructor(t){this.element=t,this.next=ir.Undefined,this.prev=ir.Undefined}};tr.Undefined=new tr(void 0);var he=tr,Wn=class{constructor(){this._first=he.Undefined,this._last=he.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===he.Undefined}clear(){let e=this._first;for(;e!==he.Undefined;){let t=e.next;e.prev=he.Undefined,e.next=he.Undefined,e=t}this._first=he.Undefined,this._last=he.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new he(e);if(this._first===he.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==he.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==he.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==he.Undefined&&e.next!==he.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===he.Undefined&&e.next===he.Undefined?(this._first=he.Undefined,this._last=he.Undefined):e.next===he.Undefined?(this._last=this._last.prev,this._last.next=he.Undefined):e.prev===he.Undefined&&(this._first=this._first.next,this._first.prev=he.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==he.Undefined;)yield e.element,e=e.next}},Ud=globalThis.performance&&typeof globalThis.performance.now=="function",qd=class Ma{static create(t){return new Ma(t)}constructor(t){this._now=Ud&&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}},Ee;(e=>{e.None=()=>Z.None;function t(M,w){return u(M,()=>{},0,void 0,!0,void 0,w)}e.defer=t;function i(M){return(w,R=null,x)=>{let B=!1,j;return j=M(N=>{if(!B)return j?j.dispose():B=!0,w.call(R,N)},null,x),B&&j.dispose(),j}}e.once=i;function s(M,w,R){return l((x,B=null,j)=>M(N=>x.call(B,w(N)),null,j),R)}e.map=s;function r(M,w,R){return l((x,B=null,j)=>M(N=>{w(N),x.call(B,N)},null,j),R)}e.forEach=r;function n(M,w,R){return l((x,B=null,j)=>M(N=>w(N)&&x.call(B,N),null,j),R)}e.filter=n;function o(M){return M}e.signal=o;function a(...M){return(w,R=null,x)=>{let B=Kd(...M.map(j=>j(N=>w.call(R,N))));return d(B,x)}}e.any=a;function h(M,w,R,x){let B=R;return s(M,j=>(B=w(B,j),B),x)}e.reduce=h;function l(M,w){let R,x={onWillAddFirstListener(){R=M(B.fire,B)},onDidRemoveLastListener(){R==null||R.dispose()}},B=new T(x);return w==null||w.add(B),B.event}function d(M,w){return w instanceof Array?w.push(M):w&&w.add(M),M}function u(M,w,R=100,x=!1,B=!1,j,N){let G,ie,W,H=0,F,Y={leakWarningThreshold:j,onWillAddFirstListener(){G=M(oe=>{H++,ie=w(ie,oe),x&&!W&&(ne.fire(ie),ie=void 0),F=()=>{let Te=ie;ie=void 0,W=void 0,(!x||H>1)&&ne.fire(Te),H=0},typeof R=="number"?(clearTimeout(W),W=setTimeout(F,R)):W===void 0&&(W=0,queueMicrotask(F))})},onWillRemoveListener(){B&&H>0&&(F==null||F())},onDidRemoveLastListener(){F=void 0,G.dispose()}},ne=new T(Y);return N==null||N.add(ne),ne.event}e.debounce=u;function f(M,w=0,R){return e.debounce(M,(x,B)=>x?(x.push(B),x):[B],w,void 0,!0,void 0,R)}e.accumulate=f;function m(M,w=(x,B)=>x===B,R){let x=!0,B;return n(M,j=>{let N=x||!w(j,B);return x=!1,B=j,N},R)}e.latch=m;function p(M,w,R){return[e.filter(M,w,R),e.filter(M,x=>!w(x),R)]}e.split=p;function _(M,w=!1,R=[],x){let B=R.slice(),j=M(ie=>{B?B.push(ie):G.fire(ie)});x&&x.add(j);let N=()=>{B==null||B.forEach(ie=>G.fire(ie)),B=null},G=new T({onWillAddFirstListener(){j||(j=M(ie=>G.fire(ie)),x&&x.add(j))},onDidAddFirstListener(){B&&(w?setTimeout(N):N())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return x&&x.add(G),G.event}e.buffer=_;function y(M,w){return(R,x,B)=>{let j=w(new b);return M(function(N){let G=j.evaluate(N);G!==S&&R.call(x,G)},void 0,B)}}e.chain=y;let S=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(w){return this.steps.push(w),this}forEach(w){return this.steps.push(R=>(w(R),R)),this}filter(w){return this.steps.push(R=>w(R)?R:S),this}reduce(w,R){let x=R;return this.steps.push(B=>(x=w(x,B),x)),this}latch(w=(R,x)=>R===x){let R=!0,x;return this.steps.push(B=>{let j=R||!w(B,x);return R=!1,x=B,j?B:S}),this}evaluate(w){for(let R of this.steps)if(w=R(w),w===S)break;return w}}function P(M,w,R=x=>x){let x=(...G)=>N.fire(R(...G)),B=()=>M.on(w,x),j=()=>M.removeListener(w,x),N=new T({onWillAddFirstListener:B,onDidRemoveLastListener:j});return N.event}e.fromNodeEventEmitter=P;function k(M,w,R=x=>x){let x=(...G)=>N.fire(R(...G)),B=()=>M.addEventListener(w,x),j=()=>M.removeEventListener(w,x),N=new T({onWillAddFirstListener:B,onDidRemoveLastListener:j});return N.event}e.fromDOMEventEmitter=k;function C(M){return new Promise(w=>i(M)(w))}e.toPromise=C;function A(M){let w=new T;return M.then(R=>{w.fire(R)},()=>{w.fire(void 0)}).finally(()=>{w.dispose()}),w.event}e.fromPromise=A;function D(M,w){return M(R=>w.fire(R))}e.forward=D;function U(M,w,R){return w(R),M(x=>w(x))}e.runAndSubscribe=U;class q{constructor(w,R){this._observable=w,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{w.addObserver(this)},onDidRemoveLastListener:()=>{w.removeObserver(this)}};this.emitter=new T(x),R&&R.add(this.emitter)}beginUpdate(w){this._counter++}handlePossibleChange(w){}handleChange(w,R){this._hasChanged=!0}endUpdate(w){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function $(M,w){return new q(M,w).emitter.event}e.fromObservable=$;function L(M){return(w,R,x)=>{let B=0,j=!1,N={beginUpdate(){B++},endUpdate(){B--,B===0&&(M.reportChanges(),j&&(j=!1,w.call(R)))},handlePossibleChange(){},handleChange(){j=!0}};M.addObserver(N),M.reportChanges();let G={dispose(){M.removeObserver(N)}};return x instanceof St?x.add(G):Array.isArray(x)&&x.push(G),G}}e.fromObservableLight=L})(Ee||(Ee={}));var sr=class rr{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${rr._idPool++}`,rr.all.add(this)}start(t){this._stopWatch=new qd,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}}};sr.all=new Set,sr._idPool=0;var Vd=sr,Yd=-1,Da=class Ra{constructor(t,i,s=(Ra._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)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=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new Jd(a,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,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Da._idPool=1;var Xd=Da,Gd=class Pa{constructor(t){this.value=t}static create(){let t=new Error;return new Pa(t.stack??"")}print(){console.warn(this.value.split(`
|
|
168
|
+
`+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)}},hu=new lu;function ns(e){cu(e)||hu.onUnexpectedError(e)}var or="Canceled";function cu(e){return e instanceof du?!0:e instanceof Error&&e.name===or&&e.message===or}var du=class extends Error{constructor(){super(or),this.name=this.message}};function uu(e){return new Error(`Illegal argument: ${e}`)}var eo=class ar extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof ar)return t;let i=new ar;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},lr=class Aa extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Aa.prototype)}};function je(e,t=0){return e[e.length-(1+t)]}var fu;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(fu||(fu={}));function _u(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var za;(e=>{function t(k){return k&&typeof k=="object"&&typeof k[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(k){yield k}e.single=r;function n(k){return t(k)?k:r(k)}e.wrap=n;function o(k){return k||i}e.from=o;function*a(k){for(let C=k.length-1;C>=0;C--)yield k[C]}e.reverse=a;function h(k){return!k||k[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(k){return k[Symbol.iterator]().next().value}e.first=l;function d(k,C){let A=0;for(let D of k)if(C(D,A++))return!0;return!1}e.some=d;function u(k,C){for(let A of k)if(C(A))return A}e.find=u;function*f(k,C){for(let A of k)C(A)&&(yield A)}e.filter=f;function*m(k,C){let A=0;for(let D of k)yield C(D,A++)}e.map=m;function*p(k,C){let A=0;for(let D of k)yield*C(D,A++)}e.flatMap=p;function*_(...k){for(let C of k)yield*C}e.concat=_;function y(k,C,A){let D=A;for(let W of k)D=C(D,W);return D}e.reduce=y;function*S(k,C,A=k.length){for(C<0&&(C+=k.length),A<0?A+=k.length:A>k.length&&(A=k.length);C<A;C++)yield k[C]}e.slice=S;function b(k,C=Number.POSITIVE_INFINITY){let A=[];if(C===0)return[A,k];let D=k[Symbol.iterator]();for(let W=0;W<C;W++){let U=D.next();if(U.done)return[A,e.empty()];A.push(U.value)}return[A,{[Symbol.iterator](){return D}}]}e.consume=b;async function P(k){let C=[];for await(let A of k)C.push(A);return Promise.resolve(C)}e.asyncToArray=P})(za||(za={}));function At(e){if(za.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 pu(...e){return he(()=>At(e))}function he(e){return{dispose:_u(()=>{e()})}}var Oa=class ja{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{At(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?ja.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)}};Oa.DISABLE_DISPOSED_WARNING=!1;var bt=Oa,J=class{constructor(){this._store=new bt,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)}};J.None=Object.freeze({dispose(){}});var ei=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}},ot=typeof window=="object"?window:globalThis,hr=class cr{constructor(t){this.element=t,this.next=cr.Undefined,this.prev=cr.Undefined}};hr.Undefined=new hr(void 0);var ce=hr,to=class{constructor(){this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ce.Undefined}clear(){let e=this._first;for(;e!==ce.Undefined;){let t=e.next;e.prev=ce.Undefined,e.next=ce.Undefined,e=t}this._first=ce.Undefined,this._last=ce.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new ce(e);if(this._first===ce.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==ce.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ce.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ce.Undefined&&e.next!==ce.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ce.Undefined&&e.next===ce.Undefined?(this._first=ce.Undefined,this._last=ce.Undefined):e.next===ce.Undefined?(this._last=this._last.prev,this._last.next=ce.Undefined):e.prev===ce.Undefined&&(this._first=this._first.next,this._first.prev=ce.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ce.Undefined;)yield e.element,e=e.next}},mu=globalThis.performance&&typeof globalThis.performance.now=="function",gu=class Ia{static create(t){return new Ia(t)}constructor(t){this._now=mu&&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}},De;(e=>{e.None=()=>J.None;function t(M,w){return u(M,()=>{},0,void 0,!0,void 0,w)}e.defer=t;function i(M){return(w,R=null,x)=>{let L=!1,I;return I=M(B=>{if(!L)return I?I.dispose():L=!0,w.call(R,B)},null,x),L&&I.dispose(),I}}e.once=i;function s(M,w,R){return l((x,L=null,I)=>M(B=>x.call(L,w(B)),null,I),R)}e.map=s;function r(M,w,R){return l((x,L=null,I)=>M(B=>{w(B),x.call(L,B)},null,I),R)}e.forEach=r;function n(M,w,R){return l((x,L=null,I)=>M(B=>w(B)&&x.call(L,B),null,I),R)}e.filter=n;function o(M){return M}e.signal=o;function a(...M){return(w,R=null,x)=>{let L=pu(...M.map(I=>I(B=>w.call(R,B))));return d(L,x)}}e.any=a;function h(M,w,R,x){let L=R;return s(M,I=>(L=w(L,I),L),x)}e.reduce=h;function l(M,w){let R,x={onWillAddFirstListener(){R=M(L.fire,L)},onDidRemoveLastListener(){R==null||R.dispose()}},L=new T(x);return w==null||w.add(L),L.event}function d(M,w){return w instanceof Array?w.push(M):w&&w.add(M),M}function u(M,w,R=100,x=!1,L=!1,I,B){let Y,te,H,K=0,V,Z={leakWarningThreshold:I,onWillAddFirstListener(){Y=M(le=>{K++,te=w(te,le),x&&!H&&(se.fire(te),te=void 0),V=()=>{let Ee=te;te=void 0,H=void 0,(!x||K>1)&&se.fire(Ee),K=0},typeof R=="number"?(clearTimeout(H),H=setTimeout(V,R)):H===void 0&&(H=0,queueMicrotask(V))})},onWillRemoveListener(){L&&K>0&&(V==null||V())},onDidRemoveLastListener(){V=void 0,Y.dispose()}},se=new T(Z);return B==null||B.add(se),se.event}e.debounce=u;function f(M,w=0,R){return e.debounce(M,(x,L)=>x?(x.push(L),x):[L],w,void 0,!0,void 0,R)}e.accumulate=f;function m(M,w=(x,L)=>x===L,R){let x=!0,L;return n(M,I=>{let B=x||!w(I,L);return x=!1,L=I,B},R)}e.latch=m;function p(M,w,R){return[e.filter(M,w,R),e.filter(M,x=>!w(x),R)]}e.split=p;function _(M,w=!1,R=[],x){let L=R.slice(),I=M(te=>{L?L.push(te):Y.fire(te)});x&&x.add(I);let B=()=>{L==null||L.forEach(te=>Y.fire(te)),L=null},Y=new T({onWillAddFirstListener(){I||(I=M(te=>Y.fire(te)),x&&x.add(I))},onDidAddFirstListener(){L&&(w?setTimeout(B):B())},onDidRemoveLastListener(){I&&I.dispose(),I=null}});return x&&x.add(Y),Y.event}e.buffer=_;function y(M,w){return(R,x,L)=>{let I=w(new b);return M(function(B){let Y=I.evaluate(B);Y!==S&&R.call(x,Y)},void 0,L)}}e.chain=y;let S=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(w){return this.steps.push(w),this}forEach(w){return this.steps.push(R=>(w(R),R)),this}filter(w){return this.steps.push(R=>w(R)?R:S),this}reduce(w,R){let x=R;return this.steps.push(L=>(x=w(x,L),x)),this}latch(w=(R,x)=>R===x){let R=!0,x;return this.steps.push(L=>{let I=R||!w(L,x);return R=!1,x=L,I?L:S}),this}evaluate(w){for(let R of this.steps)if(w=R(w),w===S)break;return w}}function P(M,w,R=x=>x){let x=(...Y)=>B.fire(R(...Y)),L=()=>M.on(w,x),I=()=>M.removeListener(w,x),B=new T({onWillAddFirstListener:L,onDidRemoveLastListener:I});return B.event}e.fromNodeEventEmitter=P;function k(M,w,R=x=>x){let x=(...Y)=>B.fire(R(...Y)),L=()=>M.addEventListener(w,x),I=()=>M.removeEventListener(w,x),B=new T({onWillAddFirstListener:L,onDidRemoveLastListener:I});return B.event}e.fromDOMEventEmitter=k;function C(M){return new Promise(w=>i(M)(w))}e.toPromise=C;function A(M){let w=new T;return M.then(R=>{w.fire(R)},()=>{w.fire(void 0)}).finally(()=>{w.dispose()}),w.event}e.fromPromise=A;function D(M,w){return M(R=>w.fire(R))}e.forward=D;function W(M,w,R){return w(R),M(x=>w(x))}e.runAndSubscribe=W;class U{constructor(w,R){this._observable=w,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{w.addObserver(this)},onDidRemoveLastListener:()=>{w.removeObserver(this)}};this.emitter=new T(x),R&&R.add(this.emitter)}beginUpdate(w){this._counter++}handlePossibleChange(w){}handleChange(w,R){this._hasChanged=!0}endUpdate(w){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function $(M,w){return new U(M,w).emitter.event}e.fromObservable=$;function N(M){return(w,R,x)=>{let L=0,I=!1,B={beginUpdate(){L++},endUpdate(){L--,L===0&&(M.reportChanges(),I&&(I=!1,w.call(R)))},handlePossibleChange(){},handleChange(){I=!0}};M.addObserver(B),M.reportChanges();let Y={dispose(){M.removeObserver(B)}};return x instanceof bt?x.add(Y):Array.isArray(x)&&x.push(Y),Y}}e.fromObservableLight=N})(De||(De={}));var dr=class ur{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ur._idPool++}`,ur.all.add(this)}start(t){this._stopWatch=new gu,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}}};dr.all=new Set,dr._idPool=0;var vu=dr,Su=-1,$a=class Ha{constructor(t,i,s=(Ha._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)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=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new wu(a,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,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};$a._idPool=1;var bu=$a,yu=class Fa{constructor(t){this.value=t}static create(){let t=new Error;return new Fa(t.stack??"")}print(){console.warn(this.value.split(`
|
|
139
169
|
`).slice(2).join(`
|
|
140
|
-
`))}},Jd=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Zd=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Qd=0,Bs=class{constructor(e){this.value=e,this.id=Qd++}},eu=2,tu,T=class{constructor(t){var i,s,r,n;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new Xd((t==null?void 0:t.onListenerError)??Qi,((s=this._options)==null?void 0:s.leakWarningThreshold)??Yd):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Vd(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var t,i,s,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),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var a,h,l,d,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new Zd(`${f}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(((a=this._options)==null?void 0:a.onListenerError)||Qi)(p),Z.None}if(this._disposed)return Z.None;i&&(t=t.bind(i));let r=new Bs(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Gd.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Bs?(this._deliveryQueue??(this._deliveryQueue=new iu),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(u=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||u.call(d,this)),this._size++;let o=le(()=>{n==null||n(),this._removeListener(r)});return s instanceof St?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-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--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*eu<=i.length){let l=0;for(let d=0;d<i.length;d++)i[d]?i[l++]=i[d]:r&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=l}}_deliver(t,i){var r;if(!t)return;let s=((r=this._options)==null?void 0:r.onListenerError)||Qi;if(!s){t.value(i);return}try{t.value(i)}catch(n){s(n)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){var i,s,r,n;if((i=this._deliveryQueue)!=null&&i.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Bs)this._deliver(this._listeners,t);else{let o=this._deliveryQueue;o.enqueue(this,t,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},iu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},nr=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,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};nr.INSTANCE=new nr;var Wr=nr;function su(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Wr.INSTANCE.onDidChangeZoomLevel;function ru(e){return Wr.INSTANCE.getZoomFactor(e)}Wr.INSTANCE.onDidChangeFullscreen;var ei=typeof navigator=="object"?navigator.userAgent:"",or=ei.indexOf("Firefox")>=0,nu=ei.indexOf("AppleWebKit")>=0,Kr=ei.indexOf("Chrome")>=0,ou=!Kr&&ei.indexOf("Safari")>=0;ei.indexOf("Electron/")>=0;ei.indexOf("Android")>=0;var Ls=!1;if(typeof nt.matchMedia=="function"){let e=nt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=nt.matchMedia("(display-mode: fullscreen)");Ls=e.matches,su(nt,e,({matches:i})=>{Ls&&t.matches||(Ls=i)})}var Vt="en",ar=!1,lr=!1,es=!1,Ba=!1,Ui,ts=Vt,Kn=Vt,au,Ve,Rt=globalThis,ke,zo;typeof Rt.vscode<"u"&&typeof Rt.vscode.process<"u"?ke=Rt.vscode.process:typeof process<"u"&&typeof((zo=process==null?void 0:process.versions)==null?void 0:zo.node)=="string"&&(ke=process);var Oo,lu=typeof((Oo=ke==null?void 0:ke.versions)==null?void 0:Oo.electron)=="string",hu=lu&&(ke==null?void 0:ke.type)==="renderer",jo;if(typeof ke=="object"){ar=ke.platform==="win32",lr=ke.platform==="darwin",es=ke.platform==="linux",es&&ke.env.SNAP&&ke.env.SNAP_REVISION,ke.env.CI||ke.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ui=Vt,ts=Vt;let e=ke.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ui=t.userLocale,Kn=t.osLocale,ts=t.resolvedLanguage||Vt,au=(jo=t.languagePack)==null?void 0:jo.translationsConfigFile}catch{}Ba=!0}else typeof navigator=="object"&&!hu?(Ve=navigator.userAgent,ar=Ve.indexOf("Windows")>=0,lr=Ve.indexOf("Macintosh")>=0,(Ve.indexOf("Macintosh")>=0||Ve.indexOf("iPad")>=0||Ve.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,es=Ve.indexOf("Linux")>=0,(Ve==null?void 0:Ve.indexOf("Mobi"))>=0,ts=globalThis._VSCODE_NLS_LANGUAGE||Vt,Ui=navigator.language.toLowerCase(),Kn=Ui):console.error("Unable to resolve platform.");var La=ar,tt=lr,cu=es,Un=Ba,it=Ve,dt=ts,du;(e=>{function t(){return dt}e.value=t;function i(){return dt.length===2?dt==="en":dt.length>=3?dt[0]==="e"&&dt[1]==="n"&&dt[2]==="-":!1}e.isDefaultVariant=i;function s(){return dt==="en"}e.isDefault=s})(du||(du={}));var uu=typeof Rt.postMessage=="function"&&!Rt.importScripts;(()=>{if(uu){let e=[];Rt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Rt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var fu=!!(it&&it.indexOf("Chrome")>=0);it&&it.indexOf("Firefox")>=0;!fu&&it&&it.indexOf("Safari")>=0;it&&it.indexOf("Edg/")>=0;it&&it.indexOf("Android")>=0;var Ht=typeof navigator=="object"?navigator:{};Un||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ht&&Ht.clipboard&&Ht.clipboard.writeText,Un||Ht&&Ht.clipboard&&Ht.clipboard.readText;var Ur=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}},Ns=new Ur,qn=new Ur,Vn=new Ur,_u=new Array(230),Na;(e=>{function t(a){return Ns.keyCodeToStr(a)}e.toString=t;function i(a){return Ns.strToKeyCode(a)}e.fromString=i;function s(a){return qn.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return Vn.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return qn.strToKeyCode(a)||Vn.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ns.keyCodeToStr(a)}e.toElectronAccelerator=o})(Na||(Na={}));var pu=class Ta{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Ta&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new mu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},mu=class{constructor(e){if(e.length===0)throw Fd("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 gu(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Na.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(or)switch(t){case 59:return 85;case 60:if(cu)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(tt)return 57;break}else if(nu&&(tt&&t===93||!tt&&t===92))return 57;return _u[t]||0}var vu=tt?256:2048,Su=512,bu=1024,yu=tt?2048:256,Yn=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=gu(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|=vu),this.altKey&&(t|=Su),this.shiftKey&&(t|=bu),this.metaKey&&(t|=yu),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new pu(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Xn=new WeakMap;function wu(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var xu=class{static getSameOriginWindowChain(e){let t=Xn.get(e);if(!t){t=[],Xn.set(e,t);let i=e,s;do s=wu(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},qi=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 i=xu.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Gn=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Kr){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?or&&!tt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")ou&&La?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?or&&!tt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Aa=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Cu;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof ku?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ee.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Aa})})(Cu||(Cu={}));var ku=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?Aa:(this._emitter||(this._emitter=new T),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},qr=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 er("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new er("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Eu=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,i=globalThis){if(this.isDisposed)throw new er("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=le(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Mu;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Mu||(Mu={}));var Jn=class He{static fromArray(t){return new He(i=>{i.emitMany(t)})}static fromPromise(t){return new He(async i=>{i.emitMany(await t)})}static fromPromises(t){return new He(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new He(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new T,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Ee.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new He(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return He.map(this,t)}static filter(t,i){return new He(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return He.filter(this,t)}static coalesce(t){return He.filter(t,i=>!!i)}coalesce(){return He.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return He.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())}};Jn.EMPTY=Jn.fromArray([]);var{getWindow:et,getWindowId:Du,onDidRegisterWindow:Ru}=(function(){let e=new Map,t={window:nt,disposables:new St};e.set(nt.vscodeWindowId,t);let i=new T,s=new T,r=new T;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Z.None;let a=new St,h={window:o,disposables:a.add(new St)};return e.set(o.vscodeWindowId,h),a.add(le(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(V(o,be.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:nt},getDocument(o){return et(o).document}}})(),Pu=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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 V(e,t,i,s){return new Pu(e,t,i,s)}var Zn=function(e,t,i,s){return V(e,t,i,s)},Vr,Bu=class extends Eu{constructor(e){super(),this.defaultTarget=e&&et(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Qn=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){Qi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Qn.sort),o.shift().execute();s.set(n,!1)};Vr=(n,o,a=0)=>{let h=Du(n),l=new Qn(o,a),d=e.get(h);return d||(d=[],e.set(h,d)),d.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function Lu(e){let t=e.getBoundingClientRect(),i=et(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var be={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"},Nu=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=Le(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Le(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Le(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Le(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Le(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Le(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Le(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Le(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Le(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Le(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Le(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=Le(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=Le(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Le(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 Le(e){return typeof e=="number"?`${e}px`:e}function xi(e){return new Nu(e)}var za=class{constructor(){this._hooks=new St,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(le(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=et(e)}this._hooks.add(V(n,be.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(V(n,be.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Tu(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Je;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Je||(Je={}));var mi=class Me extends Z{constructor(){super(),this.dispatched=!1,this.targets=new Wn,this.ignoreTargets=new Wn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ee.runAndSubscribe(Ru,({window:t,disposables:i})=>{i.add(V(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(V(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(V(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:nt,disposables:this._store}))}static addTarget(t){if(!Me.isTouchDevice())return Z.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.targets.push(t);return le(i)}static ignoreTarget(t){if(!Me.isTouchDevice())return Z.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.ignoreTargets.push(t);return le(i)}static isTouchDevice(){return"ontouchstart"in nt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Je.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Me.HOLD_DELAY&&Math.abs(h.initialPageX-ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-ze(h.rollingPageY))<30){let d=this.newGestureEvent(Je.Tap,h.initialTarget);d.pageX=ze(h.rollingPageX),d.pageY=ze(h.rollingPageY),this.dispatchEvent(d)}else if(l>=Me.HOLD_DELAY&&Math.abs(h.initialPageX-ze(h.rollingPageX))<30&&Math.abs(h.initialPageY-ze(h.rollingPageY))<30){let d=this.newGestureEvent(Je.Contextmenu,h.initialTarget);d.pageX=ze(h.rollingPageX),d.pageY=ze(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=ze(h.rollingPageX),u=ze(h.rollingPageY),f=ze(h.rollingTimestamps)-h.rollingTimestamps[0],m=d-h.rollingPageX[0],p=u-h.rollingPageY[0],_=[...this.targets].filter(y=>h.initialTarget instanceof Node&&y.contains(h.initialTarget));this.inertia(t,_,s,Math.abs(m)/f,m>0?1:-1,d,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Je.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Je.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Me.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Je.Change||t.type===Je.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=Vr(t,()=>{let d=Date.now(),u=d-s,f=0,m=0,p=!0;r+=Me.SCROLL_FRICTION*u,a+=Me.SCROLL_FRICTION*u,r>0&&(p=!1,f=n*r*u),a>0&&(p=!1,m=h*a*u);let _=this.newGestureEvent(Je.Change);_.translationX=f,_.translationY=m,i.forEach(y=>y.dispatchEvent(_)),p||this.inertia(t,i,d,r,n,o+f,a,h,l+m)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(Je.Change,o.initialTarget);a.translationX=n.pageX-ze(o.rollingPageX),a.translationY=n.pageY-ze(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};mi.SCROLL_FRICTION=-.005,mi.HOLD_DELAY=700,mi.CLEAR_TAP_COUNT_TIME=400,fe([Tu],mi,"isTouchDevice",1);var Au=mi,Yr=class extends Z{onclick(e,t){this._register(V(e,be.CLICK,i=>t(new qi(et(e),i))))}onmousedown(e,t){this._register(V(e,be.MOUSE_DOWN,i=>t(new qi(et(e),i))))}onmouseover(e,t){this._register(V(e,be.MOUSE_OVER,i=>t(new qi(et(e),i))))}onmouseleave(e,t){this._register(V(e,be.MOUSE_LEAVE,i=>t(new qi(et(e),i))))}onkeydown(e,t){this._register(V(e,be.KEY_DOWN,i=>t(new Yn(i))))}onkeyup(e,t){this._register(V(e,be.KEY_UP,i=>t(new Yn(i))))}oninput(e,t){this._register(V(e,be.INPUT,t))}onblur(e,t){this._register(V(e,be.BLUR,t))}onfocus(e,t){this._register(V(e,be.FOCUS,t))}onchange(e,t){this._register(V(e,be.CHANGE,t))}ignoreGesture(e){return Au.ignoreTarget(e)}},eo=11,zu=class extends Yr{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=eo+"px",this.domNode.style.height=eo+"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 za),this._register(Zn(this.bgDomNode,be.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Zn(this.domNode,be.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Bu),this._pointerdownScheduleRepeatTimer=this._register(new qr)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,et(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Ou=class hr{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}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,i){return new hr(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new hr(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,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},ju=class extends Z{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 Ou(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new io(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=io.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},to=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ts(e,t){let i=t-e;return function(s){return e+i*Fu(s)}}function Iu(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var io=class cr{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),Iu(Ts(t,r),Ts(n,i),.33)}return Ts(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new to(s,r,!1)}return new to(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return cr.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new cr(t,i,r,s)}};function $u(e){return Math.pow(e,3)}function Fu(e){return 1-$u(1-e)}var Hu=class extends Z{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new qr)}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":"")))}},Wu=140,Oa=class extends Yr{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 Hu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new za),this._shouldRender=!0,this.domNode=xi(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(V(this.domNode.domNode,be.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new zu(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=xi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(V(this.slider.domNode,be.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=Lu(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(La&&o>Wu){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{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()}},ja=class dr{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new dr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),d=(a-l)/(r-s),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=dr._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Ku=class extends Oa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new ja(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.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}},Uu=class extends Oa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new ja(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.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}},qu=500,so=50,Vu=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},ur=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,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Kr){let i=et(t.browserEvent),s=ru(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new Vu(t,i,s);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,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),d=Math.max(r,o),u=Math.max(n,a);d%h===0&&u%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ur.INSTANCE=new ur;var Yu=ur,Xu=class extends Yr{constructor(e,t,i){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=Ju(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Uu(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Ku(this._scrollable,this._options,s)),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=xi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=xi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=xi(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 qr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Nt(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,tt&&(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 Gn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Nt(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Gn(i))};this._mouseWheelToDispose.push(V(this._listenOnDomNode,be.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Yu.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!tt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let d=so*n,u=h.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(l,u)}if(o){let d=so*o,u=h.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(l,u)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),qu)}},Gu=class extends Xu{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Ju(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,tt&&(t.className+=" mac"),t}var fr=class extends Z{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,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 ju({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>Vr(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Gu(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(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ee.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(le(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(le(()=>this._styleElement.remove())),this._register(Ee.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(`
|
|
141
|
-
`)})),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(l=>this._handleScroll(l)))}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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};fr=fe([O(2,Pe),O(3,at),O(4,va),O(5,Qt),O(6,Be),O(7,lt)],fr);var _r=class extends Z{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,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(le(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*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()}};_r=fe([O(1,Pe),O(2,at),O(3,Li),O(4,lt)],_r);var Zu=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Xe={full:0,left:0,center:0,right:0},ut={full:0,left:0,center:0,right:0},ni={full:0,left:0,center:0,right:0},hs=class extends Z{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Zu,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(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(le(()=>{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);ut.full=this._canvas.width,ut.left=e,ut.center=t,ut.right=e,this._refreshDrawHeightConstants(),ni.full=1,ni.left=1,ni.center=1+ut.left,ni.right=1+ut.left+ut.center}_refreshDrawHeightConstants(){Xe.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);Xe.left=t,Xe.center=t,Xe.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.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(ni[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Xe[e.position||"full"]/2),ut[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Xe[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}))}};hs=fe([O(2,Pe),O(3,Li),O(4,lt),O(5,Be),O(6,Qt),O(7,at)],hs);var E;(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=`
|
|
142
|
-
`,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=""))(E||(E={}));var is;(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=""))(is||(is={}));var Ia;(e=>e.ST=`${E.ESC}\\`)(Ia||(Ia={}));var pr=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${E.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),i=this._renderService.dimensions.css.cell.height,s=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=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"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=s+"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)}}};pr=fe([O(2,Pe),O(3,Be),O(4,Ot),O(5,lt)],pr);var ye=0,we=0,xe=0,de=0,ro={css:"#00000000",rgba:0},me;(e=>{function t(r,n,o,a){return a!==void 0?`#${Ct(r)}${Ct(n)}${Ct(o)}${Ct(a)}`:`#${Ct(r)}${Ct(n)}${Ct(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(me||(me={}));var ae;(e=>{function t(h,l){if(de=(l.rgba&255)/255,de===1)return{css:l.css,rgba:l.rgba};let d=l.rgba>>24&255,u=l.rgba>>16&255,f=l.rgba>>8&255,m=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255;ye=m+Math.round((d-m)*de),we=p+Math.round((u-p)*de),xe=_+Math.round((f-_)*de);let y=me.toCss(ye,we,xe),S=me.toRgba(ye,we,xe);return{css:y,rgba:S}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,d){let u=ss.ensureContrastRatio(h.rgba,l.rgba,d);if(u)return me.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[ye,we,xe]=ss.toChannels(l),{css:me.toCss(ye,we,xe),rgba:l}}e.opaque=r;function n(h,l){return de=Math.round(l*255),[ye,we,xe]=ss.toChannels(h.rgba),{css:me.toCss(ye,we,xe,de),rgba:me.toRgba(ye,we,xe,de)}}e.opacity=n;function o(h,l){return de=h.rgba&255,n(h,de*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(ae||(ae={}));var ce;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return ye=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),xe=parseInt(r.slice(3,4).repeat(2),16),me.toColor(ye,we,xe);case 5:return ye=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),xe=parseInt(r.slice(3,4).repeat(2),16),de=parseInt(r.slice(4,5).repeat(2),16),me.toColor(ye,we,xe,de);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 ye=parseInt(n[1]),we=parseInt(n[2]),xe=parseInt(n[3]),de=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),me.toColor(ye,we,xe,de);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ye,we,xe,de]=t.getImageData(0,0,1,1).data,de!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:me.toRgba(ye,we,xe,de),css:r}}e.toColor=s})(ce||(ce={}));var De;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+d*.7152+u*.0722}e.relativeLuminance2=i})(De||(De={}));var ss;(e=>{function t(o,a){if(de=(a&255)/255,de===1)return a;let h=a>>24&255,l=a>>16&255,d=a>>8&255,u=o>>24&255,f=o>>16&255,m=o>>8&255;return ye=u+Math.round((h-u)*de),we=f+Math.round((l-f)*de),xe=m+Math.round((d-m)*de),me.toRgba(ye,we,xe)}e.blend=t;function i(o,a,h){let l=De.relativeLuminance(o>>8),d=De.relativeLuminance(a>>8);if(rt(l,d)<h){if(d<l){let m=s(o,a,h),p=rt(l,De.relativeLuminance(m>>8));if(p<h){let _=r(o,a,h),y=rt(l,De.relativeLuminance(_>>8));return p>y?m:_}return m}let u=r(o,a,h),f=rt(l,De.relativeLuminance(u>>8));if(f<h){let m=s(o,a,h),p=rt(l,De.relativeLuminance(m>>8));return f>p?u:m}return u}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,m=a>>16&255,p=a>>8&255,_=rt(De.relativeLuminance2(f,m,p),De.relativeLuminance2(l,d,u));for(;_<h&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=rt(De.relativeLuminance2(f,m,p),De.relativeLuminance2(l,d,u));return(f<<24|m<<16|p<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,m=a>>16&255,p=a>>8&255,_=rt(De.relativeLuminance2(f,m,p),De.relativeLuminance2(l,d,u));for(;_<h&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=rt(De.relativeLuminance2(f,m,p),De.relativeLuminance2(l,d,u));return(f<<24|m<<16|p<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(ss||(ss={}));function Ct(e){let t=e.toString(16);return t.length<2?"0"+t:t}function rt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Qu=class extends Bi{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},cs=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ue}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==h){if(l-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<d.length;u++)i.push(d[u])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||mt.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<l.length;d++)i.push(l[d])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)cs._mergeRanges(o,h[l])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||mt.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};cs=fe([O(0,Pe)],cs);function ef(e){return 57508<=e&&e<=57558}function tf(e){return 9472<=e&&e<=9631}function sf(e){return ef(e)||tf(e)}function rf(){return{css:{canvas:Vi(),cell:Vi()},device:{canvas:Vi(),cell:Vi(),char:{width:0,height:0,left:0,top:0}}}}function Vi(){return{width:0,height:0}}var mr=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new Ue,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,h,l,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),m=this._themeService.colors,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let _,y=0,S="",b=0,P=0,k=0,C=0,A=!1,D=0,U=!1,q=0,$=0,L=[],M=l!==-1&&d!==-1;for(let w=0;w<p;w++){e.loadCell(w,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let x=!1,B=w>=$,j=w,N=this._workCell;if(f.length>0&&w===f[0][0]&&B){let Q=f.shift(),jt=this._isCellInSelection(Q[0],t);for(b=Q[0]+1;b<Q[1];b++)B&&(B=jt===this._isCellInSelection(b,t));B&&(B=!i||n<Q[0]||n>=Q[1]),B?(x=!0,N=new Qu(this._workCell,e.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),j=Q[1]-1,R=N.getWidth()):$=Q[1]}let G=this._isCellInSelection(w,t),ie=i&&w===n,W=M&&w>=l&&w<=d,H=!1;this._decorationService.forEachDecorationAtCell(w,t,void 0,Q=>{H=!0});let F=N.getChars()||mt;if(F===" "&&(N.isUnderline()||N.isOverline())&&(F=" "),q=R*a-h.get(F,N.isBold(),N.isItalic()),!_)_=this._document.createElement("span");else if(y&&(G&&U||!G&&!U&&N.bg===P)&&(G&&U&&m.selectionForeground||N.fg===k)&&N.extended.ext===C&&W===A&&q===D&&!ie&&!x&&!H&&B){N.isInvisible()?S+=mt:S+=F,y++;continue}else y&&(_.textContent=S),_=this._document.createElement("span"),y=0,S="";if(P=N.bg,k=N.fg,C=N.extended.ext,A=W,D=q,U=G,x&&n>=w&&n<=j&&(n=w),!this._coreService.isCursorHidden&&ie&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&L.push("xterm-cursor-blink"),L.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":L.push("xterm-cursor-outline");break;case"block":L.push("xterm-cursor-block");break;case"bar":L.push("xterm-cursor-bar");break;case"underline":L.push("xterm-cursor-underline");break}}if(N.isBold()&&L.push("xterm-bold"),N.isItalic()&&L.push("xterm-italic"),N.isDim()&&L.push("xterm-dim"),N.isInvisible()?S=mt:S=N.getChars()||mt,N.isUnderline()&&(L.push(`xterm-underline-${N.extended.underlineStyle}`),S===" "&&(S=" "),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${Bi.toColorRGB(N.getUnderlineColor()).join(",")})`;else{let Q=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&Q<8&&(Q+=8),_.style.textDecorationColor=m.ansi[Q].css}N.isOverline()&&(L.push("xterm-overline"),S===" "&&(S=" ")),N.isStrikethrough()&&L.push("xterm-strikethrough"),W&&(_.style.textDecoration="underline");let Y=N.getFgColor(),ne=N.getFgColorMode(),oe=N.getBgColor(),Te=N.getBgColorMode(),Ye=!!N.isInverse();if(Ye){let Q=Y;Y=oe,oe=Q;let jt=ne;ne=Te,Te=jt}let Ie,bt,qe=!1;this._decorationService.forEachDecorationAtCell(w,t,void 0,Q=>{Q.options.layer!=="top"&&qe||(Q.backgroundColorRGB&&(Te=50331648,oe=Q.backgroundColorRGB.rgba>>8&16777215,Ie=Q.backgroundColorRGB),Q.foregroundColorRGB&&(ne=50331648,Y=Q.foregroundColorRGB.rgba>>8&16777215,bt=Q.foregroundColorRGB),qe=Q.options.layer==="top")}),!qe&&G&&(Ie=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,oe=Ie.rgba>>8&16777215,Te=50331648,qe=!0,m.selectionForeground&&(ne=50331648,Y=m.selectionForeground.rgba>>8&16777215,bt=m.selectionForeground)),qe&&L.push("xterm-decoration-top");let Ae;switch(Te){case 16777216:case 33554432:Ae=m.ansi[oe],L.push(`xterm-bg-${oe}`);break;case 50331648:Ae=me.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(_,`background-color:#${no((oe>>>0).toString(16),"0",6)}`);break;case 0:default:Ye?(Ae=m.foreground,L.push("xterm-bg-257")):Ae=m.background}switch(Ie||N.isDim()&&(Ie=ae.multiplyOpacity(Ae,.5)),ne){case 16777216:case 33554432:N.isBold()&&Y<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Y+=8),this._applyMinimumContrast(_,Ae,m.ansi[Y],N,Ie,void 0)||L.push(`xterm-fg-${Y}`);break;case 50331648:let Q=me.toColor(Y>>16&255,Y>>8&255,Y&255);this._applyMinimumContrast(_,Ae,Q,N,Ie,bt)||this._addStyle(_,`color:#${no(Y.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ae,m.foreground,N,Ie,bt)||Ye&&L.push("xterm-fg-257")}L.length&&(_.className=L.join(" "),L.length=0),!ie&&!x&&!H&&B?y++:_.textContent=S,q!==this.defaultSpacing&&(_.style.letterSpacing=`${q}px`),u.push(_),w=j}return _&&y&&(_.textContent=S),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||sf(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=ae.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};mr=fe([O(1,ya),O(2,Be),O(3,at),O(4,Ot),O(5,Li),O(6,Qt)],mr);function no(e,t,i){for(;e.length<i;)e=t+e;return e}var nf=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.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=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},of=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function af(){return new of}var As="xterm-dom-renderer-owner-",Fe="xterm-rows",Yi="xterm-fg-",oo="xterm-bg-",oi="xterm-focus",Xi="xterm-selection",lf=1,gr=class extends Z{constructor(e,t,i,s,r,n,o,a,h,l,d,u,f,m){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=lf++,this._rowElements=[],this._selectionRenderModel=af(),this.onRequestRedraw=this._register(new T).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fe),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(Xi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=rf(),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=a.createInstance(mr,document),this._element.classList.add(As+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(le(()=>{this._element.classList.remove(As+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new nf(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Fe} 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} .${Fe} { 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} .${Fe} .xterm-dim { color: ${ae.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${Fe}.${oi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Fe}.${oi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fe}.${oi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Xi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Xi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Xi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Yi}${n} { color: ${o.css}; }${this._terminalSelector} .${Yi}${n}.xterm-dim { color: ${ae.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${oo}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Yi}257 { color: ${ae.opaque(e.background).css}; }${this._terminalSelector} .${Yi}257.xterm-dim { color: ${ae.multiplyOpacity(ae.opaque(e.background),.5).css}; }${this._terminalSelector} .${oo}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(oi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(oi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let d=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let u=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,d=this._rowElements[h],u=i.lines.get(l);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${As}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=i;m<=s;++m){let p=m+a.ydisp,_=this._rowElements[m],y=a.lines.get(p);if(!_||!y)break;_.replaceChildren(...this._rowFactory.createRow(y,p,p===h,u,f,l,d,this.dimensions.css.cell.width,this._widthCache,n?m===i?e:0:-1,n?(m===s?t:r)-1:-1))}}};gr=fe([O(7,Fr),O(8,ms),O(9,Be),O(10,Pe),O(11,Ot),O(12,at),O(13,Qt)],gr);var vr=class extends Z{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new T),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new cf(this._optionsService))}catch{this._measureStrategy=this._register(new hf(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())}};vr=fe([O(2,Be)],vr);var $a=class extends Z{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)}},hf=class extends $a{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},cf=class extends $a{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}},df=class extends Z{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new uf(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(s=>this._screenDprMonitor.setWindow(s))),this._register(Ee.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(V(this._textarea,"focus",()=>this._isFocused=!0)),this._register(V(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}},uf=class extends Z{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zt),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(le(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=V(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)}},ff=class extends Z{constructor(){super(),this.linkProviders=[],this._register(le(()=>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 Xr(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function _f(e,t,i,s,r,n,o,a,h){if(!n)return;let l=Xr(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var Sr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return _f(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Xr(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Sr=fe([O(0,lt),O(1,ms)],Sr);var pf=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,i){this._rowCount=i,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=[]}},Fa={};Cd(Fa,{getSafariVersion:()=>gf,isChromeOS:()=>Ua,isFirefox:()=>Ha,isIpad:()=>vf,isIphone:()=>Sf,isLegacyEdge:()=>mf,isLinux:()=>Gr,isMac:()=>ds,isNode:()=>gs,isSafari:()=>Wa,isWindows:()=>Ka});var gs=typeof process<"u"&&"title"in process,Ni=gs?"node":navigator.userAgent,Ti=gs?"node":navigator.platform,Ha=Ni.includes("Firefox"),mf=Ni.includes("Edge"),Wa=/^((?!chrome|android).)*safari/i.test(Ni);function gf(){if(!Wa)return 0;let e=Ni.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ds=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ti),vf=Ti==="iPad",Sf=Ti==="iPhone",Ka=["Windows","Win16","Win32","WinCE"].includes(Ti),Gr=Ti.indexOf("Linux")>=0,Ua=/\bCrOS\b/.test(Ni),qa=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,i=0,s=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),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},bf=class extends qa{_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())}}},yf=class extends qa{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},us=!gs&&"requestIdleCallback"in window?yf:bf,wf=class{constructor(){this._queue=new us}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},br=class extends Z{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Zt),this._pausedResizeTask=new wf,this._observerDisposable=this._register(new Zt),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 pf((l,d)=>this._renderRows(l,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new xf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(le(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.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(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=le(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};br=fe([O(2,Be),O(3,ms),O(4,Ot),O(5,Li),O(6,Pe),O(7,at),O(8,Qt)],br);var xf=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 Cf(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Mf(r,n,e,t,i,s)+vs(n,t,i,s)+Df(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Di(Math.abs(r-e),Mi(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=Ef(n>t?e:r,i)+(a-1)*i.cols+1+kf(n>t?r:e);return Di(h,Mi(o,s))}function kf(e,t){return e-1}function Ef(e,t){return t.cols-e}function Mf(e,t,i,s,r,n){return vs(t,s,r,n).length===0?"":Di(Ya(e,t,e,t-Tt(t,r),!1,r).length,Mi("D",n))}function vs(e,t,i,s){let r=e-Tt(e,i),n=t-Tt(t,i),o=Math.abs(r-n)-Rf(e,t,i);return Di(o,Mi(Va(e,t),s))}function Df(e,t,i,s,r,n){let o;vs(t,s,r,n).length>0?o=s-Tt(s,r):o=t;let a=s,h=Pf(e,t,i,s,r,n);return Di(Ya(e,o,i,a,h==="C",r).length,Mi(h,n))}function Rf(e,t,i){var o;let s=0,r=e-Tt(e,i),n=t-Tt(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=Va(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function Tt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function Pf(e,t,i,s,r,n){let o;return vs(i,s,r,n).length>0?o=s-Tt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Va(e,t){return e>t?"A":"B"}function Ya(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Mi(e,t){let i=t?"O":"[";return E.ESC+i+e}function Di(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var Bf=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 ao(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 zs=50,Lf=15,Nf=50,Tf=500,Af=" ",zf=new RegExp(Af,"g"),yr=class extends Z{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ue,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=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Bf(this._bufferService),this._activeSelectionMode=0,this._register(le(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.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 i=this._bufferService.buffer,s=[];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 o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(zf," ")).join(Ka?`\r
|
|
170
|
+
`))}},wu=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},xu=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Cu=0,Is=class{constructor(e){this.value=e,this.id=Cu++}},ku=2,Eu,T=class{constructor(t){var i,s,r,n;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new bu((t==null?void 0:t.onListenerError)??ns,((s=this._options)==null?void 0:s.leakWarningThreshold)??Su):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new vu(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var t,i,s,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),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var a,h,l,d,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new xu(`${f}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(((a=this._options)==null?void 0:a.onListenerError)||ns)(p),J.None}if(this._disposed)return J.None;i&&(t=t.bind(i));let r=new Is(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=yu.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Is?(this._deliveryQueue??(this._deliveryQueue=new Mu),this._listeners=[this._listeners,r]):this._listeners.push(r):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=r,(u=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||u.call(d,this)),this._size++;let o=he(()=>{n==null||n(),this._removeListener(r)});return s instanceof bt?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(t){var n,o,a,h;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(a=this._options)==null?void 0:a.onDidRemoveLastListener)==null||h.call(a,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-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--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ku<=i.length){let l=0;for(let d=0;d<i.length;d++)i[d]?i[l++]=i[d]:r&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=l}}_deliver(t,i){var r;if(!t)return;let s=((r=this._options)==null?void 0:r.onListenerError)||ns;if(!s){t.value(i);return}try{t.value(i)}catch(n){s(n)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){var i,s,r,n;if((i=this._deliveryQueue)!=null&&i.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Is)this._deliver(this._listeners,t);else{let o=this._deliveryQueue;o.enqueue(this,t,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},Mu=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},fr=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,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};fr.INSTANCE=new fr;var Jr=fr;function Du(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Jr.INSTANCE.onDidChangeZoomLevel;function Ru(e){return Jr.INSTANCE.getZoomFactor(e)}Jr.INSTANCE.onDidChangeFullscreen;var ii=typeof navigator=="object"?navigator.userAgent:"",_r=ii.indexOf("Firefox")>=0,Pu=ii.indexOf("AppleWebKit")>=0,Zr=ii.indexOf("Chrome")>=0,Lu=!Zr&&ii.indexOf("Safari")>=0;ii.indexOf("Electron/")>=0;ii.indexOf("Android")>=0;var $s=!1;if(typeof ot.matchMedia=="function"){let e=ot.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ot.matchMedia("(display-mode: fullscreen)");$s=e.matches,Du(ot,e,({matches:i})=>{$s&&t.matches||($s=i)})}var Xt="en",pr=!1,mr=!1,os=!1,Wa=!1,Ji,as=Xt,io=Xt,Bu,Ye,Lt=globalThis,Me,Yo;typeof Lt.vscode<"u"&&typeof Lt.vscode.process<"u"?Me=Lt.vscode.process:typeof process<"u"&&typeof((Yo=process==null?void 0:process.versions)==null?void 0:Yo.node)=="string"&&(Me=process);var Xo,Nu=typeof((Xo=Me==null?void 0:Me.versions)==null?void 0:Xo.electron)=="string",Tu=Nu&&(Me==null?void 0:Me.type)==="renderer",Go;if(typeof Me=="object"){pr=Me.platform==="win32",mr=Me.platform==="darwin",os=Me.platform==="linux",os&&Me.env.SNAP&&Me.env.SNAP_REVISION,Me.env.CI||Me.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ji=Xt,as=Xt;let e=Me.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ji=t.userLocale,io=t.osLocale,as=t.resolvedLanguage||Xt,Bu=(Go=t.languagePack)==null?void 0:Go.translationsConfigFile}catch{}Wa=!0}else typeof navigator=="object"&&!Tu?(Ye=navigator.userAgent,pr=Ye.indexOf("Windows")>=0,mr=Ye.indexOf("Macintosh")>=0,(Ye.indexOf("Macintosh")>=0||Ye.indexOf("iPad")>=0||Ye.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,os=Ye.indexOf("Linux")>=0,(Ye==null?void 0:Ye.indexOf("Mobi"))>=0,as=globalThis._VSCODE_NLS_LANGUAGE||Xt,Ji=navigator.language.toLowerCase(),io=Ji):console.error("Unable to resolve platform.");var Ka=pr,tt=mr,Au=os,so=Wa,it=Ye,ut=as,zu;(e=>{function t(){return ut}e.value=t;function i(){return ut.length===2?ut==="en":ut.length>=3?ut[0]==="e"&&ut[1]==="n"&&ut[2]==="-":!1}e.isDefaultVariant=i;function s(){return ut==="en"}e.isDefault=s})(zu||(zu={}));var Ou=typeof Lt.postMessage=="function"&&!Lt.importScripts;(()=>{if(Ou){let e=[];Lt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Lt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var ju=!!(it&&it.indexOf("Chrome")>=0);it&&it.indexOf("Firefox")>=0;!ju&&it&&it.indexOf("Safari")>=0;it&&it.indexOf("Edg/")>=0;it&&it.indexOf("Android")>=0;var Kt=typeof navigator=="object"?navigator:{};so||document.queryCommandSupported&&document.queryCommandSupported("copy")||Kt&&Kt.clipboard&&Kt.clipboard.writeText,so||Kt&&Kt.clipboard&&Kt.clipboard.readText;var Qr=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}},Hs=new Qr,ro=new Qr,no=new Qr,Iu=new Array(230),Ua;(e=>{function t(a){return Hs.keyCodeToStr(a)}e.toString=t;function i(a){return Hs.strToKeyCode(a)}e.fromString=i;function s(a){return ro.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return no.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return ro.strToKeyCode(a)||no.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Hs.keyCodeToStr(a)}e.toElectronAccelerator=o})(Ua||(Ua={}));var $u=class qa{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof qa&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Hu([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Hu=class{constructor(e){if(e.length===0)throw uu("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 Fu(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Ua.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(_r)switch(t){case 59:return 85;case 60:if(Au)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(tt)return 57;break}else if(Pu&&(tt&&t===93||!tt&&t===92))return 57;return Iu[t]||0}var Wu=tt?256:2048,Ku=512,Uu=1024,qu=tt?2048:256,oo=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=Fu(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|=Wu),this.altKey&&(t|=Ku),this.shiftKey&&(t|=Uu),this.metaKey&&(t|=qu),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new $u(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},ao=new WeakMap;function Vu(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Yu=class{static getSameOriginWindowChain(e){let t=ao.get(e);if(!t){t=[],ao.set(e,t);let i=e,s;do s=Vu(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Zi=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 i=Yu.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},lo=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Zr){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?_r&&!tt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Lu&&Ka?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?_r&&!tt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Va=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Xu;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Gu?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:De.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Va})})(Xu||(Xu={}));var Gu=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?Va:(this._emitter||(this._emitter=new T),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},en=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 lr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new lr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ju=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,i=globalThis){if(this.isDisposed)throw new lr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=he(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Zu;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Zu||(Zu={}));var ho=class We{static fromArray(t){return new We(i=>{i.emitMany(t)})}static fromPromise(t){return new We(async i=>{i.emitMany(await t)})}static fromPromises(t){return new We(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new We(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new T,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 De.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new We(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return We.map(this,t)}static filter(t,i){return new We(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return We.filter(this,t)}static coalesce(t){return We.filter(t,i=>!!i)}coalesce(){return We.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return We.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())}};ho.EMPTY=ho.fromArray([]);var{getWindow:et,getWindowId:Qu,onDidRegisterWindow:ef}=(function(){let e=new Map,t={window:ot,disposables:new bt};e.set(ot.vscodeWindowId,t);let i=new T,s=new T,r=new T;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return J.None;let a=new bt,h={window:o,disposables:a.add(new bt)};return e.set(o.vscodeWindowId,h),a.add(he(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(q(o,ye.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:ot},getDocument(o){return et(o).document}}})(),tf=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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 q(e,t,i,s){return new tf(e,t,i,s)}var co=function(e,t,i,s){return q(e,t,i,s)},tn,sf=class extends Ju{constructor(e){super(),this.defaultTarget=e&&et(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},uo=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){ns(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(uo.sort),o.shift().execute();s.set(n,!1)};tn=(n,o,a=0)=>{let h=Qu(n),l=new uo(o,a),d=e.get(h);return d||(d=[],e.set(h,d)),d.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function rf(e){let t=e.getBoundingClientRect(),i=et(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var ye={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"},nf=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=Ae(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ae(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ae(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ae(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ae(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ae(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ae(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ae(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ae(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ae(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ae(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=Ae(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=Ae(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ae(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 Ae(e){return typeof e=="number"?`${e}px`:e}function Mi(e){return new nf(e)}var Ya=class{constructor(){this._hooks=new bt,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(he(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=et(e)}this._hooks.add(q(n,ye.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(q(n,ye.POINTER_UP,o=>this.stopMonitoring(!0)))}};function of(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Je;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Je||(Je={}));var bi=class Re extends J{constructor(){super(),this.dispatched=!1,this.targets=new to,this.ignoreTargets=new to,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(De.runAndSubscribe(ef,({window:t,disposables:i})=>{i.add(q(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(q(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(q(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ot,disposables:this._store}))}static addTarget(t){if(!Re.isTouchDevice())return J.None;Re.INSTANCE||(Re.INSTANCE=new Re);let i=Re.INSTANCE.targets.push(t);return he(i)}static ignoreTarget(t){if(!Re.isTouchDevice())return J.None;Re.INSTANCE||(Re.INSTANCE=new Re);let i=Re.INSTANCE.ignoreTargets.push(t);return he(i)}static isTouchDevice(){return"ontouchstart"in ot||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Je.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Re.HOLD_DELAY&&Math.abs(h.initialPageX-je(h.rollingPageX))<30&&Math.abs(h.initialPageY-je(h.rollingPageY))<30){let d=this.newGestureEvent(Je.Tap,h.initialTarget);d.pageX=je(h.rollingPageX),d.pageY=je(h.rollingPageY),this.dispatchEvent(d)}else if(l>=Re.HOLD_DELAY&&Math.abs(h.initialPageX-je(h.rollingPageX))<30&&Math.abs(h.initialPageY-je(h.rollingPageY))<30){let d=this.newGestureEvent(Je.Contextmenu,h.initialTarget);d.pageX=je(h.rollingPageX),d.pageY=je(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=je(h.rollingPageX),u=je(h.rollingPageY),f=je(h.rollingTimestamps)-h.rollingTimestamps[0],m=d-h.rollingPageX[0],p=u-h.rollingPageY[0],_=[...this.targets].filter(y=>h.initialTarget instanceof Node&&y.contains(h.initialTarget));this.inertia(t,_,s,Math.abs(m)/f,m>0?1:-1,d,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Je.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Je.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Re.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Je.Change||t.type===Je.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=tn(t,()=>{let d=Date.now(),u=d-s,f=0,m=0,p=!0;r+=Re.SCROLL_FRICTION*u,a+=Re.SCROLL_FRICTION*u,r>0&&(p=!1,f=n*r*u),a>0&&(p=!1,m=h*a*u);let _=this.newGestureEvent(Je.Change);_.translationX=f,_.translationY=m,i.forEach(y=>y.dispatchEvent(_)),p||this.inertia(t,i,d,r,n,o+f,a,h,l+m)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(Je.Change,o.initialTarget);a.translationX=n.pageX-je(o.rollingPageX),a.translationY=n.pageY-je(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};bi.SCROLL_FRICTION=-.005,bi.HOLD_DELAY=700,bi.CLEAR_TAP_COUNT_TIME=400,fe([of],bi,"isTouchDevice",1);var af=bi,sn=class extends J{onclick(e,t){this._register(q(e,ye.CLICK,i=>t(new Zi(et(e),i))))}onmousedown(e,t){this._register(q(e,ye.MOUSE_DOWN,i=>t(new Zi(et(e),i))))}onmouseover(e,t){this._register(q(e,ye.MOUSE_OVER,i=>t(new Zi(et(e),i))))}onmouseleave(e,t){this._register(q(e,ye.MOUSE_LEAVE,i=>t(new Zi(et(e),i))))}onkeydown(e,t){this._register(q(e,ye.KEY_DOWN,i=>t(new oo(i))))}onkeyup(e,t){this._register(q(e,ye.KEY_UP,i=>t(new oo(i))))}oninput(e,t){this._register(q(e,ye.INPUT,t))}onblur(e,t){this._register(q(e,ye.BLUR,t))}onfocus(e,t){this._register(q(e,ye.FOCUS,t))}onchange(e,t){this._register(q(e,ye.CHANGE,t))}ignoreGesture(e){return af.ignoreTarget(e)}},fo=11,lf=class extends sn{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=fo+"px",this.domNode.style.height=fo+"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 Ya),this._register(co(this.bgDomNode,ye.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(co(this.domNode,ye.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new sf),this._pointerdownScheduleRepeatTimer=this._register(new en)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,et(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hf=class gr{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}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,i){return new gr(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new gr(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,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},cf=class extends J{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 hf(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new po(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=po.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},_o=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Fs(e,t){let i=t-e;return function(s){return e+i*ff(s)}}function df(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var po=class vr{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),df(Fs(t,r),Fs(n,i),.33)}return Fs(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new _o(s,r,!1)}return new _o(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return vr.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new vr(t,i,r,s)}};function uf(e){return Math.pow(e,3)}function ff(e){return 1-uf(1-e)}var _f=class extends J{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new en)}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":"")))}},pf=140,Xa=class extends sn{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 _f(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ya),this._shouldRender=!0,this.domNode=Mi(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(q(this.domNode.domNode,ye.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new lf(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Mi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(q(this.slider.domNode,ye.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=rf(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Ka&&o>pf){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{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()}},Ga=class Sr{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Sr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),d=(a-l)/(r-s),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Sr._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},mf=class extends Xa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ga(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.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}},gf=class extends Xa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ga(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.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}},vf=500,mo=50,Sf=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},br=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,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Zr){let i=et(t.browserEvent),s=Ru(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new Sf(t,i,s);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,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),d=Math.max(r,o),u=Math.max(n,a);d%h===0&&u%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};br.INSTANCE=new br;var bf=br,yf=class extends sn{constructor(e,t,i){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=xf(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new gf(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new mf(this._scrollable,this._options,s)),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=Mi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Mi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Mi(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 en),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=At(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,tt&&(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 lo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=At(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new lo(i))};this._mouseWheelToDispose.push(q(this._listenOnDomNode,ye.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=bf.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!tt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let d=mo*n,u=h.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(l,u)}if(o){let d=mo*o,u=h.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(l,u)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),vf)}},wf=class extends yf{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function xf(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,tt&&(t.className+=" mac"),t}var yr=class extends J{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,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 cf({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>tn(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new wf(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(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(De.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(he(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(he(()=>this._styleElement.remove())),this._register(De.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(`
|
|
171
|
+
`)})),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(l=>this._handleScroll(l)))}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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};yr=fe([O(2,Be),O(3,lt),O(4,Pa),O(5,ti),O(6,Ne),O(7,ht)],yr);var wr=class extends J{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,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(he(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*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()}};wr=fe([O(1,Be),O(2,lt),O(3,zi),O(4,ht)],wr);var Cf=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Xe={full:0,left:0,center:0,right:0},ft={full:0,left:0,center:0,right:0},hi={full:0,left:0,center:0,right:0},ps=class extends J{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Cf,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(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(he(()=>{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);ft.full=this._canvas.width,ft.left=e,ft.center=t,ft.right=e,this._refreshDrawHeightConstants(),hi.full=1,hi.left=1,hi.center=1+ft.left,hi.right=1+ft.left+ft.center}_refreshDrawHeightConstants(){Xe.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);Xe.left=t,Xe.center=t,Xe.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Xe.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(hi[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Xe[e.position||"full"]/2),ft[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Xe[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}))}};ps=fe([O(2,Be),O(3,zi),O(4,ht),O(5,Ne),O(6,ti),O(7,lt)],ps);var E;(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=`
|
|
172
|
+
`,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=""))(E||(E={}));var ls;(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=""))(ls||(ls={}));var Ja;(e=>e.ST=`${E.ESC}\\`)(Ja||(Ja={}));var xr=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${E.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),i=this._renderService.dimensions.css.cell.height,s=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=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"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=s+"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)}}};xr=fe([O(2,Be),O(3,Ne),O(4,It),O(5,ht)],xr);var we=0,xe=0,Ce=0,ue=0,go={css:"#00000000",rgba:0},ge;(e=>{function t(r,n,o,a){return a!==void 0?`#${Et(r)}${Et(n)}${Et(o)}${Et(a)}`:`#${Et(r)}${Et(n)}${Et(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ge||(ge={}));var ae;(e=>{function t(h,l){if(ue=(l.rgba&255)/255,ue===1)return{css:l.css,rgba:l.rgba};let d=l.rgba>>24&255,u=l.rgba>>16&255,f=l.rgba>>8&255,m=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255;we=m+Math.round((d-m)*ue),xe=p+Math.round((u-p)*ue),Ce=_+Math.round((f-_)*ue);let y=ge.toCss(we,xe,Ce),S=ge.toRgba(we,xe,Ce);return{css:y,rgba:S}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,d){let u=hs.ensureContrastRatio(h.rgba,l.rgba,d);if(u)return ge.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[we,xe,Ce]=hs.toChannels(l),{css:ge.toCss(we,xe,Ce),rgba:l}}e.opaque=r;function n(h,l){return ue=Math.round(l*255),[we,xe,Ce]=hs.toChannels(h.rgba),{css:ge.toCss(we,xe,Ce,ue),rgba:ge.toRgba(we,xe,Ce,ue)}}e.opacity=n;function o(h,l){return ue=h.rgba&255,n(h,ue*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(ae||(ae={}));var de;(e=>{let t,i;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",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return we=parseInt(r.slice(1,2).repeat(2),16),xe=parseInt(r.slice(2,3).repeat(2),16),Ce=parseInt(r.slice(3,4).repeat(2),16),ge.toColor(we,xe,Ce);case 5:return we=parseInt(r.slice(1,2).repeat(2),16),xe=parseInt(r.slice(2,3).repeat(2),16),Ce=parseInt(r.slice(3,4).repeat(2),16),ue=parseInt(r.slice(4,5).repeat(2),16),ge.toColor(we,xe,Ce,ue);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 we=parseInt(n[1]),xe=parseInt(n[2]),Ce=parseInt(n[3]),ue=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ge.toColor(we,xe,Ce,ue);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[we,xe,Ce,ue]=t.getImageData(0,0,1,1).data,ue!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ge.toRgba(we,xe,Ce,ue),css:r}}e.toColor=s})(de||(de={}));var Pe;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+d*.7152+u*.0722}e.relativeLuminance2=i})(Pe||(Pe={}));var hs;(e=>{function t(o,a){if(ue=(a&255)/255,ue===1)return a;let h=a>>24&255,l=a>>16&255,d=a>>8&255,u=o>>24&255,f=o>>16&255,m=o>>8&255;return we=u+Math.round((h-u)*ue),xe=f+Math.round((l-f)*ue),Ce=m+Math.round((d-m)*ue),ge.toRgba(we,xe,Ce)}e.blend=t;function i(o,a,h){let l=Pe.relativeLuminance(o>>8),d=Pe.relativeLuminance(a>>8);if(nt(l,d)<h){if(d<l){let m=s(o,a,h),p=nt(l,Pe.relativeLuminance(m>>8));if(p<h){let _=r(o,a,h),y=nt(l,Pe.relativeLuminance(_>>8));return p>y?m:_}return m}let u=r(o,a,h),f=nt(l,Pe.relativeLuminance(u>>8));if(f<h){let m=s(o,a,h),p=nt(l,Pe.relativeLuminance(m>>8));return f>p?u:m}return u}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,m=a>>16&255,p=a>>8&255,_=nt(Pe.relativeLuminance2(f,m,p),Pe.relativeLuminance2(l,d,u));for(;_<h&&(f>0||m>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=nt(Pe.relativeLuminance2(f,m,p),Pe.relativeLuminance2(l,d,u));return(f<<24|m<<16|p<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,d=o>>16&255,u=o>>8&255,f=a>>24&255,m=a>>16&255,p=a>>8&255,_=nt(Pe.relativeLuminance2(f,m,p),Pe.relativeLuminance2(l,d,u));for(;_<h&&(f<255||m<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=nt(Pe.relativeLuminance2(f,m,p),Pe.relativeLuminance2(l,d,u));return(f<<24|m<<16|p<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(hs||(hs={}));function Et(e){let t=e.toString(16);return t.length<2?"0"+t:t}function nt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var kf=class extends Ai{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},ms=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new qe}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==h){if(l-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<d.length;u++)i.push(d[u])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||gt.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<l.length;d++)i.push(l[d])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)ms._mergeRanges(o,h[l])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||gt.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ms=fe([O(0,Be)],ms);function Ef(e){return 57508<=e&&e<=57558}function Mf(e){return 9472<=e&&e<=9631}function Df(e){return Ef(e)||Mf(e)}function Rf(){return{css:{canvas:Qi(),cell:Qi()},device:{canvas:Qi(),cell:Qi(),char:{width:0,height:0,left:0,top:0}}}}function Qi(){return{width:0,height:0}}var Cr=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new qe,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,h,l,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),m=this._themeService.colors,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let _,y=0,S="",b=0,P=0,k=0,C=0,A=!1,D=0,W=!1,U=0,$=0,N=[],M=l!==-1&&d!==-1;for(let w=0;w<p;w++){e.loadCell(w,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let x=!1,L=w>=$,I=w,B=this._workCell;if(f.length>0&&w===f[0][0]&&L){let ie=f.shift(),Te=this._isCellInSelection(ie[0],t);for(b=ie[0]+1;b<ie[1];b++)L&&(L=Te===this._isCellInSelection(b,t));L&&(L=!i||n<ie[0]||n>=ie[1]),L?(x=!0,B=new kf(this._workCell,e.translateToString(!0,ie[0],ie[1]),ie[1]-ie[0]),I=ie[1]-1,R=B.getWidth()):$=ie[1]}let Y=this._isCellInSelection(w,t),te=i&&w===n,H=M&&w>=l&&w<=d,K=!1;this._decorationService.forEachDecorationAtCell(w,t,void 0,ie=>{K=!0});let V=B.getChars()||gt;if(V===" "&&(B.isUnderline()||B.isOverline())&&(V=" "),U=R*a-h.get(V,B.isBold(),B.isItalic()),!_)_=this._document.createElement("span");else if(y&&(Y&&W||!Y&&!W&&B.bg===P)&&(Y&&W&&m.selectionForeground||B.fg===k)&&B.extended.ext===C&&H===A&&U===D&&!te&&!x&&!K&&L){B.isInvisible()?S+=gt:S+=V,y++;continue}else y&&(_.textContent=S),_=this._document.createElement("span"),y=0,S="";if(P=B.bg,k=B.fg,C=B.extended.ext,A=H,D=U,W=Y,x&&n>=w&&n<=I&&(n=w),!this._coreService.isCursorHidden&&te&&this._coreService.isCursorInitialized){if(N.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&N.push("xterm-cursor-blink"),N.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":N.push("xterm-cursor-outline");break;case"block":N.push("xterm-cursor-block");break;case"bar":N.push("xterm-cursor-bar");break;case"underline":N.push("xterm-cursor-underline");break}}if(B.isBold()&&N.push("xterm-bold"),B.isItalic()&&N.push("xterm-italic"),B.isDim()&&N.push("xterm-dim"),B.isInvisible()?S=gt:S=B.getChars()||gt,B.isUnderline()&&(N.push(`xterm-underline-${B.extended.underlineStyle}`),S===" "&&(S=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${Ai.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let ie=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&ie<8&&(ie+=8),_.style.textDecorationColor=m.ansi[ie].css}B.isOverline()&&(N.push("xterm-overline"),S===" "&&(S=" ")),B.isStrikethrough()&&N.push("xterm-strikethrough"),H&&(_.style.textDecoration="underline");let Z=B.getFgColor(),se=B.getFgColorMode(),le=B.getBgColor(),Ee=B.getBgColorMode(),yt=!!B.isInverse();if(yt){let ie=Z;Z=le,le=ie;let Te=se;se=Ee,Ee=Te}let Oe,$t,st=!1;this._decorationService.forEachDecorationAtCell(w,t,void 0,ie=>{ie.options.layer!=="top"&&st||(ie.backgroundColorRGB&&(Ee=50331648,le=ie.backgroundColorRGB.rgba>>8&16777215,Oe=ie.backgroundColorRGB),ie.foregroundColorRGB&&(se=50331648,Z=ie.foregroundColorRGB.rgba>>8&16777215,$t=ie.foregroundColorRGB),st=ie.options.layer==="top")}),!st&&Y&&(Oe=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,le=Oe.rgba>>8&16777215,Ee=50331648,st=!0,m.selectionForeground&&(se=50331648,Z=m.selectionForeground.rgba>>8&16777215,$t=m.selectionForeground)),st&&N.push("xterm-decoration-top");let Ve;switch(Ee){case 16777216:case 33554432:Ve=m.ansi[le],N.push(`xterm-bg-${le}`);break;case 50331648:Ve=ge.toColor(le>>16,le>>8&255,le&255),this._addStyle(_,`background-color:#${vo((le>>>0).toString(16),"0",6)}`);break;case 0:default:yt?(Ve=m.foreground,N.push("xterm-bg-257")):Ve=m.background}switch(Oe||B.isDim()&&(Oe=ae.multiplyOpacity(Ve,.5)),se){case 16777216:case 33554432:B.isBold()&&Z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Z+=8),this._applyMinimumContrast(_,Ve,m.ansi[Z],B,Oe,void 0)||N.push(`xterm-fg-${Z}`);break;case 50331648:let ie=ge.toColor(Z>>16&255,Z>>8&255,Z&255);this._applyMinimumContrast(_,Ve,ie,B,Oe,$t)||this._addStyle(_,`color:#${vo(Z.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ve,m.foreground,B,Oe,$t)||yt&&N.push("xterm-fg-257")}N.length&&(_.className=N.join(" "),N.length=0),!te&&!x&&!K&&L?y++:_.textContent=S,U!==this.defaultSpacing&&(_.style.letterSpacing=`${U}px`),u.push(_),w=I}return _&&y&&(_.textContent=S),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Df(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=ae.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Cr=fe([O(1,Na),O(2,Ne),O(3,lt),O(4,It),O(5,zi),O(6,ti)],Cr);function vo(e,t,i){for(;e.length<i;)e=t+e;return e}var Pf=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.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=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Lf=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Bf(){return new Lf}var Ws="xterm-dom-renderer-owner-",Fe="xterm-rows",es="xterm-fg-",So="xterm-bg-",ci="xterm-focus",ts="xterm-selection",Nf=1,kr=class extends J{constructor(e,t,i,s,r,n,o,a,h,l,d,u,f,m){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=m,this._terminalClass=Nf++,this._rowElements=[],this._selectionRenderModel=Bf(),this.onRequestRedraw=this._register(new T).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Fe),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(ts),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Rf(),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=a.createInstance(Cr,document),this._element.classList.add(Ws+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(he(()=>{this._element.classList.remove(Ws+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Pf(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Fe} 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} .${Fe} { 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} .${Fe} .xterm-dim { color: ${ae.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${Fe}.${ci} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Fe}.${ci} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Fe}.${ci} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Fe} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ts} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ts} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ts} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${es}${n} { color: ${o.css}; }${this._terminalSelector} .${es}${n}.xterm-dim { color: ${ae.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${So}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${es}257 { color: ${ae.opaque(e.background).css}; }${this._terminalSelector} .${es}257.xterm-dim { color: ${ae.multiplyOpacity(ae.opaque(e.background),.5).css}; }${this._terminalSelector} .${So}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(ci),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ci),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let d=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let u=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,d=this._rowElements[h],u=i.lines.get(l);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ws}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=i;m<=s;++m){let p=m+a.ydisp,_=this._rowElements[m],y=a.lines.get(p);if(!_||!y)break;_.replaceChildren(...this._rowFactory.createRow(y,p,p===h,u,f,l,d,this.dimensions.css.cell.width,this._widthCache,n?m===i?e:0:-1,n?(m===s?t:r)-1:-1))}}};kr=fe([O(7,Xr),O(8,ws),O(9,Ne),O(10,Be),O(11,It),O(12,lt),O(13,ti)],kr);var Er=class extends J{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new T),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Af(this._optionsService))}catch{this._measureStrategy=this._register(new Tf(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())}};Er=fe([O(2,Ne)],Er);var Za=class extends J{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)}},Tf=class extends Za{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},Af=class extends Za{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}},zf=class extends J{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Of(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(s=>this._screenDprMonitor.setWindow(s))),this._register(De.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,"focus",()=>this._isFocused=!0)),this._register(q(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}},Of=class extends J{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ei),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(he(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(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)}},jf=class extends J{constructor(){super(),this.linkProviders=[],this._register(he(()=>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 rn(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function If(e,t,i,s,r,n,o,a,h){if(!n)return;let l=rn(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var Mr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return If(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=rn(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Mr=fe([O(0,ht),O(1,ws)],Mr);var $f=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,i){this._rowCount=i,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=[]}},Qa={};Xd(Qa,{getSafariVersion:()=>Ff,isChromeOS:()=>sl,isFirefox:()=>el,isIpad:()=>Wf,isIphone:()=>Kf,isLegacyEdge:()=>Hf,isLinux:()=>nn,isMac:()=>gs,isNode:()=>xs,isSafari:()=>tl,isWindows:()=>il});var xs=typeof process<"u"&&"title"in process,Oi=xs?"node":navigator.userAgent,ji=xs?"node":navigator.platform,el=Oi.includes("Firefox"),Hf=Oi.includes("Edge"),tl=/^((?!chrome|android).)*safari/i.test(Oi);function Ff(){if(!tl)return 0;let e=Oi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var gs=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ji),Wf=ji==="iPad",Kf=ji==="iPhone",il=["Windows","Win16","Win32","WinCE"].includes(ji),nn=ji.indexOf("Linux")>=0,sl=/\bCrOS\b/.test(Oi),rl=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,i=0,s=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),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Uf=class extends rl{_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())}}},qf=class extends rl{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},vs=!xs&&"requestIdleCallback"in window?qf:Uf,Vf=class{constructor(){this._queue=new vs}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Dr=class extends J{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new ei),this._pausedResizeTask=new Vf,this._observerDisposable=this._register(new ei),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 $f((l,d)=>this._renderRows(l,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Yf(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(he(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.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(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=he(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Dr=fe([O(2,Ne),O(3,ws),O(4,It),O(5,zi),O(6,Be),O(7,lt),O(8,ti)],Dr);var Yf=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 Xf(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Zf(r,n,e,t,i,s)+Cs(n,t,i,s)+Qf(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Bi(Math.abs(r-e),Li(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=Jf(n>t?e:r,i)+(a-1)*i.cols+1+Gf(n>t?r:e);return Bi(h,Li(o,s))}function Gf(e,t){return e-1}function Jf(e,t){return t.cols-e}function Zf(e,t,i,s,r,n){return Cs(t,s,r,n).length===0?"":Bi(ol(e,t,e,t-zt(t,r),!1,r).length,Li("D",n))}function Cs(e,t,i,s){let r=e-zt(e,i),n=t-zt(t,i),o=Math.abs(r-n)-e_(e,t,i);return Bi(o,Li(nl(e,t),s))}function Qf(e,t,i,s,r,n){let o;Cs(t,s,r,n).length>0?o=s-zt(s,r):o=t;let a=s,h=t_(e,t,i,s,r,n);return Bi(ol(e,o,i,a,h==="C",r).length,Li(h,n))}function e_(e,t,i){var o;let s=0,r=e-zt(e,i),n=t-zt(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=nl(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function zt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function t_(e,t,i,s,r,n){let o;return Cs(i,s,r,n).length>0?o=s-zt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function nl(e,t){return e>t?"A":"B"}function ol(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Li(e,t){let i=t?"O":"[";return E.ESC+i+e}function Bi(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var i_=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 bo(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 Ks=50,s_=15,r_=50,n_=500,o_=" ",a_=new RegExp(o_,"g"),Rr=class extends J{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new qe,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=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new i_(this._bufferService),this._activeSelectionMode=0,this._register(he(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.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 i=this._bufferService.buffer,s=[];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 o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(a_," ")).join(il?`\r
|
|
143
173
|
`:`
|
|
144
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Gr&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=ao(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Xr(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-zs),zs),t/=zs,t/Math.abs(t)+Math.round(t*(Lf-1)))}shouldForceSelection(e){return ds?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(),Nf)}_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&&!(ds&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<Tf&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=Cf(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,d=0,u=0,f=0,m=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let y=e[0],S=e[0];n.getWidth(y)===0&&(d++,y--),n.getWidth(S)===2&&(u++,S++);let b=n.getString(S).length;for(b>1&&(m+=b-1,h+=b-1);y>0&&a>0&&!this._isCharWordSeparator(n.loadCell(y-1,this._workCell));){n.loadCell(y-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,y--):P>1&&(f+=P-1,a-=P-1),a--,y--}for(;S<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(S+1,this._workCell));){n.loadCell(S+1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,S++):P>1&&(m+=P-1,h+=P-1),h++,S++}}h++;let p=a+l-d+f,_=Math.min(this._bufferService.cols,h-a+d+u-f-m);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&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 S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let b=this._bufferService.cols-S.start;p-=b,_+=b}}}if(s&&p+_===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 S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(_+=S.length)}}return{start:p,length:_}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=ao(i,this._bufferService.cols)}};yr=fe([O(3,Pe),O(4,Ot),O(5,Hr),O(6,Be),O(7,lt),O(8,at)],yr);var lo=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},ho=class{constructor(){this._color=new lo,this._css=new lo}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ge=Object.freeze((()=>{let e=[ce.toColor("#2e3436"),ce.toColor("#cc0000"),ce.toColor("#4e9a06"),ce.toColor("#c4a000"),ce.toColor("#3465a4"),ce.toColor("#75507b"),ce.toColor("#06989a"),ce.toColor("#d3d7cf"),ce.toColor("#555753"),ce.toColor("#ef2929"),ce.toColor("#8ae234"),ce.toColor("#fce94f"),ce.toColor("#729fcf"),ce.toColor("#ad7fa8"),ce.toColor("#34e2e2"),ce.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:me.toCss(s,r,n),rgba:me.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:me.toCss(s,s,s),rgba:me.toRgba(s,s,s)})}return e})()),Et=ce.toColor("#ffffff"),gi=ce.toColor("#000000"),co=ce.toColor("#ffffff"),uo=gi,ai={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Of=Et,wr=class extends Z{constructor(e){super(),this._optionsService=e,this._contrastCache=new ho,this._halfContrastCache=new ho,this._onChangeColors=this._register(new T),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Et,background:gi,cursor:co,cursorAccent:uo,selectionForeground:void 0,selectionBackgroundTransparent:ai,selectionBackgroundOpaque:ae.blend(gi,ai),selectionInactiveBackgroundTransparent:ai,selectionInactiveBackgroundOpaque:ae.blend(gi,ai),scrollbarSliderBackground:ae.opacity(Et,.2),scrollbarSliderHoverBackground:ae.opacity(Et,.4),scrollbarSliderActiveBackground:ae.opacity(Et,.5),overviewRulerBorder:Et,ansi:ge.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=se(e.foreground,Et),t.background=se(e.background,gi),t.cursor=ae.blend(t.background,se(e.cursor,co)),t.cursorAccent=ae.blend(t.background,se(e.cursorAccent,uo)),t.selectionBackgroundTransparent=se(e.selectionBackground,ai),t.selectionBackgroundOpaque=ae.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=se(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ae.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?se(e.selectionForeground,ro):void 0,t.selectionForeground===ro&&(t.selectionForeground=void 0),ae.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ae.opacity(t.selectionBackgroundTransparent,.3)),ae.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ae.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=se(e.scrollbarSliderBackground,ae.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=se(e.scrollbarSliderHoverBackground,ae.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=se(e.scrollbarSliderActiveBackground,ae.opacity(t.foreground,.5)),t.overviewRulerBorder=se(e.overviewRulerBorder,Of),t.ansi=ge.slice(),t.ansi[0]=se(e.black,ge[0]),t.ansi[1]=se(e.red,ge[1]),t.ansi[2]=se(e.green,ge[2]),t.ansi[3]=se(e.yellow,ge[3]),t.ansi[4]=se(e.blue,ge[4]),t.ansi[5]=se(e.magenta,ge[5]),t.ansi[6]=se(e.cyan,ge[6]),t.ansi[7]=se(e.white,ge[7]),t.ansi[8]=se(e.brightBlack,ge[8]),t.ansi[9]=se(e.brightRed,ge[9]),t.ansi[10]=se(e.brightGreen,ge[10]),t.ansi[11]=se(e.brightYellow,ge[11]),t.ansi[12]=se(e.brightBlue,ge[12]),t.ansi[13]=se(e.brightMagenta,ge[13]),t.ansi[14]=se(e.brightCyan,ge[14]),t.ansi[15]=se(e.brightWhite,ge[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=se(e.extendedAnsi[s],ge[s+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()}}};wr=fe([O(0,Be)],wr);function se(e,t){if(e!==void 0)try{return ce.toColor(e)}catch{}return t}var jf=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},If=class{constructor(){this._services=new jf,this._services.set(Fr,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Bd(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[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,...s)}},$f={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ff="xterm.js: ",xr=class extends Z{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=$f[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Ff)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};xr=fe([O(0,Be)],xr);var fo=class extends Z{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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},J=3,pe=Object.freeze(new Bi),Gi=0,Os=2,vi=class Xa{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*J);let r=i||Ue.fromCharData([0,_a,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*J+0],s=i&2097151;return[this._data[t*J+1],i&2097152?this._combined[t]:s?_t(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*J+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*J+0]=t|2097152|i[2]<<22):this._data[t*J+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*J+0]>>22}hasWidth(t){return this._data[t*J+0]&12582912}getFg(t){return this._data[t*J+1]}getBg(t){return this._data[t*J+2]}hasContent(t){return this._data[t*J+0]&4194303}getCodePoint(t){let i=this._data[t*J+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*J+0]&2097152}getString(t){let i=this._data[t*J+0];return i&2097152?this._combined[t]:i&2097151?_t(i&2097151):""}isProtected(t){return this._data[t*J+2]&536870912}loadCell(t,i){return Gi=t*J,i.content=this._data[Gi+0],i.fg=this._data[Gi+1],i.bg=this._data[Gi+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*J+0]=i.content,this._data[t*J+1]=i.fg,this._data[t*J+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*J+0]=i|s<<22,this._data[t*J+1]=r.fg,this._data[t*J+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*J+0];r&2097152?this._combined[t]+=_t(i):r&2097151?(this._combined[t]=_t(r&2097151)+_t(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*J+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new Ue;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new Ue;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Os<this._data.buffer.byteLength;let s=t*J;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*Os<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Os<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Xa(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*J+0]&4194303)return t+(this._data[t*J+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*J+0]&4194303||this._data[t*J+2]&50331648)return t+(this._data[t*J+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<J;l++)this._data[(s+h)*J+l]=o[(i+h)*J+l];o[(i+h)*J+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<J;l++)this._data[(s+h)*J+l]=o[(i+h)*J+l];o[(i+h)*J+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*J+0],a=o&2097151,h=o&2097152?this._combined[i]:a?_t(a):mt;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Hf(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let d=[e.get(a)];for(;h<e.length&&l.isWrapped;)d.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=d.length-1;continue}let u=0,f=Ri(d,u,t),m=1,p=0;for(;m<d.length;){let y=Ri(d,m,t),S=y-p,b=i-f,P=Math.min(S,b);d[u].copyCellsFrom(d[m],p,f,P,!1),f+=P,f===i&&(u++,f=0),p+=P,p===y&&(m++,p=0),f===0&&u!==0&&d[u-1].getWidth(i-1)===2&&(d[u].copyCellsFrom(d[u-1],i-1,f++,1,!1),d[u-1].setCell(i-1,r))}d[u].replaceCells(f,i,r);let _=0;for(let y=d.length-1;y>0&&(y>u||d[y].getTrimmedLength()===0);y--)_++;_>0&&(o.push(a+d.length-_),o.push(_)),a+=d.length-1}return o}function Wf(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Kf(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Uf(e,t,i){let s=[],r=e.map((h,l)=>Ri(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=Ri(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let d=l?i-1:i;s.push(d),a+=d}return s}function Ri(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Ga=class Ja{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Ja._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(),Nt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ga._nextId=1;var qf=Ga,Se={},Mt=Se.B;Se[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Se.A={"#":"£"};Se.B=void 0;Se[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Se.C=Se[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Se.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Se.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Se.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Se.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Se.E=Se[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Se.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Se.H=Se[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Se["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var _o=4294967295,po=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=pe.clone(),this.savedCharset=Mt,this.markers=[],this._nullCell=Ue.fromCharData([0,_a,1,0]),this._whitespaceCell=Ue.fromCharData([0,mt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new us,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new fo(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 ls),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 ls),this._whitespaceCell}getBlankLine(e,t){return new vi(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>_o?_o:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=pe);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 fo(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(pe),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 vi(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new vi(e,i)));else for(let o=this._rows;o>t;o--)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 o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,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++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=Hf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(pe),i);if(s.length>0){let r=Wf(this.lines,s);Kf(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(pe),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new vi(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(pe),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let P=this.ybase+this.y;if(P>=o&&P<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),d=Uf(h,this._cols,e),u=d.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let P=0;P<u;P++){let k=this.getBlankLine(pe,!0);m.push(k)}m.length>0&&(r.push({start:o+h.length+n,newLines:m}),n+=m.length),h.push(...m);let p=d.length-1,_=d[p];_===0&&(p--,_=d[p]);let y=h.length-u-1,S=l;for(;y>=0;){let P=Math.min(S,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[y],S-P,_-P,P,!0),_-=P,_===0&&(p--,_=d[p]),S-=P,S===0){y--;let k=Math.max(y,0);S=Ri(h,k,this._cols)}}for(let P=0;P<h.length;P++)d[P]<e&&h[P].setCell(d[P],s);let b=u-f;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+u,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let h=this.lines.length,l=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+n-1);_>=0;_--)if(u&&u.start>l+f){for(let y=u.newLines.length-1;y>=0;y--)this.lines.set(_--,u.newLines[y]);_++,o.push({index:l+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(_,a[l--]);let m=0;for(let _=o.length-1;_>=0;_--)o[_].index+=m,this.lines.onInsertEmitter.fire(o[_]),m+=o[_].amount;let p=Math.max(0,h+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 qf(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Vf=class extends Z{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 po(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new po(!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)}},Za=2,Qa=1,Cr=class extends Z{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,Za),this.rows=Math.max(e.rawOptions.rows||0,Qa),this.buffers=this._register(new Vf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Cr=fe([O(0,Be)],Cr);var Wt={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:ds,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Yf=["normal","bold","100","200","300","400","500","600","700","800","900"],Xf=class extends Z{constructor(e){super(),this._onOptionChange=this._register(new T),this.onOptionChange=this._onOptionChange.event;let t={...Wt};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(le(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Wt))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Wt[e]),!Gf(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Wt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Yf.includes(t)?t:Wt[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 Gf(e){return e==="block"||e==="underline"||e==="bar"}function Si(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Si(e[s],t-1);return i}var mo=Object.freeze({insertMode:!1}),go=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),kr=class extends Z{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,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=Si(mo),this.decPrivateModes=Si(go)}reset(){this.modes=Si(mo),this.decPrivateModes=Si(go)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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))}};kr=fe([O(0,Pe),O(1,Sa),O(2,Be)],kr);var vo={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 js(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Is=String.fromCharCode,So={DEFAULT:e=>{let t=[js(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Is(t[0])}${Is(t[1])}${Is(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${js(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${js(e,!0)};${e.x};${e.y}${t}`}},Er=class extends Z{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,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 s of Object.keys(vo))this.addProtocol(s,vo[s]);for(let s of Object.keys(So))this.addEncoding(s,So[s]);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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+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,i){if(i){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)}};Er=fe([O(0,Pe),O(1,Ot),O(2,Be)],Er);var $s=[[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]],Jf=[[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]],ve;function Zf(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Qf=class{constructor(){if(this.version="6",!ve){ve=new Uint8Array(65536),ve.fill(1),ve[0]=0,ve.fill(0,1,32),ve.fill(0,127,160),ve.fill(2,4352,4448),ve[9001]=2,ve[9002]=2,ve.fill(2,11904,42192),ve[12351]=1,ve.fill(2,44032,55204),ve.fill(2,63744,64256),ve.fill(2,65040,65050),ve.fill(2,65072,65136),ve.fill(2,65280,65377),ve.fill(2,65504,65511);for(let e=0;e<$s.length;++e)ve.fill(0,$s[e][0],$s[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ve[e]:Zf(e,Jf)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Dt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Dt.createPropertyValue(0,i,s)}},Dt=class rs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new T,this.onChange=this._onChange.event;let t=new Qf;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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 i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=rs.extractWidth(a);rs.extractShouldJoin(a)&&(h-=rs.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},e_=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 bo(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var li=2147483647,t_=256,el=class Mr{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>t_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Mr;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Mr(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>li?li: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>li?li:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,li):t}},hi=[],i_=class{constructor(){this._state=0,this._active=hi,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=hi}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=hi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||hi,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",ps(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=hi,this._id=-1,this._state=0}}},Oe=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ps(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},ci=[],s_=class{constructor(){this._handlers=Object.create(null),this._active=ci,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ci}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=ci,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ci,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",ps(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ci,this._ident=0}},bi=new el;bi.addParam(0);var yo=class{constructor(e){this._handler=e,this._data="",this._params=bi,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():bi,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ps(e,t,i),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(i=>(this._params=bi,this._data="",this._hitLimit=!1,i));return this._params=bi,this._data="",this._hitLimit=!1,t}},r_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Ke=160,n_=(function(){let e=new r_(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,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(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ke,0,2,0),e.add(Ke,8,5,8),e.add(Ke,6,0,6),e.add(Ke,11,0,11),e.add(Ke,13,13,13),e})(),o_=class extends Z{constructor(e=n_){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 el,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(le(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new i_),this._dcsParser=this._register(new s_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===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 a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:Ke)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<Ke){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ke){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ke){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ke){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],u=d?d.length-1:-1;for(;u>=0&&(o=d[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,d,u,r,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<Ke){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===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 f=a+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<Ke){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},a_=/^([\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})$/,l_=/^[\da-f]+$/;function wo(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=a_.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),l_.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Fs(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function h_(e,t=16){let[i,s,r]=e;return`rgb:${Fs(i,t)}/${Fs(s,t)}/${Fs(r,t)}`}var c_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ft=131072,xo=10;function Co(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 ko=5e3,Eo=0,d_=class extends Z{constructor(e,t,i,s,r,n,o,a,h=new o_){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Rd,this._utf8Decoder=new Pd,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=pe.clone(),this._eraseAttrDataInternal=pe.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 Dr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:d.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:d,data:u})}),this._parser.setDcsHandlerFallback((l,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:d,payload:u})}),this._parser.setPrintHandler((l,d,u)=>this.print(l,d,u)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(E.BEL,()=>this.bell()),this._parser.setExecuteHandler(E.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(E.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(E.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(E.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(E.BS,()=>this.backspace()),this._parser.setExecuteHandler(E.HT,()=>this.tab()),this._parser.setExecuteHandler(E.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(E.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(is.IND,()=>this.index()),this._parser.setExecuteHandler(is.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(is.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Oe(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Oe(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Oe(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Oe(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Oe(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Oe(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Oe(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Oe(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Oe(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Oe(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Oe(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Oe(l=>this.restoreCursorColor(l))),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 l in Se)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new yo((l,d)=>this.requestStatusString(l,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ko))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ko} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ft&&(n=this._parseStack.position+ft)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ft&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ft))),o||this._dirtyRowTracker.clearRange(),e.length>ft)for(let l=n;l<e.length;l+=ft){let d=l+ft<e.length?l+ft:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(l,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=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(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let m=t;m<i;++m){if(s=e[m],s<127&&n){let S=n[String.fromCharCode(s)];S&&(s=S.charCodeAt(0))}let p=this._unicodeService.charProperties(s,f);r=Dt.extractWidth(p);let _=Dt.extractShouldJoin(p),y=_?Dt.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(_t(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-y>a){if(h){let S=u,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&u instanceof vi&&u.copyCellsFrom(S,b,0,y,!1);b<a;)S.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let S=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-S,s,r);for(let b=r-y;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(l&&(u.insertCells(this._activeBuffer.x,r-y,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.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,i=>Co(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new yo(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Oe(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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,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}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(pe));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=Dt.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let d=n.codePointAt(l)||0;o[a++]=d,l+=d>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(E.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(E.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(E.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(E.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(E.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,Mt),this._charsetService.setgCharset(1,Mt),this._charsetService.setgCharset(2,Mt),this._charsetService.setgCharset(3,Mt);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){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:d}=a,u=this._optionsService.rawOptions,f=(_,y)=>(o.triggerDataEvent(`${E.ESC}[${t?"":"?"}${_};${y}$y`),!0),m=_=>_?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,m(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(s.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,m(s.origin)):p===7?f(p,m(s.wraparound)):p===8?f(p,3):p===9?f(p,m(r==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!o.isCursorHidden)):p===45?f(p,m(s.reverseWraparound)):p===66?f(p,m(s.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(r==="VT200")):p===1002?f(p,m(r==="DRAG")):p===1003?f(p,m(r==="ANY")):p===1004?f(p,m(s.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(n==="SGR")):p===1015?f(p,4):p===1016?f(p,m(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(l===d)):p===2004?f(p,m(s.bracketedPasteMode)):p===2026?f(p,m(s.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Bi.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[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=pe.fg,e.bg=pe.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=pe.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=pe.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=pe.fg&16777215,s.bg&=-67108864,s.bg|=pe.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${E.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${E.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${E.ESC}[?${t};${i}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=pe.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Co(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(`${E.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>xo&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>xo&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Mo(n))if(r==="?")t.push({type:0,index:n});else{let o=wo(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=wo(i[s]);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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Mo(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,Mt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(c_[e[0]],Se[e[1]]||Mt),!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=pe.clone(),this._eraseAttrDataInternal=pe.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 Ue;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${E.ESC}${o}${E.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.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)}},Dr=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&&(Eo=e,e=t,t=Eo),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Dr=fe([O(0,Pe)],Dr);function Mo(e){return 0<=e&&e<256}var u_=5e7,Do=12,f_=50,__=class extends Z{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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>u_)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Do?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Do)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>f_&&(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()}},Rr=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 a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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 i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Rr=fe([O(0,Pe)],Rr);var Ro=!1,p_=class extends Z{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zt),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 If,this.optionsService=this._register(new Xf(e)),this._instantiationService.setService(Be,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Cr)),this._instantiationService.setService(Pe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(xr)),this._instantiationService.setService(Sa,this._logService),this.coreService=this._register(this._instantiationService.createInstance(kr)),this._instantiationService.setService(Ot,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Er)),this._instantiationService.setService(va,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Dt)),this._instantiationService.setService(Td,this.unicodeService),this._charsetService=this._instantiationService.createInstance(e_),this._instantiationService.setService(Nd,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Rr),this._instantiationService.setService(ba,this._oscLinkService),this._inputHandler=this._register(new d_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ee.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ee.forward(this._bufferService.onResize,this._onResize)),this._register(Ee.forward(this.coreService.onData,this._onData)),this._register(Ee.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 __((t,i)=>this._inputHandler.parse(t,i))),this._register(Ee.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&&!Ro&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ro=!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,Za),t=Math.max(t,Qa),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(bo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(bo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=le(()=>{for(let t of e)t.dispose()})}}},m_={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 g_(e,t,i,s){var o;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=E.ESC+"OA":r.key=E.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=E.ESC+"OD":r.key=E.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=E.ESC+"OC":r.key=E.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=E.ESC+"OB":r.key=E.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":E.DEL,e.altKey&&(r.key=E.ESC+r.key);break;case 9:if(e.shiftKey){r.key=E.ESC+"[Z";break}r.key=E.HT,r.cancel=!0;break;case 13:r.key=e.altKey?E.ESC+E.CR:E.CR,r.cancel=!0;break;case 27:r.key=E.ESC,e.altKey&&(r.key=E.ESC+E.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"D":t?r.key=E.ESC+"OD":r.key=E.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"C":t?r.key=E.ESC+"OC":r.key=E.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"A":t?r.key=E.ESC+"OA":r.key=E.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"B":t?r.key=E.ESC+"OB":r.key=E.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=E.ESC+"[2~");break;case 46:n?r.key=E.ESC+"[3;"+(n+1)+"~":r.key=E.ESC+"[3~";break;case 36:n?r.key=E.ESC+"[1;"+(n+1)+"H":t?r.key=E.ESC+"OH":r.key=E.ESC+"[H";break;case 35:n?r.key=E.ESC+"[1;"+(n+1)+"F":t?r.key=E.ESC+"OF":r.key=E.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=E.ESC+"[5;"+(n+1)+"~":r.key=E.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=E.ESC+"[6;"+(n+1)+"~":r.key=E.ESC+"[6~";break;case 112:n?r.key=E.ESC+"[1;"+(n+1)+"P":r.key=E.ESC+"OP";break;case 113:n?r.key=E.ESC+"[1;"+(n+1)+"Q":r.key=E.ESC+"OQ";break;case 114:n?r.key=E.ESC+"[1;"+(n+1)+"R":r.key=E.ESC+"OR";break;case 115:n?r.key=E.ESC+"[1;"+(n+1)+"S":r.key=E.ESC+"OS";break;case 116:n?r.key=E.ESC+"[15;"+(n+1)+"~":r.key=E.ESC+"[15~";break;case 117:n?r.key=E.ESC+"[17;"+(n+1)+"~":r.key=E.ESC+"[17~";break;case 118:n?r.key=E.ESC+"[18;"+(n+1)+"~":r.key=E.ESC+"[18~";break;case 119:n?r.key=E.ESC+"[19;"+(n+1)+"~":r.key=E.ESC+"[19~";break;case 120:n?r.key=E.ESC+"[20;"+(n+1)+"~":r.key=E.ESC+"[20~";break;case 121:n?r.key=E.ESC+"[21;"+(n+1)+"~":r.key=E.ESC+"[21~";break;case 122:n?r.key=E.ESC+"[23;"+(n+1)+"~":r.key=E.ESC+"[23~";break;case 123:n?r.key=E.ESC+"[24;"+(n+1)+"~":r.key=E.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=E.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=E.DEL:e.keyCode===219?r.key=E.ESC:e.keyCode===220?r.key=E.FS:e.keyCode===221&&(r.key=E.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=m_[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=E.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=E.ESC+l}else if(e.keyCode===32)r.key=E.ESC+(e.ctrlKey?E.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=E.ESC+h,r.cancel=!0}}else i&&!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=E.US),e.key==="@"&&(r.key=E.NUL));break}return r}var _e=0,v_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new us,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new us,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(_e=this._search(t),_e===-1)||this._getKey(this._array[_e])!==t)return!1;do if(this._array[_e]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(_e),!0;while(++_e<this._array.length&&this._getKey(this._array[_e])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(_e=this._search(e),!(_e<0||_e>=this._array.length)&&this._getKey(this._array[_e])===e))do yield this._array[_e];while(++_e<this._array.length&&this._getKey(this._array[_e])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(_e=this._search(e),!(_e<0||_e>=this._array.length)&&this._getKey(this._array[_e])===e))do t(this._array[_e]);while(++_e<this._array.length&&this._getKey(this._array[_e])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Hs=0,Po=0,S_=class extends Z{constructor(){super(),this._decorations=new v_(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(le(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new b_(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Hs=r.options.x??0,Po=Hs+(r.options.width??1),e>=Hs&&e<Po&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},b_=class extends St{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=ce.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ce.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},y_=1e3,w_=class{constructor(e,t=y_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-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)}},Bo=20,fs=class extends Z{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,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 w_(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(`
|
|
145
|
-
`))),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(
|
|
146
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Bo+1&&(this._liveRegion.textContent+=Xs.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.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 a;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let d=h instanceof Text?h.parentNode:h,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let m=l<f.length?f[l]:f.slice(-1)[0]+1;return m>=this._terminal.cols&&(++u,m=0),{row:u,column:m}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};fs=fe([O(1,Fr),O(2,at),O(3,lt)],fs);var Pr=class extends Z{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,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(le(()=>{var n;Nt(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(V(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(V(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(V(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(V(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,d;if(this._isMouseOut)return;let h=a==null?void 0:a.map(u=>({link:u}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&x_(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,Nt(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 i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Pr=fe([O(1,Hr),O(2,lt),O(3,Pe),O(4,wa)],Pr);function x_(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 C_=class extends p_{constructor(e={}){super(e),this._linkifier=this._register(new Zt),this.browser=Fa,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zt),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(S_),this._instantiationService.setService(Li,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ff),this._instantiationService.setService(wa,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Js)),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(Ee.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ee.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ee.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ee.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(le(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=ae.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${E.ESC}]${s};${h_(r)}${Ia.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=me.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=me.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(fs,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(E.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(E.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(V(this.element,"copy",t=>{this.hasSelection()&&Md(t,this._selectionService)}));let e=t=>Dd(t,this.textarea,this.coreService,this.optionsService);this._register(V(this.textarea,"paste",e)),this._register(V(this.element,"paste",e)),Ha?this._register(V(this.element,"mousedown",t=>{t.button===2&&$n(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(V(this.element,"contextmenu",t=>{$n(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Gr&&this._register(V(this.element,"auxclick",t=>{t.button===1&&fa(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(V(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(V(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(V(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(V(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(V(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(V(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(V(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(V(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ys.get()),Ua||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(df,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(at,this._coreBrowserService),this._register(V(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(V(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(vr,this._document,this._helperContainer),this._instantiationService.setService(ms,this._charSizeService),this._themeService=this._instantiationService.createInstance(wr),this._instantiationService.setService(Qt,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(cs),this._instantiationService.setService(ya,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(br,this.rows,this.screenElement)),this._instantiationService.setService(lt,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(pr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Sr),this._instantiationService.setService(Hr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Pr,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(fr,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(yr,this.element,this.screenElement,s)),this._instantiationService.setService(zd,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(Ee.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(_r,this.screenElement)),this._register(V(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(fs,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hs,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(gr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,d,u,f,m;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=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,(f=(u=(d=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:f.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return!1;h=p<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(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?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(V(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(V(t,"wheel",n=>{var o,a,h,l,d;if(!s.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,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let u=E.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.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){ua(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,i){this._selectionService.setSelection(e,t,i)}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 i;(i=this._selectionService)==null||i.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 i=g_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===E.ETX||i.key===E.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(k_(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 i;(i=this._charSizeService)==null||i.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(pe));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(E.ESC+"[I"):this.coreService.triggerDataEvent(E.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${E.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${E.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function k_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var E_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},M_=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 Ue)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Lo=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 M_(t)}getNullCell(){return new Ue}},D_=class extends Z{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new T),this.onBufferChange=this._onBufferChange.event,this._normal=new Lo(this._core.buffers.normal,"normal"),this._alternate=new Lo(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)}},R_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},P_=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}},B_=["cols","rows"],Ge=0,L_=class extends Z{constructor(e){super(),this._core=this._register(new C_(e)),this._addonManager=this._register(new E_),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(B_.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 R_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new P_(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new D_(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
|
|
147
|
-
`,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
|
|
174
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),nn&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=bo(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=rn(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Ks),Ks),t/=Ks,t/Math.abs(t)+Math.round(t*(s_-1)))}shouldForceSelection(e){return gs?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(),r_)}_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&&!(gs&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<n_&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=Xf(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,d=0,u=0,f=0,m=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let y=e[0],S=e[0];n.getWidth(y)===0&&(d++,y--),n.getWidth(S)===2&&(u++,S++);let b=n.getString(S).length;for(b>1&&(m+=b-1,h+=b-1);y>0&&a>0&&!this._isCharWordSeparator(n.loadCell(y-1,this._workCell));){n.loadCell(y-1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,y--):P>1&&(f+=P-1,a-=P-1),a--,y--}for(;S<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(S+1,this._workCell));){n.loadCell(S+1,this._workCell);let P=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,S++):P>1&&(m+=P-1,h+=P-1),h++,S++}}h++;let p=a+l-d+f,_=Math.min(this._bufferService.cols,h-a+d+u-f-m);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&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 S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let b=this._bufferService.cols-S.start;p-=b,_+=b}}}if(s&&p+_===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 S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(_+=S.length)}}return{start:p,length:_}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=bo(i,this._bufferService.cols)}};Rr=fe([O(3,Be),O(4,It),O(5,Gr),O(6,Ne),O(7,ht),O(8,lt)],Rr);var yo=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},wo=class{constructor(){this._color=new yo,this._css=new yo}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ve=Object.freeze((()=>{let e=[de.toColor("#2e3436"),de.toColor("#cc0000"),de.toColor("#4e9a06"),de.toColor("#c4a000"),de.toColor("#3465a4"),de.toColor("#75507b"),de.toColor("#06989a"),de.toColor("#d3d7cf"),de.toColor("#555753"),de.toColor("#ef2929"),de.toColor("#8ae234"),de.toColor("#fce94f"),de.toColor("#729fcf"),de.toColor("#ad7fa8"),de.toColor("#34e2e2"),de.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ge.toCss(s,r,n),rgba:ge.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ge.toCss(s,s,s),rgba:ge.toRgba(s,s,s)})}return e})()),Dt=de.toColor("#ffffff"),yi=de.toColor("#000000"),xo=de.toColor("#ffffff"),Co=yi,di={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},l_=Dt,Pr=class extends J{constructor(e){super(),this._optionsService=e,this._contrastCache=new wo,this._halfContrastCache=new wo,this._onChangeColors=this._register(new T),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Dt,background:yi,cursor:xo,cursorAccent:Co,selectionForeground:void 0,selectionBackgroundTransparent:di,selectionBackgroundOpaque:ae.blend(yi,di),selectionInactiveBackgroundTransparent:di,selectionInactiveBackgroundOpaque:ae.blend(yi,di),scrollbarSliderBackground:ae.opacity(Dt,.2),scrollbarSliderHoverBackground:ae.opacity(Dt,.4),scrollbarSliderActiveBackground:ae.opacity(Dt,.5),overviewRulerBorder:Dt,ansi:ve.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=re(e.foreground,Dt),t.background=re(e.background,yi),t.cursor=ae.blend(t.background,re(e.cursor,xo)),t.cursorAccent=ae.blend(t.background,re(e.cursorAccent,Co)),t.selectionBackgroundTransparent=re(e.selectionBackground,di),t.selectionBackgroundOpaque=ae.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=re(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ae.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?re(e.selectionForeground,go):void 0,t.selectionForeground===go&&(t.selectionForeground=void 0),ae.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ae.opacity(t.selectionBackgroundTransparent,.3)),ae.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ae.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=re(e.scrollbarSliderBackground,ae.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=re(e.scrollbarSliderHoverBackground,ae.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=re(e.scrollbarSliderActiveBackground,ae.opacity(t.foreground,.5)),t.overviewRulerBorder=re(e.overviewRulerBorder,l_),t.ansi=ve.slice(),t.ansi[0]=re(e.black,ve[0]),t.ansi[1]=re(e.red,ve[1]),t.ansi[2]=re(e.green,ve[2]),t.ansi[3]=re(e.yellow,ve[3]),t.ansi[4]=re(e.blue,ve[4]),t.ansi[5]=re(e.magenta,ve[5]),t.ansi[6]=re(e.cyan,ve[6]),t.ansi[7]=re(e.white,ve[7]),t.ansi[8]=re(e.brightBlack,ve[8]),t.ansi[9]=re(e.brightRed,ve[9]),t.ansi[10]=re(e.brightGreen,ve[10]),t.ansi[11]=re(e.brightYellow,ve[11]),t.ansi[12]=re(e.brightBlue,ve[12]),t.ansi[13]=re(e.brightMagenta,ve[13]),t.ansi[14]=re(e.brightCyan,ve[14]),t.ansi[15]=re(e.brightWhite,ve[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=re(e.extendedAnsi[s],ve[s+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()}}};Pr=fe([O(0,Ne)],Pr);function re(e,t){if(e!==void 0)try{return de.toColor(e)}catch{}return t}var h_=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},c_=class{constructor(){this._services=new h_,this._services.set(Xr,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=iu(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[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,...s)}},d_={trace:0,debug:1,info:2,warn:3,error:4,off:5},u_="xterm.js: ",Lr=class extends J{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=d_[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":u_)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Lr=fe([O(0,Ne)],Lr);var ko=class extends J{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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},G=3,me=Object.freeze(new Ai),is=0,Us=2,wi=class al{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*G);let r=i||qe.fromCharData([0,Ea,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*G+0],s=i&2097151;return[this._data[t*G+1],i&2097152?this._combined[t]:s?pt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*G+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*G+0]=t|2097152|i[2]<<22):this._data[t*G+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*G+0]>>22}hasWidth(t){return this._data[t*G+0]&12582912}getFg(t){return this._data[t*G+1]}getBg(t){return this._data[t*G+2]}hasContent(t){return this._data[t*G+0]&4194303}getCodePoint(t){let i=this._data[t*G+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*G+0]&2097152}getString(t){let i=this._data[t*G+0];return i&2097152?this._combined[t]:i&2097151?pt(i&2097151):""}isProtected(t){return this._data[t*G+2]&536870912}loadCell(t,i){return is=t*G,i.content=this._data[is+0],i.fg=this._data[is+1],i.bg=this._data[is+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*G+0]=i.content,this._data[t*G+1]=i.fg,this._data[t*G+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*G+0]=i|s<<22,this._data[t*G+1]=r.fg,this._data[t*G+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*G+0];r&2097152?this._combined[t]+=pt(i):r&2097151?(this._combined[t]=pt(r&2097151)+pt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*G+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new qe;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new qe;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Us<this._data.buffer.byteLength;let s=t*G;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*Us<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Us<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new al(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303)return t+(this._data[t*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303||this._data[t*G+2]&50331648)return t+(this._data[t*G+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<G;l++)this._data[(s+h)*G+l]=o[(i+h)*G+l];o[(i+h)*G+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<G;l++)this._data[(s+h)*G+l]=o[(i+h)*G+l];o[(i+h)*G+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*G+0],a=o&2097151,h=o&2097152?this._combined[i]:a?pt(a):gt;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function f_(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let d=[e.get(a)];for(;h<e.length&&l.isWrapped;)d.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=d.length-1;continue}let u=0,f=Ni(d,u,t),m=1,p=0;for(;m<d.length;){let y=Ni(d,m,t),S=y-p,b=i-f,P=Math.min(S,b);d[u].copyCellsFrom(d[m],p,f,P,!1),f+=P,f===i&&(u++,f=0),p+=P,p===y&&(m++,p=0),f===0&&u!==0&&d[u-1].getWidth(i-1)===2&&(d[u].copyCellsFrom(d[u-1],i-1,f++,1,!1),d[u-1].setCell(i-1,r))}d[u].replaceCells(f,i,r);let _=0;for(let y=d.length-1;y>0&&(y>u||d[y].getTrimmedLength()===0);y--)_++;_>0&&(o.push(a+d.length-_),o.push(_)),a+=d.length-1}return o}function __(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function p_(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function m_(e,t,i){let s=[],r=e.map((h,l)=>Ni(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=Ni(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let d=l?i-1:i;s.push(d),a+=d}return s}function Ni(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var ll=class hl{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=hl._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(),At(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ll._nextId=1;var g_=ll,be={},Rt=be.B;be[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:"≥","{":"π","|":"≠","}":"£","~":"·"};be.A={"#":"£"};be.B=void 0;be[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};be.C=be[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};be.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};be.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};be.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};be.E=be[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};be.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};be.H=be[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};be["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Eo=4294967295,Mo=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=me.clone(),this.savedCharset=Rt,this.markers=[],this._nullCell=qe.fromCharData([0,Ea,1,0]),this._whitespaceCell=qe.fromCharData([0,gt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new vs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ko(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 _s),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 _s),this._whitespaceCell}getBlankLine(e,t){return new wi(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>Eo?Eo:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=me);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 ko(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(me),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 wi(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new wi(e,i)));else for(let o=this._rows;o>t;o--)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 o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,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++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=f_(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(me),i);if(s.length>0){let r=__(this.lines,s);p_(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(me),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new wi(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(me),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let P=this.ybase+this.y;if(P>=o&&P<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),d=m_(h,this._cols,e),u=d.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let P=0;P<u;P++){let k=this.getBlankLine(me,!0);m.push(k)}m.length>0&&(r.push({start:o+h.length+n,newLines:m}),n+=m.length),h.push(...m);let p=d.length-1,_=d[p];_===0&&(p--,_=d[p]);let y=h.length-u-1,S=l;for(;y>=0;){let P=Math.min(S,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[y],S-P,_-P,P,!0),_-=P,_===0&&(p--,_=d[p]),S-=P,S===0){y--;let k=Math.max(y,0);S=Ni(h,k,this._cols)}}for(let P=0;P<h.length;P++)d[P]<e&&h[P].setCell(d[P],s);let b=u-f;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+u,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let h=this.lines.length,l=h-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+n-1);_>=0;_--)if(u&&u.start>l+f){for(let y=u.newLines.length-1;y>=0;y--)this.lines.set(_--,u.newLines[y]);_++,o.push({index:l+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(_,a[l--]);let m=0;for(let _=o.length-1;_>=0;_--)o[_].index+=m,this.lines.onInsertEmitter.fire(o[_]),m+=o[_].amount;let p=Math.max(0,h+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 g_(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},v_=class extends J{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 Mo(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Mo(!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)}},cl=2,dl=1,Br=class extends J{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,cl),this.rows=Math.max(e.rawOptions.rows||0,dl),this.buffers=this._register(new v_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Br=fe([O(0,Ne)],Br);var Ut={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:gs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},S_=["normal","bold","100","200","300","400","500","600","700","800","900"],b_=class extends J{constructor(e){super(),this._onOptionChange=this._register(new T),this.onOptionChange=this._onOptionChange.event;let t={...Ut};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(he(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Ut))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Ut))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ut[e]),!y_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ut[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=S_.includes(t)?t:Ut[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 y_(e){return e==="block"||e==="underline"||e==="bar"}function xi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&xi(e[s],t-1);return i}var Do=Object.freeze({insertMode:!1}),Ro=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Nr=class extends J{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,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=xi(Do),this.decPrivateModes=xi(Ro)}reset(){this.modes=xi(Do),this.decPrivateModes=xi(Ro)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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))}};Nr=fe([O(0,Be),O(1,La),O(2,Ne)],Nr);var Po={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 qs(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Vs=String.fromCharCode,Lo={DEFAULT:e=>{let t=[qs(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Vs(t[0])}${Vs(t[1])}${Vs(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qs(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qs(e,!0)};${e.x};${e.y}${t}`}},Tr=class extends J{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,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 s of Object.keys(Po))this.addProtocol(s,Po[s]);for(let s of Object.keys(Lo))this.addEncoding(s,Lo[s]);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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+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,i){if(i){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)}};Tr=fe([O(0,Be),O(1,It),O(2,Ne)],Tr);var Ys=[[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]],w_=[[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]],Se;function x_(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var C_=class{constructor(){if(this.version="6",!Se){Se=new Uint8Array(65536),Se.fill(1),Se[0]=0,Se.fill(0,1,32),Se.fill(0,127,160),Se.fill(2,4352,4448),Se[9001]=2,Se[9002]=2,Se.fill(2,11904,42192),Se[12351]=1,Se.fill(2,44032,55204),Se.fill(2,63744,64256),Se.fill(2,65040,65050),Se.fill(2,65072,65136),Se.fill(2,65280,65377),Se.fill(2,65504,65511);for(let e=0;e<Ys.length;++e)Se.fill(0,Ys[e][0],Ys[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Se[e]:x_(e,w_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Pt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Pt.createPropertyValue(0,i,s)}},Pt=class cs{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new T,this.onChange=this._onChange.event;let t=new C_;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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 i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=cs.extractWidth(a);cs.extractShouldJoin(a)&&(h-=cs.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},k_=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 Bo(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var ui=2147483647,E_=256,ul=class Ar{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>E_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Ar;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Ar(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>ui?ui: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>ui?ui:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,ui):t}},fi=[],M_=class{constructor(){this._state=0,this._active=fi,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=fi}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=fi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fi,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",ys(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=fi,this._id=-1,this._state=0}}},Ie=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ys(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},_i=[],D_=class{constructor(){this._handlers=Object.create(null),this._active=_i,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=_i}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=_i,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||_i,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",ys(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=_i,this._ident=0}},Ci=new ul;Ci.addParam(0);var No=class{constructor(e){this._handler=e,this._data="",this._params=Ci,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ci,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ys(e,t,i),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(i=>(this._params=Ci,this._data="",this._hitLimit=!1,i));return this._params=Ci,this._data="",this._hitLimit=!1,t}},R_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Ue=160,P_=(function(){let e=new R_(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,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(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ue,0,2,0),e.add(Ue,8,5,8),e.add(Ue,6,0,6),e.add(Ue,11,0,11),e.add(Ue,13,13,13),e})(),L_=class extends J{constructor(e=P_){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 ul,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(he(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new M_),this._dcsParser=this._register(new D_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===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 a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:Ue)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<Ue){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ue){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ue){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ue){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],u=d?d.length-1:-1;for(;u>=0&&(o=d[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,d,u,r,a),o;u<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<Ue){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===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 f=a+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<Ue){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},B_=/^([\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})$/,N_=/^[\da-f]+$/;function To(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=B_.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),N_.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Xs(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function T_(e,t=16){let[i,s,r]=e;return`rgb:${Xs(i,t)}/${Xs(s,t)}/${Xs(r,t)}`}var A_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},_t=131072,Ao=10;function zo(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 Oo=5e3,jo=0,z_=class extends J{constructor(e,t,i,s,r,n,o,a,h=new L_){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new eu,this._utf8Decoder=new tu,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=me.clone(),this._eraseAttrDataInternal=me.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 zr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:d.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:d,data:u})}),this._parser.setDcsHandlerFallback((l,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:d,payload:u})}),this._parser.setPrintHandler((l,d,u)=>this.print(l,d,u)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(E.BEL,()=>this.bell()),this._parser.setExecuteHandler(E.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(E.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(E.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(E.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(E.BS,()=>this.backspace()),this._parser.setExecuteHandler(E.HT,()=>this.tab()),this._parser.setExecuteHandler(E.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(E.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ls.IND,()=>this.index()),this._parser.setExecuteHandler(ls.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ls.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ie(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Ie(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Ie(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Ie(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Ie(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Ie(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Ie(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Ie(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Ie(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Ie(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Ie(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Ie(l=>this.restoreCursorColor(l))),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 l in be)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new No((l,d)=>this.requestStatusString(l,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Oo))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Oo} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>_t&&(n=this._parseStack.position+_t)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<_t&&(this._parseBuffer=new Uint32Array(Math.min(e.length,_t))),o||this._dirtyRowTracker.clearRange(),e.length>_t)for(let l=n;l<e.length;l+=_t){let d=l+_t<e.length?l+_t:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(l,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=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(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let m=t;m<i;++m){if(s=e[m],s<127&&n){let S=n[String.fromCharCode(s)];S&&(s=S.charCodeAt(0))}let p=this._unicodeService.charProperties(s,f);r=Pt.extractWidth(p);let _=Pt.extractShouldJoin(p),y=_?Pt.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(pt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-y>a){if(h){let S=u,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&u instanceof wi&&u.copyCellsFrom(S,b,0,y,!1);b<a;)S.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let S=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-S,s,r);for(let b=r-y;--b>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(l&&(u.insertCells(this._activeBuffer.x,r-y,this._activeBuffer.getNullCell(d)),u.getWidth(a-1)===2&&u.setCellFromCodepoint(a-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.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,i=>zo(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new No(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ie(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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,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}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(me));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=Pt.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let d=n.codePointAt(l)||0;o[a++]=d,l+=d>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(E.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(E.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(E.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(E.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(E.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,Rt),this._charsetService.setgCharset(1,Rt),this._charsetService.setgCharset(2,Rt),this._charsetService.setgCharset(3,Rt);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){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:d}=a,u=this._optionsService.rawOptions,f=(_,y)=>(o.triggerDataEvent(`${E.ESC}[${t?"":"?"}${_};${y}$y`),!0),m=_=>_?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,m(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,m(u.convertEol)):f(p,0):p===1?f(p,m(s.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,m(s.origin)):p===7?f(p,m(s.wraparound)):p===8?f(p,3):p===9?f(p,m(r==="X10")):p===12?f(p,m(u.cursorBlink)):p===25?f(p,m(!o.isCursorHidden)):p===45?f(p,m(s.reverseWraparound)):p===66?f(p,m(s.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,m(r==="VT200")):p===1002?f(p,m(r==="DRAG")):p===1003?f(p,m(r==="ANY")):p===1004?f(p,m(s.sendFocus)):p===1005?f(p,4):p===1006?f(p,m(n==="SGR")):p===1015?f(p,4):p===1016?f(p,m(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,m(l===d)):p===2004?f(p,m(s.bracketedPasteMode)):p===2026?f(p,m(s.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Ai.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[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=me.fg,e.bg=me.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=me.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=me.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=me.fg&16777215,s.bg&=-67108864,s.bg|=me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${E.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${E.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${E.ESC}[?${t};${i}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=me.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!zo(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(`${E.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ao&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ao&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Io(n))if(r==="?")t.push({type:0,index:n});else{let o=To(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=To(i[s]);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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Io(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,Rt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(A_[e[0]],be[e[1]]||Rt),!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=me.clone(),this._eraseAttrDataInternal=me.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 qe;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${E.ESC}${o}${E.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.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)}},zr=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&&(jo=e,e=t,t=jo),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};zr=fe([O(0,Be)],zr);function Io(e){return 0<=e&&e<256}var O_=5e7,$o=12,j_=50,I_=class extends J{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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>O_)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=$o?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=$o)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()}},Or=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 a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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 i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Or=fe([O(0,Be)],Or);var Ho=!1,$_=class extends J{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ei),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 c_,this.optionsService=this._register(new b_(e)),this._instantiationService.setService(Ne,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Br)),this._instantiationService.setService(Be,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Lr)),this._instantiationService.setService(La,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Nr)),this._instantiationService.setService(It,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Tr)),this._instantiationService.setService(Pa,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Pt)),this._instantiationService.setService(nu,this.unicodeService),this._charsetService=this._instantiationService.createInstance(k_),this._instantiationService.setService(ru,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Or),this._instantiationService.setService(Ba,this._oscLinkService),this._inputHandler=this._register(new z_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(De.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(De.forward(this._bufferService.onResize,this._onResize)),this._register(De.forward(this.coreService.onData,this._onData)),this._register(De.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 I_((t,i)=>this._inputHandler.parse(t,i))),this._register(De.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&&!Ho&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ho=!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,cl),t=Math.max(t,dl),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(Bo.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Bo(this._bufferService),!1))),this._windowsWrappingHeuristics.value=he(()=>{for(let t of e)t.dispose()})}}},H_={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function F_(e,t,i,s){var o;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=E.ESC+"OA":r.key=E.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=E.ESC+"OD":r.key=E.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=E.ESC+"OC":r.key=E.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=E.ESC+"OB":r.key=E.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":E.DEL,e.altKey&&(r.key=E.ESC+r.key);break;case 9:if(e.shiftKey){r.key=E.ESC+"[Z";break}r.key=E.HT,r.cancel=!0;break;case 13:r.key=e.altKey?E.ESC+E.CR:E.CR,r.cancel=!0;break;case 27:r.key=E.ESC,e.altKey&&(r.key=E.ESC+E.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"D":t?r.key=E.ESC+"OD":r.key=E.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"C":t?r.key=E.ESC+"OC":r.key=E.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"A":t?r.key=E.ESC+"OA":r.key=E.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=E.ESC+"[1;"+(n+1)+"B":t?r.key=E.ESC+"OB":r.key=E.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=E.ESC+"[2~");break;case 46:n?r.key=E.ESC+"[3;"+(n+1)+"~":r.key=E.ESC+"[3~";break;case 36:n?r.key=E.ESC+"[1;"+(n+1)+"H":t?r.key=E.ESC+"OH":r.key=E.ESC+"[H";break;case 35:n?r.key=E.ESC+"[1;"+(n+1)+"F":t?r.key=E.ESC+"OF":r.key=E.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=E.ESC+"[5;"+(n+1)+"~":r.key=E.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=E.ESC+"[6;"+(n+1)+"~":r.key=E.ESC+"[6~";break;case 112:n?r.key=E.ESC+"[1;"+(n+1)+"P":r.key=E.ESC+"OP";break;case 113:n?r.key=E.ESC+"[1;"+(n+1)+"Q":r.key=E.ESC+"OQ";break;case 114:n?r.key=E.ESC+"[1;"+(n+1)+"R":r.key=E.ESC+"OR";break;case 115:n?r.key=E.ESC+"[1;"+(n+1)+"S":r.key=E.ESC+"OS";break;case 116:n?r.key=E.ESC+"[15;"+(n+1)+"~":r.key=E.ESC+"[15~";break;case 117:n?r.key=E.ESC+"[17;"+(n+1)+"~":r.key=E.ESC+"[17~";break;case 118:n?r.key=E.ESC+"[18;"+(n+1)+"~":r.key=E.ESC+"[18~";break;case 119:n?r.key=E.ESC+"[19;"+(n+1)+"~":r.key=E.ESC+"[19~";break;case 120:n?r.key=E.ESC+"[20;"+(n+1)+"~":r.key=E.ESC+"[20~";break;case 121:n?r.key=E.ESC+"[21;"+(n+1)+"~":r.key=E.ESC+"[21~";break;case 122:n?r.key=E.ESC+"[23;"+(n+1)+"~":r.key=E.ESC+"[23~";break;case 123:n?r.key=E.ESC+"[24;"+(n+1)+"~":r.key=E.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=E.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=E.DEL:e.keyCode===219?r.key=E.ESC:e.keyCode===220?r.key=E.FS:e.keyCode===221&&(r.key=E.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=H_[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=E.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=E.ESC+l}else if(e.keyCode===32)r.key=E.ESC+(e.ctrlKey?E.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=E.ESC+h,r.cancel=!0}}else i&&!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=E.US),e.key==="@"&&(r.key=E.NUL));break}return r}var pe=0,W_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new vs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new vs,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,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(pe=this._search(t),pe===-1)||this._getKey(this._array[pe])!==t)return!1;do if(this._array[pe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(pe),!0;while(++pe<this._array.length&&this._getKey(this._array[pe])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(pe=this._search(e),!(pe<0||pe>=this._array.length)&&this._getKey(this._array[pe])===e))do yield this._array[pe];while(++pe<this._array.length&&this._getKey(this._array[pe])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(pe=this._search(e),!(pe<0||pe>=this._array.length)&&this._getKey(this._array[pe])===e))do t(this._array[pe]);while(++pe<this._array.length&&this._getKey(this._array[pe])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Gs=0,Fo=0,K_=class extends J{constructor(){super(),this._decorations=new W_(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(he(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new U_(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Gs=r.options.x??0,Fo=Gs+(r.options.width??1),e>=Gs&&e<Fo&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},U_=class extends bt{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=de.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=de.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},q_=1e3,V_=class{constructor(e,t=q_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-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)}},Wo=20,Ss=class extends J{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,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 V_(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(`
|
|
175
|
+
`))),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(q(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(he(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Wo+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
176
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Wo+1&&(this._liveRegion.textContent+=sr.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.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 a;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let d=h instanceof Text?h.parentNode:h,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let m=l<f.length?f[l]:f.slice(-1)[0]+1;return m>=this._terminal.cols&&(++u,m=0),{row:u,column:m}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Ss=fe([O(1,Xr),O(2,lt),O(3,ht)],Ss);var jr=class extends J{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,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(he(()=>{var n;At(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(q(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(q(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(q(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,d;if(this._isMouseOut)return;let h=a==null?void 0:a.map(u=>({link:u}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Y_(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,At(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 i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};jr=fe([O(1,Gr),O(2,ht),O(3,Be),O(4,Ta)],jr);function Y_(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 X_=class extends $_{constructor(e={}){super(e),this._linkifier=this._register(new ei),this.browser=Qa,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ei),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(K_),this._instantiationService.setService(zi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jf),this._instantiationService.setService(Ta,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(De.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(De.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(De.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(De.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(he(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=ae.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${E.ESC}]${s};${T_(r)}${Ja.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ge.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ge.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(Ss,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(E.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(E.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(q(this.element,"copy",t=>{this.hasSelection()&&Zd(t,this._selectionService)}));let e=t=>Qd(t,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,"paste",e)),this._register(q(this.element,"paste",e)),el?this._register(q(this.element,"mousedown",t=>{t.button===2&&Zn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,"contextmenu",t=>{Zn(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nn&&this._register(q(this.element,"auxclick",t=>{t.button===1&&ka(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(q(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(q(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(q(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(q(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(q(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 i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ir.get()),sl||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(zf,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(lt,this._coreBrowserService),this._register(q(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(q(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Er,this._document,this._helperContainer),this._instantiationService.setService(ws,this._charSizeService),this._themeService=this._instantiationService.createInstance(Pr),this._instantiationService.setService(ti,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ms),this._instantiationService.setService(Na,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Dr,this.rows,this.screenElement)),this._instantiationService.setService(ht,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(xr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Mr),this._instantiationService.setService(Gr,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(jr,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(yr,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(Rr,this.element,this.screenElement,s)),this._instantiationService.setService(au,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(De.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(wr,this.screenElement)),this._register(q(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(Ss,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ps,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ps,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(kr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,d,u,f,m;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=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,(f=(u=(d=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:f.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return!1;h=p<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(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?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(q(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(q(t,"wheel",n=>{var o,a,h,l,d;if(!s.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,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let u=E.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.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){Ca(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,i){this._selectionService.setSelection(e,t,i)}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 i;(i=this._selectionService)==null||i.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 i=F_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===E.ETX||i.key===E.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(G_(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 i;(i=this._charSizeService)==null||i.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(me));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(E.ESC+"[I"):this.coreService.triggerDataEvent(E.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${E.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${E.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function G_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var J_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},Z_=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 qe)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Ko=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 Z_(t)}getNullCell(){return new qe}},Q_=class extends J{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new T),this.onBufferChange=this._onBufferChange.event,this._normal=new Ko(this._core.buffers.normal,"normal"),this._alternate=new Ko(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)}},ep=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},tp=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}},ip=["cols","rows"],Ge=0,sp=class extends J{constructor(e){super(),this._core=this._register(new X_(e)),this._addonManager=this._register(new J_),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(ip.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 ep(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new tp(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 Q_(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
|
|
177
|
+
`,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 ir.get()},set promptLabel(e){ir.set(e)},get tooMuchOutput(){return sr.get()},set tooMuchOutput(e){sr.set(e)}}}_verifyIntegers(...e){for(Ge of e)if(Ge===1/0||isNaN(Ge)||Ge%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Ge of e)if(Ge&&(Ge===1/0||isNaN(Ge)||Ge%1!==0||Ge<0))throw new Error("This API only accepts positive integers")}};/**
|
|
148
178
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
149
179
|
* @license MIT
|
|
150
180
|
*
|
|
@@ -155,7 +185,7 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
|
|
|
155
185
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
156
186
|
* http://bellard.org/jslinux/
|
|
157
187
|
* Copyright (c) 2011 Fabrice Bellard
|
|
158
|
-
*/var
|
|
188
|
+
*/var rp=2,np=1,op=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 u;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:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,d=r-h-t;return{cols:Math.max(rp,Math.floor(d/e.css.cell.width)),rows:Math.max(np,Math.floor(l/e.css.cell.height))}}};/**
|
|
159
189
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
160
190
|
* @license MIT
|
|
161
191
|
*
|
|
@@ -166,22 +196,22 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
|
|
|
166
196
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
167
197
|
* http://bellard.org/jslinux/
|
|
168
198
|
* Copyright (c) 2011 Fabrice Bellard
|
|
169
|
-
*/var
|
|
170
|
-
\x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const y=h.current;if(y>=
|
|
171
|
-
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const S=Math.min(
|
|
172
|
-
\x1B[33m-- Terminal disconnected. Reconnecting in ${(S/1e3).toFixed(0)}s (attempt ${y+1}/${
|
|
173
|
-
`))r.startsWith("__FILE_CHANGE__")?i.push(r.replace("__FILE_CHANGE__","")):r.startsWith("__COMMAND__")?s.push(r.replace("__COMMAND__","")):t.push(r);return{textLines:t,fileChanges:i,commands:s}}function
|
|
199
|
+
*/var ap=class{constructor(e,t,i,s={}){this._terminal=e,this._regex=t,this._handler=i,this._options=s}provideLinks(e,t){let i=hp.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r)}},t))}};function lp(e){try{let t=new URL(e),i=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(i.toLocaleLowerCase())}catch{return!1}}var hp=class ds{static computeLink(t,i,s,r){let n=new RegExp(i.source,(i.flags||"")+"g"),[o,a]=ds._getWindowedLineStrings(t-1,s),h=o.join(""),l,d=[];for(;l=n.exec(h);){let u=l[0];if(!lp(u))continue;let[f,m]=ds._mapStrIdx(s,a,0,l.index),[p,_]=ds._mapStrIdx(s,f,m,u.length);if(f===-1||m===-1||p===-1||_===-1)continue;let y={start:{x:m+1,y:f+1},end:{x:_,y:p+1}};d.push({range:y,text:u,activate:r})}return d}static _getWindowedLineStrings(t,i){let s,r=t,n=t,o=0,a="",h=[];if(s=i.buffer.active.getLine(t)){let l=s.translateToString(!0);if(s.isWrapped&&l[0]!==" "){for(o=0;(s=i.buffer.active.getLine(--r))&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),!(!s.isWrapped||a.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),o=0;(s=i.buffer.active.getLine(++n))&&s.isWrapped&&o<2048&&(a=s.translateToString(!0),o+=a.length,h.push(a),a.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,i,s,r){let n=t.buffer.active,o=n.getNullCell(),a=s;for(;r;){let h=n.getLine(i);if(!h)return[-1,-1];for(let l=a;l<h.length;++l){h.getCell(l,o);let d=o.getChars();if(o.getWidth()&&(r-=d.length||1,l===h.length-1&&d==="")){let u=n.getLine(i+1);u&&u.isWrapped&&(u.getCell(0,o),o.getWidth()===2&&(r+=1))}if(r<0)return[i,l]}i++,a=0}return[i,a]}},cp=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function dp(e,t){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var up=class{constructor(e=dp,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,i=t.urlRegex||cp;this._linkProvider=this._terminal.registerLinkProvider(new ap(this._terminal,i,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const Uo=10,fp=1e3,_p=3e4;function pp({sessionId:e,isActive:t}){const i=g.useRef(null),s=g.useRef(null),r=g.useRef(null),n=g.useRef(null),o=g.useRef(null),a=g.useRef(!0),h=g.useRef(0),l=g.useCallback(()=>{const u=n.current,f=s.current;u&&u.readyState===WebSocket.OPEN&&f&&u.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},[]),d=g.useCallback(()=>{if(!a.current)return;n.current&&(n.current.onclose=null,n.current.onerror=null,n.current.close(),n.current=null);const f=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal/${e}`,m=new WebSocket(f);n.current=m,m.onopen=()=>{h.current=0;const p=s.current;p&&p.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const _=r.current;if(_&&p){try{_.fit()}catch{}l()}},m.onmessage=p=>{try{const _=JSON.parse(p.data);_.type==="output"&&s.current?s.current.write(_.data):_.type==="error"&&s.current&&s.current.writeln(`\x1B[31m${_.data}\x1B[0m`)}catch{s.current&&s.current.write(p.data)}},m.onclose=p=>{if(!a.current)return;const _=s.current;if(p.code===4e3){_&&_.writeln(`\r
|
|
200
|
+
\x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const y=h.current;if(y>=Uo){_&&_.writeln(`\r
|
|
201
|
+
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const S=Math.min(fp*Math.pow(2,y),_p);h.current=y+1,_&&_.writeln(`\r
|
|
202
|
+
\x1B[33m-- Terminal disconnected. Reconnecting in ${(S/1e3).toFixed(0)}s (attempt ${y+1}/${Uo})... --\x1B[0m`),o.current=setTimeout(()=>{a.current&&d()},S)},m.onerror=()=>{}},[e,l]);return g.useEffect(()=>{a.current=!0,h.current=0;const u=i.current;if(!u)return;const f=new sp({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}),m=new op,p=new up;f.loadAddon(m),f.loadAddon(p),f.open(u),s.current=f,r.current=m;try{m.fit()}catch{}f.onData(S=>{const b=n.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"input",data:S}))}),d();let _=null;const y=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!r.current||!s.current))try{r.current.fit(),l()}catch{}},50)});return y.observe(u),()=>{a.current=!1,y.disconnect(),_&&clearTimeout(_),o.current&&clearTimeout(o.current),n.current&&(n.current.onclose=null,n.current.close(),n.current=null),f.dispose(),s.current=null,r.current=null}},[d,l]),g.useEffect(()=>{if(t&&r.current&&s.current){const u=setTimeout(()=>{var f;try{(f=r.current)==null||f.fit(),l()}catch{}},50);return()=>clearTimeout(u)}},[t,l]),c.jsx("div",{ref:i,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}function Mt(e,t){if(e.length===0)return e;const i=[...e],s=i[i.length-1];return i[i.length-1]={...s,...t(s)},i}function mp(e){const t=[],i=[],s=[];for(const r of e.split(`
|
|
203
|
+
`))r.startsWith("__FILE_CHANGE__")?i.push(r.replace("__FILE_CHANGE__","")):r.startsWith("__COMMAND__")?s.push(r.replace("__COMMAND__","")):t.push(r);return{textLines:t,fileChanges:i,commands:s}}function gp({msg:e}){var o;const[t,i]=g.useState(!1),s=g.useMemo(()=>e.role==="system"?mp(e.content):null,[e.role,e.content]);if(e.role==="user")return c.jsx("div",{className:"flex justify-end",children:c.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-primary/10 text-ink",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:e.content})})});const r=s?s.textLines.join(`
|
|
174
204
|
`).trim():e.content,n=r.split(`
|
|
175
|
-
`).length>30;return c.jsx("div",{className:"flex justify-start",children:c.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:[s&&s.commands.length>0&&c.jsx("div",{className:"mb-2 space-y-0.5",children:s.commands.map((a,h)=>c.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:[c.jsx(
|
|
205
|
+
`).length>30;return c.jsx("div",{className:"flex justify-start",children:c.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:[s&&s.commands.length>0&&c.jsx("div",{className:"mb-2 space-y-0.5",children:s.commands.map((a,h)=>c.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:[c.jsx($r,{size:10,className:"text-muted/60 flex-shrink-0"}),c.jsx("span",{className:"truncate",children:a})]},h))}),c.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[n&&!t?r.split(`
|
|
176
206
|
`).slice(0,30).join(`
|
|
177
207
|
`)+`
|
|
178
208
|
...`:r,e.isStreaming&&c.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&&c.jsx("button",{onClick:()=>i(a=>!a),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:t?"Show less":`Show all (${r.split(`
|
|
179
|
-
`).length} lines)`}),s&&s.fileChanges.length>0&&c.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[c.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[c.jsx(
|
|
180
|
-
[cancelled]`}:{})),(D=_.current)==null||D.focus()},[e]),P=g.useCallback(async D=>{var
|
|
181
|
-
`);n(w=>
|
|
182
|
-
`)||"Done.",filesChanged:$.files_changed,returncode:$.returncode}:{})),((
|
|
209
|
+
`).length} lines)`}),s&&s.fileChanges.length>0&&c.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[c.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[c.jsx(Ke,{size:11}),"Files modified (",s.fileChanges.length,")"]}),c.jsx("ul",{className:"mt-1 space-y-0.5",children:s.fileChanges.map((a,h)=>c.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:a},h))})]}),e.filesChanged&&e.filesChanged.length>0&&c.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[c.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[c.jsx(Ke,{size:11}),"Changed files (",e.filesChanged.length,")"]}),c.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((a,h)=>c.jsx("li",{className:"text-[11px] font-mono text-muted",children:a},h))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&c.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?c.jsxs("span",{children:["Done",s&&(s.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${s.fileChanges.length+(((o=e.filesChanged)==null?void 0:o.length)||0)} files changed`:"",s&&s.commands.length>0?`, ${s.commands.length} commands run`:""]}):c.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})})]})})}const vp={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"};function Sp({sessionId:e,defaultMode:t,onFilesChanged:i,services:s}){var A;const[r,n]=g.useState([]),[o,a]=g.useState(""),[h,l]=g.useState(t||"quick"),[d,u]=g.useState(!1),[f,m]=g.useState(!1),p=g.useRef(null),_=g.useRef(null),y=g.useRef(null),S=g.useRef(null);g.useEffect(()=>{const D=sessionStorage.getItem(`chat_${e}`);if(D)try{n(JSON.parse(D))}catch{}},[e]),g.useEffect(()=>{r.length>0&&sessionStorage.setItem(`chat_${e}`,JSON.stringify(r.slice(-50)))},[r,e]),g.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[r]),g.useEffect(()=>()=>{y.current&&y.current.abort()},[]);const b=g.useCallback(async()=>{var D;if(y.current&&(y.current.abort(),y.current=null),S.current){try{await ee.chatCancel(e,S.current)}catch{}S.current=null}m(!1),u(!1),n(W=>Mt(W,U=>U.isStreaming?{isStreaming:!1,content:U.content+`
|
|
210
|
+
[cancelled]`}:{})),(D=_.current)==null||D.focus()},[e]),P=g.useCallback(async D=>{var N;let U=0,$;do{if(await new Promise(M=>setTimeout(M,2e3)),$=await ee.chatPoll(e,D),U++,$.output_lines.length>0){const M=$.output_lines.join(`
|
|
211
|
+
`);n(w=>Mt(w,R=>R.role==="system"&&R.isStreaming?{content:M}:{}))}U>=150&&($={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(!$.complete);n(M=>Mt(M,w=>w.role==="system"?{isStreaming:!1,content:$.output_lines.join(`
|
|
212
|
+
`)||"Done.",filesChanged:$.files_changed,returncode:$.returncode}:{})),((N=$.files_changed)==null?void 0:N.length)>0&&i&&i($.files_changed)},[e,i]),k=g.useCallback(async D=>{var U;const W=new AbortController;y.current=W,S.current=D,m(!0);try{const $=ee.chatStreamUrl(e,D),N=await fetch($,{signal:W.signal});if(!N.ok||!N.body)throw new Error(`Stream failed: ${N.status}`);const M=N.body.getReader(),w=new TextDecoder;let R="";for(;;){const{done:x,value:L}=await M.read();if(x)break;R+=w.decode(L,{stream:!0});const I=R.split(`
|
|
183
213
|
|
|
184
|
-
`);R=
|
|
185
|
-
`);let
|
|
186
|
-
`+H:H}:{}))}catch{}else if(ie==="complete"&&W)try{const{returncode:H,files_changed:F}=JSON.parse(W);n(Y=>kt(Y,ne=>ne.role==="system"&&ne.isStreaming?{isStreaming:!1,filesChanged:F,returncode:H,content:ne.content||"Done."}:{})),(F==null?void 0:F.length)>0&&i&&i(F)}catch{}else if(ie==="error"&&W)try{const{error:H}=JSON.parse(W);n(F=>kt(F,Y=>Y.role==="system"&&Y.isStreaming?{isStreaming:!1,content:`Error: ${H}`}:{}))}catch{}}}}catch($){if($ instanceof DOMException&&$.name==="AbortError")return;await P(D)}finally{m(!1),u(!1),y.current=null,S.current=null,(q=_.current)==null||q.focus()}},[e,i,P]),C=async()=>{var $;const D=o.trim();if(!D||d)return;const U={role:"user",content:D,timestamp:new Date().toISOString()},q={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};n(L=>[...L,U,q]),a(""),u(!0);try{const{task_id:L}=await te.chatStart(e,D,h);await k(L)}catch(L){n(M=>kt(M,w=>w.role==="system"&&w.isStreaming?{isStreaming:!1,content:`Error: ${L instanceof Error?L.message:"Request failed"}`}:{})),u(!1),($=_.current)==null||$.focus()}};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[r.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(Io,{size:28,className:"text-muted/30 mb-3"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No messages yet"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-1 max-w-[200px]",children:"Ask the AI to build, modify, or explain your code."})]}),r.map((D,U)=>c.jsx(q_,{msg:D},U))]}),c.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&c.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[c.jsx("span",{className:"text-[10px] text-muted font-mono",children:"Streaming..."}),c.jsxs("button",{onClick:b,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[c.jsx(os,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(s==null?void 0:s.some(D=>D.fix_status==="fixing"))&&c.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[c.jsx(Ph,{size:10,className:"text-yellow-400 animate-spin"}),c.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(A=s.find(D=>D.fix_status==="fixing"))==null?void 0:A.name]})]}),c.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(D=>c.jsx("button",{onClick:()=>l(D),title:V_[D],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===D?"bg-primary text-white":"text-muted hover:text-ink"}`,children:D},D))}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("textarea",{ref:_,value:o,onChange:D=>a(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),C())},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}),f?c.jsx(Kt,{size:"sm",icon:os,onClick:b,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):c.jsx(Kt,{size:"sm",icon:wh,onClick:C,disabled:d||!o.trim(),"aria-label":"Send message",children:"Send"})]})]})]})}const To=[{id:"terminal",label:"Terminal",icon:Lr,alwaysShow:!0},{id:"chat",label:"AI Chat",icon:Io,alwaysShow:!0},{id:"build",label:"Build Log",icon:bh},{id:"agents",label:"Agents",icon:Ul},{id:"quality",label:"Quality",icon:Ho}];function X_({status:e}){switch(e){case"pass":return c.jsx(Fl,{size:14,className:"text-success"});case"fail":return c.jsx(Ci,{size:14,className:"text-danger"});default:return c.jsx($l,{size:14,className:"text-muted"})}}function G_({agents:e}){return!e||e.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(Dh,{size:24,className:"text-muted/30 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):c.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[c.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),c.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),c.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),c.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function J_({checklist:e}){return!e||!e.items||e.items.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(Ho,{size:24,className:"text-muted/30 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):c.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[c.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[c.jsx("span",{children:"Gate"}),c.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[c.jsx(X_,{status:t.status}),c.jsx("span",{className:"text-ink",children:t.label}),t.details&&c.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function Z_({logs:e,logsLoading:t,agents:i,checklist:s,sessionId:r,isRunning:n,subscribe:o,buildMode:a}){var p;const[h,l]=g.useState("terminal"),d=i&&i.length>0,u=s&&s.items&&s.items.length>0,f=e&&e.length>0,m=To.filter(_=>!!(_.alwaysShow||_.id==="build"&&(f||n)||_.id==="agents"&&(d||n)||_.id==="quality"&&(u||n)));return m.find(_=>_.id===h)||l("terminal"),c.jsxs("div",{className:"h-full flex flex-col bg-card",children:[c.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:m.map(_=>{const y=_.icon,S=h===_.id;return c.jsxs("button",{role:"tab","aria-selected":S,onClick:()=>l(_.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${S?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[c.jsx(y,{size:14}),_.label,_.id==="agents"&&d&&c.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:i.length}),_.id==="quality"&&u&&c.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[s.passed,"/",s.total]})]},_.id)})}),c.jsxs("div",{role:"tabpanel","aria-label":(p=To.find(_=>_.id===h))==null?void 0:p.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[c.jsx("div",{className:"absolute inset-0",style:{visibility:h==="terminal"?"visible":"hidden",zIndex:h==="terminal"?1:0},children:c.jsx(K_,{sessionId:r,isActive:h==="terminal"})}),h==="build"&&c.jsx(Nl,{logs:e,loading:t,subscribe:o}),h==="agents"&&c.jsx(G_,{agents:i}),h==="quality"&&c.jsx(J_,{checklist:s}),h==="chat"&&c.jsx(Y_,{sessionId:r,defaultMode:a})]})]})}const tl=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),di=tl?"Cmd":"Ctrl",Q_=[{keys:[`${di}+S`],label:"Save file"},{keys:[`${di}+P`],label:"Quick open file"},{keys:[`${di}+\``],label:"Toggle terminal"},{keys:[`${di}+B`],label:"Start / stop build"},{keys:[`${di}+?`],label:"Show keyboard shortcuts"},{keys:["Escape"],label:"Close modals"}];function ep({onToggleTerminal:e,onToggleBuild:t}){const[i,s]=g.useState(!1),r=g.useCallback(n=>{const o=tl?n.metaKey:n.ctrlKey;if(o&&(n.key==="?"||n.shiftKey&&n.key==="/")){n.preventDefault(),s(a=>!a);return}if(o&&n.key==="`"){n.preventDefault(),e==null||e();return}if(o&&n.key==="b"){n.preventDefault(),t==null||t();return}n.key==="Escape"&&i&&s(!1)},[e,t,i]);return g.useEffect(()=>(window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)),[r]),{showHelp:i,setShowHelp:s}}function tp({open:e,onClose:t}){return e?c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:c.jsxs("div",{className:"bg-card rounded-card shadow-card-hover border border-border w-full max-w-md mx-4",onClick:i=>i.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_h,{size:16,className:"text-primary"}),c.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:c.jsx(Ci,{size:16})})]}),c.jsx("div",{className:"p-4 space-y-1",children:Q_.map(i=>c.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[c.jsx("span",{className:"text-xs text-ink",children:i.label}),c.jsx("div",{className:"flex items-center gap-1",children:i.keys.map(s=>c.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:s},s))})]},i.label))}),c.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:c.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",c.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 ip({onClick:e}){return c.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 Br(e,t,i){var n;if(t==="directory")return i?c.jsx(Ws,{size:14}):c.jsx(ch,{size:14});const s=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"";return{js:c.jsx(We,{size:14,className:"text-yellow-600"}),ts:c.jsx(We,{size:14,className:"text-blue-500"}),tsx:c.jsx(We,{size:14,className:"text-blue-400"}),jsx:c.jsx(We,{size:14,className:"text-yellow-500"}),py:c.jsx(We,{size:14,className:"text-green-600"}),html:c.jsx(eh,{size:14,className:"text-orange-500"}),css:c.jsx(rh,{size:14,className:"text-purple-500"}),json:c.jsx(Jl,{size:14,className:"text-green-500"}),md:c.jsx($o,{size:14,className:"text-muted"}),go:c.jsx(We,{size:14,className:"text-cyan-600"}),rs:c.jsx(We,{size:14,className:"text-orange-600"}),rb:c.jsx(We,{size:14,className:"text-red-500"}),sh:c.jsx(We,{size:14,className:"text-green-600"})}[s]||c.jsx(oh,{size:14})}function sp(e){var r;const t=((r=e.split(".").pop())==null?void 0:r.toLowerCase())||"",i={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"},s=e.toLowerCase();return s==="dockerfile"?"dockerfile":s==="makefile"?"makefile":i[t]||"plaintext"}function il(e,t){for(const i of e){if(i.path===t)return i.size;if(i.children){const s=il(i.children,t);if(s!==void 0)return s}}}function sl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function rl({nodes:e,selectedPath:t,onSelect:i,onDelete:s,onContextMenu:r,depth:n=0}){const[o,a]=g.useState(()=>{const h=new Set;return n<2&&e.filter(l=>l.type==="directory").forEach(l=>h.add(l.path)),h});return c.jsx("div",{role:n===0?"tree":"group",children:e.map(h=>{const l=h.type==="directory",d=o.has(h.path),u=h.path===t;return c.jsxs("div",{className:"group/file",children:[c.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":u,...l?{"aria-expanded":d}:{},onContextMenu:f=>{f.preventDefault(),r==null||r(f,h.path,h.name,h.type)},onClick:()=>{l?a(f=>{const m=new Set(f);return m.has(h.path)?m.delete(h.path):m.add(h.path),m}):i(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 ${u?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${n*14+8}px`},children:[l?c.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:d?c.jsx(zl,{size:14}):c.jsx(Ol,{size:14})}):c.jsx("span",{className:"w-3 flex-shrink-0"}),c.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${l?"text-primary":""}`,children:Br(h.name,h.type,d)}),c.jsxs("span",{className:"truncate",children:[h.name,l?"/":""]}),!l&&h.size!=null&&h.size>0&&c.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:sl(h.size)}),!l&&s&&c.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),s(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),s(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:c.jsx(Ci,{size:12})})]}),l&&d&&h.children&&c.jsx(rl,{nodes:h.children,selectedPath:t,onSelect:i,onDelete:s,onContextMenu:r,depth:n+1})]},h.path)})})}function nl(e,t=""){const i=[];for(const s of e)s.type==="file"&&i.push({path:s.path,name:s.name}),s.children&&i.push(...nl(s.children,s.path+"/"));return i}function rp(){const[e,t]=g.useState({}),[i,s]=g.useState(""),[r,n]=g.useState(""),[o,a]=g.useState(!0),[h,l]=g.useState(null),[d,u]=g.useState(new Set),f=g.useCallback(async()=>{try{const S=await te.getSecrets();t(S)}catch{}a(!1)},[]);g.useEffect(()=>{f()},[f]);const m=async()=>{const S=i.trim();if(S){if(!/^[A-Z_][A-Z0-9_]*$/.test(S)){l("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}l(null);try{await te.setSecret(S,r),s(""),n(""),await f()}catch(b){l(b instanceof Error?b.message:"Failed to set secret")}}},p=async S=>{if(window.confirm(`Delete secret "${S}"?`))try{await te.deleteSecret(S),await f()}catch(b){l(b instanceof Error?b.message:"Failed to delete secret")}},_=S=>{u(b=>{const P=new Set(b);return P.has(S)?P.delete(S):P.add(S),P})},y=Object.keys(e);return o?c.jsxs("div",{className:"p-6 space-y-4",children:[c.jsx(xs,{variant:"text",width:"180px",height:"16px"}),c.jsx(xs,{variant:"block",width:"100%",height:"60px"}),c.jsx(xs,{variant:"block",width:"100%",height:"80px"})]}):c.jsx("div",{className:"h-full flex flex-col",children:c.jsxs("div",{className:"p-6 overflow-y-auto",children:[c.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),c.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[c.jsx(jl,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),c.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&&c.jsx("div",{className:"card mb-6",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border",children:[c.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),c.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),c.jsx("th",{className:"w-20 px-4 py-2"})]})}),c.jsx("tbody",{children:y.map(S=>c.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[c.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:S}),c.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{children:d.has(S)?e[S]:"***"}),c.jsx("button",{onClick:()=>_(S),className:"text-muted hover:text-ink transition-colors",title:d.has(S)?"Hide value":"Show value",children:d.has(S)?c.jsx(Xl,{size:14}):c.jsx(ui,{size:14})})]})}),c.jsx("td",{className:"px-4 py-2.5 text-right",children:c.jsx("button",{onClick:()=>p(S),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:c.jsx(Fo,{size:14})})})]},S))})]})}),y.length===0&&c.jsx("div",{className:"card p-4 mb-6",children:c.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&c.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),c.jsxs("div",{className:"flex items-end gap-3",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),c.jsx("input",{type:"text",value:i,onChange:S=>s(S.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"})]}),c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),c.jsx("input",{type:"password",value:r,onChange:S=>n(S.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"})]}),c.jsxs("button",{onClick:m,disabled:!i.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:[c.jsx(Il,{size:14}),"Add"]})]})]})]})})}function np({session:e,onClose:t}){var cn;const[i,s]=g.useState(null),[r,n]=g.useState(""),[o,a]=g.useState(null),[h,l]=g.useState(null),[d,u]=g.useState(!1),[f,m]=g.useState("code"),[p,_]=g.useState(!1),[y,S]=g.useState(!1),[b,P]=g.useState(e),k=g.useRef(null),[C,A]=g.useState([]),[D,U]=g.useState(!1),[q,$]=g.useState(""),L=g.useRef(null),M=g.useRef(null),[w,R]=g.useState(0),[x,B]=g.useState(null),[j,N]=g.useState(()=>sessionStorage.getItem(`pl_buildmode_${b.id}`)||"standard"),[G,ie]=g.useState(()=>sessionStorage.getItem(`pl_provider_${b.id}`)||"claude"),[W,H]=g.useState(null),[F,Y]=g.useState(null),[ne,oe]=g.useState(!1),[Te,Ye]=g.useState(!1),[Ie,bt]=g.useState(!1),[qe,Ae]=g.useState(null),Q=g.useRef(null),{subscribe:jt}=Ml(),ht=g.useCallback(async()=>{try{const v=await te.getSessionDetail(b.id);P(v)}catch{}},[b.id]),Jr=g.useCallback(async()=>{try{await te.stopSession(),oe(!1),Ye(!1)}catch{}},[]),ol=g.useCallback(async()=>{try{await te.pauseSession(),Ye(!0)}catch{}},[]),al=g.useCallback(async()=>{try{await te.resumeSession(),Ye(!1)}catch{}},[]);g.useEffect(()=>{const v=async()=>{try{const K=await te.getStatus();oe(K.running),Ye(K.paused),K.provider&&ie(K.provider)}catch{}};v();const I=setInterval(v,1e4);return()=>clearInterval(I)},[]),g.useEffect(()=>{if(!(F!=null&&F.loading))return;const v=setInterval(()=>{Y(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(v)},[F==null?void 0:F.loading]);const[X,ll]=g.useState(null);g.useEffect(()=>{te.getPreviewInfo(b.id).then(ll).catch(()=>{})},[b.id]);const[z,Ai]=g.useState(null),[ti,Zr]=g.useState(!1),[Qr,en]=g.useState(!1),[tn,zi]=g.useState(null),[yt,hl]=g.useState("");g.useEffect(()=>{const v=jt("file_changed",I=>{const K=I;!K.paths||K.paths.length===0||(bt(!0),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>bt(!1),2e3),ht(),i&&K.paths.some($e=>$e===i||i.endsWith($e))&&Ae(i),f==="preview"&&!(z!=null&&z.running)&&R(ee=>ee+1))});return()=>{v(),Q.current&&clearTimeout(Q.current)}},[jt,i,f,z==null?void 0:z.running,ht]);const cl=g.useCallback(async()=>{if(!(!qe||!b.id)){try{const v=await te.getSessionFileContent(b.id,qe);a(v.content),l(v.content),_(!1),A(I=>I.map(K=>K.path===qe?{...K,content:v.content,modified:!1}:K))}catch{}Ae(null)}},[qe,b.id]);g.useEffect(()=>{if(f!=="preview")return;let v=!1;const I=async()=>{try{const ee=await te.devserver.status(b.id);v||Ai(ee)}catch{}};I();const K=setInterval(I,3e3);return()=>{v=!0,clearInterval(K)}},[f,b.id]);const It=g.useCallback(async v=>{Zr(!0),zi(null);try{const I=await te.devserver.start(b.id,v);if(I.status==="error")zi(I.message||"Failed to start dev server");else{const K=await te.devserver.status(b.id);Ai(K)}}catch(I){zi(I instanceof Error?I.message:"Failed to start dev server")}Zr(!1)},[b.id]),sn=g.useRef(!1);g.useEffect(()=>{sn.current||X!=null&&X.dev_command&&(z!=null&&z.running||(z==null?void 0:z.status)==="starting"||ti||(sn.current=!0,It(X.dev_command)))},[X==null?void 0:X.dev_command,z==null?void 0:z.running,z==null?void 0:z.status,ti,It]);const dl=g.useCallback(async()=>{try{await te.devserver.stop(b.id);const v=await te.devserver.status(b.id);Ai(v)}catch{}},[b.id]),ul=g.useCallback(async()=>{en(!0);try{const v=await te.fixProject(b.id);if(v.task_id){let K=0,ee;do await new Promise(El=>setTimeout(El,2e3)),ee=await te.chatPoll(b.id,v.task_id),K++;while(!ee.complete&&K<150);const $e=await te.devserver.status(b.id);Ai($e)}}catch(v){zi(v instanceof Error?v.message:"Fix failed")}en(!1)},[b.id]),$t=z!=null&&z.running&&(z!=null&&z.port)?z.framework==="expo"?`/api/sessions/${encodeURIComponent(b.id)}/expo-qr`:z.portless_url||`http://localhost:${z.port}/`:null,fl=(X==null?void 0:X.preview_url)||`/api/sessions/${encodeURIComponent(b.id)}/preview/index.html`,_l=$t||fl,[Oi,rn]=g.useState([]),[st,ji]=g.useState(0);g.useEffect(()=>{const v=$t||(X==null?void 0:X.preview_url);v&&(rn([v]),ji(0))},[$t,X==null?void 0:X.preview_url]);const wt=Oi[st]||_l,[nn,Ss]=g.useState(wt),pl=g.useCallback((v,I,K,ee)=>{v.preventDefault(),B({x:v.clientX,y:v.clientY,path:I,name:K,type:ee})},[]),ml=g.useCallback(()=>{st>0&&(ji(v=>v-1),R(v=>v+1))},[st]),gl=g.useCallback(()=>{st<Oi.length-1&&(ji(v=>v+1),R(v=>v+1))},[st,Oi.length]),vl=g.useCallback(v=>{let I=v;if(v.startsWith("/")&&$t)try{I=`${new URL($t).origin}${v}`}catch{const K=z==null?void 0:z.port;K&&(I=`http://localhost:${K}${v}`)}rn(K=>[...K.slice(0,st+1),I]),ji(K=>K+1),R(K=>K+1)},[st,$t,z==null?void 0:z.port]);g.useEffect(()=>{try{const v=new URL(wt,window.location.origin);Ss(v.pathname+v.search+v.hash||"/")}catch{Ss(wt)}},[wt]);const Ii=g.useCallback(async()=>{Y({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),H(null);try{const v=await te.reviewProject(b.id);H(v.output)}catch(v){H(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Y(null)}},[b.id]),$i=g.useCallback(async()=>{Y({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),H(null);try{const v=await te.testProject(b.id);H(v.output)}catch(v){H(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Y(null)}},[b.id]),bs=g.useCallback(async()=>{Y({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),H(null);try{const v=await te.explainProject(b.id);H(v.output)}catch(v){H(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Y(null)}},[b.id]),ys=g.useCallback(async(v,I)=>{if(window.confirm(`Delete "${I}"?`))try{await te.deleteSessionFile(b.id,v),i===v&&(s(null),n(""),a(null),l(null),_(!1)),await ht()}catch(ee){const $e=ee instanceof Error?ee.message:"Unknown error";window.alert(`Delete failed: ${$e}`)}},[b.id,i,ht]),Sl=g.useCallback(v=>v.type==="file"?[{label:"Review",icon:ui,onClick:()=>{Ii()}},{label:"Generate Tests",icon:ks,onClick:()=>{$i()}},{label:"Explain",icon:pn,onClick:()=>{bs()}},{label:"Delete",icon:Fo,onClick:()=>{ys(v.path,v.name)},variant:"danger"}]:[{label:"Review Project",icon:ui,onClick:()=>{Ii()}},{label:"Run Tests",icon:ks,onClick:()=>{$i()}}],[Ii,$i,bs,ys]),ii=g.useCallback(async(v,I)=>{Ae(null),p&&i&&h!==null&&A(ee=>ee.map($e=>$e.path===i?{...$e,content:h,modified:!0}:$e));const K=C.find(ee=>ee.path===v);if(K){s(v),n(I),a(K.content),l(K.content),_(K.modified);return}s(v),n(I),u(!0),_(!1);try{const ee=b.id?await te.getSessionFileContent(b.id,v):await te.getFileContent(v);a(ee.content),l(ee.content),A($e=>[...$e,{path:v,name:I,content:ee.content,modified:!1}])}catch{a("[Error loading file]"),l("[Error loading file]")}finally{u(!1)}},[b.id,p,i,h,C]),ws=g.useCallback(async()=>{var v;if(!(!i||h===null||!b.id)){S(!0);try{await te.saveSessionFile(b.id,i,h),a(h),_(!1),A(K=>K.map(ee=>ee.path===i?{...ee,content:h,modified:!1}:ee));const I=((v=i.split(".").pop())==null?void 0:v.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&R(K=>K+1)}catch(I){const K=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${K}`)}finally{S(!1)}}},[i,h,b.id]),on=g.useCallback(v=>{const I=C.find(K=>K.path===v);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(A(K=>K.filter(ee=>ee.path!==v)),i===v)){const K=C.filter(ee=>ee.path!==v);if(K.length>0){const ee=K[K.length-1];s(ee.path),n(ee.name),a(ee.content),l(ee.content),_(ee.modified)}else s(null),n(""),a(null),l(null),_(!1)}},[C,i]);g.useEffect(()=>{const v=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&i&&ws()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),U(K=>!K),$("")),I.key==="Escape"&&D&&U(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p,i,ws,D]),g.useEffect(()=>{D&&L.current&&L.current.focus()},[D]);const an=nl(b.files),si=q?an.filter(v=>v.path.toLowerCase().includes(q.toLowerCase())):an;g.useEffect(()=>{const v=b.files.find(I=>I.name==="index.html"&&I.type==="file");v&&ii(v.path,v.name)},[]);const bl=g.useCallback(v=>{v!==void 0&&(l(v),_(v!==o))},[o]),yl=g.useCallback(v=>{k.current=v},[]),wl=g.useCallback(async()=>{const v=window.prompt("New file name (e.g. src/utils.ts):");if(!(!v||!v.trim()))try{await te.createSessionFile(b.id,v.trim()),await ht()}catch(I){const K=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${K}`)}},[b.id,ht]),xl=g.useCallback(async()=>{const v=window.prompt("New folder name (e.g. src/components):");if(!(!v||!v.trim()))try{await te.createSessionDirectory(b.id,v.trim()),await ht()}catch(I){const K=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${K}`)}},[b.id,ht]),ln=i?il(b.files,i):void 0,Cl=((cn=r.split(".").pop())==null?void 0:cn.toUpperCase())||"",{showHelp:kl,setShowHelp:hn}=ep({onToggleBuild:()=>{ne&&Jr()}});return c.jsxs("div",{className:"flex flex-col h-full relative",children:[c.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[c.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"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:b.id}),c.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:b.path})]}),c.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}),!ne&&c.jsx(Kt,{variant:"primary",size:"sm",icon:Cs,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 te.startSession({prd:v,provider:G,projectDir:b.path}),oe(!0)}catch(v){window.alert(`Failed to start: ${v instanceof Error?v.message:"Unknown error"}`)}},title:"Start build for this project",children:"Build"}),ne&&c.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[Te?c.jsx(Kt,{variant:"ghost",size:"sm",icon:Cs,onClick:al,title:"Resume build",children:"Resume"}):c.jsx(Kt,{variant:"ghost",size:"sm",icon:Tl,onClick:ol,title:"Pause build",children:"Pause"}),c.jsx(Kt,{variant:"danger",size:"sm",icon:os,onClick:Jr,title:"Stop build",children:"Stop"})]}),c.jsx(ct,{icon:ui,label:"Review project",size:"sm",onClick:Ii,disabled:!!(F!=null&&F.loading)}),c.jsx(ct,{icon:ks,label:"Run tests",size:"sm",onClick:$i,disabled:!!(F!=null&&F.loading)}),c.jsx(ct,{icon:pn,label:"Explain project",size:"sm",onClick:bs,disabled:!!(F!=null&&F.loading)}),c.jsx(ip,{onClick:()=>hn(!0)})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsxs(qs,{orientation:"vertical",children:[c.jsx(pi,{defaultSize:70,minSize:40,children:c.jsxs(qs,{orientation:"horizontal",className:"h-full",children:[c.jsx(pi,{defaultSize:20,minSize:15,children:c.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[c.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[c.jsxs("span",{className:"text-xs text-muted-accessible uppercase tracking-wider font-semibold flex-1",children:["Files",Ie&&c.jsx("span",{className:"ml-2 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),c.jsxs("button",{onClick:wl,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:[c.jsx(ih,{size:12})," New"]}),c.jsxs("button",{onClick:xl,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:[c.jsx(lh,{size:12})," New"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:b.files.length>0?c.jsx(rl,{nodes:b.files,selectedPath:i,onSelect:ii,onDelete:ys,onContextMenu:pl}):c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(Ws,{size:28,className:"text-muted/40 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})})]})}),c.jsx(Vs,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),c.jsx(pi,{defaultSize:80,minSize:40,children:c.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[c.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:Vl},{id:"preview",label:"Preview",icon:ui},{id:"config",label:"Config",icon:Dl},{id:"secrets",label:"Secrets",icon:uh},{id:"prd",label:"PRD",icon:$o}].map(v=>c.jsxs("button",{role:"tab","aria-selected":f===v.id,onClick:()=>m(v.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===v.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[c.jsx(v.icon,{size:14}),v.label]},v.id))}),c.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&c.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[C.length>0&&c.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:C.map(v=>c.jsxs("button",{onClick:()=>ii(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===i?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[c.jsx("span",{className:"w-4 flex items-center justify-center",children:Br(v.name,"file")}),v.name,v.modified&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),c.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),on(v.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),on(v.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:c.jsx(Ci,{size:12})})]},v.path))}),i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[c.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:i}),y&&c.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),c.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:ln!=null?sl(ln):""}),c.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:Cl}),p&&c.jsx("button",{onClick:ws,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"})]}),qe===i&&c.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[c.jsx(vh,{size:12,className:"text-warning"}),c.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),c.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[c.jsx("button",{onClick:cl,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"}),c.jsx("button",{onClick:()=>Ae(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"})]})]}),c.jsx("div",{className:"flex-1 min-h-0",children:d?c.jsx(Rl,{}):c.jsx(Ji,{name:"Editor",children:c.jsx(Ic,{value:h??"",language:sp(r),theme:"vs",onChange:bl,onMount:yl,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}}})})})]}):c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[c.jsx(We,{size:32,className:"text-muted/30 mb-3"}),c.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),c.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",c.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"]})]})]}),f==="preview"&&c.jsx(Ji,{name:"Preview",children:c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover",children:z!=null&&z.running||X!=null&&X.preview_url?c.jsxs(c.Fragment,{children:[c.jsx(ct,{icon:Hl,label:"Back",size:"sm",onClick:ml,disabled:st<=0}),c.jsx(ct,{icon:Pl,label:"Forward",size:"sm",onClick:gl,disabled:st>=Oi.length-1}),c.jsx(ct,{icon:Al,label:"Refresh",size:"sm",onClick:()=>R(v=>v+1)}),c.jsx("input",{value:nn,onChange:v=>Ss(v.target.value),onKeyDown:v=>{v.key==="Enter"&&vl(nn)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),c.jsx(ct,{icon:Wl,label:"Open in new tab",size:"sm",onClick:()=>window.open(wt,"_blank")}),(z==null?void 0:z.running)&&c.jsxs("button",{onClick:dl,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:[c.jsx(os,{size:12}),"Stop"]})]}):X?c.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:c.jsx("span",{className:"font-medium text-ink",children:X.description})}):c.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),z&&z.status!=="stopped"&&c.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs ${z.running?"bg-green-50 border-green-200 text-green-700":z.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":z.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${z.running?"bg-green-500":z.status==="starting"?"bg-yellow-500 animate-pulse":z.status==="error"?"bg-red-500":"bg-gray-400"}`}),z.running&&z.portless_url&&c.jsxs("span",{children:["Running at ",z.portless_url]}),z.running&&z.port&&!z.portless_url&&c.jsxs("span",{children:["Running on port ",z.port]}),z.status==="starting"&&c.jsx("span",{children:"Starting dev server..."}),z.status==="error"&&!z.auto_fix_status&&c.jsx("span",{children:"Dev server crashed"}),z.status==="error"&&z.auto_fix_status&&c.jsxs("span",{children:["Auto-fixing: ",z.auto_fix_status]}),z.command&&c.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:z.command})]}),z!=null&&z.running?c.jsx("div",{className:"flex-1 bg-white",children:c.jsx("iframe",{ref:M,src:wt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},w)}):X!=null&&X.preview_url?c.jsx("div",{className:"flex-1 bg-white",children:c.jsx("iframe",{ref:M,src:wt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},w)}):X?c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:X.type==="api"||X.type==="python-api"?c.jsx(Ch,{size:28,className:"text-primary"}):X.type==="library"?c.jsx(mh,{size:28,className:"text-primary"}):X.type==="go-app"||X.type==="rust-app"?c.jsx(Lr,{size:28,className:"text-primary"}):c.jsx(Ws,{size:28,className:"text-primary"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:X.type.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase())}),c.jsx("p",{className:"text-sm text-muted",children:X.description})]}),c.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[X.dev_command&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:X.dev_command}),c.jsxs("button",{onClick:()=>It(X.dev_command||void 0),disabled:ti,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:[c.jsx(Cs,{size:12}),ti?"Starting...":"Start"]})]})]}),c.jsxs("div",{className:X.dev_command?"pt-2 border-t border-border":"",children:[c.jsx("p",{className:"text-xs text-muted mb-2",children:X.dev_command?"Or use a custom command:":"Start a dev server:"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{value:yt,onChange:v=>hl(v.target.value),onKeyDown:v=>{v.key==="Enter"&&yt.trim()&&It(yt.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"}),c.jsx("button",{onClick:()=>yt.trim()&&It(yt.trim()),disabled:ti||!yt.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"})]})]})]}),tn&&c.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[c.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),c.jsx("p",{className:"text-xs text-danger/80",children:tn})]}),(z==null?void 0:z.status)==="error"&&c.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:ul,disabled:Qr,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:Qr?"Fixing...":"Fix Error"}),c.jsx("button",{onClick:()=>It(X.dev_command||yt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),z.auto_fix_status&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),c.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",z.auto_fix_status]}),z.auto_fix_attempts!==void 0&&z.auto_fix_attempts>0&&c.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",z.auto_fix_attempts,"/3"]})]}),z.output.length>0&&c.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:z.output.slice(-10).join(`
|
|
187
|
-
`)})]}),X.port&&!(z!=null&&z.running)&&c.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",X.port]})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&c.jsx("div",{className:"h-full flex flex-col",children:c.jsxs("div",{className:"p-6 overflow-y-auto",children:[c.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),c.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",c.jsx("span",{className:"font-semibold text-ink capitalize",children:
|
|
214
|
+
`);R=I.pop()||"";for(const B of I){if(!B.trim())continue;const Y=B.split(`
|
|
215
|
+
`);let te="",H="";for(const K of Y)K.startsWith("event:")?te=K.slice(6).trim():K.startsWith("data:")&&(H=K.slice(5).trim());if(te==="output"&&H)try{const{line:K}=JSON.parse(H);n(V=>Mt(V,Z=>Z.role==="system"&&Z.isStreaming?{content:Z.content?Z.content+`
|
|
216
|
+
`+K:K}:{}))}catch{}else if(te==="complete"&&H)try{const{returncode:K,files_changed:V}=JSON.parse(H);n(Z=>Mt(Z,se=>se.role==="system"&&se.isStreaming?{isStreaming:!1,filesChanged:V,returncode:K,content:se.content||"Done."}:{})),(V==null?void 0:V.length)>0&&i&&i(V)}catch{}else if(te==="error"&&H)try{const{error:K}=JSON.parse(H);n(V=>Mt(V,Z=>Z.role==="system"&&Z.isStreaming?{isStreaming:!1,content:`Error: ${K}`}:{}))}catch{}}}}catch($){if($ instanceof DOMException&&$.name==="AbortError")return;await P(D)}finally{m(!1),u(!1),y.current=null,S.current=null,(U=_.current)==null||U.focus()}},[e,i,P]),C=async()=>{var $;const D=o.trim();if(!D||d)return;const W={role:"user",content:D,timestamp:new Date().toISOString()},U={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};n(N=>[...N,W,U]),a(""),u(!0);try{const{task_id:N}=await ee.chatStart(e,D,h);await k(N)}catch(N){n(M=>Mt(M,w=>w.role==="system"&&w.isStreaming?{isStreaming:!1,content:`Error: ${N instanceof Error?N.message:"Request failed"}`}:{})),u(!1),($=_.current)==null||$.focus()}};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[r.length===0&&c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(Jo,{size:28,className:"text-muted/30 mb-3"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No messages yet"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-1 max-w-[200px]",children:"Ask the AI to build, modify, or explain your code."})]}),r.map((D,W)=>c.jsx(gp,{msg:D},W))]}),c.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&c.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[c.jsx("span",{className:"text-[10px] text-muted font-mono",children:"Streaming..."}),c.jsxs("button",{onClick:b,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[c.jsx(us,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(s==null?void 0:s.some(D=>D.fix_status==="fixing"))&&c.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[c.jsx(tc,{size:10,className:"text-yellow-400 animate-spin"}),c.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(A=s.find(D=>D.fix_status==="fixing"))==null?void 0:A.name]})]}),c.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(D=>c.jsx("button",{onClick:()=>l(D),title:vp[D],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===D?"bg-primary text-white":"text-muted hover:text-ink"}`,children:D},D))}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("textarea",{ref:_,value:o,onChange:D=>a(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),C())},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}),f?c.jsx(qt,{size:"sm",icon:us,onClick:b,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):c.jsx(qt,{size:"sm",icon:Vh,onClick:C,disabled:d||!o.trim(),"aria-label":"Send message",children:"Send"})]})]})]})}const qo=[{id:"terminal",label:"Terminal",icon:$r,alwaysShow:!0},{id:"chat",label:"AI Chat",icon:Jo,alwaysShow:!0},{id:"build",label:"Build Log",icon:Uh},{id:"agents",label:"Agents",icon:nh},{id:"quality",label:"Quality",icon:ea}];function bp({status:e}){switch(e){case"pass":return c.jsx(ih,{size:14,className:"text-success"});case"fail":return c.jsx(Di,{size:14,className:"text-danger"});default:return c.jsx(th,{size:14,className:"text-muted"})}}function yp({agents:e}){return!e||e.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(Qh,{size:24,className:"text-muted/30 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):c.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[c.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),c.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),c.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),c.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function wp({checklist:e}){return!e||!e.items||e.items.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(ea,{size:24,className:"text-muted/30 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):c.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[c.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[c.jsx("span",{children:"Gate"}),c.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[c.jsx(bp,{status:t.status}),c.jsx("span",{className:"text-ink",children:t.label}),t.details&&c.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function xp({logs:e,logsLoading:t,agents:i,checklist:s,sessionId:r,isRunning:n,subscribe:o,buildMode:a}){var p;const[h,l]=g.useState("terminal"),d=i&&i.length>0,u=s&&s.items&&s.items.length>0,f=e&&e.length>0,m=qo.filter(_=>!!(_.alwaysShow||_.id==="build"&&(f||n)||_.id==="agents"&&(d||n)||_.id==="quality"&&(u||n)));return m.find(_=>_.id===h)||l("terminal"),c.jsxs("div",{className:"h-full flex flex-col bg-card",children:[c.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:m.map(_=>{const y=_.icon,S=h===_.id;return c.jsxs("button",{role:"tab","aria-selected":S,onClick:()=>l(_.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${S?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[c.jsx(y,{size:14}),_.label,_.id==="agents"&&d&&c.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:i.length}),_.id==="quality"&&u&&c.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[s.passed,"/",s.total]})]},_.id)})}),c.jsxs("div",{role:"tabpanel","aria-label":(p=qo.find(_=>_.id===h))==null?void 0:p.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[c.jsx("div",{className:"absolute inset-0",style:{visibility:h==="terminal"?"visible":"hidden",zIndex:h==="terminal"?1:0},children:c.jsx(pp,{sessionId:r,isActive:h==="terminal"})}),h==="build"&&c.jsx(Yl,{logs:e,loading:t,subscribe:o}),h==="agents"&&c.jsx(yp,{agents:i}),h==="quality"&&c.jsx(wp,{checklist:s}),h==="chat"&&c.jsx(Sp,{sessionId:r,defaultMode:a})]})]})}const fl=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),pi=fl?"Cmd":"Ctrl",Cp=[{keys:[`${pi}+S`],label:"Save file"},{keys:[`${pi}+P`],label:"Quick open file"},{keys:[`${pi}+\``],label:"Toggle terminal"},{keys:[`${pi}+B`],label:"Start / stop build"},{keys:[`${pi}+?`],label:"Show keyboard shortcuts"},{keys:["Escape"],label:"Close modals"}];function kp({onToggleTerminal:e,onToggleBuild:t}){const[i,s]=g.useState(!1),r=g.useCallback(n=>{const o=fl?n.metaKey:n.ctrlKey;if(o&&(n.key==="?"||n.shiftKey&&n.key==="/")){n.preventDefault(),s(a=>!a);return}if(o&&n.key==="`"){n.preventDefault(),e==null||e();return}if(o&&n.key==="b"){n.preventDefault(),t==null||t();return}n.key==="Escape"&&i&&s(!1)},[e,t,i]);return g.useEffect(()=>(window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)),[r]),{showHelp:i,setShowHelp:s}}function Ep({open:e,onClose:t}){return e?c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:c.jsxs("div",{className:"bg-card rounded-card shadow-card-hover border border-border w-full max-w-md mx-4",onClick:i=>i.stopPropagation(),children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Dh,{size:16,className:"text-primary"}),c.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),c.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:c.jsx(Di,{size:16})})]}),c.jsx("div",{className:"p-4 space-y-1",children:Cp.map(i=>c.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[c.jsx("span",{className:"text-xs text-ink",children:i.label}),c.jsx("div",{className:"flex items-center gap-1",children:i.keys.map(s=>c.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:s},s))})]},i.label))}),c.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:c.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",c.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 Mp({onClick:e}){return c.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 Ir(e,t,i){var n;if(t==="directory")return i?c.jsx(Js,{size:14}):c.jsx(Ch,{size:14});const s=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"";return{js:c.jsx(Ke,{size:14,className:"text-yellow-600"}),ts:c.jsx(Ke,{size:14,className:"text-blue-500"}),tsx:c.jsx(Ke,{size:14,className:"text-blue-400"}),jsx:c.jsx(Ke,{size:14,className:"text-yellow-500"}),py:c.jsx(Ke,{size:14,className:"text-green-600"}),html:c.jsx(_h,{size:14,className:"text-orange-500"}),css:c.jsx(vh,{size:14,className:"text-purple-500"}),json:c.jsx(dh,{size:14,className:"text-green-500"}),md:c.jsx(Zo,{size:14,className:"text-muted"}),go:c.jsx(Ke,{size:14,className:"text-cyan-600"}),rs:c.jsx(Ke,{size:14,className:"text-orange-600"}),rb:c.jsx(Ke,{size:14,className:"text-red-500"}),sh:c.jsx(Ke,{size:14,className:"text-green-600"})}[s]||c.jsx(bh,{size:14})}function Dp(e){var r;const t=((r=e.split(".").pop())==null?void 0:r.toLowerCase())||"",i={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"},s=e.toLowerCase();return s==="dockerfile"?"dockerfile":s==="makefile"?"makefile":i[t]||"plaintext"}function _l(e,t){for(const i of e){if(i.path===t)return i.size;if(i.children){const s=_l(i.children,t);if(s!==void 0)return s}}}function pl(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ml({nodes:e,selectedPath:t,onSelect:i,onDelete:s,onContextMenu:r,depth:n=0}){const[o,a]=g.useState(()=>{const h=new Set;return n<2&&e.filter(l=>l.type==="directory").forEach(l=>h.add(l.path)),h});return c.jsx("div",{role:n===0?"tree":"group",children:e.map(h=>{const l=h.type==="directory",d=o.has(h.path),u=h.path===t;return c.jsxs("div",{className:"group/file",children:[c.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":u,...l?{"aria-expanded":d}:{},onContextMenu:f=>{f.preventDefault(),r==null||r(f,h.path,h.name,h.type)},onClick:()=>{l?a(f=>{const m=new Set(f);return m.has(h.path)?m.delete(h.path):m.add(h.path),m}):i(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 ${u?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${n*14+8}px`},children:[l?c.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:d?c.jsx(Jl,{size:14}):c.jsx(Zl,{size:14})}):c.jsx("span",{className:"w-3 flex-shrink-0"}),c.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${l?"text-primary":""}`,children:Ir(h.name,h.type,d)}),c.jsxs("span",{className:"truncate",children:[h.name,l?"/":""]}),!l&&h.size!=null&&h.size>0&&c.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:pl(h.size)}),!l&&s&&c.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),s(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),s(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:c.jsx(Di,{size:12})})]}),l&&d&&h.children&&c.jsx(ml,{nodes:h.children,selectedPath:t,onSelect:i,onDelete:s,onContextMenu:r,depth:n+1})]},h.path)})})}function gl(e,t=""){const i=[];for(const s of e)s.type==="file"&&i.push({path:s.path,name:s.name}),s.children&&i.push(...gl(s.children,s.path+"/"));return i}function Rp(){const[e,t]=g.useState({}),[i,s]=g.useState(""),[r,n]=g.useState(""),[o,a]=g.useState(!0),[h,l]=g.useState(null),[d,u]=g.useState(new Set),f=g.useCallback(async()=>{try{const S=await ee.getSecrets();t(S)}catch{}a(!1)},[]);g.useEffect(()=>{f()},[f]);const m=async()=>{const S=i.trim();if(S){if(!/^[A-Z_][A-Z0-9_]*$/.test(S)){l("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}l(null);try{await ee.setSecret(S,r),s(""),n(""),await f()}catch(b){l(b instanceof Error?b.message:"Failed to set secret")}}},p=async S=>{if(window.confirm(`Delete secret "${S}"?`))try{await ee.deleteSecret(S),await f()}catch(b){l(b instanceof Error?b.message:"Failed to delete secret")}},_=S=>{u(b=>{const P=new Set(b);return P.has(S)?P.delete(S):P.add(S),P})},y=Object.keys(e);return o?c.jsxs("div",{className:"p-6 space-y-4",children:[c.jsx(Ls,{variant:"text",width:"180px",height:"16px"}),c.jsx(Ls,{variant:"block",width:"100%",height:"60px"}),c.jsx(Ls,{variant:"block",width:"100%",height:"80px"})]}):c.jsx("div",{className:"h-full flex flex-col",children:c.jsxs("div",{className:"p-6 overflow-y-auto",children:[c.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),c.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[c.jsx(Ql,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),c.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&&c.jsx("div",{className:"card mb-6",children:c.jsxs("table",{className:"w-full text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"border-b border-border",children:[c.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),c.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),c.jsx("th",{className:"w-20 px-4 py-2"})]})}),c.jsx("tbody",{children:y.map(S=>c.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[c.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:S}),c.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx("span",{children:d.has(S)?e[S]:"***"}),c.jsx("button",{onClick:()=>_(S),className:"text-muted hover:text-ink transition-colors",title:d.has(S)?"Hide value":"Show value",children:d.has(S)?c.jsx(hh,{size:14}):c.jsx(mi,{size:14})})]})}),c.jsx("td",{className:"px-4 py-2.5 text-right",children:c.jsx("button",{onClick:()=>p(S),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:c.jsx(Qo,{size:14})})})]},S))})]})}),y.length===0&&c.jsx("div",{className:"card p-4 mb-6",children:c.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&c.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),c.jsxs("div",{className:"flex items-end gap-3",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),c.jsx("input",{type:"text",value:i,onChange:S=>s(S.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"})]}),c.jsxs("div",{className:"flex-1",children:[c.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),c.jsx("input",{type:"password",value:r,onChange:S=>n(S.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"})]}),c.jsxs("button",{onClick:m,disabled:!i.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:[c.jsx(eh,{size:14}),"Add"]})]})]})]})})}function Pp({session:e,onClose:t}){var bn;const[i,s]=g.useState(null),[r,n]=g.useState(""),[o,a]=g.useState(null),[h,l]=g.useState(null),[d,u]=g.useState(!1),[f,m]=g.useState("code"),[p,_]=g.useState(!1),[y,S]=g.useState(!1),[b,P]=g.useState(e),k=g.useRef(null),[C,A]=g.useState([]),[D,W]=g.useState(!1),[U,$]=g.useState(""),N=g.useRef(null),M=g.useRef(null),[w,R]=g.useState(0),[x,L]=g.useState(null),[I,B]=g.useState(!0),[Y,te]=g.useState(!0),[H,K]=g.useState(!1),[V,Z]=g.useState("overview"),se=57374,[le,Ee]=g.useState(null),yt=g.useCallback(()=>{K(v=>{const j=!v;return B(!j),te(!j),j})},[]),[Oe,$t]=g.useState(()=>sessionStorage.getItem(`pl_buildmode_${b.id}`)||"standard"),[st,Ve]=g.useState(()=>sessionStorage.getItem(`pl_provider_${b.id}`)||"claude"),[ie,Te]=g.useState(null),[_e,wt]=g.useState(null),[ks,Es]=g.useState(!1),[vl,Ii]=g.useState(!1),[Sl,on]=g.useState(!1),[si,$i]=g.useState(null),ri=g.useRef(null),{subscribe:an}=Hl(),ct=g.useCallback(async()=>{try{const v=await ee.getSessionDetail(b.id);P(v)}catch{}},[b.id]),ln=g.useCallback(async()=>{try{await ee.stopSession(),Es(!1),Ii(!1)}catch{}},[]),bl=g.useCallback(async()=>{try{await ee.pauseSession(),Ii(!0)}catch{}},[]),yl=g.useCallback(async()=>{try{await ee.resumeSession(),Ii(!1)}catch{}},[]);g.useEffect(()=>{const v=async()=>{try{const F=await ee.getStatus();Es(F.running),Ii(F.paused),F.provider&&Ve(F.provider)}catch{}};v();const j=setInterval(v,1e4);return()=>clearInterval(j)},[]),g.useEffect(()=>{if(!(_e!=null&&_e.loading))return;const v=setInterval(()=>{wt(j=>j?{...j,elapsed:Math.floor((Date.now()-j.startTime)/1e3)}:null)},1e3);return()=>clearInterval(v)},[_e==null?void 0:_e.loading]);const[X,wl]=g.useState(null);g.useEffect(()=>{ee.getPreviewInfo(b.id).then(wl).catch(()=>{})},[b.id]);const[z,Hi]=g.useState(null),[ni,hn]=g.useState(!1),[cn,dn]=g.useState(!1),[un,Fi]=g.useState(null),[xt,xl]=g.useState("");g.useEffect(()=>{const v=an("file_changed",j=>{const F=j;!F.paths||F.paths.length===0||(on(!0),ri.current&&clearTimeout(ri.current),ri.current=setTimeout(()=>on(!1),2e3),ct(),i&&F.paths.some(He=>He===i||i.endsWith(He))&&$i(i),f==="preview"&&!(z!=null&&z.running)&&R(Q=>Q+1))});return()=>{v(),ri.current&&clearTimeout(ri.current)}},[an,i,f,z==null?void 0:z.running,ct]);const Cl=g.useCallback(async()=>{if(!(!si||!b.id)){try{const v=await ee.getSessionFileContent(b.id,si);a(v.content),l(v.content),_(!1),A(j=>j.map(F=>F.path===si?{...F,content:v.content,modified:!1}:F))}catch{}$i(null)}},[si,b.id]);g.useEffect(()=>{if(f!=="preview")return;let v=!1;const j=async()=>{try{const Q=await ee.devserver.status(b.id);v||Hi(Q)}catch{}};j();const F=setInterval(j,3e3);return()=>{v=!0,clearInterval(F)}},[f,b.id]),g.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${se}/health`).then(v=>Ee(v.ok)).catch(()=>Ee(!1))},[f]);const Ht=g.useCallback(async v=>{hn(!0),Fi(null);try{const j=await ee.devserver.start(b.id,v);if(j.status==="error")Fi(j.message||"Failed to start dev server");else{const F=await ee.devserver.status(b.id);Hi(F)}}catch(j){Fi(j instanceof Error?j.message:"Failed to start dev server")}hn(!1)},[b.id]),fn=g.useRef(!1);g.useEffect(()=>{fn.current||X!=null&&X.dev_command&&(z!=null&&z.running||(z==null?void 0:z.status)==="starting"||ni||(fn.current=!0,Ht(X.dev_command)))},[X==null?void 0:X.dev_command,z==null?void 0:z.running,z==null?void 0:z.status,ni,Ht]);const kl=g.useCallback(async()=>{try{await ee.devserver.stop(b.id);const v=await ee.devserver.status(b.id);Hi(v)}catch{}},[b.id]),El=g.useCallback(async()=>{dn(!0);try{const v=await ee.fixProject(b.id);if(v.task_id){let F=0,Q;do await new Promise($l=>setTimeout($l,2e3)),Q=await ee.chatPoll(b.id,v.task_id),F++;while(!Q.complete&&F<150);const He=await ee.devserver.status(b.id);Hi(He)}}catch(v){Fi(v instanceof Error?v.message:"Fix failed")}dn(!1)},[b.id]),Ft=z!=null&&z.running&&(z!=null&&z.port)?z.framework==="expo"?`/api/sessions/${encodeURIComponent(b.id)}/expo-qr`:z.portless_url||`http://localhost:${z.port}/`:null,Ml=(X==null?void 0:X.preview_url)||`/api/sessions/${encodeURIComponent(b.id)}/preview/index.html`,Dl=Ft||Ml,[Wi,_n]=g.useState([]),[rt,Ki]=g.useState(0);g.useEffect(()=>{const v=Ft||(X==null?void 0:X.preview_url);v&&(_n([v]),Ki(0))},[Ft,X==null?void 0:X.preview_url]);const Ct=Wi[rt]||Dl,[pn,Ms]=g.useState(Ct),Rl=g.useCallback((v,j,F,Q)=>{v.preventDefault(),L({x:v.clientX,y:v.clientY,path:j,name:F,type:Q})},[]),Pl=g.useCallback(()=>{rt>0&&(Ki(v=>v-1),R(v=>v+1))},[rt]),Ll=g.useCallback(()=>{rt<Wi.length-1&&(Ki(v=>v+1),R(v=>v+1))},[rt,Wi.length]),Bl=g.useCallback(v=>{let j=v;if(v.startsWith("/")&&Ft)try{j=`${new URL(Ft).origin}${v}`}catch{const F=z==null?void 0:z.port;F&&(j=`http://localhost:${F}${v}`)}_n(F=>[...F.slice(0,rt+1),j]),Ki(F=>F+1),R(F=>F+1)},[rt,Ft,z==null?void 0:z.port]);g.useEffect(()=>{try{const v=new URL(Ct,window.location.origin);Ms(v.pathname+v.search+v.hash||"/")}catch{Ms(Ct)}},[Ct]);const Ui=g.useCallback(async()=>{wt({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),Te(null);try{const v=await ee.reviewProject(b.id);Te(v.output)}catch(v){Te(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{wt(null)}},[b.id]),qi=g.useCallback(async()=>{wt({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),Te(null);try{const v=await ee.testProject(b.id);Te(v.output)}catch(v){Te(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{wt(null)}},[b.id]),Ds=g.useCallback(async()=>{wt({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),Te(null);try{const v=await ee.explainProject(b.id);Te(v.output)}catch(v){Te(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{wt(null)}},[b.id]),Rs=g.useCallback(async(v,j)=>{if(window.confirm(`Delete "${j}"?`))try{await ee.deleteSessionFile(b.id,v),i===v&&(s(null),n(""),a(null),l(null),_(!1)),await ct()}catch(Q){const He=Q instanceof Error?Q.message:"Unknown error";window.alert(`Delete failed: ${He}`)}},[b.id,i,ct]),Nl=g.useCallback(v=>v.type==="file"?[{label:"Review",icon:mi,onClick:()=>{Ui()}},{label:"Generate Tests",icon:Ns,onClick:()=>{qi()}},{label:"Explain",icon:kn,onClick:()=>{Ds()}},{label:"Delete",icon:Qo,onClick:()=>{Rs(v.path,v.name)},variant:"danger"}]:[{label:"Review Project",icon:mi,onClick:()=>{Ui()}},{label:"Run Tests",icon:Ns,onClick:()=>{qi()}}],[Ui,qi,Ds,Rs]),oi=g.useCallback(async(v,j)=>{$i(null),p&&i&&h!==null&&A(Q=>Q.map(He=>He.path===i?{...He,content:h,modified:!0}:He));const F=C.find(Q=>Q.path===v);if(F){s(v),n(j),a(F.content),l(F.content),_(F.modified);return}s(v),n(j),u(!0),_(!1);try{const Q=b.id?await ee.getSessionFileContent(b.id,v):await ee.getFileContent(v);a(Q.content),l(Q.content),A(He=>[...He,{path:v,name:j,content:Q.content,modified:!1}])}catch{a("[Error loading file]"),l("[Error loading file]")}finally{u(!1)}},[b.id,p,i,h,C]),Ps=g.useCallback(async()=>{var v;if(!(!i||h===null||!b.id)){S(!0);try{await ee.saveSessionFile(b.id,i,h),a(h),_(!1),A(F=>F.map(Q=>Q.path===i?{...Q,content:h,modified:!1}:Q));const j=((v=i.split(".").pop())==null?void 0:v.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(j)&&R(F=>F+1)}catch(j){const F=j instanceof Error?j.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{S(!1)}}},[i,h,b.id]),mn=g.useCallback(v=>{const j=C.find(F=>F.path===v);if(!(j!=null&&j.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(A(F=>F.filter(Q=>Q.path!==v)),i===v)){const F=C.filter(Q=>Q.path!==v);if(F.length>0){const Q=F[F.length-1];s(Q.path),n(Q.name),a(Q.content),l(Q.content),_(Q.modified)}else s(null),n(""),a(null),l(null),_(!1)}},[C,i]);g.useEffect(()=>{const v=j=>{(j.metaKey||j.ctrlKey)&&j.key==="s"&&(j.preventDefault(),p&&i&&Ps()),(j.metaKey||j.ctrlKey)&&j.key==="p"&&(j.preventDefault(),W(F=>!F),$("")),j.key==="Escape"&&D&&W(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p,i,Ps,D]),g.useEffect(()=>{D&&N.current&&N.current.focus()},[D]);const gn=gl(b.files),ai=U?gn.filter(v=>v.path.toLowerCase().includes(U.toLowerCase())):gn;g.useEffect(()=>{const v=b.files.find(j=>j.name==="index.html"&&j.type==="file");v&&oi(v.path,v.name)},[]);const Tl=g.useCallback(v=>{v!==void 0&&(l(v),_(v!==o))},[o]),Al=g.useCallback(v=>{k.current=v},[]),zl=g.useCallback(async()=>{const v=window.prompt("New file name (e.g. src/utils.ts):");if(!(!v||!v.trim()))try{await ee.createSessionFile(b.id,v.trim()),await ct()}catch(j){const F=j instanceof Error?j.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[b.id,ct]),Ol=g.useCallback(async()=>{const v=window.prompt("New folder name (e.g. src/components):");if(!(!v||!v.trim()))try{await ee.createSessionDirectory(b.id,v.trim()),await ct()}catch(j){const F=j instanceof Error?j.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[b.id,ct]),vn=i?_l(b.files,i):void 0,jl=((bn=r.split(".").pop())==null?void 0:bn.toUpperCase())||"",{showHelp:Il,setShowHelp:Sn}=kp({onToggleBuild:()=>{ks&&ln()}});return c.jsxs("div",{className:"flex flex-col h-full relative",children:[c.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[c.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"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:b.id}),c.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:b.path})]}),c.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}),c.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[c.jsx("button",{onClick:()=>B(v=>!v),title:I?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:I?c.jsx(Fl,{size:16}):c.jsx(Hh,{size:16})}),c.jsx("button",{onClick:()=>te(v=>!v),title:Y?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:Y?c.jsx(Oh,{size:16}):c.jsx(Ih,{size:16})}),c.jsx("button",{onClick:yt,title:H?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${H?"text-primary":"text-muted hover:text-ink"}`,children:H?c.jsx(Nh,{size:16}):c.jsx(Lh,{size:16})})]}),!ks&&c.jsx(qt,{variant:"primary",size:"sm",icon:Bs,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 ee.startSession({prd:v,provider:st,projectDir:b.path}),Es(!0)}catch(v){window.alert(`Failed to start: ${v instanceof Error?v.message:"Unknown error"}`)}},title:"Start build for this project",children:"Build"}),ks&&c.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[vl?c.jsx(qt,{variant:"ghost",size:"sm",icon:Bs,onClick:yl,title:"Resume build",children:"Resume"}):c.jsx(qt,{variant:"ghost",size:"sm",icon:Xl,onClick:bl,title:"Pause build",children:"Pause"}),c.jsx(qt,{variant:"danger",size:"sm",icon:us,onClick:ln,title:"Stop build",children:"Stop"})]}),c.jsx(dt,{icon:mi,label:"Review project",size:"sm",onClick:Ui,disabled:!!(_e!=null&&_e.loading)}),c.jsx(dt,{icon:Ns,label:"Run tests",size:"sm",onClick:qi,disabled:!!(_e!=null&&_e.loading)}),c.jsx(dt,{icon:kn,label:"Explain project",size:"sm",onClick:Ds,disabled:!!(_e!=null&&_e.loading)}),c.jsx(Mp,{onClick:()=>Sn(!0)})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsxs(er,{orientation:"vertical",children:[c.jsx(Si,{defaultSize:70,minSize:40,children:c.jsxs(er,{orientation:"horizontal",className:"h-full",children:[I&&c.jsx(Si,{defaultSize:20,minSize:15,children:c.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[c.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[c.jsxs("span",{className:"text-xs text-muted-accessible uppercase tracking-wider font-semibold flex-1",children:["Files",Sl&&c.jsx("span",{className:"ml-2 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),c.jsxs("button",{onClick:zl,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:[c.jsx(mh,{size:12})," New"]}),c.jsxs("button",{onClick:Ol,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:[c.jsx(wh,{size:12})," New"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:b.files.length>0?c.jsx(ml,{nodes:b.files,selectedPath:i,onSelect:oi,onDelete:Rs,onContextMenu:Rl}):c.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[c.jsx(Js,{size:28,className:"text-muted/40 mb-2"}),c.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),c.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})})]})}),I&&c.jsx(tr,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),c.jsx(Si,{defaultSize:80,minSize:40,children:c.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[c.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:ah},{id:"preview",label:"Preview",icon:mi},{id:"config",label:"Config",icon:Wl},{id:"secrets",label:"Secrets",icon:Eh},{id:"prd",label:"PRD",icon:Zo},{id:"dashboard",label:"Dashboard",icon:Mn}].map(v=>c.jsxs("button",{role:"tab","aria-selected":f===v.id,onClick:()=>m(v.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===v.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[c.jsx(v.icon,{size:14}),v.label]},v.id))}),c.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&c.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[C.length>0&&c.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:C.map(v=>c.jsxs("button",{onClick:()=>oi(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===i?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[c.jsx("span",{className:"w-4 flex items-center justify-center",children:Ir(v.name,"file")}),v.name,v.modified&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),c.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:j=>{j.stopPropagation(),mn(v.path)},onKeyDown:j=>{j.key==="Enter"&&(j.stopPropagation(),mn(v.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:c.jsx(Di,{size:12})})]},v.path))}),i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[c.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:i}),y&&c.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),c.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:vn!=null?pl(vn):""}),c.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:jl}),p&&c.jsx("button",{onClick:Ps,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"})]}),si===i&&c.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[c.jsx(Wh,{size:12,className:"text-warning"}),c.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),c.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[c.jsx("button",{onClick:Cl,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"}),c.jsx("button",{onClick:()=>$i(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"})]})]}),c.jsx("div",{className:"flex-1 min-h-0",children:d?c.jsx(Kl,{}):c.jsx(ss,{name:"Editor",children:c.jsx(cd,{value:h??"",language:Dp(r),theme:"vs",onChange:Tl,onMount:Al,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}}})})})]}):c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[c.jsx(Ke,{size:32,className:"text-muted/30 mb-3"}),c.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),c.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",c.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"]})]})]}),f==="preview"&&c.jsx(ss,{name:"Preview",children:c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover",children:z!=null&&z.running||X!=null&&X.preview_url?c.jsxs(c.Fragment,{children:[c.jsx(dt,{icon:sh,label:"Back",size:"sm",onClick:Pl,disabled:rt<=0}),c.jsx(dt,{icon:Ul,label:"Forward",size:"sm",onClick:Ll,disabled:rt>=Wi.length-1}),c.jsx(dt,{icon:Gl,label:"Refresh",size:"sm",onClick:()=>R(v=>v+1)}),c.jsx("input",{value:pn,onChange:v=>Ms(v.target.value),onKeyDown:v=>{v.key==="Enter"&&Bl(pn)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),c.jsx(dt,{icon:En,label:"Open in new tab",size:"sm",onClick:()=>window.open(Ct,"_blank")}),(z==null?void 0:z.running)&&c.jsxs("button",{onClick:kl,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:[c.jsx(us,{size:12}),"Stop"]})]}):X?c.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:c.jsx("span",{className:"font-medium text-ink",children:X.description})}):c.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),z&&z.status!=="stopped"&&c.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs ${z.running?"bg-green-50 border-green-200 text-green-700":z.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":z.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${z.running?"bg-green-500":z.status==="starting"?"bg-yellow-500 animate-pulse":z.status==="error"?"bg-red-500":"bg-gray-400"}`}),z.running&&z.portless_url&&c.jsxs("span",{children:["Running at ",z.portless_url]}),z.running&&z.port&&!z.portless_url&&c.jsxs("span",{children:["Running on port ",z.port]}),z.status==="starting"&&c.jsx("span",{children:"Starting dev server..."}),z.status==="error"&&!z.auto_fix_status&&c.jsx("span",{children:"Dev server crashed"}),z.status==="error"&&z.auto_fix_status&&c.jsxs("span",{children:["Auto-fixing: ",z.auto_fix_status]}),z.command&&c.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:z.command})]}),z!=null&&z.running?c.jsx("div",{className:"flex-1 bg-white",children:c.jsx("iframe",{ref:M,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},w)}):X!=null&&X.preview_url?c.jsx("div",{className:"flex-1 bg-white",children:c.jsx("iframe",{ref:M,src:Ct,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},w)}):X?c.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:X.type==="api"||X.type==="python-api"?c.jsx(Xh,{size:28,className:"text-primary"}):X.type==="library"?c.jsx(Ah,{size:28,className:"text-primary"}):X.type==="go-app"||X.type==="rust-app"?c.jsx($r,{size:28,className:"text-primary"}):c.jsx(Js,{size:28,className:"text-primary"})}),c.jsxs("div",{children:[c.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:X.type.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase())}),c.jsx("p",{className:"text-sm text-muted",children:X.description})]}),c.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[X.dev_command&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:X.dev_command}),c.jsxs("button",{onClick:()=>Ht(X.dev_command||void 0),disabled:ni,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:[c.jsx(Bs,{size:12}),ni?"Starting...":"Start"]})]})]}),c.jsxs("div",{className:X.dev_command?"pt-2 border-t border-border":"",children:[c.jsx("p",{className:"text-xs text-muted mb-2",children:X.dev_command?"Or use a custom command:":"Start a dev server:"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("input",{value:xt,onChange:v=>xl(v.target.value),onKeyDown:v=>{v.key==="Enter"&&xt.trim()&&Ht(xt.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"}),c.jsx("button",{onClick:()=>xt.trim()&&Ht(xt.trim()),disabled:ni||!xt.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&&c.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[c.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),c.jsx("p",{className:"text-xs text-danger/80",children:un})]}),(z==null?void 0:z.status)==="error"&&c.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{onClick:El,disabled:cn,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:cn?"Fixing...":"Fix Error"}),c.jsx("button",{onClick:()=>Ht(X.dev_command||xt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),z.auto_fix_status&&c.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),c.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",z.auto_fix_status]}),z.auto_fix_attempts!==void 0&&z.auto_fix_attempts>0&&c.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",z.auto_fix_attempts,"/3"]})]}),z.output.length>0&&c.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:z.output.slice(-10).join(`
|
|
217
|
+
`)})]}),X.port&&!(z!=null&&z.running)&&c.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",X.port]})]}):c.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&c.jsx("div",{className:"h-full flex flex-col",children:c.jsxs("div",{className:"p-6 overflow-y-auto",children:[c.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),c.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",c.jsx("span",{className:"font-semibold text-ink capitalize",children:st})]}),c.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(v=>c.jsx("button",{onClick:()=>{Ve(v),sessionStorage.setItem(`pl_provider_${b.id}`,v),ee.setProvider(v).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${st===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))})]}),c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),c.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(v=>c.jsx("button",{onClick:()=>{$t(v),sessionStorage.setItem(`pl_buildmode_${b.id}`,v)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${Oe===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))})]}),c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),c.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"})]}),c.jsxs("div",{className:"card p-4",children:[c.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),c.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"})]})]})]})}),f==="secrets"&&c.jsx(Rp,{}),f==="prd"&&c.jsx("div",{className:"h-full flex flex-col",children:c.jsxs("div",{className:"p-6 overflow-y-auto",children:[c.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),b.prd?c.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}):c.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No PRD found for this project."})]})}),f==="dashboard"&&(le===!1?c.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[c.jsx(Mn,{size:48,className:"text-muted/30"}),c.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),c.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."}),c.jsx("button",{onClick:async()=>{Ee(null);try{const v=await fetch(`http://127.0.0.1:${se}/health`);Ee(v.ok)}catch{Ee(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):c.jsxs("div",{className:"h-full flex flex-col",children:[c.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=>c.jsx("button",{onClick:()=>Z(v.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${V===v.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:v.label},v.id)),c.jsx("div",{className:"flex-1"}),c.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 ",c.jsx(En,{size:12})]})]}),c.jsx("iframe",{src:`http://127.0.0.1:${se}/#${V}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]}))]})]})})]})}),Y&&c.jsx(tr,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),Y&&c.jsx(Si,{defaultSize:30,minSize:15,collapsible:!0,children:c.jsx(ss,{name:"ActivityPanel",children:c.jsx(xp,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:b.status==="running"||b.status==="in_progress",buildMode:Oe})})})]})}),(_e==null?void 0:_e.loading)&&c.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),c.jsxs("span",{className:"text-sm font-medium text-ink",children:[_e.type==="review"?"Reviewing project":_e.type==="test"?"Generating tests":"Analyzing project","..."]}),c.jsxs("span",{className:"text-xs font-mono text-muted",children:[_e.elapsed,"s"]})]})}),ie&&c.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:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),c.jsx(dt,{icon:Di,label:"Close",size:"sm",onClick:()=>Te(null)})]}),c.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ie})]}),x&&c.jsx(Vd,{x:x.x,y:x.y,items:Nl(x),onClose:()=>L(null)}),D&&c.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:()=>W(!1),children:c.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:v=>v.stopPropagation(),children:[c.jsx("input",{ref:N,type:"text",value:U,onChange: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"&&ai.length>0&&(oi(ai[0].path,ai[0].name),W(!1)),v.key==="Escape"&&W(!1)}}),c.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[ai.slice(0,20).map(v=>c.jsxs("button",{onClick:()=>{oi(v.path,v.name),W(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[c.jsx("span",{className:"w-5 flex items-center justify-center",children:Ir(v.name,"file")}),c.jsx("span",{className:"text-ink",children:v.name}),c.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:v.path})]},v.path)),ai.length===0&&c.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),c.jsx(Ep,{open:Il,onClose:()=>Sn(!1)})]})}function Fp(){const{sessionId:e}=ql(),t=Vl(),[i,s]=g.useState(null),[r,n]=g.useState(!0),[o,a]=g.useState(null);return g.useEffect(()=>{e&&(n(!0),a(null),ee.getSessionDetail(e).then(h=>{s(h),n(!1)}).catch(h=>{a(h instanceof Error?h.message:"Failed to load session"),n(!1)}))},[e]),r?c.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),c.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):o||!i?c.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:c.jsxs("div",{className:"text-center",children:[c.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),c.jsx("p",{className:"text-xs text-muted mt-1",children:o||`Session ${e} does not exist`}),c.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"})]})}):c.jsx("div",{className:"h-screen bg-background flex flex-col",children:c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(ss,{name:"ProjectWorkspace",children:c.jsx(Pp,{session:i,onClose:()=>t("/")})})})})}export{Fp as default};
|