loki-mode 6.74.1 → 6.74.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/{AdminPage-DSVmBtfU.js → AdminPage-DZhVlTXm.js} +1 -1
- package/web-app/dist/assets/{Avatar-iQomSLqm.js → Avatar-Bbw5Q-Wz.js} +1 -1
- package/web-app/dist/assets/{Badge-CRQf9raK.js → Badge-iZ84_iz4.js} +1 -1
- package/web-app/dist/assets/{Button-6Zk1L1cC.js → Button-DO-Xq3YT.js} +1 -1
- package/web-app/dist/assets/{ComparePage-CAKioZhP.js → ComparePage-CMjaGKwJ.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-Bb_2EF_6.js → GitHubIssuesPanel-TLudouS-.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-DYOecXRG.js → GitHubPRsPanel-bjj0yQTk.js} +1 -1
- package/web-app/dist/assets/{HomePage-DlSguM1Q.js → HomePage-t5G7OAGE.js} +1 -1
- package/web-app/dist/assets/{LoginPage-D9XLoEDY.js → LoginPage-CeQRXV4C.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-83qdwlaU.js → MetricsPage-B2zKVyJq.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-NluBAEO7.js → NotFoundPage-CxCe17V-.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-CDA2ae03.js → ProjectPage-B1Wti2GW.js} +66 -66
- package/web-app/dist/assets/{ProjectsPage-D-jr3x9O.js → ProjectsPage-BDWfVwLK.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-DpbxZSt5.js → SettingsPage-DlH1leQV.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-D-kDpbLm.js → ShowcasePage-DPnh3esb.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-GqkBfeIX.js → SystemSettingsPage-DZLDjoUr.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-Cq0qdHn2.js → TeamsPage-BbYt_ldg.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-BfMR3aIm.js → TemplatesPage-BuiIghxK.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-CrRPhsRz.js → TerminalOutput-xGAottmX.js} +1 -1
- package/web-app/dist/assets/{activity-C-_9ghb5.js → activity-CmQBMOsV.js} +1 -1
- package/web-app/dist/assets/{bell-B_GMuNpB.js → bell-BzaVT-q-.js} +1 -1
- package/web-app/dist/assets/{bot-aZr-7umF.js → bot-CwK5RJjE.js} +1 -1
- package/web-app/dist/assets/{check-D6wFq8bk.js → check-CxwV5Bzq.js} +1 -1
- package/web-app/dist/assets/{chevron-left-BNnuWY4z.js → chevron-left--TWMaYeL.js} +1 -1
- package/web-app/dist/assets/{circle-alert-CnP3jeCc.js → circle-alert-BeU0GAf7.js} +1 -1
- package/web-app/dist/assets/{clock-ClgakR4Z.js → clock-CasItKBM.js} +1 -1
- package/web-app/dist/assets/{cloud-D0xieZg5.js → cloud-p2bU6CXv.js} +1 -1
- package/web-app/dist/assets/{copy-C285R_fX.js → copy-BD_1Idwb.js} +1 -1
- package/web-app/dist/assets/{database-mdGcS39f.js → database-DpRtc5nU.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-BC6TADZT.js → dollar-sign-22E4a6bP.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-B1p5CnHA.js → file-code-corner-D1Re8J8b.js} +1 -1
- package/web-app/dist/assets/{file-plus-BSk4yJzf.js → file-plus-BuKNP2FZ.js} +1 -1
- package/web-app/dist/assets/{folder-open-B7QbzD3h.js → folder-open-DI7rcz5V.js} +1 -1
- package/web-app/dist/assets/{git-commit-horizontal-EX05JMQ0.js → git-commit-horizontal-C4J-dLq2.js} +1 -1
- package/web-app/dist/assets/{globe-D3hBe7DD.js → globe-3vM1jtqs.js} +1 -1
- package/web-app/dist/assets/{hammer-D2PC2fIG.js → hammer-ukr7gJ35.js} +1 -1
- package/web-app/dist/assets/{index-E5sBU86N.js → index-BYtEgkrl.js} +12 -12
- package/web-app/dist/assets/{layers-a282sv4e.js → layers-DZtUCskD.js} +1 -1
- package/web-app/dist/assets/{lightbulb-C5hiAWsm.js → lightbulb-CS390qaD.js} +1 -1
- package/web-app/dist/assets/{loader-circle-Ci-OWEEc.js → loader-circle-BB_MVBmf.js} +1 -1
- package/web-app/dist/assets/{lock-BbcHkL-_.js → lock-BtBqgsZ0.js} +1 -1
- package/web-app/dist/assets/{mail-Zom9mgsv.js → mail-rabbO_5W.js} +1 -1
- package/web-app/dist/assets/{package-DSEab8Te.js → package-MkQHuN6g.js} +1 -1
- package/web-app/dist/assets/{plus-D5MQ_Vkt.js → plus-C_Sb_op9.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-CG_nDxiH.js → refresh-cw-DEs70a7E.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-agat414Q.js → rotate-ccw-DvMVZ3AX.js} +1 -1
- package/web-app/dist/assets/{save-C4RFt-bD.js → save-DOEP5ubi.js} +1 -1
- package/web-app/dist/assets/{server-D_AeO3vG.js → server-DJBVZTUn.js} +1 -1
- package/web-app/dist/assets/{shield-alert-Da7Bj9HC.js → shield-alert-xdJ97H55.js} +1 -1
- package/web-app/dist/assets/{trash-2-S4CiRzBK.js → trash-2-DuD7ogiq.js} +1 -1
- package/web-app/dist/assets/{trending-down-8qM2V_wO.js → trending-down-BYq7V2Q5.js} +1 -1
- package/web-app/dist/assets/{trending-up-DVLalru7.js → trending-up-BeD-iNQC.js} +1 -1
- package/web-app/dist/assets/{usePolling-DxBJjX_P.js → usePolling-2LO_f1l4.js} +1 -1
- package/web-app/dist/assets/{user-Dmxx5pWF.js → user-CJc2DWfN.js} +1 -1
- package/web-app/dist/index.html +1 -1
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-
|
|
2
|
-
var ea=e=>{throw TypeError(e)};var ta=(e,t,s)=>t.has(e)||ea("Cannot "+s);var
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-TLudouS-.js","assets/index-BYtEgkrl.js","assets/index-CVM4A1Fw.css","assets/Button-DO-Xq3YT.js","assets/refresh-cw-DEs70a7E.js","assets/circle-alert-BeU0GAf7.js","assets/user-CJc2DWfN.js","assets/rotate-ccw-DvMVZ3AX.js","assets/loader-circle-BB_MVBmf.js","assets/TerminalOutput-xGAottmX.js","assets/lock-BtBqgsZ0.js","assets/package-MkQHuN6g.js","assets/file-code-corner-D1Re8J8b.js","assets/file-plus-BuKNP2FZ.js","assets/clock-CasItKBM.js","assets/activity-CmQBMOsV.js","assets/bot-CwK5RJjE.js","assets/check-CxwV5Bzq.js","assets/hammer-ukr7gJ35.js","assets/dollar-sign-22E4a6bP.js","assets/globe-3vM1jtqs.js","assets/copy-BD_1Idwb.js","assets/git-commit-horizontal-C4J-dLq2.js","assets/plus-C_Sb_op9.js","assets/trash-2-DuD7ogiq.js","assets/trending-down-BYq7V2Q5.js","assets/save-DOEP5ubi.js","assets/trending-up-BeD-iNQC.js","assets/layers-DZtUCskD.js","assets/folder-open-DI7rcz5V.js","assets/server-DJBVZTUn.js","assets/GitHubPRsPanel-bjj0yQTk.js","assets/chevron-left--TWMaYeL.js","assets/shield-alert-xdJ97H55.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ea=e=>{throw TypeError(e)};var ta=(e,t,s)=>t.has(e)||ea("Cannot "+s);var Fs=(e,t,s)=>(ta(e,t,"read from private field"),s?s.call(e):t.get(e)),sa=(e,t,s)=>t.has(e)?ea("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ia=(e,t,s,i)=>(ta(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as oe,r as d,W as ks,j as r,f as Wl,g as lr,h as ls,I as Ul,T as Ot,R as $t,i as es,M as Kl,k as Ji,l as kt,S as ql,U as pd,X as ft,m as ts,Z as Zt,a as K,E as ss,G as ze,K as _d,n as gd,o as xd,F as cr,P as It,_ as Xn,b as hr,p as Vl,q as Gl,s as vd,t as bd,A as Jn,L as yd,B as Jr,v as Zr,w as Sd,e as wd,x as ys,y as ra,z as na,D as Cd,H as kd,J as Nr,N as Nd,u as jd}from"./index-BYtEgkrl.js";import{T as Ed,R as Rd,S as Zi,C as Qr,P as Yl,F as Dd,E as $i}from"./TerminalOutput-xGAottmX.js";import{B as ue}from"./Button-DO-Xq3YT.js";import{P as Xl}from"./package-MkQHuN6g.js";import{F as Z}from"./file-code-corner-D1Re8J8b.js";import{F as dr}from"./file-plus-BuKNP2FZ.js";import{C as nt}from"./clock-CasItKBM.js";import{A as Pd}from"./activity-CmQBMOsV.js";import{B as Md}from"./bot-CwK5RJjE.js";import{C as Ut}from"./check-CxwV5Bzq.js";import{L as di}from"./loader-circle-BB_MVBmf.js";import{H as Ld}from"./hammer-ukr7gJ35.js";import{D as Jl}from"./dollar-sign-22E4a6bP.js";import{R as Ct}from"./refresh-cw-DEs70a7E.js";import{C as Ds}from"./circle-alert-BeU0GAf7.js";import{G as en}from"./globe-3vM1jtqs.js";import{C as Zn}from"./copy-BD_1Idwb.js";import{G as Zl}from"./git-commit-horizontal-C4J-dLq2.js";import{P as ur}from"./plus-C_Sb_op9.js";import{T as Qn}from"./trash-2-DuD7ogiq.js";import{R as Ql,E as Bd}from"./rotate-ccw-DvMVZ3AX.js";import{M as ec,T as Td}from"./trending-down-BYq7V2Q5.js";import{S as zd}from"./save-DOEP5ubi.js";import{T as Ad}from"./trending-up-BeD-iNQC.js";import{L as Od}from"./layers-DZtUCskD.js";import{F as tn}from"./folder-open-DI7rcz5V.js";import{S as $d}from"./server-DJBVZTUn.js";/**
|
|
3
3
|
* @license lucide-react v0.577.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const Id=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Fd=oe("at-sign",Id);/**
|
|
8
8
|
* @license lucide-react v0.577.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const
|
|
12
|
+
*/const Hd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],tc=oe("ban",Hd);/**
|
|
13
13
|
* @license lucide-react v0.577.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const
|
|
17
|
+
*/const Wd=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Ud=oe("camera",Wd);/**
|
|
18
18
|
* @license lucide-react v0.577.0 - ISC
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
21
|
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const
|
|
22
|
+
*/const Kd=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],qd=oe("check-check",Kd);/**
|
|
23
23
|
* @license lucide-react v0.577.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
26
|
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const
|
|
27
|
+
*/const Vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Gd=oe("circle-dot",Vd);/**
|
|
28
28
|
* @license lucide-react v0.577.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const
|
|
32
|
+
*/const Yd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Xd=oe("compass",Yd);/**
|
|
33
33
|
* @license lucide-react v0.577.0 - ISC
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
36
|
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const
|
|
37
|
+
*/const Jd=[["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"}]],eo=oe("file-braces",Jd);/**
|
|
38
38
|
* @license lucide-react v0.577.0 - ISC
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const
|
|
42
|
+
*/const Zd=[["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"}]],sc=oe("file-code",Zd);/**
|
|
43
43
|
* @license lucide-react v0.577.0 - ISC
|
|
44
44
|
*
|
|
45
45
|
* This source code is licensed under the ISC license.
|
|
46
46
|
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const
|
|
47
|
+
*/const Qd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],ic=oe("file-question-mark",Qd);/**
|
|
48
48
|
* @license lucide-react v0.577.0 - ISC
|
|
49
49
|
*
|
|
50
50
|
* This source code is licensed under the ISC license.
|
|
51
51
|
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const
|
|
52
|
+
*/const eu=[["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"}]],to=oe("file-type",eu);/**
|
|
53
53
|
* @license lucide-react v0.577.0 - ISC
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the ISC license.
|
|
56
56
|
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const
|
|
57
|
+
*/const tu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],su=oe("file-x",tu);/**
|
|
58
58
|
* @license lucide-react v0.577.0 - ISC
|
|
59
59
|
*
|
|
60
60
|
* This source code is licensed under the ISC license.
|
|
61
61
|
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const
|
|
62
|
+
*/const iu=[["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"}]],so=oe("file",iu);/**
|
|
63
63
|
* @license lucide-react v0.577.0 - ISC
|
|
64
64
|
*
|
|
65
65
|
* This source code is licensed under the ISC license.
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const
|
|
67
|
+
*/const ru=[["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"}]],io=oe("folder",ru);/**
|
|
68
68
|
* @license lucide-react v0.577.0 - ISC
|
|
69
69
|
*
|
|
70
70
|
* This source code is licensed under the ISC license.
|
|
71
71
|
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const
|
|
72
|
+
*/const nu=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],sn=oe("git-pull-request",nu);/**
|
|
73
73
|
* @license lucide-react v0.577.0 - ISC
|
|
74
74
|
*
|
|
75
75
|
* This source code is licensed under the ISC license.
|
|
76
76
|
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/const
|
|
77
|
+
*/const ou=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],au=oe("github",ou);/**
|
|
78
78
|
* @license lucide-react v0.577.0 - ISC
|
|
79
79
|
*
|
|
80
80
|
* This source code is licensed under the ISC license.
|
|
81
81
|
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const
|
|
82
|
+
*/const lu=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],cu=oe("hash",lu);/**
|
|
83
83
|
* @license lucide-react v0.577.0 - ISC
|
|
84
84
|
*
|
|
85
85
|
* This source code is licensed under the ISC license.
|
|
86
86
|
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const
|
|
87
|
+
*/const hu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],rn=oe("history",hu);/**
|
|
88
88
|
* @license lucide-react v0.577.0 - ISC
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the ISC license.
|
|
91
91
|
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const
|
|
92
|
+
*/const du=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],oa=oe("image",du);/**
|
|
93
93
|
* @license lucide-react v0.577.0 - ISC
|
|
94
94
|
*
|
|
95
95
|
* This source code is licensed under the ISC license.
|
|
96
96
|
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const
|
|
97
|
+
*/const uu=[["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"}]],fu=oe("key-round",uu);/**
|
|
98
98
|
* @license lucide-react v0.577.0 - ISC
|
|
99
99
|
*
|
|
100
100
|
* This source code is licensed under the ISC license.
|
|
101
101
|
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const
|
|
102
|
+
*/const mu=[["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"}]],jr=oe("layout-dashboard",mu);/**
|
|
103
103
|
* @license lucide-react v0.577.0 - ISC
|
|
104
104
|
*
|
|
105
105
|
* This source code is licensed under the ISC license.
|
|
106
106
|
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/const
|
|
107
|
+
*/const pu=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],rc=oe("link",pu);/**
|
|
108
108
|
* @license lucide-react v0.577.0 - ISC
|
|
109
109
|
*
|
|
110
110
|
* This source code is licensed under the ISC license.
|
|
111
111
|
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
-
*/const
|
|
112
|
+
*/const _u=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],fr=oe("loader",_u);/**
|
|
113
113
|
* @license lucide-react v0.577.0 - ISC
|
|
114
114
|
*
|
|
115
115
|
* This source code is licensed under the ISC license.
|
|
116
116
|
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
-
*/const
|
|
117
|
+
*/const gu=[["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"}]],nn=oe("maximize-2",gu);/**
|
|
118
118
|
* @license lucide-react v0.577.0 - ISC
|
|
119
119
|
*
|
|
120
120
|
* This source code is licensed under the ISC license.
|
|
121
121
|
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
-
*/const
|
|
122
|
+
*/const xu=[["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"}]],nc=oe("minimize-2",xu);/**
|
|
123
123
|
* @license lucide-react v0.577.0 - ISC
|
|
124
124
|
*
|
|
125
125
|
* This source code is licensed under the ISC license.
|
|
126
126
|
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
-
*/const
|
|
127
|
+
*/const vu=[["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"}]],bu=oe("panel-bottom-close",vu);/**
|
|
128
128
|
* @license lucide-react v0.577.0 - ISC
|
|
129
129
|
*
|
|
130
130
|
* This source code is licensed under the ISC license.
|
|
131
131
|
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
-
*/const
|
|
132
|
+
*/const yu=[["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"}]],Su=oe("panel-bottom-open",yu);/**
|
|
133
133
|
* @license lucide-react v0.577.0 - ISC
|
|
134
134
|
*
|
|
135
135
|
* This source code is licensed under the ISC license.
|
|
136
136
|
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const
|
|
137
|
+
*/const wu=[["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"}]],Cu=oe("panel-left-open",wu);/**
|
|
138
138
|
* @license lucide-react v0.577.0 - ISC
|
|
139
139
|
*
|
|
140
140
|
* This source code is licensed under the ISC license.
|
|
141
141
|
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const
|
|
142
|
+
*/const ku=[["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"}]],Nu=oe("scroll-text",ku);/**
|
|
143
143
|
* @license lucide-react v0.577.0 - ISC
|
|
144
144
|
*
|
|
145
145
|
* This source code is licensed under the ISC license.
|
|
146
146
|
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/const
|
|
147
|
+
*/const ju=[["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"}]],Eu=oe("send",ju);/**
|
|
148
148
|
* @license lucide-react v0.577.0 - ISC
|
|
149
149
|
*
|
|
150
150
|
* This source code is licensed under the ISC license.
|
|
151
151
|
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
-
*/const
|
|
152
|
+
*/const Ru=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],ro=oe("share-2",Ru);/**
|
|
153
153
|
* @license lucide-react v0.577.0 - ISC
|
|
154
154
|
*
|
|
155
155
|
* This source code is licensed under the ISC license.
|
|
156
156
|
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/const
|
|
157
|
+
*/const Du=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Pu=oe("smartphone",Du);/**
|
|
158
158
|
* @license lucide-react v0.577.0 - ISC
|
|
159
159
|
*
|
|
160
160
|
* This source code is licensed under the ISC license.
|
|
161
161
|
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
-
*/const
|
|
162
|
+
*/const Mu=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],Lu=oe("tablet",Mu);/**
|
|
163
163
|
* @license lucide-react v0.577.0 - ISC
|
|
164
164
|
*
|
|
165
165
|
* This source code is licensed under the ISC license.
|
|
166
166
|
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
-
*/const
|
|
167
|
+
*/const Bu=[["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"}]],si=oe("test-tube-diagonal",Bu);/**
|
|
168
168
|
* @license lucide-react v0.577.0 - ISC
|
|
169
169
|
*
|
|
170
170
|
* This source code is licensed under the ISC license.
|
|
171
171
|
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
-
*/const
|
|
172
|
+
*/const Tu=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],zu=oe("thumbs-down",Tu);/**
|
|
173
173
|
* @license lucide-react v0.577.0 - ISC
|
|
174
174
|
*
|
|
175
175
|
* This source code is licensed under the ISC license.
|
|
176
176
|
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
-
*/const
|
|
177
|
+
*/const Au=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],Ou=oe("thumbs-up",Au);/**
|
|
178
178
|
* @license lucide-react v0.577.0 - ISC
|
|
179
179
|
*
|
|
180
180
|
* This source code is licensed under the ISC license.
|
|
181
181
|
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
-
*/const
|
|
182
|
+
*/const $u=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],oc=oe("timer",$u);/**
|
|
183
183
|
* @license lucide-react v0.577.0 - ISC
|
|
184
184
|
*
|
|
185
185
|
* This source code is licensed under the ISC license.
|
|
186
186
|
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
-
*/const
|
|
187
|
+
*/const Iu=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Fu=oe("unplug",Iu);/**
|
|
188
188
|
* @license lucide-react v0.577.0 - ISC
|
|
189
189
|
*
|
|
190
190
|
* This source code is licensed under the ISC license.
|
|
191
191
|
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
-
*/const
|
|
193
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function la(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ca(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?la(Object(s),!0).forEach(function(i){
|
|
192
|
+
*/const Hu=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ac=oe("upload",Hu);function aa(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function Wu(e){if(Array.isArray(e))return e}function Uu(e,t,s){return(t=Ju(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Ku(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,n,o,a,l=[],h=!0,c=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(h=(i=o.call(s)).done)&&(l.push(i.value),l.length!==t);h=!0);}catch(u){c=!0,n=u}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(c)throw n}}return l}}function qu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
193
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function la(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ca(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?la(Object(s),!0).forEach(function(i){Uu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):la(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Vu(e,t){if(e==null)return{};var s,i,n=Gu(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)s=o[i],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Gu(e,t){if(e==null)return{};var s={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;s[i]=e[i]}return s}function Yu(e,t){return Wu(e)||Ku(e,t)||Zu(e,t)||qu()}function Xu(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var i=s.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ju(e){var t=Xu(e,"string");return typeof t=="symbol"?t:t+""}function Zu(e,t){if(e){if(typeof e=="string")return aa(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?aa(e,t):void 0}}function Qu(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function ha(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function da(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ha(Object(s),!0).forEach(function(i){Qu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ha(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function ef(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(i){return t.reduceRight(function(n,o){return o(n)},i)}}function Gs(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function Qi(e){return{}.toString.call(e).includes("Object")}function tf(e){return!Object.keys(e).length}function oi(e){return typeof e=="function"}function sf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function rf(e,t){return Qi(t)||Ft("changeType"),Object.keys(t).some(function(s){return!sf(e,s)})&&Ft("changeField"),t}function nf(e){oi(e)||Ft("selectorType")}function of(e){oi(e)||Qi(e)||Ft("handlerType"),Qi(e)&&Object.values(e).some(function(t){return!oi(t)})&&Ft("handlersType")}function af(e){e||Ft("initialIsRequired"),Qi(e)||Ft("initialType"),tf(e)&&Ft("initialContent")}function lf(e,t){throw new Error(e[t]||e.default)}var cf={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"},Ft=Gs(lf)(cf),Ri={changes:rf,selector:nf,handler:of,initial:af};function hf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ri.initial(e),Ri.handler(t);var s={current:e},i=Gs(ff)(s,t),n=Gs(uf)(s),o=Gs(Ri.changes)(e),a=Gs(df)(s);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Ri.selector(c),c(s.current)}function h(c){ef(i,n,o,a)(c)}return[l,h]}function df(e,t){return oi(t)?t(e.current):t}function uf(e,t){return e.current=da(da({},e.current),t),t}function ff(e,t,s){return oi(t)?t(e.current):Object.keys(s).forEach(function(i){var n;return(n=t[i])===null||n===void 0?void 0:n.call(t,e.current[i])}),s}var mf={create:hf},pf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function _f(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function gf(e){return{}.toString.call(e).includes("Object")}function xf(e){return e||ua("configIsRequired"),gf(e)||ua("configType"),e.urls?(vf(),{paths:{vs:e.urls.monacoBase}}):e}function vf(){console.warn(lc.deprecation)}function bf(e,t){throw new Error(e[t]||e.default)}var lc={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!
|
|
194
194
|
You are using deprecated way of configuration.
|
|
195
195
|
|
|
196
196
|
Instead of using
|
|
@@ -199,7 +199,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
199
199
|
monaco.config({ paths: { vs: '...' } })
|
|
200
200
|
|
|
201
201
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
202
|
-
`},ua=gf(yf)(lc),Sf={config:vf},wf=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function cc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],cc(e[s],t[s]))}),ca(ca({},e),t)}var Cf={type:"cancelation",msg:"operation is manually canceled"};function Er(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(Cf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var kf=["monaco"],Nf=pf.create({config:_f,isInitialized:!1,resolve:null,reject:null,monaco:null}),hc=Xu(Nf,2),fi=hc[0],mr=hc[1];function jf(e){var t=Sf.config(e),s=t.monaco,i=Gu(t,kf);mr(function(n){return{config:cc(n.config,i),monaco:s}})}function Ef(){var e=fi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(mr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Er(Rr);if(window.monaco&&window.monaco.editor)return dc(window.monaco),e.resolve(window.monaco),Er(Rr);wf(Rf,Pf)(Mf)}return Er(Rr)}function Rf(e){return document.body.appendChild(e)}function Df(e){var t=document.createElement("script");return e&&(t.src=e),t}function Pf(e){var t=fi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Df("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Mf(){var e=fi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;dc(i),e.resolve(i)},function(s){e.reject(s)})}function dc(e){fi().monaco||mr({monaco:e})}function Lf(){return fi(function(e){var t=e.monaco;return t})}var Rr=new Promise(function(e,t){return mr({resolve:e,reject:t})}),uc={config:jf,init:Ef,__getMonacoInstance:Lf},Bf={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Dr=Bf,Tf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},zf=Tf;function Af({children:e}){return Ns.createElement("div",{style:zf.container},e)}var Of=Af,$f=Of;function If({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ns.createElement("section",{style:{...Dr.wrapper,width:e,height:t},...a},!s&&Ns.createElement($f,null,i),Ns.createElement("div",{ref:n,style:{...Dr.fullWidth,...!s&&Dr.hide},className:o}))}var Ff=If,fc=d.memo(Ff);function Hf(e){d.useEffect(e,[])}var mc=Hf;function Wf(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var Qe=Wf;function ri(){}function ws(e,t,s,i){return Uf(e,i)||Kf(e,t,s,i)}function Uf(e,t){return e.editor.getModel(pc(e,t))}function Kf(e,t,s,i){return e.editor.createModel(t,s,i?pc(e,i):void 0)}function pc(e,t){return e.Uri.parse(t)}function qf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:g="100%",className:p,wrapperProps:_={},beforeMount:v=ri,onMount:y=ri}){let[x,k]=d.useState(!1),[N,w]=d.useState(!0),R=d.useRef(null),T=d.useRef(null),W=d.useRef(null),G=d.useRef(y),U=d.useRef(v),A=d.useRef(!1);mc(()=>{let S=uc.init();return S.then(j=>(T.current=j)&&w(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>R.current?L():S.cancel()}),Qe(()=>{if(R.current&&T.current){let S=R.current.getOriginalEditor(),j=ws(T.current,e||"",i||s||"text",o||"");j!==S.getModel()&&S.setModel(j)}},[o],x),Qe(()=>{if(R.current&&T.current){let S=R.current.getModifiedEditor(),j=ws(T.current,t||"",n||s||"text",a||"");j!==S.getModel()&&S.setModel(j)}},[a],x),Qe(()=>{let S=R.current.getModifiedEditor();S.getOption(T.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),Qe(()=>{var S,j;(j=(S=R.current)==null?void 0:S.getModel())==null||j.original.setValue(e||"")},[e],x),Qe(()=>{let{original:S,modified:j}=R.current.getModel();T.current.editor.setModelLanguage(S,i||s||"text"),T.current.editor.setModelLanguage(j,n||s||"text")},[s,i,n],x),Qe(()=>{var S;(S=T.current)==null||S.editor.setTheme(c)},[c],x),Qe(()=>{var S;(S=R.current)==null||S.updateOptions(m)},[m],x);let M=d.useCallback(()=>{var C;if(!T.current)return;U.current(T.current);let S=ws(T.current,e||"",i||s||"text",o||""),j=ws(T.current,t||"",n||s||"text",a||"");(C=R.current)==null||C.setModel({original:S,modified:j})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&W.current&&(R.current=T.current.editor.createDiffEditor(W.current,{automaticLayout:!0,...m}),M(),(S=T.current)==null||S.editor.setTheme(c),k(!0),A.current=!0)},[m,c,M]);d.useEffect(()=>{x&&G.current(R.current,T.current)},[x]),d.useEffect(()=>{!N&&!x&&E()},[N,x,E]);function L(){var j,C,B,X;let S=(j=R.current)==null?void 0:j.getModel();l||((C=S==null?void 0:S.original)==null||C.dispose()),h||((B=S==null?void 0:S.modified)==null||B.dispose()),(X=R.current)==null||X.dispose()}return Ns.createElement(fc,{width:g,height:f,isEditorReady:x,loading:u,_ref:W,className:p,wrapperProps:_})}var Vf=qf;d.memo(Vf);function Gf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Yf=Gf,Di=new Map;function Xf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:g="100%",height:p="100%",className:_,wrapperProps:v={},beforeMount:y=ri,onMount:x=ri,onChange:k,onValidate:N=ri}){let[w,R]=d.useState(!1),[T,W]=d.useState(!0),G=d.useRef(null),U=d.useRef(null),A=d.useRef(null),M=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),j=Yf(o),C=d.useRef(!1),B=d.useRef(!1);mc(()=>{let q=uc.init();return q.then(Q=>(G.current=Q)&&W(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>U.current?ae():q.cancel()}),Qe(()=>{var Q,ie,he,de;let q=ws(G.current,e||i||"",t||n||"",o||s||"");q!==((Q=U.current)==null?void 0:Q.getModel())&&(m&&Di.set(j,(ie=U.current)==null?void 0:ie.saveViewState()),(he=U.current)==null||he.setModel(q),m&&((de=U.current)==null||de.restoreViewState(Di.get(o))))},[o],w),Qe(()=>{var q;(q=U.current)==null||q.updateOptions(c)},[c],w),Qe(()=>{!U.current||i===void 0||(U.current.getOption(G.current.editor.EditorOption.readOnly)?U.current.setValue(i):i!==U.current.getValue()&&(B.current=!0,U.current.executeEdits("",[{range:U.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),U.current.pushUndoStop(),B.current=!1))},[i],w),Qe(()=>{var Q,ie;let q=(Q=U.current)==null?void 0:Q.getModel();q&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(q,n))},[n],w),Qe(()=>{var q;l!==void 0&&((q=U.current)==null||q.revealLine(l))},[l],w),Qe(()=>{var q;(q=G.current)==null||q.editor.setTheme(a)},[a],w);let X=d.useCallback(()=>{var q;if(!(!A.current||!G.current)&&!C.current){E.current(G.current);let Q=o||s,ie=ws(G.current,i||e||"",t||n||"",Q||"");U.current=(q=G.current)==null?void 0:q.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&U.current.restoreViewState(Di.get(Q)),G.current.editor.setTheme(a),l!==void 0&&U.current.revealLine(l),R(!0),C.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&M.current(U.current,G.current)},[w]),d.useEffect(()=>{!T&&!w&&X()},[T,w,X]),S.current=i,d.useEffect(()=>{var q,Q;w&&k&&((q=L.current)==null||q.dispose(),L.current=(Q=U.current)==null?void 0:Q.onDidChangeModelContent(ie=>{B.current||k(U.current.getValue(),ie)}))},[w,k]),d.useEffect(()=>{if(w){let q=G.current.editor.onDidChangeMarkers(Q=>{var he;let ie=(he=U.current.getModel())==null?void 0:he.uri;if(ie&&Q.find(de=>de.path===ie.path)){let de=G.current.editor.getModelMarkers({resource:ie});N==null||N(de)}});return()=>{q==null||q.dispose()}}return()=>{}},[w,N]);function ae(){var q,Q;(q=L.current)==null||q.dispose(),f?m&&Di.set(o,U.current.saveViewState()):(Q=U.current.getModel())==null||Q.dispose(),U.current.dispose()}return Ns.createElement(fc,{width:g,height:p,isEditorReady:w,loading:h,_ref:A,className:_,wrapperProps:v})}var Jf=Xf,Zf=d.memo(Jf),Qf=Zf;function em(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function tm(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function sm(e){return e/100*window.innerHeight}function im(e){return e/100*window.innerWidth}function rm(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 Xs({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=rm(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=tm(t,n);break}case"em":{i=em(t,n);break}case"vh":{i=sm(n);break}case"vw":{i=im(n);break}}return i}function Ge(e){return parseFloat(e.toFixed(3))}function Rs({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function on(e){const{panels:t}=e,s=Rs({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Ge(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Ge(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.minSize});h=Ge(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Ge(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function an(e,t){return Array.from(t).sort(e==="horizontal"?nm:om)}function nm(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function om(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function _c(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function gc(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 am({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=gc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Pi;function lm(){return Pi===void 0&&(typeof matchMedia=="function"?Pi=!!matchMedia("(pointer:coarse)").matches:Pi=!1),Pi}function xc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=an(s,Array.from(t.children).filter(_c).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,g=[];{let p=-1;for(const _ of o)_.hasAttribute("data-panel")&&(p++,_.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const _ of o)if(_.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===_);if(v){if(f){const y=f.element.getBoundingClientRect(),x=_.getBoundingClientRect();let k;if(h){const N=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(g.length){case 0:{k=[N,w];break}case 1:{const R=g[0],T=am({orientation:s,rects:[y,x],targetRect:R.element.getBoundingClientRect()});k=[R,T===y?w:N];break}default:{k=g;break}}}else g.length?k=g:k=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const N of k){let w="width"in N?N:N.element.getBoundingClientRect();const R=lm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<R){const W=R-w.width;w=new DOMRect(w.x-W/2,w.y,w.width+W,w.height)}if(w.height<R){const W=R-w.height;w=new DOMRect(w.x,w.y-W/2,w.width,w.height+W)}const T=p<=c||p>u;!l&&!T&&a.push({group:e,groupSize:Rs({group:e}),panels:[f,v],separator:"width"in N?void 0:N,rect:w}),l=!1}}h=!1,f=v,g=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===_);v?g.push(v):(f=void 0,g=[])}else h=!0}return a}var zt,$l;let vc=($l=class{constructor(){sa(this,zt,{})}addListener(t,s){const i=Hs(this,zt)[t];return i===void 0?Hs(this,zt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Hs(this,zt)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){ia(this,zt,{})}removeListener(t,s){const i=Hs(this,zt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},zt=new WeakMap,$l),mt=new Map;const bc=new vc;function cm(e){mt=new Map(mt),mt.delete(e)}function fa(e,t){for(const[s]of mt)if(s.id===e)return s}function Ht(e,t){for(const[s,i]of mt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function cs(){return mt}function no(e,t){return bc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Nt(e,t){const s=mt.get(e);mt=new Map(mt),mt.set(e,t),bc.emit("groupChange",{group:e,prev:s,next:t})}function hm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=gc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function dm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function um(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:_a(e),b:_a(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:pa(ma(s.a)),b:pa(ma(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const fm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function mm(e){const t=getComputedStyle(yc(e)??e).display;return t==="flex"||t==="inline-flex"}function pm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||mm(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"||fm.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ma(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),pm(s))return s}return null}function pa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _a(e){const t=[];for(;e;)t.push(e),e=yc(e);return t}function yc(e){const{parentNode:t}=e;return dm(t)?t.host:t}function _m(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 gm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!_c(s)||s.contains(e)||e.contains(s))return!0;if(um(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(_m(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function oo(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=xc(n),a=hm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&gm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function xm(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function He(e,t,s=0){return Math.abs(Ge(e)-Ge(t))<=s}function ut(e,t){return He(e,t)?0:e>t?1:-1}function Cs({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(ut(i,h)<0)if(o){const c=(n+h)/2;ut(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Ge(i),i}function li({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(He(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const _=e<0?m:u,v=s[_];pe(v,`Panel constraints not found for index ${_}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[_];if(pe(N!=null,`Previous layout not found for panel index ${_}`),He(N,y)){const w=k-N;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const _=e<0?u:m,v=s[_];pe(v,`No panel constraints found for index ${_}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[_];if(pe(N!=null,`Previous layout not found for panel index ${_}`),He(N,k)){const w=N-y;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const _=e<0?m:u,v=s[_];pe(v,`Panel constraints not found for index ${_}`);const y=l[_],{collapsible:x,collapsedSize:k,minSize:N}=v;if(x&&ut(y,N)<0)if(e>0){const w=N-k,R=w/2,T=y+e;ut(T,N)<0&&(e=ut(e,R)<=0?0:w)}else{const w=N-k,R=100-w/2,T=y-e;ut(T,N)<0&&(e=ut(100+e,R)>0?0:-w)}break}}{const _=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const k=l[v];pe(k!=null,`Previous layout not found for panel index ${v}`);const N=Cs({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:k,size:100})-k;if(y+=N,v+=_,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let _=e<0?u:m;for(;_>=0&&_<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[_];pe(y!=null,`Previous layout not found for panel index ${_}`);const x=y-v,k=Cs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:y,size:x});if(!He(y,k)&&(f+=y-k,c[_]=k,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(xm(h,c))return n;{const _=e<0?m:u,v=l[_];pe(v!=null,`Previous layout not found for panel index ${_}`);const y=v+f,x=Cs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:v,size:y});if(c[_]=x,!He(x,y)){let k=y-x,N=e<0?m:u;for(;N>=0&&N<s.length;){const w=c[N];pe(w!=null,`Previous layout not found for panel index ${N}`);const R=w+k,T=Cs({overrideDisabledPanels:a,panelConstraints:s[N],prevSize:w,size:R});if(He(w,T)||(k-=T-w,c[N]=T),He(k,0))break;e>0?N--:N++}}}const g=Object.values(c).reduce((_,v)=>v+_,0);if(!He(g,100,.1))return n;const p=Object.keys(n);return c.reduce((_,v,y)=>(_[p[y]]=v,_),{})}function is(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||ut(e[s],t[s])!==0)return!1;return!0}function rs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!He(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=Cs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!He(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=Cs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,He(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Sc({groupId:e,panelId:t}){const s=()=>{const l=cs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:g}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:g};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:g,separatorToPanels:p}=s(),_=m.panels.findIndex(k=>k.id===t),v=_===m.panels.length-1,y=li({delta:v?h-l:l-h,initialLayout:g,panelConstraints:u,pivotIndices:v?[_-1,_]:[_,_+1],prevLayout:g,trigger:"imperative-api"}),x=rs({layout:y,panelConstraints:u});is(g,x)||Nt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&He(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Rs({group:h}),m=Xs({groupSize:u,panelElement:c,styleProp:l}),f=Ge(m/u*100);a(f)}}}function ga(e){if(e.defaultPrevented)return;const t=cs();oo(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=Sc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ii(e){const t=cs();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function wc({groupId:e}){const t=()=>{const s=cs();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=rs({layout:s,panelConstraints:n});return i?l:(is(l,c)||Nt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function qt(e,t){const s=Ii(e),i=Ht(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=wc({groupId:s.id}).getLayout(),h=li({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=rs({layout:h,panelConstraints:i.derivedPanelConstraints});is(l,c)||Nt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function xa(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ii(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&qt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&qt(t,-5);break}case"End":{e.preventDefault(),qt(t,100);break}case"Enter":{e.preventDefault();const i=Ii(t),n=Ht(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],g=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;qt(t,g-f)}break}case"F6":{e.preventDefault();const i=Ii(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),qt(t,-100);break}}}let js={cursorFlags:0,state:"inactive"};const ao=new vc;function ns(){return js}function vm(e){return ao.addListener("change",e)}function bm(e){const t=js,s={...js};s.cursorFlags=e,js=s,ao.emit("change",{prev:t,next:s})}function Es(e){const t=js;js=e,ao.emit("change",{prev:t,next:e})}function va(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=cs(),s=oo(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),Es({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const ym=e=>e,Pr=()=>{},Cc=1,kc=2,Nc=4,jc=8,ba=3,ya=12;let Mi;function Sa(){return Mi===void 0&&(Mi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Mi=!0)),Mi}function Sm({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&Sa()){const o=(e&Cc)!==0,a=(e&kc)!==0,l=(e&Nc)!==0,h=(e&jc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Sa()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const wa=new WeakMap;function lo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=wa.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ns();switch(i.state){case"active":case"hover":{const n=Sm({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}wa.set(e,{prevStyle:t,styleSheet:s})}function Ec({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:g}=u,{disableCursor:p}=u.mutableState;let _=0;o?f==="horizontal"?_=(t.clientX-o.x)/m*100:_=(t.clientY-o.y)/m*100:f==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:w,separatorToPanels:R}=y;if(k&&w&&R){const T=li({delta:_,initialLayout:v,panelConstraints:k,pivotIndices:c.panels.map(W=>g.indexOf(W)),prevLayout:w,trigger:"mouse-or-touch"});if(is(T,w)){if(_!==0&&!p)switch(f){case"horizontal":{l|=_<0?Cc:kc;break}case"vertical":{l|=_<0?Nc:jc;break}}}else Nt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:T,separatorToPanels:R})}});let h=0;t.movementX===0?h|=a&ba:h|=l&ba,t.movementY===0?h|=a&ya:h|=l&ya,bm(h),lo(e)}function Ca(e){const t=cs(),s=ns();switch(s.state){case"active":Ec({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function ka(e){if(e.defaultPrevented)return;const t=ns(),s=cs();switch(t.state){case"active":{if(e.buttons===0){Es({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Ht(i.group.id,!0);Nt(i.group,n)});return}Ec({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=oo(e,s);i.length===0?t.state!=="inactive"&&Es({cursorFlags:0,state:"inactive"}):Es({cursorFlags:0,hitRegions:i,state:"hover"}),lo(e.currentTarget);break}}}function Na(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ns().state){case"hover":Es({cursorFlags:0,state:"inactive"})}}function ja(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ns();switch(t.state){case"active":Es({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(lo(e.currentTarget),t.hitRegions.forEach(s=>{const i=Ht(s.group.id,!0);Nt(s.group,i)}),e.preventDefault())}}function Ea(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Ge(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Ge((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function wm(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Rs({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Ge(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function Cm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function km({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=f/100*s,p=Ge(g/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Ge(f/o*c)}else{const m=Ge(c/h.length);for(const f of h)u[f]=m}return u}function Nm(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const xs=new Map;function jm(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const _ of p){const{borderBoxSize:v,target:y}=_;if(y===e.element){if(t){const x=Rs({group:e});if(x===0)return;const k=Ht(e.id);if(!k)return;const N=on(e),w=k.defaultLayoutDeferred?Ea(N):k.layout,R=km({group:e,nextGroupSize:x,prevGroupSize:k.groupSize,prevLayout:w}),T=rs({layout:R,panelConstraints:N});if(!k.defaultLayoutDeferred&&is(k.layout,T)&&Cm(k.derivedPanelConstraints,N)&&k.groupSize===x)return;Nt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:N,groupSize:x,layout:T,separatorToPanels:k.separatorToPanels})}}else wm(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Rs({group:e}),l=on(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(Nm(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Ea(l),m=rs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;xs.set(f,(xs.get(f)??0)+1);const g=new Map;return xc(e).forEach(p=>{p.separator&&g.set(p.separator,p.panels)}),Nt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:g}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",xa)}),xs.get(f)===1&&(f.addEventListener("dblclick",ga,!0),f.addEventListener("pointerdown",va,!0),f.addEventListener("pointerleave",Ca),f.addEventListener("pointermove",ka),f.addEventListener("pointerout",Na),f.addEventListener("pointerup",ja,!0)),function(){t=!1,xs.set(f,Math.max(0,(xs.get(f)??0)-1)),cm(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",xa)}),xs.get(f)||(f.removeEventListener("dblclick",ga,!0),f.removeEventListener("pointerdown",va,!0),f.removeEventListener("pointerleave",Ca),f.removeEventListener("pointermove",ka),f.removeEventListener("pointerout",Na),f.removeEventListener("pointerup",ja,!0)),o.disconnect()}}function Em(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function co(e){const t=d.useId();return`${e??t}`}const hs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ni(e){const t=d.useRef(e);return hs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function ho(...e){return ni(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function uo(e){const t=d.useRef({...e});return hs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Rc=d.createContext(null);function Rm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:ym});d.useImperativeHandle(t,()=>s.current,[]),hs(()=>{Object.assign(s.current,wc({groupId:e}))})}function ln({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,...g}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=ni(A=>{is(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=ni(A=>{is(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=co(l),x=d.useRef(null),[k,N]=Em(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),R=ho(x,o);Rm(y,a);const T=ni((A,M)=>{const E=ns(),L=fa(A),S=Ht(A);if(S){let j=!1;switch(E.state){case"active":{j=E.hitRegions.some(C=>C.group===L);break}}return{flexGrow:S.layout[M]??1,pointerEvents:j?"none":void 0}}return{flexGrow:(s==null?void 0:s[M])??1}}),W=uo({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!W.disableCursor},getPanelStyles:T,id:y,orientation:u,registerPanel:A=>{const M=w.current;return M.panels=an(u,[...M.panels,A]),N(),()=>{M.panels=M.panels.filter(E=>E!==A),N()}},registerSeparator:A=>{const M=w.current;return M.separators=an(u,[...M.separators,A]),N(),()=>{M.separators=M.separators.filter(E=>E!==A),N()}},togglePanelDisabled:(A,M)=>{const E=w.current.panels.find(j=>j.id===A);E&&(E.panelConstraints.disabled=M);const L=fa(y),S=Ht(y);L&&S&&Nt(L,{...S,derivedPanelConstraints:on(L)})},toggleSeparatorDisabled:(A,M)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=M)}}),[T,y,N,u,W]),U=d.useRef(null);return hs(()=>{const A=x.current;if(A===null)return;const M=w.current;let E;if(W.defaultLayout!==void 0&&Object.keys(W.defaultLayout).length===M.panels.length){E={};for(const ae of M.panels){const q=W.defaultLayout[ae.id];q!==void 0&&(E[ae.id]=q)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!W.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};U.current=L;const S=jm(L),{defaultLayoutDeferred:j,derivedPanelConstraints:C,layout:B}=Ht(L.id,!0);!j&&C.length>0&&(_(B),v(B));const X=no(y,ae=>{const{defaultLayoutDeferred:q,derivedPanelConstraints:Q,layout:ie}=ae.next;if(q||Q.length===0)return;const he=L.panels.map(({id:z})=>z).join(",");L.mutableState.layouts[he]=ie,Q.forEach(z=>{if(z.collapsible){const{layout:V}=ae.prev??{};if(V){const J=He(z.collapsedSize,ie[z.panelId]),D=He(z.collapsedSize,V[z.panelId]);J&&!D&&(L.mutableState.expandedPanelSizes[z.panelId]=V[z.panelId])}}});const de=ns().state!=="active";_(ie),de&&v(ie)});return()=>{U.current=null,S(),X()}},[n,y,v,_,u,k,W]),d.useEffect(()=>{const A=U.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Rc.Provider,{value:G,children:r.jsx("div",{...g,className:t,"data-group":!0,"data-testid":y,id:y,ref:R,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}ln.displayName="Group";function fo(){const e=d.useContext(Rc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Dm(e,t){const{id:s}=fo(),i=d.useRef({collapse:Pr,expand:Pr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Pr});d.useImperativeHandle(t,()=>i.current,[]),hs(()=>{Object.assign(i.current,Sc({groupId:s,panelId:e}))})}function Js({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:g,...p}){const _=!!h,v=co(h),y=uo({disabled:o}),x=d.useRef(null),k=ho(x,a),{getPanelStyles:N,id:w,orientation:R,registerPanel:T,togglePanelDisabled:W}=fo(),G=m!==null,U=ni((M,E,L)=>{m==null||m(M,h,L)});hs(()=>{const M=x.current;if(M!==null){const E={element:M,id:v,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?U:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return T(E)}},[l,s,i,n,G,v,_,c,u,U,T,y]),d.useEffect(()=>{W(v,!!o)},[o,v,W]),Dm(v,f);const A=d.useSyncExternalStore(M=>no(w,M),()=>JSON.stringify(N(w,v)),()=>JSON.stringify(N(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:k,style:{...Pm,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:R==="horizontal"?"pan-y":"pan-x"},children:e})})}Js.displayName="Panel";const Pm={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Mm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=rs({layout:li({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=rs({layout:li({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function cn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=co(n),h=uo({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),g=d.useRef(null),p=ho(g,i),{disableCursor:_,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:k}=fo(),N=y==="horizontal"?"vertical":"horizontal";hs(()=>{const R=g.current;if(R!==null){const T={disabled:h.disabled,element:R,id:l},W=x(T),G=vm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(M=>M.separator===T)?A.next.state:"inactive")}),U=no(v,A=>{const{derivedPanelConstraints:M,layout:E,separatorToPanels:L}=A.next,S=L.get(T);if(S){const j=S[0],C=S.indexOf(j);u(Mm({layout:E,panelConstraints:M,panelId:j.id,panelIndex:C}))}});return()=>{G(),U(),W()}}},[v,l,x,h]),d.useEffect(()=>{k(l,!!s)},[s,l,k]);let w;return s&&!_&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":N,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}cn.displayName="Separator";const Lm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Bm={sm:"w-7 h-7",md:"w-8 h-8"},Tm={sm:14,md:16};function Pt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Lm[i],Bm[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Tm[s]})})}function zm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const g=(f+1)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const g=(f-1+s.length)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:g=>{l.current[u]=g},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},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:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
|
|
202
|
+
`},ua=_f(bf)(lc),yf={config:xf},Sf=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function cc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],cc(e[s],t[s]))}),ca(ca({},e),t)}var wf={type:"cancelation",msg:"operation is manually canceled"};function Er(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(wf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var Cf=["monaco"],kf=mf.create({config:pf,isInitialized:!1,resolve:null,reject:null,monaco:null}),hc=Yu(kf,2),ui=hc[0],mr=hc[1];function Nf(e){var t=yf.config(e),s=t.monaco,i=Vu(t,Cf);mr(function(n){return{config:cc(n.config,i),monaco:s}})}function jf(){var e=ui(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(mr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Er(Rr);if(window.monaco&&window.monaco.editor)return dc(window.monaco),e.resolve(window.monaco),Er(Rr);Sf(Ef,Df)(Pf)}return Er(Rr)}function Ef(e){return document.body.appendChild(e)}function Rf(e){var t=document.createElement("script");return e&&(t.src=e),t}function Df(e){var t=ui(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Rf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Pf(){var e=ui(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;dc(i),e.resolve(i)},function(s){e.reject(s)})}function dc(e){ui().monaco||mr({monaco:e})}function Mf(){return ui(function(e){var t=e.monaco;return t})}var Rr=new Promise(function(e,t){return mr({resolve:e,reject:t})}),uc={config:Nf,init:jf,__getMonacoInstance:Mf},Lf={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Dr=Lf,Bf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Tf=Bf;function zf({children:e}){return ks.createElement("div",{style:Tf.container},e)}var Af=zf,Of=Af;function $f({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return ks.createElement("section",{style:{...Dr.wrapper,width:e,height:t},...a},!s&&ks.createElement(Of,null,i),ks.createElement("div",{ref:n,style:{...Dr.fullWidth,...!s&&Dr.hide},className:o}))}var If=$f,fc=d.memo(If);function Ff(e){d.useEffect(e,[])}var mc=Ff;function Hf(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var Qe=Hf;function ii(){}function Ss(e,t,s,i){return Wf(e,i)||Uf(e,t,s,i)}function Wf(e,t){return e.editor.getModel(pc(e,t))}function Uf(e,t,s,i){return e.editor.createModel(t,s,i?pc(e,i):void 0)}function pc(e,t){return e.Uri.parse(t)}function Kf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:g="100%",className:p,wrapperProps:_={},beforeMount:v=ii,onMount:y=ii}){let[x,k]=d.useState(!1),[N,w]=d.useState(!0),R=d.useRef(null),T=d.useRef(null),W=d.useRef(null),G=d.useRef(y),U=d.useRef(v),A=d.useRef(!1);mc(()=>{let S=uc.init();return S.then(j=>(T.current=j)&&w(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>R.current?L():S.cancel()}),Qe(()=>{if(R.current&&T.current){let S=R.current.getOriginalEditor(),j=Ss(T.current,e||"",i||s||"text",o||"");j!==S.getModel()&&S.setModel(j)}},[o],x),Qe(()=>{if(R.current&&T.current){let S=R.current.getModifiedEditor(),j=Ss(T.current,t||"",n||s||"text",a||"");j!==S.getModel()&&S.setModel(j)}},[a],x),Qe(()=>{let S=R.current.getModifiedEditor();S.getOption(T.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),Qe(()=>{var S,j;(j=(S=R.current)==null?void 0:S.getModel())==null||j.original.setValue(e||"")},[e],x),Qe(()=>{let{original:S,modified:j}=R.current.getModel();T.current.editor.setModelLanguage(S,i||s||"text"),T.current.editor.setModelLanguage(j,n||s||"text")},[s,i,n],x),Qe(()=>{var S;(S=T.current)==null||S.editor.setTheme(c)},[c],x),Qe(()=>{var S;(S=R.current)==null||S.updateOptions(m)},[m],x);let M=d.useCallback(()=>{var C;if(!T.current)return;U.current(T.current);let S=Ss(T.current,e||"",i||s||"text",o||""),j=Ss(T.current,t||"",n||s||"text",a||"");(C=R.current)==null||C.setModel({original:S,modified:j})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&W.current&&(R.current=T.current.editor.createDiffEditor(W.current,{automaticLayout:!0,...m}),M(),(S=T.current)==null||S.editor.setTheme(c),k(!0),A.current=!0)},[m,c,M]);d.useEffect(()=>{x&&G.current(R.current,T.current)},[x]),d.useEffect(()=>{!N&&!x&&E()},[N,x,E]);function L(){var j,C,B,X;let S=(j=R.current)==null?void 0:j.getModel();l||((C=S==null?void 0:S.original)==null||C.dispose()),h||((B=S==null?void 0:S.modified)==null||B.dispose()),(X=R.current)==null||X.dispose()}return ks.createElement(fc,{width:g,height:f,isEditorReady:x,loading:u,_ref:W,className:p,wrapperProps:_})}var qf=Kf;d.memo(qf);function Vf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Gf=Vf,Di=new Map;function Yf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:g="100%",height:p="100%",className:_,wrapperProps:v={},beforeMount:y=ii,onMount:x=ii,onChange:k,onValidate:N=ii}){let[w,R]=d.useState(!1),[T,W]=d.useState(!0),G=d.useRef(null),U=d.useRef(null),A=d.useRef(null),M=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),j=Gf(o),C=d.useRef(!1),B=d.useRef(!1);mc(()=>{let q=uc.init();return q.then(Q=>(G.current=Q)&&W(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>U.current?ae():q.cancel()}),Qe(()=>{var Q,ie,he,de;let q=Ss(G.current,e||i||"",t||n||"",o||s||"");q!==((Q=U.current)==null?void 0:Q.getModel())&&(m&&Di.set(j,(ie=U.current)==null?void 0:ie.saveViewState()),(he=U.current)==null||he.setModel(q),m&&((de=U.current)==null||de.restoreViewState(Di.get(o))))},[o],w),Qe(()=>{var q;(q=U.current)==null||q.updateOptions(c)},[c],w),Qe(()=>{!U.current||i===void 0||(U.current.getOption(G.current.editor.EditorOption.readOnly)?U.current.setValue(i):i!==U.current.getValue()&&(B.current=!0,U.current.executeEdits("",[{range:U.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),U.current.pushUndoStop(),B.current=!1))},[i],w),Qe(()=>{var Q,ie;let q=(Q=U.current)==null?void 0:Q.getModel();q&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(q,n))},[n],w),Qe(()=>{var q;l!==void 0&&((q=U.current)==null||q.revealLine(l))},[l],w),Qe(()=>{var q;(q=G.current)==null||q.editor.setTheme(a)},[a],w);let X=d.useCallback(()=>{var q;if(!(!A.current||!G.current)&&!C.current){E.current(G.current);let Q=o||s,ie=Ss(G.current,i||e||"",t||n||"",Q||"");U.current=(q=G.current)==null?void 0:q.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&U.current.restoreViewState(Di.get(Q)),G.current.editor.setTheme(a),l!==void 0&&U.current.revealLine(l),R(!0),C.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&M.current(U.current,G.current)},[w]),d.useEffect(()=>{!T&&!w&&X()},[T,w,X]),S.current=i,d.useEffect(()=>{var q,Q;w&&k&&((q=L.current)==null||q.dispose(),L.current=(Q=U.current)==null?void 0:Q.onDidChangeModelContent(ie=>{B.current||k(U.current.getValue(),ie)}))},[w,k]),d.useEffect(()=>{if(w){let q=G.current.editor.onDidChangeMarkers(Q=>{var he;let ie=(he=U.current.getModel())==null?void 0:he.uri;if(ie&&Q.find(de=>de.path===ie.path)){let de=G.current.editor.getModelMarkers({resource:ie});N==null||N(de)}});return()=>{q==null||q.dispose()}}return()=>{}},[w,N]);function ae(){var q,Q;(q=L.current)==null||q.dispose(),f?m&&Di.set(o,U.current.saveViewState()):(Q=U.current.getModel())==null||Q.dispose(),U.current.dispose()}return ks.createElement(fc,{width:g,height:p,isEditorReady:w,loading:h,_ref:A,className:_,wrapperProps:v})}var Xf=Yf,Jf=d.memo(Xf),Zf=Jf;function Qf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function em(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function tm(e){return e/100*window.innerHeight}function sm(e){return e/100*window.innerWidth}function im(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 Ys({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=im(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=em(t,n);break}case"em":{i=Qf(t,n);break}case"vh":{i=tm(n);break}case"vw":{i=sm(n);break}}return i}function Ve(e){return parseFloat(e.toFixed(3))}function Es({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function on(e){const{panels:t}=e,s=Es({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Ys({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Ve(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Ys({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Ve(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Ys({groupSize:s,panelElement:n,styleProp:o.minSize});h=Ve(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Ys({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Ve(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function an(e,t){return Array.from(t).sort(e==="horizontal"?rm:nm)}function rm(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function nm(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function _c(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function gc(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 om({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=gc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Pi;function am(){return Pi===void 0&&(typeof matchMedia=="function"?Pi=!!matchMedia("(pointer:coarse)").matches:Pi=!1),Pi}function xc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=an(s,Array.from(t.children).filter(_c).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,g=[];{let p=-1;for(const _ of o)_.hasAttribute("data-panel")&&(p++,_.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const _ of o)if(_.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===_);if(v){if(f){const y=f.element.getBoundingClientRect(),x=_.getBoundingClientRect();let k;if(h){const N=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(g.length){case 0:{k=[N,w];break}case 1:{const R=g[0],T=om({orientation:s,rects:[y,x],targetRect:R.element.getBoundingClientRect()});k=[R,T===y?w:N];break}default:{k=g;break}}}else g.length?k=g:k=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const N of k){let w="width"in N?N:N.element.getBoundingClientRect();const R=am()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<R){const W=R-w.width;w=new DOMRect(w.x-W/2,w.y,w.width+W,w.height)}if(w.height<R){const W=R-w.height;w=new DOMRect(w.x,w.y-W/2,w.width,w.height+W)}const T=p<=c||p>u;!l&&!T&&a.push({group:e,groupSize:Es({group:e}),panels:[f,v],separator:"width"in N?void 0:N,rect:w}),l=!1}}h=!1,f=v,g=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===_);v?g.push(v):(f=void 0,g=[])}else h=!0}return a}var zt,$l;let vc=($l=class{constructor(){sa(this,zt,{})}addListener(t,s){const i=Fs(this,zt)[t];return i===void 0?Fs(this,zt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Fs(this,zt)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){ia(this,zt,{})}removeListener(t,s){const i=Fs(this,zt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},zt=new WeakMap,$l),mt=new Map;const bc=new vc;function lm(e){mt=new Map(mt),mt.delete(e)}function fa(e,t){for(const[s]of mt)if(s.id===e)return s}function Ht(e,t){for(const[s,i]of mt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function cs(){return mt}function no(e,t){return bc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Nt(e,t){const s=mt.get(e);mt=new Map(mt),mt.set(e,t),bc.emit("groupChange",{group:e,prev:s,next:t})}function cm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=gc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function hm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function dm(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:_a(e),b:_a(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:pa(ma(s.a)),b:pa(ma(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const um=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function fm(e){const t=getComputedStyle(yc(e)??e).display;return t==="flex"||t==="inline-flex"}function mm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||fm(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"||um.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ma(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),mm(s))return s}return null}function pa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _a(e){const t=[];for(;e;)t.push(e),e=yc(e);return t}function yc(e){const{parentNode:t}=e;return hm(t)?t.host:t}function pm(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 _m({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!_c(s)||s.contains(e)||e.contains(s))return!0;if(dm(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(pm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function oo(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=xc(n),a=cm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&_m({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function gm(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function He(e,t,s=0){return Math.abs(Ve(e)-Ve(t))<=s}function ut(e,t){return He(e,t)?0:e>t?1:-1}function ws({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(ut(i,h)<0)if(o){const c=(n+h)/2;ut(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Ve(i),i}function ai({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(He(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const _=e<0?m:u,v=s[_];pe(v,`Panel constraints not found for index ${_}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[_];if(pe(N!=null,`Previous layout not found for panel index ${_}`),He(N,y)){const w=k-N;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const _=e<0?u:m,v=s[_];pe(v,`No panel constraints found for index ${_}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[_];if(pe(N!=null,`Previous layout not found for panel index ${_}`),He(N,k)){const w=N-y;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const _=e<0?m:u,v=s[_];pe(v,`Panel constraints not found for index ${_}`);const y=l[_],{collapsible:x,collapsedSize:k,minSize:N}=v;if(x&&ut(y,N)<0)if(e>0){const w=N-k,R=w/2,T=y+e;ut(T,N)<0&&(e=ut(e,R)<=0?0:w)}else{const w=N-k,R=100-w/2,T=y-e;ut(T,N)<0&&(e=ut(100+e,R)>0?0:-w)}break}}{const _=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const k=l[v];pe(k!=null,`Previous layout not found for panel index ${v}`);const N=ws({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:k,size:100})-k;if(y+=N,v+=_,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let _=e<0?u:m;for(;_>=0&&_<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[_];pe(y!=null,`Previous layout not found for panel index ${_}`);const x=y-v,k=ws({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:y,size:x});if(!He(y,k)&&(f+=y-k,c[_]=k,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(gm(h,c))return n;{const _=e<0?m:u,v=l[_];pe(v!=null,`Previous layout not found for panel index ${_}`);const y=v+f,x=ws({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:v,size:y});if(c[_]=x,!He(x,y)){let k=y-x,N=e<0?m:u;for(;N>=0&&N<s.length;){const w=c[N];pe(w!=null,`Previous layout not found for panel index ${N}`);const R=w+k,T=ws({overrideDisabledPanels:a,panelConstraints:s[N],prevSize:w,size:R});if(He(w,T)||(k-=T-w,c[N]=T),He(k,0))break;e>0?N--:N++}}}const g=Object.values(c).reduce((_,v)=>v+_,0);if(!He(g,100,.1))return n;const p=Object.keys(n);return c.reduce((_,v,y)=>(_[p[y]]=v,_),{})}function is(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||ut(e[s],t[s])!==0)return!1;return!0}function rs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!He(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!He(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,He(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Sc({groupId:e,panelId:t}){const s=()=>{const l=cs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:g}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:g};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:g,separatorToPanels:p}=s(),_=m.panels.findIndex(k=>k.id===t),v=_===m.panels.length-1,y=ai({delta:v?h-l:l-h,initialLayout:g,panelConstraints:u,pivotIndices:v?[_-1,_]:[_,_+1],prevLayout:g,trigger:"imperative-api"}),x=rs({layout:y,panelConstraints:u});is(g,x)||Nt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&He(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Es({group:h}),m=Ys({groupSize:u,panelElement:c,styleProp:l}),f=Ve(m/u*100);a(f)}}}function ga(e){if(e.defaultPrevented)return;const t=cs();oo(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=Sc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ii(e){const t=cs();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function wc({groupId:e}){const t=()=>{const s=cs();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=rs({layout:s,panelConstraints:n});return i?l:(is(l,c)||Nt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function qt(e,t){const s=Ii(e),i=Ht(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=wc({groupId:s.id}).getLayout(),h=ai({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=rs({layout:h,panelConstraints:i.derivedPanelConstraints});is(l,c)||Nt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function xa(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ii(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&qt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&qt(t,-5);break}case"End":{e.preventDefault(),qt(t,100);break}case"Enter":{e.preventDefault();const i=Ii(t),n=Ht(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],g=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;qt(t,g-f)}break}case"F6":{e.preventDefault();const i=Ii(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),qt(t,-100);break}}}let Ns={cursorFlags:0,state:"inactive"};const ao=new vc;function ns(){return Ns}function xm(e){return ao.addListener("change",e)}function vm(e){const t=Ns,s={...Ns};s.cursorFlags=e,Ns=s,ao.emit("change",{prev:t,next:s})}function js(e){const t=Ns;Ns=e,ao.emit("change",{prev:t,next:e})}function va(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=cs(),s=oo(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),js({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const bm=e=>e,Pr=()=>{},Cc=1,kc=2,Nc=4,jc=8,ba=3,ya=12;let Mi;function Sa(){return Mi===void 0&&(Mi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Mi=!0)),Mi}function ym({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&Sa()){const o=(e&Cc)!==0,a=(e&kc)!==0,l=(e&Nc)!==0,h=(e&jc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Sa()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const wa=new WeakMap;function lo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=wa.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ns();switch(i.state){case"active":case"hover":{const n=ym({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}wa.set(e,{prevStyle:t,styleSheet:s})}function Ec({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:g}=u,{disableCursor:p}=u.mutableState;let _=0;o?f==="horizontal"?_=(t.clientX-o.x)/m*100:_=(t.clientY-o.y)/m*100:f==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:w,separatorToPanels:R}=y;if(k&&w&&R){const T=ai({delta:_,initialLayout:v,panelConstraints:k,pivotIndices:c.panels.map(W=>g.indexOf(W)),prevLayout:w,trigger:"mouse-or-touch"});if(is(T,w)){if(_!==0&&!p)switch(f){case"horizontal":{l|=_<0?Cc:kc;break}case"vertical":{l|=_<0?Nc:jc;break}}}else Nt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:T,separatorToPanels:R})}});let h=0;t.movementX===0?h|=a&ba:h|=l&ba,t.movementY===0?h|=a&ya:h|=l&ya,vm(h),lo(e)}function Ca(e){const t=cs(),s=ns();switch(s.state){case"active":Ec({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function ka(e){if(e.defaultPrevented)return;const t=ns(),s=cs();switch(t.state){case"active":{if(e.buttons===0){js({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Ht(i.group.id,!0);Nt(i.group,n)});return}Ec({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=oo(e,s);i.length===0?t.state!=="inactive"&&js({cursorFlags:0,state:"inactive"}):js({cursorFlags:0,hitRegions:i,state:"hover"}),lo(e.currentTarget);break}}}function Na(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ns().state){case"hover":js({cursorFlags:0,state:"inactive"})}}function ja(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ns();switch(t.state){case"active":js({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(lo(e.currentTarget),t.hitRegions.forEach(s=>{const i=Ht(s.group.id,!0);Nt(s.group,i)}),e.preventDefault())}}function Ea(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Ve(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Ve((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function Sm(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Es({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Ve(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function wm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Cm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=f/100*s,p=Ve(g/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Ve(f/o*c)}else{const m=Ve(c/h.length);for(const f of h)u[f]=m}return u}function km(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const gs=new Map;function Nm(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const _ of p){const{borderBoxSize:v,target:y}=_;if(y===e.element){if(t){const x=Es({group:e});if(x===0)return;const k=Ht(e.id);if(!k)return;const N=on(e),w=k.defaultLayoutDeferred?Ea(N):k.layout,R=Cm({group:e,nextGroupSize:x,prevGroupSize:k.groupSize,prevLayout:w}),T=rs({layout:R,panelConstraints:N});if(!k.defaultLayoutDeferred&&is(k.layout,T)&&wm(k.derivedPanelConstraints,N)&&k.groupSize===x)return;Nt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:N,groupSize:x,layout:T,separatorToPanels:k.separatorToPanels})}}else Sm(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Es({group:e}),l=on(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(km(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Ea(l),m=rs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;gs.set(f,(gs.get(f)??0)+1);const g=new Map;return xc(e).forEach(p=>{p.separator&&g.set(p.separator,p.panels)}),Nt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:g}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",xa)}),gs.get(f)===1&&(f.addEventListener("dblclick",ga,!0),f.addEventListener("pointerdown",va,!0),f.addEventListener("pointerleave",Ca),f.addEventListener("pointermove",ka),f.addEventListener("pointerout",Na),f.addEventListener("pointerup",ja,!0)),function(){t=!1,gs.set(f,Math.max(0,(gs.get(f)??0)-1)),lm(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",xa)}),gs.get(f)||(f.removeEventListener("dblclick",ga,!0),f.removeEventListener("pointerdown",va,!0),f.removeEventListener("pointerleave",Ca),f.removeEventListener("pointermove",ka),f.removeEventListener("pointerout",Na),f.removeEventListener("pointerup",ja,!0)),o.disconnect()}}function jm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function co(e){const t=d.useId();return`${e??t}`}const hs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ri(e){const t=d.useRef(e);return hs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function ho(...e){return ri(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function uo(e){const t=d.useRef({...e});return hs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Rc=d.createContext(null);function Em(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:bm});d.useImperativeHandle(t,()=>s.current,[]),hs(()=>{Object.assign(s.current,wc({groupId:e}))})}function ln({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,...g}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=ri(A=>{is(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=ri(A=>{is(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=co(l),x=d.useRef(null),[k,N]=jm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),R=ho(x,o);Em(y,a);const T=ri((A,M)=>{const E=ns(),L=fa(A),S=Ht(A);if(S){let j=!1;switch(E.state){case"active":{j=E.hitRegions.some(C=>C.group===L);break}}return{flexGrow:S.layout[M]??1,pointerEvents:j?"none":void 0}}return{flexGrow:(s==null?void 0:s[M])??1}}),W=uo({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!W.disableCursor},getPanelStyles:T,id:y,orientation:u,registerPanel:A=>{const M=w.current;return M.panels=an(u,[...M.panels,A]),N(),()=>{M.panels=M.panels.filter(E=>E!==A),N()}},registerSeparator:A=>{const M=w.current;return M.separators=an(u,[...M.separators,A]),N(),()=>{M.separators=M.separators.filter(E=>E!==A),N()}},togglePanelDisabled:(A,M)=>{const E=w.current.panels.find(j=>j.id===A);E&&(E.panelConstraints.disabled=M);const L=fa(y),S=Ht(y);L&&S&&Nt(L,{...S,derivedPanelConstraints:on(L)})},toggleSeparatorDisabled:(A,M)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=M)}}),[T,y,N,u,W]),U=d.useRef(null);return hs(()=>{const A=x.current;if(A===null)return;const M=w.current;let E;if(W.defaultLayout!==void 0&&Object.keys(W.defaultLayout).length===M.panels.length){E={};for(const ae of M.panels){const q=W.defaultLayout[ae.id];q!==void 0&&(E[ae.id]=q)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!W.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};U.current=L;const S=Nm(L),{defaultLayoutDeferred:j,derivedPanelConstraints:C,layout:B}=Ht(L.id,!0);!j&&C.length>0&&(_(B),v(B));const X=no(y,ae=>{const{defaultLayoutDeferred:q,derivedPanelConstraints:Q,layout:ie}=ae.next;if(q||Q.length===0)return;const he=L.panels.map(({id:z})=>z).join(",");L.mutableState.layouts[he]=ie,Q.forEach(z=>{if(z.collapsible){const{layout:V}=ae.prev??{};if(V){const J=He(z.collapsedSize,ie[z.panelId]),D=He(z.collapsedSize,V[z.panelId]);J&&!D&&(L.mutableState.expandedPanelSizes[z.panelId]=V[z.panelId])}}});const de=ns().state!=="active";_(ie),de&&v(ie)});return()=>{U.current=null,S(),X()}},[n,y,v,_,u,k,W]),d.useEffect(()=>{const A=U.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Rc.Provider,{value:G,children:r.jsx("div",{...g,className:t,"data-group":!0,"data-testid":y,id:y,ref:R,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}ln.displayName="Group";function fo(){const e=d.useContext(Rc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Rm(e,t){const{id:s}=fo(),i=d.useRef({collapse:Pr,expand:Pr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Pr});d.useImperativeHandle(t,()=>i.current,[]),hs(()=>{Object.assign(i.current,Sc({groupId:s,panelId:e}))})}function Xs({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:g,...p}){const _=!!h,v=co(h),y=uo({disabled:o}),x=d.useRef(null),k=ho(x,a),{getPanelStyles:N,id:w,orientation:R,registerPanel:T,togglePanelDisabled:W}=fo(),G=m!==null,U=ri((M,E,L)=>{m==null||m(M,h,L)});hs(()=>{const M=x.current;if(M!==null){const E={element:M,id:v,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?U:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return T(E)}},[l,s,i,n,G,v,_,c,u,U,T,y]),d.useEffect(()=>{W(v,!!o)},[o,v,W]),Rm(v,f);const A=d.useSyncExternalStore(M=>no(w,M),()=>JSON.stringify(N(w,v)),()=>JSON.stringify(N(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:k,style:{...Dm,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:R==="horizontal"?"pan-y":"pan-x"},children:e})})}Xs.displayName="Panel";const Dm={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Pm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=rs({layout:ai({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=rs({layout:ai({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function cn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=co(n),h=uo({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),g=d.useRef(null),p=ho(g,i),{disableCursor:_,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:k}=fo(),N=y==="horizontal"?"vertical":"horizontal";hs(()=>{const R=g.current;if(R!==null){const T={disabled:h.disabled,element:R,id:l},W=x(T),G=xm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(M=>M.separator===T)?A.next.state:"inactive")}),U=no(v,A=>{const{derivedPanelConstraints:M,layout:E,separatorToPanels:L}=A.next,S=L.get(T);if(S){const j=S[0],C=S.indexOf(j);u(Pm({layout:E,panelConstraints:M,panelId:j.id,panelIndex:C}))}});return()=>{G(),U(),W()}}},[v,l,x,h]),d.useEffect(()=>{k(l,!!s)},[s,l,k]);let w;return s&&!_&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":N,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}cn.displayName="Separator";const Mm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Lm={sm:"w-7 h-7",md:"w-8 h-8"},Bm={sm:14,md:16};function Pt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Mm[i],Lm[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Bm[s]})})}function Tm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const g=(f+1)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const g=(f-1+s.length)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:g=>{l.current[u]=g},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},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:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
|
|
203
203
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
204
204
|
* @license MIT
|
|
205
205
|
*
|
|
@@ -210,21 +210,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
210
210
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
211
211
|
* http://bellard.org/jslinux/
|
|
212
212
|
* Copyright (c) 2011 Fabrice Bellard
|
|
213
|
-
*/var Dc=Object.defineProperty,
|
|
213
|
+
*/var Dc=Object.defineProperty,zm=Object.getOwnPropertyDescriptor,Am=(e,t)=>{for(var s in t)Dc(e,s,{get:t[s],enumerable:!0})},we=(e,t,s,i)=>{for(var n=i>1?void 0:i?zm(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&Dc(t,s,n),n},H=(e,t)=>(s,i)=>t(s,i,e),Ra="Terminal input",hn={get:()=>Ra,set:e=>Ra=e},Da="Too much output to announce, navigate to rows manually to read",dn={get:()=>Da,set:e=>Da=e};function Om(e){return e.replace(/\r?\n/g,"\r")}function $m(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Im(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Fm(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Pc(n,t,s,i)}}function Pc(e,t,s,i){e=Om(e),e=$m(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Mc(e,t,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function Pa(e,t,s,i,n){Mc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Tt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function pr(e,t=0,s=e.length){let i="";for(let n=t;n<s;++n){let o=e[n];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Hm=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},Wm=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)g<<=6,g|=_;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=v-p;for(;c<y;){if(c>=s)return 0;if(_=e[c++],(_&192)!==128){c--,f=!0;break}else this.interim[p++]=_,g<<=6,g|=_&63}f||(v===2?g<128?c--:t[i++]=g:v===3?g<2048||g>=55296&&g<=57343||g===65279||(t[i++]=g):g<65536||g>1114111||(t[i++]=g)),this.interim.fill(0)}let u=s-4,m=c;for(;m<s;){for(;m<u&&!((n=e[m])&128)&&!((o=e[m+1])&128)&&!((a=e[m+2])&128)&&!((l=e[m+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=l,m+=4;if(n=e[m++],n<128)t[i++]=n;else if((n&224)===192){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(h=(n&31)<<6|o&63,h<128){m--;continue}t[i++]=h}else if((n&240)===224){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((n&248)===240){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if(l=e[m++],(l&192)!==128){m--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Lc="",At=" ",fi=class Bc{constructor(){this.fg=0,this.bg=0,this.extended=new er}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 Bc;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}},er=class Tc{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Tc(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},rt=class zc extends fi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new er,this.combinedData=""}static fromCharData(t){let s=new zc;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Tt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ma="di$target",un="di$dependencies",Mr=new Map;function Um(e){return e[un]||[]}function Ae(e){if(Mr.has(e))return Mr.get(e);let t=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Km(t,s,n)};return t._id=e,Mr.set(e,t),t}function Km(e,t,s){t[Ma]===t?t[un].push({id:e,index:s}):(t[un]=[{id:e,index:s}],t[Ma]=t)}var We=Ae("BufferService"),Ac=Ae("CoreMouseService"),ds=Ae("CoreService"),qm=Ae("CharsetService"),mo=Ae("InstantiationService"),Oc=Ae("LogService"),Ue=Ae("OptionsService"),$c=Ae("OscLinkService"),Vm=Ae("UnicodeService"),mi=Ae("DecorationService"),fn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new rt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let m=0;m<a;m++)if(!(h===-1&&!s.hasContent(m))){if(s.loadCell(m,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=m,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&m===a-1){let f=(u=this._oscLinkService.getLinkData(l))==null?void 0:u.uri;if(f){let g={start:{x:h+1,y:e},end:{x:m+(!c&&m===a-1?1:0),y:e}},p=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let _=new URL(f);["http:","https:"].includes(_.protocol)||(p=!0)}catch{p=!0}p||i.push({text:f,range:g,activate:(_,v)=>n?n.activate(_,v,g):Gm(_,v),hover:(_,v)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,_,v,g)},leave:(_,v)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,_,v,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,l=o.extended.urlId):(h=-1,l=-1)}}t(i)}};fn=we([H(0,We),H(1,Ue),H(2,$c)],fn);function Gm(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
214
214
|
|
|
215
|
-
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var _r=Ae("CharSizeService"),jt=Ae("CoreBrowserService"),po=Ae("MouseService"),Et=Ae("RenderService"),
|
|
215
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var _r=Ae("CharSizeService"),jt=Ae("CoreBrowserService"),po=Ae("MouseService"),Et=Ae("RenderService"),Ym=Ae("SelectionService"),Ic=Ae("CharacterJoinerService"),Ps=Ae("ThemeService"),Fc=Ae("LinkProviderService"),Xm=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?La.isErrorNoTelemetry(e)?new La(e.message+`
|
|
216
216
|
|
|
217
217
|
`+e.stack):new Error(e.message+`
|
|
218
218
|
|
|
219
|
-
`+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)}},Zm=new Jm;function Fi(e){Qm(e)||Zm.onUnexpectedError(e)}var mn="Canceled";function Qm(e){return e instanceof ep?!0:e instanceof Error&&e.name===mn&&e.message===mn}var ep=class extends Error{constructor(){super(mn),this.name=this.message}};function tp(e){return new Error(`Illegal argument: ${e}`)}var La=class pn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof pn)return t;let s=new pn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_n=class Hc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Hc.prototype)}};function Je(e,t=0){return e[e.length-(1+t)]}var sp;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(sp||(sp={}));function ip(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Wc;(e=>{function t(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(N){yield N}e.single=n;function o(N){return t(N)?N:n(N)}e.wrap=o;function a(N){return N||s}e.from=a;function*l(N){for(let w=N.length-1;w>=0;w--)yield N[w]}e.reverse=l;function h(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(N){return N[Symbol.iterator]().next().value}e.first=c;function u(N,w){let R=0;for(let T of N)if(w(T,R++))return!0;return!1}e.some=u;function m(N,w){for(let R of N)if(w(R))return R}e.find=m;function*f(N,w){for(let R of N)w(R)&&(yield R)}e.filter=f;function*g(N,w){let R=0;for(let T of N)yield w(T,R++)}e.map=g;function*p(N,w){let R=0;for(let T of N)yield*w(T,R++)}e.flatMap=p;function*_(...N){for(let w of N)yield*w}e.concat=_;function v(N,w,R){let T=R;for(let W of N)T=w(T,W);return T}e.reduce=v;function*y(N,w,R=N.length){for(w<0&&(w+=N.length),R<0?R+=N.length:R>N.length&&(R=N.length);w<R;w++)yield N[w]}e.slice=y;function x(N,w=Number.POSITIVE_INFINITY){let R=[];if(w===0)return[R,N];let T=N[Symbol.iterator]();for(let W=0;W<w;W++){let G=T.next();if(G.done)return[R,e.empty()];R.push(G.value)}return[R,{[Symbol.iterator](){return T}}]}e.consume=x;async function k(N){let w=[];for await(let R of N)w.push(R);return Promise.resolve(w)}e.asyncToArray=k})(Wc||(Wc={}));function os(e){if(Wc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function rp(...e){return ve(()=>os(e))}function ve(e){return{dispose:ip(()=>{e()})}}var Uc=class Kc{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{os(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?Kc.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)}};Uc.DISABLE_DISPOSED_WARNING=!1;var Wt=Uc,ne=class{constructor(){this._store=new Wt,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)}};ne.None=Object.freeze({dispose(){}});var Ds=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}},wt=typeof window=="object"?window:globalThis,gn=class xn{constructor(t){this.element=t,this.next=xn.Undefined,this.prev=xn.Undefined}};gn.Undefined=new gn(void 0);var be=gn,Ba=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},np=globalThis.performance&&typeof globalThis.performance.now=="function",op=class qc{static create(t){return new qc(t)}constructor(t){this._now=np&&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}},$e;(e=>{e.None=()=>ne.None;function t(M,E){return m(M,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(M){return(E,L=null,S)=>{let j=!1,C;return C=M(B=>{if(!j)return C?C.dispose():j=!0,E.call(L,B)},null,S),j&&C.dispose(),C}}e.once=s;function i(M,E,L){return c((S,j=null,C)=>M(B=>S.call(j,E(B)),null,C),L)}e.map=i;function n(M,E,L){return c((S,j=null,C)=>M(B=>{E(B),S.call(j,B)},null,C),L)}e.forEach=n;function o(M,E,L){return c((S,j=null,C)=>M(B=>E(B)&&S.call(j,B),null,C),L)}e.filter=o;function a(M){return M}e.signal=a;function l(...M){return(E,L=null,S)=>{let j=rp(...M.map(C=>C(B=>E.call(L,B))));return u(j,S)}}e.any=l;function h(M,E,L,S){let j=L;return i(M,C=>(j=E(j,C),j),S)}e.reduce=h;function c(M,E){let L,S={onWillAddFirstListener(){L=M(j.fire,j)},onDidRemoveLastListener(){L==null||L.dispose()}},j=new O(S);return E==null||E.add(j),j.event}function u(M,E){return E instanceof Array?E.push(M):E&&E.add(M),M}function m(M,E,L=100,S=!1,j=!1,C,B){let X,ae,q,Q=0,ie,he={leakWarningThreshold:C,onWillAddFirstListener(){X=M(z=>{Q++,ae=E(ae,z),S&&!q&&(de.fire(ae),ae=void 0),ie=()=>{let V=ae;ae=void 0,q=void 0,(!S||Q>1)&&de.fire(V),Q=0},typeof L=="number"?(clearTimeout(q),q=setTimeout(ie,L)):q===void 0&&(q=0,queueMicrotask(ie))})},onWillRemoveListener(){j&&Q>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,X.dispose()}},de=new O(he);return B==null||B.add(de),de.event}e.debounce=m;function f(M,E=0,L){return e.debounce(M,(S,j)=>S?(S.push(j),S):[j],E,void 0,!0,void 0,L)}e.accumulate=f;function g(M,E=(S,j)=>S===j,L){let S=!0,j;return o(M,C=>{let B=S||!E(C,j);return S=!1,j=C,B},L)}e.latch=g;function p(M,E,L){return[e.filter(M,E,L),e.filter(M,S=>!E(S),L)]}e.split=p;function _(M,E=!1,L=[],S){let j=L.slice(),C=M(ae=>{j?j.push(ae):X.fire(ae)});S&&S.add(C);let B=()=>{j==null||j.forEach(ae=>X.fire(ae)),j=null},X=new O({onWillAddFirstListener(){C||(C=M(ae=>X.fire(ae)),S&&S.add(C))},onDidAddFirstListener(){j&&(E?setTimeout(B):B())},onDidRemoveLastListener(){C&&C.dispose(),C=null}});return S&&S.add(X),X.event}e.buffer=_;function v(M,E){return(L,S,j)=>{let C=E(new x);return M(function(B){let X=C.evaluate(B);X!==y&&L.call(S,X)},void 0,j)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(j=>(S=E(S,j),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(j=>{let C=L||!E(j,S);return L=!1,S=j,C?j:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function k(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.on(E,S),C=()=>M.removeListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromNodeEventEmitter=k;function N(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.addEventListener(E,S),C=()=>M.removeEventListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromDOMEventEmitter=N;function w(M){return new Promise(E=>s(M)(E))}e.toPromise=w;function R(M){let E=new O;return M.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=R;function T(M,E){return M(L=>E.fire(L))}e.forward=T;function W(M,E,L){return E(L),M(S=>E(S))}e.runAndSubscribe=W;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(M,E){return new G(M,E).emitter.event}e.fromObservable=U;function A(M){return(E,L,S)=>{let j=0,C=!1,B={beginUpdate(){j++},endUpdate(){j--,j===0&&(M.reportChanges(),C&&(C=!1,E.call(L)))},handlePossibleChange(){},handleChange(){C=!0}};M.addObserver(B),M.reportChanges();let X={dispose(){M.removeObserver(B)}};return S instanceof Wt?S.add(X):Array.isArray(S)&&S.push(X),X}}e.fromObservableLight=A})($e||($e={}));var vn=class bn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${bn._idPool++}`,bn.all.add(this)}start(t){this._stopWatch=new op,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}}};vn.all=new Set,vn._idPool=0;var ap=vn,lp=-1,Vc=class Gc{constructor(t,s,i=(Gc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new dp(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Vc._idPool=1;var cp=Vc,hp=class Yc{constructor(t){this.value=t}static create(){let t=new Error;return new Yc(t.stack??"")}print(){console.warn(this.value.split(`
|
|
219
|
+
`+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)}},Jm=new Xm;function Fi(e){Zm(e)||Jm.onUnexpectedError(e)}var mn="Canceled";function Zm(e){return e instanceof Qm?!0:e instanceof Error&&e.name===mn&&e.message===mn}var Qm=class extends Error{constructor(){super(mn),this.name=this.message}};function ep(e){return new Error(`Illegal argument: ${e}`)}var La=class pn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof pn)return t;let s=new pn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_n=class Hc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Hc.prototype)}};function Je(e,t=0){return e[e.length-(1+t)]}var tp;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(tp||(tp={}));function sp(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Wc;(e=>{function t(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(N){yield N}e.single=n;function o(N){return t(N)?N:n(N)}e.wrap=o;function a(N){return N||s}e.from=a;function*l(N){for(let w=N.length-1;w>=0;w--)yield N[w]}e.reverse=l;function h(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(N){return N[Symbol.iterator]().next().value}e.first=c;function u(N,w){let R=0;for(let T of N)if(w(T,R++))return!0;return!1}e.some=u;function m(N,w){for(let R of N)if(w(R))return R}e.find=m;function*f(N,w){for(let R of N)w(R)&&(yield R)}e.filter=f;function*g(N,w){let R=0;for(let T of N)yield w(T,R++)}e.map=g;function*p(N,w){let R=0;for(let T of N)yield*w(T,R++)}e.flatMap=p;function*_(...N){for(let w of N)yield*w}e.concat=_;function v(N,w,R){let T=R;for(let W of N)T=w(T,W);return T}e.reduce=v;function*y(N,w,R=N.length){for(w<0&&(w+=N.length),R<0?R+=N.length:R>N.length&&(R=N.length);w<R;w++)yield N[w]}e.slice=y;function x(N,w=Number.POSITIVE_INFINITY){let R=[];if(w===0)return[R,N];let T=N[Symbol.iterator]();for(let W=0;W<w;W++){let G=T.next();if(G.done)return[R,e.empty()];R.push(G.value)}return[R,{[Symbol.iterator](){return T}}]}e.consume=x;async function k(N){let w=[];for await(let R of N)w.push(R);return Promise.resolve(w)}e.asyncToArray=k})(Wc||(Wc={}));function os(e){if(Wc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function ip(...e){return ve(()=>os(e))}function ve(e){return{dispose:sp(()=>{e()})}}var Uc=class Kc{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{os(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?Kc.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)}};Uc.DISABLE_DISPOSED_WARNING=!1;var Wt=Uc,ne=class{constructor(){this._store=new Wt,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)}};ne.None=Object.freeze({dispose(){}});var Rs=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}},wt=typeof window=="object"?window:globalThis,gn=class xn{constructor(t){this.element=t,this.next=xn.Undefined,this.prev=xn.Undefined}};gn.Undefined=new gn(void 0);var be=gn,Ba=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},rp=globalThis.performance&&typeof globalThis.performance.now=="function",np=class qc{static create(t){return new qc(t)}constructor(t){this._now=rp&&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}},$e;(e=>{e.None=()=>ne.None;function t(M,E){return m(M,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(M){return(E,L=null,S)=>{let j=!1,C;return C=M(B=>{if(!j)return C?C.dispose():j=!0,E.call(L,B)},null,S),j&&C.dispose(),C}}e.once=s;function i(M,E,L){return c((S,j=null,C)=>M(B=>S.call(j,E(B)),null,C),L)}e.map=i;function n(M,E,L){return c((S,j=null,C)=>M(B=>{E(B),S.call(j,B)},null,C),L)}e.forEach=n;function o(M,E,L){return c((S,j=null,C)=>M(B=>E(B)&&S.call(j,B),null,C),L)}e.filter=o;function a(M){return M}e.signal=a;function l(...M){return(E,L=null,S)=>{let j=ip(...M.map(C=>C(B=>E.call(L,B))));return u(j,S)}}e.any=l;function h(M,E,L,S){let j=L;return i(M,C=>(j=E(j,C),j),S)}e.reduce=h;function c(M,E){let L,S={onWillAddFirstListener(){L=M(j.fire,j)},onDidRemoveLastListener(){L==null||L.dispose()}},j=new O(S);return E==null||E.add(j),j.event}function u(M,E){return E instanceof Array?E.push(M):E&&E.add(M),M}function m(M,E,L=100,S=!1,j=!1,C,B){let X,ae,q,Q=0,ie,he={leakWarningThreshold:C,onWillAddFirstListener(){X=M(z=>{Q++,ae=E(ae,z),S&&!q&&(de.fire(ae),ae=void 0),ie=()=>{let V=ae;ae=void 0,q=void 0,(!S||Q>1)&&de.fire(V),Q=0},typeof L=="number"?(clearTimeout(q),q=setTimeout(ie,L)):q===void 0&&(q=0,queueMicrotask(ie))})},onWillRemoveListener(){j&&Q>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,X.dispose()}},de=new O(he);return B==null||B.add(de),de.event}e.debounce=m;function f(M,E=0,L){return e.debounce(M,(S,j)=>S?(S.push(j),S):[j],E,void 0,!0,void 0,L)}e.accumulate=f;function g(M,E=(S,j)=>S===j,L){let S=!0,j;return o(M,C=>{let B=S||!E(C,j);return S=!1,j=C,B},L)}e.latch=g;function p(M,E,L){return[e.filter(M,E,L),e.filter(M,S=>!E(S),L)]}e.split=p;function _(M,E=!1,L=[],S){let j=L.slice(),C=M(ae=>{j?j.push(ae):X.fire(ae)});S&&S.add(C);let B=()=>{j==null||j.forEach(ae=>X.fire(ae)),j=null},X=new O({onWillAddFirstListener(){C||(C=M(ae=>X.fire(ae)),S&&S.add(C))},onDidAddFirstListener(){j&&(E?setTimeout(B):B())},onDidRemoveLastListener(){C&&C.dispose(),C=null}});return S&&S.add(X),X.event}e.buffer=_;function v(M,E){return(L,S,j)=>{let C=E(new x);return M(function(B){let X=C.evaluate(B);X!==y&&L.call(S,X)},void 0,j)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(j=>(S=E(S,j),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(j=>{let C=L||!E(j,S);return L=!1,S=j,C?j:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function k(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.on(E,S),C=()=>M.removeListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromNodeEventEmitter=k;function N(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.addEventListener(E,S),C=()=>M.removeEventListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromDOMEventEmitter=N;function w(M){return new Promise(E=>s(M)(E))}e.toPromise=w;function R(M){let E=new O;return M.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=R;function T(M,E){return M(L=>E.fire(L))}e.forward=T;function W(M,E,L){return E(L),M(S=>E(S))}e.runAndSubscribe=W;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(M,E){return new G(M,E).emitter.event}e.fromObservable=U;function A(M){return(E,L,S)=>{let j=0,C=!1,B={beginUpdate(){j++},endUpdate(){j--,j===0&&(M.reportChanges(),C&&(C=!1,E.call(L)))},handlePossibleChange(){},handleChange(){C=!0}};M.addObserver(B),M.reportChanges();let X={dispose(){M.removeObserver(B)}};return S instanceof Wt?S.add(X):Array.isArray(S)&&S.push(X),X}}e.fromObservableLight=A})($e||($e={}));var vn=class bn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${bn._idPool++}`,bn.all.add(this)}start(t){this._stopWatch=new np,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}}};vn.all=new Set,vn._idPool=0;var op=vn,ap=-1,Vc=class Gc{constructor(t,s,i=(Gc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new hp(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Vc._idPool=1;var lp=Vc,cp=class Yc{constructor(t){this.value=t}static create(){let t=new Error;return new Yc(t.stack??"")}print(){console.warn(this.value.split(`
|
|
220
220
|
`).slice(2).join(`
|
|
221
|
-
`))}},dp=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},up=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},fp=0,Lr=class{constructor(e){this.value=e,this.id=fp++}},mp=2,pp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new cp((t==null?void 0:t.onListenerError)??Fi,((i=this._options)==null?void 0:i.leakWarningThreshold)??lp):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new ap(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;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 g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new up(`${f}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Fi)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new Lr(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=hp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Lr?(this._deliveryQueue??(this._deliveryQueue=new _p),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Wt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*mp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Fi;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Lr)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},_p=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},yn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};yn.INSTANCE=new yn;var _o=yn;function gp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}_o.INSTANCE.onDidChangeZoomLevel;function xp(e){return _o.INSTANCE.getZoomFactor(e)}_o.INSTANCE.onDidChangeFullscreen;var Ls=typeof navigator=="object"?navigator.userAgent:"",Sn=Ls.indexOf("Firefox")>=0,vp=Ls.indexOf("AppleWebKit")>=0,go=Ls.indexOf("Chrome")>=0,bp=!go&&Ls.indexOf("Safari")>=0;Ls.indexOf("Electron/")>=0;Ls.indexOf("Android")>=0;var Br=!1;if(typeof wt.matchMedia=="function"){let e=wt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=wt.matchMedia("(display-mode: fullscreen)");Br=e.matches,gp(wt,e,({matches:s})=>{Br&&t.matches||(Br=s)})}var ks="en",wn=!1,Cn=!1,Hi=!1,Xc=!1,Li,Wi=ks,Ta=ks,yp,lt,Qt=globalThis,Oe,Il;typeof Qt.vscode<"u"&&typeof Qt.vscode.process<"u"?Oe=Qt.vscode.process:typeof process<"u"&&typeof((Il=process==null?void 0:process.versions)==null?void 0:Il.node)=="string"&&(Oe=process);var Fl,Sp=typeof((Fl=Oe==null?void 0:Oe.versions)==null?void 0:Fl.electron)=="string",wp=Sp&&(Oe==null?void 0:Oe.type)==="renderer",Hl;if(typeof Oe=="object"){wn=Oe.platform==="win32",Cn=Oe.platform==="darwin",Hi=Oe.platform==="linux",Hi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Li=ks,Wi=ks;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Li=t.userLocale,Ta=t.osLocale,Wi=t.resolvedLanguage||ks,yp=(Hl=t.languagePack)==null?void 0:Hl.translationsConfigFile}catch{}Xc=!0}else typeof navigator=="object"&&!wp?(lt=navigator.userAgent,wn=lt.indexOf("Windows")>=0,Cn=lt.indexOf("Macintosh")>=0,(lt.indexOf("Macintosh")>=0||lt.indexOf("iPad")>=0||lt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Hi=lt.indexOf("Linux")>=0,(lt==null?void 0:lt.indexOf("Mobi"))>=0,Wi=globalThis._VSCODE_NLS_LANGUAGE||ks,Li=navigator.language.toLowerCase(),Ta=Li):console.error("Unable to resolve platform.");var Jc=wn,_t=Cn,Cp=Hi,za=Xc,gt=lt,Mt=Wi,kp;(e=>{function t(){return Mt}e.value=t;function s(){return Mt.length===2?Mt==="en":Mt.length>=3?Mt[0]==="e"&&Mt[1]==="n"&&Mt[2]==="-":!1}e.isDefaultVariant=s;function i(){return Mt==="en"}e.isDefault=i})(kp||(kp={}));var Np=typeof Qt.postMessage=="function"&&!Qt.importScripts;(()=>{if(Np){let e=[];Qt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Qt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var jp=!!(gt&>.indexOf("Chrome")>=0);gt&>.indexOf("Firefox")>=0;!jp&>&>.indexOf("Safari")>=0;gt&>.indexOf("Edg/")>=0;gt&>.indexOf("Android")>=0;var vs=typeof navigator=="object"?navigator:{};za||document.queryCommandSupported&&document.queryCommandSupported("copy")||vs&&vs.clipboard&&vs.clipboard.writeText,za||vs&&vs.clipboard&&vs.clipboard.readText;var xo=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}},Tr=new xo,Aa=new xo,Oa=new xo,Ep=new Array(230),Zc;(e=>{function t(l){return Tr.keyCodeToStr(l)}e.toString=t;function s(l){return Tr.strToKeyCode(l)}e.fromString=s;function i(l){return Aa.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Oa.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Aa.strToKeyCode(l)||Oa.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Tr.keyCodeToStr(l)}e.toElectronAccelerator=a})(Zc||(Zc={}));var Rp=class Qc{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof Qc&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Dp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Dp=class{constructor(e){if(e.length===0)throw tp("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Pp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Zc.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Sn)switch(t){case 59:return 85;case 60:if(Cp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(vp&&(_t&&t===93||!_t&&t===92))return 57;return Ep[t]||0}var Mp=_t?256:2048,Lp=512,Bp=1024,Tp=_t?2048:256,$a=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=Pp(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|=Mp),this.altKey&&(t|=Lp),this.shiftKey&&(t|=Bp),this.metaKey&&(t|=Tp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Rp(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ia=new WeakMap;function zp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Ap=class{static getSameOriginWindowChain(e){let t=Ia.get(e);if(!t){t=[],Ia.set(e,t);let s=e,i;do i=zp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Bi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Ap.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Fa=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(go){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Sn&&!_t?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")bp&&Jc?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Sn&&!_t?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},eh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Op;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof $p?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:eh})})(Op||(Op={}));var $p=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?eh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},vo=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 _n("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _n("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ip=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Fp;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Fp||(Fp={}));var Ha=class st{static fromArray(t){return new st(s=>{s.emitMany(t)})}static fromPromise(t){return new st(async s=>{s.emitMany(await t)})}static fromPromises(t){return new st(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new st(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new st(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return st.map(this,t)}static filter(t,s){return new st(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return st.filter(this,t)}static coalesce(t){return st.filter(t,s=>!!s)}coalesce(){return st.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return st.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())}};Ha.EMPTY=Ha.fromArray([]);var{getWindow:pt,getWindowId:Hp,onDidRegisterWindow:Wp}=(function(){let e=new Map,t={window:wt,disposables:new Wt};e.set(wt.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Wt,h={window:a,disposables:l.add(new Wt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(Y(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:wt},getDocument(a){return pt(a).document}}})(),Up=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(e,t,s,i){return new Up(e,t,s,i)}var Wa=function(e,t,s,i){return Y(e,t,s,i)},bo,Kp=class extends Ip{constructor(e){super(),this.defaultTarget=e&&pt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ua=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){Fi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(Ua.sort),a.shift().execute();i.set(o,!1)};bo=(o,a,l=0)=>{let h=Hp(o),c=new Ua(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function qp(e){let t=e.getBoundingClientRect(),s=pt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Vp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Ve(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ve(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ve(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ve(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ve(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ve(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ve(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ve(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ve(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ve(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ve(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=Ve(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=Ve(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ve(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 Ve(e){return typeof e=="number"?`${e}px`:e}function oi(e){return new Vp(e)}var th=class{constructor(){this._hooks=new Wt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=pt(e)}this._hooks.add(Y(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Y(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Gp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var dt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(dt||(dt={}));var Zs=class Ie extends ne{constructor(){super(),this.dispatched=!1,this.targets=new Ba,this.ignoreTargets=new Ba,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Wp,({window:t,disposables:s})=>{s.add(Y(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Y(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Y(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:wt,disposables:this._store}))}static addTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in wt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(dt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Tap,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Contextmenu,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=Je(h.rollingPageX),m=Je(h.rollingPageY),f=Je(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],p=m-h.rollingPageY[0],_=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,_,i,Math.abs(g)/f,g>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(dt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===dt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ie.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===dt.Change||t.type===dt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=bo(t,()=>{let u=Date.now(),m=u-i,f=0,g=0,p=!0;n+=Ie.SCROLL_FRICTION*m,l+=Ie.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,g=h*l*m);let _=this.newGestureEvent(dt.Change);_.translationX=f,_.translationY=g,s.forEach(v=>v.dispatchEvent(_)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(dt.Change,a.initialTarget);l.translationX=o.pageX-Je(a.rollingPageX),l.translationY=o.pageY-Je(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Zs.SCROLL_FRICTION=-.005,Zs.HOLD_DELAY=700,Zs.CLEAR_TAP_COUNT_TIME=400,we([Gp],Zs,"isTouchDevice",1);var Yp=Zs,yo=class extends ne{onclick(e,t){this._register(Y(e,Me.CLICK,s=>t(new Bi(pt(e),s))))}onmousedown(e,t){this._register(Y(e,Me.MOUSE_DOWN,s=>t(new Bi(pt(e),s))))}onmouseover(e,t){this._register(Y(e,Me.MOUSE_OVER,s=>t(new Bi(pt(e),s))))}onmouseleave(e,t){this._register(Y(e,Me.MOUSE_LEAVE,s=>t(new Bi(pt(e),s))))}onkeydown(e,t){this._register(Y(e,Me.KEY_DOWN,s=>t(new $a(s))))}onkeyup(e,t){this._register(Y(e,Me.KEY_UP,s=>t(new $a(s))))}oninput(e,t){this._register(Y(e,Me.INPUT,t))}onblur(e,t){this._register(Y(e,Me.BLUR,t))}onfocus(e,t){this._register(Y(e,Me.FOCUS,t))}onchange(e,t){this._register(Y(e,Me.CHANGE,t))}ignoreGesture(e){return Yp.ignoreTarget(e)}},Ka=11,Xp=class extends yo{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=Ka+"px",this.domNode.style.height=Ka+"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 th),this._register(Wa(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Wa(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Kp),this._pointerdownScheduleRepeatTimer=this._register(new vo)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,pt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Jp=class kn{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new kn(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new kn(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Zp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Jp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Va(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Va.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},qa=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function zr(e,t){let s=t-e;return function(i){return e+s*t_(i)}}function Qp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Va=class Nn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Qp(zr(t,n),zr(o,s),.33)}return zr(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new qa(i,n,!1)}return new qa(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Nn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Nn(t,s,n,i)}};function e_(e){return Math.pow(e,3)}function t_(e){return 1-e_(1-e)}var s_=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new vo)}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":"")))}},i_=140,sh=class extends yo{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 s_(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new th),this._shouldRender=!0,this.domNode=oi(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(Y(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Xp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=oi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=qp(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(Jc&&a>i_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ih=class jn{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new jn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=jn._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},r_=class extends sh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ih(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.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}},n_=class extends sh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ih(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.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}},o_=500,Ga=50,a_=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},En=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(go){let s=pt(t.browserEvent),i=xp(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new a_(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=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]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};En.INSTANCE=new En;var l_=En,c_=class extends yo{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=d_(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new n_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new r_(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=oi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=oi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=oi(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,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new vo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=os(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,_t&&(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 Fa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=os(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Fa(s))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=l_.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!_t&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Ga*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Ga*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),o_)}},h_=class extends c_{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function d_(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,_t&&(t.className+=" mac"),t}var Rn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Zp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>bo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new h_(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(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
222
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Rn=we([H(2,We),H(3,jt),H(4,Ac),H(5,Ms),H(6,Ue),H(7,Et)],Rn);var Dn=class extends ne{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,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(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Dn=we([H(1,We),H(2,jt),H(3,pi),H(4,Et)],Dn);var u_=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ct={full:0,left:0,center:0,right:0},Lt={full:0,left:0,center:0,right:0},Ws={full:0,left:0,center:0,right:0},tr=class extends ne{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new u_,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var u;return(u=this._canvas)==null?void 0:u.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);Lt.full=this._canvas.width,Lt.left=e,Lt.center=t,Lt.right=e,this._refreshDrawHeightConstants(),Ws.full=1,Ws.left=1,Ws.center=1+Lt.left,Ws.right=1+Lt.left+Lt.center}_refreshDrawHeightConstants(){ct.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);ct.left=t,ct.center=t,ct.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ct[e.position||"full"]/2),Lt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ct[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}))}};tr=we([H(2,We),H(3,pi),H(4,Et),H(5,Ue),H(6,Ms),H(7,jt)],tr);var P;(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=`
|
|
223
|
-
`,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=""))(P||(P={}));var Ui;(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=""))(Ui||(Ui={}));var rh;(e=>e.ST=`${P.ESC}\\`)(rh||(rh={}));var Pn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${P.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Pn=we([H(2,We),H(3,Ue),H(4,ds),H(5,Et)],Pn);var Le=0,Be=0,Te=0,Se=0,Ya={css:"#00000000",rgba:0},je;(e=>{function t(n,o,a,l){return l!==void 0?`#${Vt(n)}${Vt(o)}${Vt(a)}${Vt(l)}`:`#${Vt(n)}${Vt(o)}${Vt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(je||(je={}));var xe;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,g=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255;Le=g+Math.round((u-g)*Se),Be=p+Math.round((m-p)*Se),Te=_+Math.round((f-_)*Se);let v=je.toCss(Le,Be,Te),y=je.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Ki.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return je.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Ki.toChannels(c),{css:je.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Ki.toChannels(h.rgba),{css:je.toCss(Le,Be,Te,Se),rgba:je.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(xe||(xe={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),je.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),je.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),je.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:je.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Fe;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Fe||(Fe={}));var Ki;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,g=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=g+Math.round((u-g)*Se),je.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Fe.relativeLuminance(a>>8),u=Fe.relativeLuminance(l>>8);if(yt(c,u)<h){if(u<c){let g=i(a,l,h),p=yt(c,Fe.relativeLuminance(g>>8));if(p<h){let _=n(a,l,h),v=yt(c,Fe.relativeLuminance(_>>8));return p>v?g:_}return g}let m=n(a,l,h),f=yt(c,Fe.relativeLuminance(m>>8));if(f<h){let g=i(a,l,h),p=yt(c,Fe.relativeLuminance(g>>8));return f>p?m:g}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,g=l>>16&255,p=l>>8&255,_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));for(;_<h&&(f>0||g>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),g-=Math.max(0,Math.ceil(g*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));return(f<<24|g<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,g=l>>16&255,p=l>>8&255,_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));for(;_<h&&(f<255||g<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));return(f<<24|g<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Ki||(Ki={}));function Vt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function yt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var f_=class extends mi{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},sr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||At.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)sr._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||At.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};sr=we([H(0,We)],sr);function m_(e){return 57508<=e&&e<=57558}function p_(e){return 9472<=e&&e<=9631}function __(e){return m_(e)||p_(e)}function g_(){return{css:{canvas:Ti(),cell:Ti()},device:{canvas:Ti(),cell:Ti(),char:{width:0,height:0,left:0,top:0}}}}function Ti(){return{width:0,height:0}}var Mn=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let _,v=0,y="",x=0,k=0,N=0,w=0,R=!1,T=0,W=!1,G=0,U=0,A=[],M=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,j=E>=U,C=E,B=this._workCell;if(f.length>0&&E===f[0][0]&&j){let ee=f.shift(),fe=this._isCellInSelection(ee[0],t);for(x=ee[0]+1;x<ee[1];x++)j&&(j=fe===this._isCellInSelection(x,t));j&&(j=!s||o<ee[0]||o>=ee[1]),j?(S=!0,B=new f_(this._workCell,e.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),C=ee[1]-1,L=B.getWidth()):U=ee[1]}let X=this._isCellInSelection(E,t),ae=s&&E===o,q=M&&E>=c&&E<=u,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{Q=!0});let ie=B.getChars()||At;if(ie===" "&&(B.isUnderline()||B.isOverline())&&(ie=" "),G=L*l-h.get(ie,B.isBold(),B.isItalic()),!_)_=this._document.createElement("span");else if(v&&(X&&W||!X&&!W&&B.bg===k)&&(X&&W&&g.selectionForeground||B.fg===N)&&B.extended.ext===w&&q===R&&G===T&&!ae&&!S&&!Q&&j){B.isInvisible()?y+=At:y+=ie,v++;continue}else v&&(_.textContent=y),_=this._document.createElement("span"),v=0,y="";if(k=B.bg,N=B.fg,w=B.extended.ext,R=q,T=G,W=X,S&&o>=E&&o<=C&&(o=E),!this._coreService.isCursorHidden&&ae&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(B.isBold()&&A.push("xterm-bold"),B.isItalic()&&A.push("xterm-italic"),B.isDim()&&A.push("xterm-dim"),B.isInvisible()?y=At:y=B.getChars()||At,B.isUnderline()&&(A.push(`xterm-underline-${B.extended.underlineStyle}`),y===" "&&(y=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${mi.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let ee=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&ee<8&&(ee+=8),_.style.textDecorationColor=g.ansi[ee].css}B.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),B.isStrikethrough()&&A.push("xterm-strikethrough"),q&&(_.style.textDecoration="underline");let he=B.getFgColor(),de=B.getFgColorMode(),z=B.getBgColor(),V=B.getBgColorMode(),J=!!B.isInverse();if(J){let ee=he;he=z,z=ee;let fe=de;de=V,V=fe}let D,le,ge=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{ee.options.layer!=="top"&&ge||(ee.backgroundColorRGB&&(V=50331648,z=ee.backgroundColorRGB.rgba>>8&16777215,D=ee.backgroundColorRGB),ee.foregroundColorRGB&&(de=50331648,he=ee.foregroundColorRGB.rgba>>8&16777215,le=ee.foregroundColorRGB),ge=ee.options.layer==="top")}),!ge&&X&&(D=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,z=D.rgba>>8&16777215,V=50331648,ge=!0,g.selectionForeground&&(de=50331648,he=g.selectionForeground.rgba>>8&16777215,le=g.selectionForeground)),ge&&A.push("xterm-decoration-top");let Ee;switch(V){case 16777216:case 33554432:Ee=g.ansi[z],A.push(`xterm-bg-${z}`);break;case 50331648:Ee=je.toColor(z>>16,z>>8&255,z&255),this._addStyle(_,`background-color:#${Xa((z>>>0).toString(16),"0",6)}`);break;case 0:default:J?(Ee=g.foreground,A.push("xterm-bg-257")):Ee=g.background}switch(D||B.isDim()&&(D=xe.multiplyOpacity(Ee,.5)),de){case 16777216:case 33554432:B.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(_,Ee,g.ansi[he],B,D,void 0)||A.push(`xterm-fg-${he}`);break;case 50331648:let ee=je.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(_,Ee,ee,B,D,le)||this._addStyle(_,`color:#${Xa(he.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ee,g.foreground,B,D,le)||J&&A.push("xterm-fg-257")}A.length&&(_.className=A.join(" "),A.length=0),!ae&&!S&&!Q&&j?v++:_.textContent=y,G!==this.defaultSpacing&&(_.style.letterSpacing=`${G}px`),m.push(_),E=C}return _&&v&&(_.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||__(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=xe.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Mn=we([H(1,Ic),H(2,Ue),H(3,jt),H(4,ds),H(5,pi),H(6,Ms)],Mn);function Xa(e,t,s){for(;e.length<s;)e=t+e;return e}var x_=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},v_=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function b_(){return new v_}var Ar="xterm-dom-renderer-owner-",tt="xterm-rows",zi="xterm-fg-",Ja="xterm-bg-",Us="xterm-focus",Ai="xterm-selection",y_=1,Ln=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=g,this._terminalClass=y_++,this._rowElements=[],this._selectionRenderModel=b_(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(tt),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(Ai),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=g_(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Mn,document),this._element.classList.add(Ar+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Ar+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new x_(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${tt} 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} .${tt} { 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} .${tt} .xterm-dim { color: ${xe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${tt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ai} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ai} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ai} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${zi}${o} { color: ${a.css}; }${this._terminalSelector} .${zi}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Ja}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${zi}257 { color: ${xe.opaque(e.background).css}; }${this._terminalSelector} .${zi}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ja}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Us),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Us),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ar}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let p=g+l.ydisp,_=this._rowElements[g],v=l.lines.get(p);if(!_||!v)break;_.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===i?t:n)-1:-1))}}};Ln=we([H(7,mo),H(8,_r),H(9,Ue),H(10,We),H(11,ds),H(12,jt),H(13,Ms)],Ln);var Bn=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new w_(this._optionsService))}catch{this._measureStrategy=this._register(new S_(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())}};Bn=we([H(2,Ue)],Bn);var nh=class extends ne{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)}},S_=class extends nh{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},w_=class extends nh{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}},C_=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new k_(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(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}},k_=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ds),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(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)}},N_=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>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 So(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function j_(e,t,s,i,n,o,a,l,h){if(!o)return;let c=So(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var Tn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return j_(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=So(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Tn=we([H(0,Et),H(1,_r)],Tn);var E_=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oh={};Om(oh,{getSafariVersion:()=>D_,isChromeOS:()=>hh,isFirefox:()=>ah,isIpad:()=>P_,isIphone:()=>M_,isLegacyEdge:()=>R_,isLinux:()=>wo,isMac:()=>ir,isNode:()=>gr,isSafari:()=>lh,isWindows:()=>ch});var gr=typeof process<"u"&&"title"in process,_i=gr?"node":navigator.userAgent,gi=gr?"node":navigator.platform,ah=_i.includes("Firefox"),R_=_i.includes("Edge"),lh=/^((?!chrome|android).)*safari/i.test(_i);function D_(){if(!lh)return 0;let e=_i.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ir=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(gi),P_=gi==="iPad",M_=gi==="iPhone",ch=["Windows","Win16","Win32","WinCE"].includes(gi),wo=gi.indexOf("Linux")>=0,hh=/\bCrOS\b/.test(_i),dh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},L_=class extends dh{_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())}}},B_=class extends dh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},rr=!gr&&"requestIdleCallback"in window?B_:L_,T_=class{constructor(){this._queue=new rr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},zn=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Ds),this._pausedResizeTask=new T_,this._observerDisposable=this._register(new Ds),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 O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new E_((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new z_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};zn=we([H(2,Ue),H(3,_r),H(4,ds),H(5,pi),H(6,We),H(7,jt),H(8,Ms)],zn);var z_=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function A_(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return I_(n,o,e,t,s,i)+xr(o,t,s,i)+F_(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",hi(Math.abs(n-e),ci(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=$_(o>t?e:n,s)+(l-1)*s.cols+1+O_(o>t?n:e);return hi(h,ci(a,i))}function O_(e,t){return e-1}function $_(e,t){return t.cols-e}function I_(e,t,s,i,n,o){return xr(t,i,n,o).length===0?"":hi(fh(e,t,e,t-as(t,n),!1,n).length,ci("D",o))}function xr(e,t,s,i){let n=e-as(e,s),o=t-as(t,s),a=Math.abs(n-o)-H_(e,t,s);return hi(a,ci(uh(e,t),i))}function F_(e,t,s,i,n,o){let a;xr(t,i,n,o).length>0?a=i-as(i,n):a=t;let l=i,h=W_(e,t,s,i,n,o);return hi(fh(e,a,s,l,h==="C",n).length,ci(h,o))}function H_(e,t,s){var a;let i=0,n=e-as(e,s),o=t-as(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=uh(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function as(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function W_(e,t,s,i,n,o){let a;return xr(s,i,n,o).length>0?a=i-as(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function uh(e,t){return e>t?"A":"B"}function fh(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function ci(e,t){let s=t?"O":"[";return P.ESC+s+e}function hi(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var U_=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 Za(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 Or=50,K_=15,q_=50,V_=500,G_=" ",Y_=new RegExp(G_,"g"),An=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new U_(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(Y_," ")).join(ch?`\r
|
|
221
|
+
`))}},hp=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},dp=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},up=0,Lr=class{constructor(e){this.value=e,this.id=up++}},fp=2,mp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new lp((t==null?void 0:t.onListenerError)??Fi,((i=this._options)==null?void 0:i.leakWarningThreshold)??ap):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new op(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;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 g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new dp(`${f}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Fi)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new Lr(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=cp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Lr?(this._deliveryQueue??(this._deliveryQueue=new pp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Wt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*fp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Fi;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Lr)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},pp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},yn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};yn.INSTANCE=new yn;var _o=yn;function _p(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}_o.INSTANCE.onDidChangeZoomLevel;function gp(e){return _o.INSTANCE.getZoomFactor(e)}_o.INSTANCE.onDidChangeFullscreen;var Ms=typeof navigator=="object"?navigator.userAgent:"",Sn=Ms.indexOf("Firefox")>=0,xp=Ms.indexOf("AppleWebKit")>=0,go=Ms.indexOf("Chrome")>=0,vp=!go&&Ms.indexOf("Safari")>=0;Ms.indexOf("Electron/")>=0;Ms.indexOf("Android")>=0;var Br=!1;if(typeof wt.matchMedia=="function"){let e=wt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=wt.matchMedia("(display-mode: fullscreen)");Br=e.matches,_p(wt,e,({matches:s})=>{Br&&t.matches||(Br=s)})}var Cs="en",wn=!1,Cn=!1,Hi=!1,Xc=!1,Li,Wi=Cs,Ta=Cs,bp,lt,Qt=globalThis,Oe,Il;typeof Qt.vscode<"u"&&typeof Qt.vscode.process<"u"?Oe=Qt.vscode.process:typeof process<"u"&&typeof((Il=process==null?void 0:process.versions)==null?void 0:Il.node)=="string"&&(Oe=process);var Fl,yp=typeof((Fl=Oe==null?void 0:Oe.versions)==null?void 0:Fl.electron)=="string",Sp=yp&&(Oe==null?void 0:Oe.type)==="renderer",Hl;if(typeof Oe=="object"){wn=Oe.platform==="win32",Cn=Oe.platform==="darwin",Hi=Oe.platform==="linux",Hi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Li=Cs,Wi=Cs;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Li=t.userLocale,Ta=t.osLocale,Wi=t.resolvedLanguage||Cs,bp=(Hl=t.languagePack)==null?void 0:Hl.translationsConfigFile}catch{}Xc=!0}else typeof navigator=="object"&&!Sp?(lt=navigator.userAgent,wn=lt.indexOf("Windows")>=0,Cn=lt.indexOf("Macintosh")>=0,(lt.indexOf("Macintosh")>=0||lt.indexOf("iPad")>=0||lt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Hi=lt.indexOf("Linux")>=0,(lt==null?void 0:lt.indexOf("Mobi"))>=0,Wi=globalThis._VSCODE_NLS_LANGUAGE||Cs,Li=navigator.language.toLowerCase(),Ta=Li):console.error("Unable to resolve platform.");var Jc=wn,_t=Cn,wp=Hi,za=Xc,gt=lt,Mt=Wi,Cp;(e=>{function t(){return Mt}e.value=t;function s(){return Mt.length===2?Mt==="en":Mt.length>=3?Mt[0]==="e"&&Mt[1]==="n"&&Mt[2]==="-":!1}e.isDefaultVariant=s;function i(){return Mt==="en"}e.isDefault=i})(Cp||(Cp={}));var kp=typeof Qt.postMessage=="function"&&!Qt.importScripts;(()=>{if(kp){let e=[];Qt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Qt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Np=!!(gt&>.indexOf("Chrome")>=0);gt&>.indexOf("Firefox")>=0;!Np&>&>.indexOf("Safari")>=0;gt&>.indexOf("Edg/")>=0;gt&>.indexOf("Android")>=0;var xs=typeof navigator=="object"?navigator:{};za||document.queryCommandSupported&&document.queryCommandSupported("copy")||xs&&xs.clipboard&&xs.clipboard.writeText,za||xs&&xs.clipboard&&xs.clipboard.readText;var xo=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}},Tr=new xo,Aa=new xo,Oa=new xo,jp=new Array(230),Zc;(e=>{function t(l){return Tr.keyCodeToStr(l)}e.toString=t;function s(l){return Tr.strToKeyCode(l)}e.fromString=s;function i(l){return Aa.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Oa.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Aa.strToKeyCode(l)||Oa.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Tr.keyCodeToStr(l)}e.toElectronAccelerator=a})(Zc||(Zc={}));var Ep=class Qc{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof Qc&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Rp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Rp=class{constructor(e){if(e.length===0)throw ep("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Dp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Zc.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Sn)switch(t){case 59:return 85;case 60:if(wp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(xp&&(_t&&t===93||!_t&&t===92))return 57;return jp[t]||0}var Pp=_t?256:2048,Mp=512,Lp=1024,Bp=_t?2048:256,$a=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=Dp(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|=Pp),this.altKey&&(t|=Mp),this.shiftKey&&(t|=Lp),this.metaKey&&(t|=Bp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ep(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ia=new WeakMap;function Tp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var zp=class{static getSameOriginWindowChain(e){let t=Ia.get(e);if(!t){t=[],Ia.set(e,t);let s=e,i;do i=Tp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Bi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=zp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Fa=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(go){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Sn&&!_t?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")vp&&Jc?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Sn&&!_t?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},eh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Ap;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Op?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:eh})})(Ap||(Ap={}));var Op=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?eh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},vo=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 _n("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _n("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},$p=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ip;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Ip||(Ip={}));var Ha=class st{static fromArray(t){return new st(s=>{s.emitMany(t)})}static fromPromise(t){return new st(async s=>{s.emitMany(await t)})}static fromPromises(t){return new st(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new st(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new st(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return st.map(this,t)}static filter(t,s){return new st(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return st.filter(this,t)}static coalesce(t){return st.filter(t,s=>!!s)}coalesce(){return st.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return st.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())}};Ha.EMPTY=Ha.fromArray([]);var{getWindow:pt,getWindowId:Fp,onDidRegisterWindow:Hp}=(function(){let e=new Map,t={window:wt,disposables:new Wt};e.set(wt.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Wt,h={window:a,disposables:l.add(new Wt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(Y(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:wt},getDocument(a){return pt(a).document}}})(),Wp=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(e,t,s,i){return new Wp(e,t,s,i)}var Wa=function(e,t,s,i){return Y(e,t,s,i)},bo,Up=class extends $p{constructor(e){super(),this.defaultTarget=e&&pt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ua=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){Fi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(Ua.sort),a.shift().execute();i.set(o,!1)};bo=(o,a,l=0)=>{let h=Fp(o),c=new Ua(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Kp(e){let t=e.getBoundingClientRect(),s=pt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={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"},qp=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=qe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=qe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=qe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=qe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=qe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=qe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=qe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=qe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=qe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=qe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=qe(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=qe(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=qe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=qe(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 qe(e){return typeof e=="number"?`${e}px`:e}function ni(e){return new qp(e)}var th=class{constructor(){this._hooks=new Wt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=pt(e)}this._hooks.add(Y(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Y(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Vp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var dt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(dt||(dt={}));var Js=class Ie extends ne{constructor(){super(),this.dispatched=!1,this.targets=new Ba,this.ignoreTargets=new Ba,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Hp,({window:t,disposables:s})=>{s.add(Y(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Y(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Y(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:wt,disposables:this._store}))}static addTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in wt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(dt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Tap,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Contextmenu,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=Je(h.rollingPageX),m=Je(h.rollingPageY),f=Je(h.rollingTimestamps)-h.rollingTimestamps[0],g=u-h.rollingPageX[0],p=m-h.rollingPageY[0],_=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,_,i,Math.abs(g)/f,g>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(dt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===dt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ie.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===dt.Change||t.type===dt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=bo(t,()=>{let u=Date.now(),m=u-i,f=0,g=0,p=!0;n+=Ie.SCROLL_FRICTION*m,l+=Ie.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,g=h*l*m);let _=this.newGestureEvent(dt.Change);_.translationX=f,_.translationY=g,s.forEach(v=>v.dispatchEvent(_)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(dt.Change,a.initialTarget);l.translationX=o.pageX-Je(a.rollingPageX),l.translationY=o.pageY-Je(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Js.SCROLL_FRICTION=-.005,Js.HOLD_DELAY=700,Js.CLEAR_TAP_COUNT_TIME=400,we([Vp],Js,"isTouchDevice",1);var Gp=Js,yo=class extends ne{onclick(e,t){this._register(Y(e,Me.CLICK,s=>t(new Bi(pt(e),s))))}onmousedown(e,t){this._register(Y(e,Me.MOUSE_DOWN,s=>t(new Bi(pt(e),s))))}onmouseover(e,t){this._register(Y(e,Me.MOUSE_OVER,s=>t(new Bi(pt(e),s))))}onmouseleave(e,t){this._register(Y(e,Me.MOUSE_LEAVE,s=>t(new Bi(pt(e),s))))}onkeydown(e,t){this._register(Y(e,Me.KEY_DOWN,s=>t(new $a(s))))}onkeyup(e,t){this._register(Y(e,Me.KEY_UP,s=>t(new $a(s))))}oninput(e,t){this._register(Y(e,Me.INPUT,t))}onblur(e,t){this._register(Y(e,Me.BLUR,t))}onfocus(e,t){this._register(Y(e,Me.FOCUS,t))}onchange(e,t){this._register(Y(e,Me.CHANGE,t))}ignoreGesture(e){return Gp.ignoreTarget(e)}},Ka=11,Yp=class extends yo{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=Ka+"px",this.domNode.style.height=Ka+"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 th),this._register(Wa(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Wa(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Up),this._pointerdownScheduleRepeatTimer=this._register(new vo)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,pt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Xp=class kn{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new kn(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new kn(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Jp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Xp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Va(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Va.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},qa=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function zr(e,t){let s=t-e;return function(i){return e+s*e_(i)}}function Zp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Va=class Nn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Zp(zr(t,n),zr(o,s),.33)}return zr(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new qa(i,n,!1)}return new qa(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Nn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Nn(t,s,n,i)}};function Qp(e){return Math.pow(e,3)}function e_(e){return 1-Qp(1-e)}var t_=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new vo)}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":"")))}},s_=140,sh=class extends yo{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 t_(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new th),this._shouldRender=!0,this.domNode=ni(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(Y(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Yp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=ni(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Kp(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(Jc&&a>s_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ih=class jn{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new jn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=jn._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},i_=class extends sh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ih(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.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}},r_=class extends sh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ih(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.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}},n_=500,Ga=50,o_=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},En=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(go){let s=pt(t.browserEvent),i=gp(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new o_(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=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]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};En.INSTANCE=new En;var a_=En,l_=class extends yo{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=h_(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new r_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new i_(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ni(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ni(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ni(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,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new vo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=os(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,_t&&(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 Fa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=os(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Fa(s))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=a_.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!_t&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Ga*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Ga*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),n_)}},c_=class extends l_{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function h_(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,_t&&(t.className+=" mac"),t}var Rn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Jp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>bo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new c_(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(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
222
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Rn=we([H(2,We),H(3,jt),H(4,Ac),H(5,Ps),H(6,Ue),H(7,Et)],Rn);var Dn=class extends ne{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,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(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Dn=we([H(1,We),H(2,jt),H(3,mi),H(4,Et)],Dn);var d_=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ct={full:0,left:0,center:0,right:0},Lt={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},tr=class extends ne{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new d_,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var u;return(u=this._canvas)==null?void 0:u.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);Lt.full=this._canvas.width,Lt.left=e,Lt.center=t,Lt.right=e,this._refreshDrawHeightConstants(),Hs.full=1,Hs.left=1,Hs.center=1+Lt.left,Hs.right=1+Lt.left+Lt.center}_refreshDrawHeightConstants(){ct.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);ct.left=t,ct.center=t,ct.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.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(Hs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ct[e.position||"full"]/2),Lt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ct[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}))}};tr=we([H(2,We),H(3,mi),H(4,Et),H(5,Ue),H(6,Ps),H(7,jt)],tr);var P;(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=`
|
|
223
|
+
`,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=""))(P||(P={}));var Ui;(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=""))(Ui||(Ui={}));var rh;(e=>e.ST=`${P.ESC}\\`)(rh||(rh={}));var Pn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${P.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Pn=we([H(2,We),H(3,Ue),H(4,ds),H(5,Et)],Pn);var Le=0,Be=0,Te=0,Se=0,Ya={css:"#00000000",rgba:0},je;(e=>{function t(n,o,a,l){return l!==void 0?`#${Vt(n)}${Vt(o)}${Vt(a)}${Vt(l)}`:`#${Vt(n)}${Vt(o)}${Vt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(je||(je={}));var xe;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,g=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255;Le=g+Math.round((u-g)*Se),Be=p+Math.round((m-p)*Se),Te=_+Math.round((f-_)*Se);let v=je.toCss(Le,Be,Te),y=je.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Ki.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return je.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Ki.toChannels(c),{css:je.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Ki.toChannels(h.rgba),{css:je.toCss(Le,Be,Te,Se),rgba:je.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(xe||(xe={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),je.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),je.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),je.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:je.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Fe;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Fe||(Fe={}));var Ki;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,g=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=g+Math.round((u-g)*Se),je.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Fe.relativeLuminance(a>>8),u=Fe.relativeLuminance(l>>8);if(yt(c,u)<h){if(u<c){let g=i(a,l,h),p=yt(c,Fe.relativeLuminance(g>>8));if(p<h){let _=n(a,l,h),v=yt(c,Fe.relativeLuminance(_>>8));return p>v?g:_}return g}let m=n(a,l,h),f=yt(c,Fe.relativeLuminance(m>>8));if(f<h){let g=i(a,l,h),p=yt(c,Fe.relativeLuminance(g>>8));return f>p?m:g}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,g=l>>16&255,p=l>>8&255,_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));for(;_<h&&(f>0||g>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),g-=Math.max(0,Math.ceil(g*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));return(f<<24|g<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,g=l>>16&255,p=l>>8&255,_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));for(;_<h&&(f<255||g<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=yt(Fe.relativeLuminance2(f,g,p),Fe.relativeLuminance2(c,u,m));return(f<<24|g<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Ki||(Ki={}));function Vt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function yt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var u_=class extends fi{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},sr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||At.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)sr._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||At.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};sr=we([H(0,We)],sr);function f_(e){return 57508<=e&&e<=57558}function m_(e){return 9472<=e&&e<=9631}function p_(e){return f_(e)||m_(e)}function __(){return{css:{canvas:Ti(),cell:Ti()},device:{canvas:Ti(),cell:Ti(),char:{width:0,height:0,left:0,top:0}}}}function Ti(){return{width:0,height:0}}var Mn=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let _,v=0,y="",x=0,k=0,N=0,w=0,R=!1,T=0,W=!1,G=0,U=0,A=[],M=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,j=E>=U,C=E,B=this._workCell;if(f.length>0&&E===f[0][0]&&j){let ee=f.shift(),fe=this._isCellInSelection(ee[0],t);for(x=ee[0]+1;x<ee[1];x++)j&&(j=fe===this._isCellInSelection(x,t));j&&(j=!s||o<ee[0]||o>=ee[1]),j?(S=!0,B=new u_(this._workCell,e.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),C=ee[1]-1,L=B.getWidth()):U=ee[1]}let X=this._isCellInSelection(E,t),ae=s&&E===o,q=M&&E>=c&&E<=u,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{Q=!0});let ie=B.getChars()||At;if(ie===" "&&(B.isUnderline()||B.isOverline())&&(ie=" "),G=L*l-h.get(ie,B.isBold(),B.isItalic()),!_)_=this._document.createElement("span");else if(v&&(X&&W||!X&&!W&&B.bg===k)&&(X&&W&&g.selectionForeground||B.fg===N)&&B.extended.ext===w&&q===R&&G===T&&!ae&&!S&&!Q&&j){B.isInvisible()?y+=At:y+=ie,v++;continue}else v&&(_.textContent=y),_=this._document.createElement("span"),v=0,y="";if(k=B.bg,N=B.fg,w=B.extended.ext,R=q,T=G,W=X,S&&o>=E&&o<=C&&(o=E),!this._coreService.isCursorHidden&&ae&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(B.isBold()&&A.push("xterm-bold"),B.isItalic()&&A.push("xterm-italic"),B.isDim()&&A.push("xterm-dim"),B.isInvisible()?y=At:y=B.getChars()||At,B.isUnderline()&&(A.push(`xterm-underline-${B.extended.underlineStyle}`),y===" "&&(y=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${fi.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let ee=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&ee<8&&(ee+=8),_.style.textDecorationColor=g.ansi[ee].css}B.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),B.isStrikethrough()&&A.push("xterm-strikethrough"),q&&(_.style.textDecoration="underline");let he=B.getFgColor(),de=B.getFgColorMode(),z=B.getBgColor(),V=B.getBgColorMode(),J=!!B.isInverse();if(J){let ee=he;he=z,z=ee;let fe=de;de=V,V=fe}let D,le,ge=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{ee.options.layer!=="top"&&ge||(ee.backgroundColorRGB&&(V=50331648,z=ee.backgroundColorRGB.rgba>>8&16777215,D=ee.backgroundColorRGB),ee.foregroundColorRGB&&(de=50331648,he=ee.foregroundColorRGB.rgba>>8&16777215,le=ee.foregroundColorRGB),ge=ee.options.layer==="top")}),!ge&&X&&(D=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,z=D.rgba>>8&16777215,V=50331648,ge=!0,g.selectionForeground&&(de=50331648,he=g.selectionForeground.rgba>>8&16777215,le=g.selectionForeground)),ge&&A.push("xterm-decoration-top");let Ee;switch(V){case 16777216:case 33554432:Ee=g.ansi[z],A.push(`xterm-bg-${z}`);break;case 50331648:Ee=je.toColor(z>>16,z>>8&255,z&255),this._addStyle(_,`background-color:#${Xa((z>>>0).toString(16),"0",6)}`);break;case 0:default:J?(Ee=g.foreground,A.push("xterm-bg-257")):Ee=g.background}switch(D||B.isDim()&&(D=xe.multiplyOpacity(Ee,.5)),de){case 16777216:case 33554432:B.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(_,Ee,g.ansi[he],B,D,void 0)||A.push(`xterm-fg-${he}`);break;case 50331648:let ee=je.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(_,Ee,ee,B,D,le)||this._addStyle(_,`color:#${Xa(he.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,Ee,g.foreground,B,D,le)||J&&A.push("xterm-fg-257")}A.length&&(_.className=A.join(" "),A.length=0),!ae&&!S&&!Q&&j?v++:_.textContent=y,G!==this.defaultSpacing&&(_.style.letterSpacing=`${G}px`),m.push(_),E=C}return _&&v&&(_.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||p_(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=xe.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Mn=we([H(1,Ic),H(2,Ue),H(3,jt),H(4,ds),H(5,mi),H(6,Ps)],Mn);function Xa(e,t,s){for(;e.length<s;)e=t+e;return e}var g_=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},x_=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function v_(){return new x_}var Ar="xterm-dom-renderer-owner-",tt="xterm-rows",zi="xterm-fg-",Ja="xterm-bg-",Ws="xterm-focus",Ai="xterm-selection",b_=1,Ln=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=g,this._terminalClass=b_++,this._rowElements=[],this._selectionRenderModel=v_(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(tt),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(Ai),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=__(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Mn,document),this._element.classList.add(Ar+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Ar+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new g_(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${tt} 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} .${tt} { 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} .${tt} .xterm-dim { color: ${xe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ai} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ai} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ai} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${zi}${o} { color: ${a.css}; }${this._terminalSelector} .${zi}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Ja}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${zi}257 { color: ${xe.opaque(e.background).css}; }${this._terminalSelector} .${zi}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ja}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ws),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ws),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ar}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let p=g+l.ydisp,_=this._rowElements[g],v=l.lines.get(p);if(!_||!v)break;_.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===i?t:n)-1:-1))}}};Ln=we([H(7,mo),H(8,_r),H(9,Ue),H(10,We),H(11,ds),H(12,jt),H(13,Ps)],Ln);var Bn=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new S_(this._optionsService))}catch{this._measureStrategy=this._register(new y_(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())}};Bn=we([H(2,Ue)],Bn);var nh=class extends ne{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)}},y_=class extends nh{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},S_=class extends nh{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}},w_=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new C_(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(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}},C_=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Rs),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(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)}},k_=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>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 So(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function N_(e,t,s,i,n,o,a,l,h){if(!o)return;let c=So(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var Tn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return N_(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=So(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Tn=we([H(0,Et),H(1,_r)],Tn);var j_=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},oh={};Am(oh,{getSafariVersion:()=>R_,isChromeOS:()=>hh,isFirefox:()=>ah,isIpad:()=>D_,isIphone:()=>P_,isLegacyEdge:()=>E_,isLinux:()=>wo,isMac:()=>ir,isNode:()=>gr,isSafari:()=>lh,isWindows:()=>ch});var gr=typeof process<"u"&&"title"in process,pi=gr?"node":navigator.userAgent,_i=gr?"node":navigator.platform,ah=pi.includes("Firefox"),E_=pi.includes("Edge"),lh=/^((?!chrome|android).)*safari/i.test(pi);function R_(){if(!lh)return 0;let e=pi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ir=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(_i),D_=_i==="iPad",P_=_i==="iPhone",ch=["Windows","Win16","Win32","WinCE"].includes(_i),wo=_i.indexOf("Linux")>=0,hh=/\bCrOS\b/.test(pi),dh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},M_=class extends dh{_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())}}},L_=class extends dh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},rr=!gr&&"requestIdleCallback"in window?L_:M_,B_=class{constructor(){this._queue=new rr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},zn=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Rs),this._pausedResizeTask=new B_,this._observerDisposable=this._register(new Rs),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 O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new j_((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new T_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};zn=we([H(2,Ue),H(3,_r),H(4,ds),H(5,mi),H(6,We),H(7,jt),H(8,Ps)],zn);var T_=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function z_(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return $_(n,o,e,t,s,i)+xr(o,t,s,i)+I_(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",ci(Math.abs(n-e),li(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=O_(o>t?e:n,s)+(l-1)*s.cols+1+A_(o>t?n:e);return ci(h,li(a,i))}function A_(e,t){return e-1}function O_(e,t){return t.cols-e}function $_(e,t,s,i,n,o){return xr(t,i,n,o).length===0?"":ci(fh(e,t,e,t-as(t,n),!1,n).length,li("D",o))}function xr(e,t,s,i){let n=e-as(e,s),o=t-as(t,s),a=Math.abs(n-o)-F_(e,t,s);return ci(a,li(uh(e,t),i))}function I_(e,t,s,i,n,o){let a;xr(t,i,n,o).length>0?a=i-as(i,n):a=t;let l=i,h=H_(e,t,s,i,n,o);return ci(fh(e,a,s,l,h==="C",n).length,li(h,o))}function F_(e,t,s){var a;let i=0,n=e-as(e,s),o=t-as(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=uh(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function as(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function H_(e,t,s,i,n,o){let a;return xr(s,i,n,o).length>0?a=i-as(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function uh(e,t){return e>t?"A":"B"}function fh(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function li(e,t){let s=t?"O":"[";return P.ESC+s+e}function ci(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var W_=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 Za(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 Or=50,U_=15,K_=50,q_=500,V_=" ",G_=new RegExp(V_,"g"),An=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new W_(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(G_," ")).join(ch?`\r
|
|
224
224
|
`:`
|
|
225
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wo&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Za(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=So(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Or),Or),t/=Or,t/Math.abs(t)+Math.round(t*(K_-1)))}shouldForceSelection(e){return ir?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(),q_)}_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&&!(ir&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<V_&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=A_(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(g+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):k>1&&(f+=k-1,l-=k-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):k>1&&(g+=k-1,h+=k-1),h++,y++}}h++;let p=l+c-u+f,_=Math.min(this._bufferService.cols,h-l+u+m-f-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,_+=x}}}if(i&&p+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(_+=y.length)}}return{start:p,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Za(s,this._bufferService.cols)}};An=we([H(3,We),H(4,ds),H(5,po),H(6,Ue),H(7,Et),H(8,jt)],An);var Qa=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},el=class{constructor(){this._color=new Qa,this._css=new Qa}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Re=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:je.toCss(i,n,o),rgba:je.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:je.toCss(i,i,i),rgba:je.toRgba(i,i,i)})}return e})()),Yt=ye.toColor("#ffffff"),Qs=ye.toColor("#000000"),tl=ye.toColor("#ffffff"),sl=Qs,Ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},X_=Yt,On=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new el,this._halfContrastCache=new el,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Yt,background:Qs,cursor:tl,cursorAccent:sl,selectionForeground:void 0,selectionBackgroundTransparent:Ks,selectionBackgroundOpaque:xe.blend(Qs,Ks),selectionInactiveBackgroundTransparent:Ks,selectionInactiveBackgroundOpaque:xe.blend(Qs,Ks),scrollbarSliderBackground:xe.opacity(Yt,.2),scrollbarSliderHoverBackground:xe.opacity(Yt,.4),scrollbarSliderActiveBackground:xe.opacity(Yt,.5),overviewRulerBorder:Yt,ansi:Re.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=me(e.foreground,Yt),t.background=me(e.background,Qs),t.cursor=xe.blend(t.background,me(e.cursor,tl)),t.cursorAccent=xe.blend(t.background,me(e.cursorAccent,sl)),t.selectionBackgroundTransparent=me(e.selectionBackground,Ks),t.selectionBackgroundOpaque=xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Ya):void 0,t.selectionForeground===Ya&&(t.selectionForeground=void 0),xe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=xe.opacity(t.selectionBackgroundTransparent,.3)),xe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=xe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,xe.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,X_),t.ansi=Re.slice(),t.ansi[0]=me(e.black,Re[0]),t.ansi[1]=me(e.red,Re[1]),t.ansi[2]=me(e.green,Re[2]),t.ansi[3]=me(e.yellow,Re[3]),t.ansi[4]=me(e.blue,Re[4]),t.ansi[5]=me(e.magenta,Re[5]),t.ansi[6]=me(e.cyan,Re[6]),t.ansi[7]=me(e.white,Re[7]),t.ansi[8]=me(e.brightBlack,Re[8]),t.ansi[9]=me(e.brightRed,Re[9]),t.ansi[10]=me(e.brightGreen,Re[10]),t.ansi[11]=me(e.brightYellow,Re[11]),t.ansi[12]=me(e.brightBlue,Re[12]),t.ansi[13]=me(e.brightMagenta,Re[13]),t.ansi[14]=me(e.brightCyan,Re[14]),t.ansi[15]=me(e.brightWhite,Re[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],Re[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};On=we([H(0,Ue)],On);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var J_=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Z_=class{constructor(){this._services=new J_,this._services.set(mo,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Km(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Q_={trace:0,debug:1,info:2,warn:3,error:4,off:5},eg="xterm.js: ",$n=class extends ne{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=Q_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":eg)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};$n=we([H(0,Ue)],$n);var il=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,Ne=Object.freeze(new mi),Oi=0,$r=2,ei=class mh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||rt.fromCharData([0,Lc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?Tt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?Tt(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Oi=t*re,s.content=this._data[Oi+0],s.fg=this._data[Oi+1],s.bg=this._data[Oi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=Tt(s):n&2097151?(this._combined[t]=Tt(n&2097151)+Tt(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new rt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new rt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*$r<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*$r<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*$r<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new mh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Tt(l):At;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function tg(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=di(u,m,t),g=1,p=0;for(;g<u.length;){let v=di(u,g,t),y=v-p,x=s-f,k=Math.min(y,x);u[m].copyCellsFrom(u[g],p,f,k,!1),f+=k,f===s&&(m++,f=0),p+=k,p===v&&(g++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let _=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)_++;_>0&&(a.push(l+u.length-_),a.push(_)),l+=u.length-1}return a}function sg(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function ig(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function rg(e,t,s){let i=[],n=e.map((h,c)=>di(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=di(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function di(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var ph=class _h{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=_h._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),os(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ph._nextId=1;var ng=ph,Pe={},Xt=Pe.B;Pe[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Pe.A={"#":"£"};Pe.B=void 0;Pe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pe.C=Pe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pe.E=Pe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pe.H=Pe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var rl=4294967295,nl=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ne.clone(),this.savedCharset=Xt,this.markers=[],this._nullCell=rt.fromCharData([0,Lc,1,0]),this._whitespaceCell=rt.fromCharData([0,At,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new rr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new il(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 er),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 er),this._whitespaceCell}getBlankLine(e,t){return new ei(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>rl?rl:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ne);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 il(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Ne),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ei(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ei(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),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 o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=tg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ne),s);if(i.length>0){let n=sg(this.lines,i);ig(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Ne),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ei(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ne),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let k=this.ybase+this.y;if(k>=a&&k<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=rg(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let g=[];for(let k=0;k<m;k++){let N=this.getBlankLine(Ne,!0);g.push(N)}g.length>0&&(n.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let p=u.length-1,_=u[p];_===0&&(p--,_=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let k=Math.min(y,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-k,_-k,k,!0),_-=k,_===0&&(p--,_=u[p]),y-=k,y===0){v--;let N=Math.max(v,0);y=di(h,N,this._cols)}}for(let k=0;k<h.length;k++)u[k]<e&&h[k].setCell(u[k],i);let x=m-f;for(;x-- >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+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(_--,m.newLines[v]);_++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(_,l[c--]);let g=0;for(let _=a.length-1;_>=0;_--)a[_].index+=g,this.lines.onInsertEmitter.fire(a[_]),g+=a[_].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new ng(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},og=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),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 nl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new nl(!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)}},gh=2,xh=1,In=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,gh),this.rows=Math.max(e.rawOptions.rows||0,xh),this.buffers=this._register(new og(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};In=we([H(0,Ue)],In);var bs={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:ir,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ag=["normal","bold","100","200","300","400","500","600","700","800","900"],lg=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...bs};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in bs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in bs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=bs[e]),!cg(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=bs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=ag.includes(t)?t:bs[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 cg(e){return e==="block"||e==="underline"||e==="bar"}function ti(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ti(e[i],t-1);return s}var ol=Object.freeze({insertMode:!1}),al=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ti(ol),this.decPrivateModes=ti(al)}reset(){this.modes=ti(ol),this.decPrivateModes=ti(al)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Fn=we([H(0,We),H(1,Oc),H(2,Ue)],Fn);var ll={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 Ir(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Fr=String.fromCharCode,cl={DEFAULT:e=>{let t=[Ir(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Fr(t[0])}${Fr(t[1])}${Fr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ir(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ir(e,!0)};${e.x};${e.y}${t}`}},Hn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(ll))this.addProtocol(i,ll[i]);for(let i of Object.keys(cl))this.addEncoding(i,cl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Hn=we([H(0,We),H(1,ds),H(2,Ue)],Hn);var Hr=[[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]],hg=[[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]],De;function dg(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var ug=class{constructor(){if(this.version="6",!De){De=new Uint8Array(65536),De.fill(1),De[0]=0,De.fill(0,1,32),De.fill(0,127,160),De.fill(2,4352,4448),De[9001]=2,De[9002]=2,De.fill(2,11904,42192),De[12351]=1,De.fill(2,44032,55204),De.fill(2,63744,64256),De.fill(2,65040,65050),De.fill(2,65072,65136),De.fill(2,65280,65377),De.fill(2,65504,65511);for(let e=0;e<Hr.length;++e)De.fill(0,Hr[e][0],Hr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?De[e]:dg(e,hg)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=Jt.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return Jt.createPropertyValue(0,s,i)}},Jt=class qi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new ug;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=qi.extractWidth(l);qi.extractShouldJoin(l)&&(h-=qi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},fg=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 hl(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var qs=2147483647,mg=256,vh=class Wn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>mg)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Wn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new Wn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}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>qs?qs: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>qs?qs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,qs):t}},Vs=[],pg=class{constructor(){this._state=0,this._active=Vs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}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=Vs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Vs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",pr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._id=-1,this._state=0}}},Ze=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=pr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Gs=[],_g=class{constructor(){this._handlers=Object.create(null),this._active=Gs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",pr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gs,this._ident=0}},si=new vh;si.addParam(0);var dl=class{constructor(e){this._handler=e,this._data="",this._params=si,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():si,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=pr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=si,this._data="",this._hitLimit=!1,s));return this._params=si,this._data="",this._hitLimit=!1,t}},gg=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},it=160,xg=(function(){let e=new gg(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(it,0,2,0),e.add(it,8,5,8),e.add(it,6,0,6),e.add(it,11,0,11),e.add(it,13,13,13),e})(),vg=class extends ne{constructor(e=xg){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 vh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new pg),this._dcsParser=this._register(new _g),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:it)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<it){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=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=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<it){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},bg=/^([\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})$/,yg=/^[\da-f]+$/;function ul(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=bg.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),yg.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Wr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function Sg(e,t=16){let[s,i,n]=e;return`rgb:${Wr(s,t)}/${Wr(i,t)}/${Wr(n,t)}`}var wg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bt=131072,fl=10;function ml(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 pl=5e3,_l=0,Cg=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new vg){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Wm,this._utf8Decoder=new Um,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),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 Un(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(P.BEL,()=>this.bell()),this._parser.setExecuteHandler(P.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(P.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(P.BS,()=>this.backspace()),this._parser.setExecuteHandler(P.HT,()=>this.tab()),this._parser.setExecuteHandler(P.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(P.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ui.IND,()=>this.index()),this._parser.setExecuteHandler(Ui.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ui.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ze(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Ze(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Ze(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Ze(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Ze(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Ze(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Ze(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Ze(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Ze(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Ze(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Ze(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Ze(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Pe)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new dl((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),pl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${pl} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Bt&&(o=this._parseStack.position+Bt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Bt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Bt))),a||this._dirtyRowTracker.clearRange(),e.length>Bt)for(let c=o;c<e.length;c+=Bt){let u=c+Bt<e.length?c+Bt:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let g=t;g<s;++g){if(i=e[g],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=Jt.extractWidth(p);let _=Jt.extractShouldJoin(p),v=_?Jt.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Tt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof ei&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(_&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>ml(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new dl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ze(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ne));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=Jt.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(P.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(P.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(P.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(P.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(P.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,Xt),this._charsetService.setgCharset(1,Xt),this._charsetService.setgCharset(2,Xt),this._charsetService.setgCharset(3,Xt);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||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(_,v)=>(a.triggerDataEvent(`${P.ESC}[${t?"":"?"}${_};${v}$y`),!0),g=_=>_?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,g(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,g(m.convertEol)):f(p,0):p===1?f(p,g(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,g(i.origin)):p===7?f(p,g(i.wraparound)):p===8?f(p,3):p===9?f(p,g(n==="X10")):p===12?f(p,g(m.cursorBlink)):p===25?f(p,g(!a.isCursorHidden)):p===45?f(p,g(i.reverseWraparound)):p===66?f(p,g(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,g(n==="VT200")):p===1002?f(p,g(n==="DRAG")):p===1003?f(p,g(n==="ANY")):p===1004?f(p,g(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,g(o==="SGR")):p===1015?f(p,4):p===1016?f(p,g(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,g(c===u)):p===2004?f(p,g(i.bracketedPasteMode)):p===2026?f(p,g(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=mi.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_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=Ne.fg,e.bg=Ne.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ne.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ne.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ne.fg&16777215,i.bg&=-67108864,i.bg|=Ne.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${P.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ne.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ml(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(`${P.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>fl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>fl&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(gl(o))if(n==="?")t.push({type:0,index:o});else{let a=ul(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=ul(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);gl(n)&&t.push({type:2,index:n})}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,Xt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(wg[e[0]],Pe[e[1]]||Xt),!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=Ne.clone(),this._eraseAttrDataInternal=Ne.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 rt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${P.ESC}${a}${P.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Un=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&&(_l=e,e=t,t=_l),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Un=we([H(0,We)],Un);function gl(e){return 0<=e&&e<256}var kg=5e7,xl=12,Ng=50,jg=class extends ne{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 O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>kg)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=xl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=xl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ng&&(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()}},Kn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Kn=we([H(0,We)],Kn);var vl=!1,Eg=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ds),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new Z_,this.optionsService=this._register(new lg(e)),this._instantiationService.setService(Ue,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(In)),this._instantiationService.setService(We,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($n)),this._instantiationService.setService(Oc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fn)),this._instantiationService.setService(ds,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(Ac,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Jt)),this._instantiationService.setService(Gm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(fg),this._instantiationService.setService(Vm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Kn),this._instantiationService.setService($c,this._oscLinkService),this._inputHandler=this._register(new Cg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.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 jg((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),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&&!vl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),vl=!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,gh),t=Math.max(t,xh),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(hl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(hl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},Rg={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 Dg(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(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?n.key=P.ESC+"OA":n.key=P.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=P.ESC+"OD":n.key=P.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=P.ESC+"OC":n.key=P.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=P.ESC+"OB":n.key=P.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":P.DEL,e.altKey&&(n.key=P.ESC+n.key);break;case 9:if(e.shiftKey){n.key=P.ESC+"[Z";break}n.key=P.HT,n.cancel=!0;break;case 13:n.key=e.altKey?P.ESC+P.CR:P.CR,n.cancel=!0;break;case 27:n.key=P.ESC,e.altKey&&(n.key=P.ESC+P.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"D":t?n.key=P.ESC+"OD":n.key=P.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"C":t?n.key=P.ESC+"OC":n.key=P.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"A":t?n.key=P.ESC+"OA":n.key=P.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"B":t?n.key=P.ESC+"OB":n.key=P.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=P.ESC+"[2~");break;case 46:o?n.key=P.ESC+"[3;"+(o+1)+"~":n.key=P.ESC+"[3~";break;case 36:o?n.key=P.ESC+"[1;"+(o+1)+"H":t?n.key=P.ESC+"OH":n.key=P.ESC+"[H";break;case 35:o?n.key=P.ESC+"[1;"+(o+1)+"F":t?n.key=P.ESC+"OF":n.key=P.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=P.ESC+"[5;"+(o+1)+"~":n.key=P.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=P.ESC+"[6;"+(o+1)+"~":n.key=P.ESC+"[6~";break;case 112:o?n.key=P.ESC+"[1;"+(o+1)+"P":n.key=P.ESC+"OP";break;case 113:o?n.key=P.ESC+"[1;"+(o+1)+"Q":n.key=P.ESC+"OQ";break;case 114:o?n.key=P.ESC+"[1;"+(o+1)+"R":n.key=P.ESC+"OR";break;case 115:o?n.key=P.ESC+"[1;"+(o+1)+"S":n.key=P.ESC+"OS";break;case 116:o?n.key=P.ESC+"[15;"+(o+1)+"~":n.key=P.ESC+"[15~";break;case 117:o?n.key=P.ESC+"[17;"+(o+1)+"~":n.key=P.ESC+"[17~";break;case 118:o?n.key=P.ESC+"[18;"+(o+1)+"~":n.key=P.ESC+"[18~";break;case 119:o?n.key=P.ESC+"[19;"+(o+1)+"~":n.key=P.ESC+"[19~";break;case 120:o?n.key=P.ESC+"[20;"+(o+1)+"~":n.key=P.ESC+"[20~";break;case 121:o?n.key=P.ESC+"[21;"+(o+1)+"~":n.key=P.ESC+"[21~";break;case 122:o?n.key=P.ESC+"[23;"+(o+1)+"~":n.key=P.ESC+"[23~";break;case 123:o?n.key=P.ESC+"[24;"+(o+1)+"~":n.key=P.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=P.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=P.DEL:e.keyCode===219?n.key=P.ESC:e.keyCode===220?n.key=P.FS:e.keyCode===221&&(n.key=P.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=Rg[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=P.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=P.ESC+c}else if(e.keyCode===32)n.key=P.ESC+(e.ctrlKey?P.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=P.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=P.US),e.key==="@"&&(n.key=P.NUL));break}return n}var ke=0,Pg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new rr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new rr,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((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ke=this._search(t),ke===-1)||this._getKey(this._array[ke])!==t)return!1;do if(this._array[ke]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do t(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Ur=0,bl=0,Mg=class extends ne{constructor(){super(),this._decorations=new Pg(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Lg(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Ur=n.options.x??0,bl=Ur+(n.options.width??1),e>=Ur&&e<bl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},Lg=class extends Wt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),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=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Bg=1e3,Tg=class{constructor(e,t=Bg){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_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)}},yl=20,nr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Tg(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
225
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),wo&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Za(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=So(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Or),Or),t/=Or,t/Math.abs(t)+Math.round(t*(U_-1)))}shouldForceSelection(e){return ir?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(),K_)}_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&&!(ir&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<q_&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=z_(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(g+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):k>1&&(f+=k-1,l-=k-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):k>1&&(g+=k-1,h+=k-1),h++,y++}}h++;let p=l+c-u+f,_=Math.min(this._bufferService.cols,h-l+u+m-f-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,_+=x}}}if(i&&p+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(_+=y.length)}}return{start:p,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Za(s,this._bufferService.cols)}};An=we([H(3,We),H(4,ds),H(5,po),H(6,Ue),H(7,Et),H(8,jt)],An);var Qa=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},el=class{constructor(){this._color=new Qa,this._css=new Qa}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Re=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:je.toCss(i,n,o),rgba:je.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:je.toCss(i,i,i),rgba:je.toRgba(i,i,i)})}return e})()),Yt=ye.toColor("#ffffff"),Zs=ye.toColor("#000000"),tl=ye.toColor("#ffffff"),sl=Zs,Us={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Y_=Yt,On=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new el,this._halfContrastCache=new el,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Yt,background:Zs,cursor:tl,cursorAccent:sl,selectionForeground:void 0,selectionBackgroundTransparent:Us,selectionBackgroundOpaque:xe.blend(Zs,Us),selectionInactiveBackgroundTransparent:Us,selectionInactiveBackgroundOpaque:xe.blend(Zs,Us),scrollbarSliderBackground:xe.opacity(Yt,.2),scrollbarSliderHoverBackground:xe.opacity(Yt,.4),scrollbarSliderActiveBackground:xe.opacity(Yt,.5),overviewRulerBorder:Yt,ansi:Re.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=me(e.foreground,Yt),t.background=me(e.background,Zs),t.cursor=xe.blend(t.background,me(e.cursor,tl)),t.cursorAccent=xe.blend(t.background,me(e.cursorAccent,sl)),t.selectionBackgroundTransparent=me(e.selectionBackground,Us),t.selectionBackgroundOpaque=xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Ya):void 0,t.selectionForeground===Ya&&(t.selectionForeground=void 0),xe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=xe.opacity(t.selectionBackgroundTransparent,.3)),xe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=xe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,xe.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,Y_),t.ansi=Re.slice(),t.ansi[0]=me(e.black,Re[0]),t.ansi[1]=me(e.red,Re[1]),t.ansi[2]=me(e.green,Re[2]),t.ansi[3]=me(e.yellow,Re[3]),t.ansi[4]=me(e.blue,Re[4]),t.ansi[5]=me(e.magenta,Re[5]),t.ansi[6]=me(e.cyan,Re[6]),t.ansi[7]=me(e.white,Re[7]),t.ansi[8]=me(e.brightBlack,Re[8]),t.ansi[9]=me(e.brightRed,Re[9]),t.ansi[10]=me(e.brightGreen,Re[10]),t.ansi[11]=me(e.brightYellow,Re[11]),t.ansi[12]=me(e.brightBlue,Re[12]),t.ansi[13]=me(e.brightMagenta,Re[13]),t.ansi[14]=me(e.brightCyan,Re[14]),t.ansi[15]=me(e.brightWhite,Re[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],Re[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};On=we([H(0,Ue)],On);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var X_=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},J_=class{constructor(){this._services=new X_,this._services.set(mo,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Um(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Z_={trace:0,debug:1,info:2,warn:3,error:4,off:5},Q_="xterm.js: ",$n=class extends ne{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=Z_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Q_)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};$n=we([H(0,Ue)],$n);var il=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,Ne=Object.freeze(new fi),Oi=0,$r=2,Qs=class mh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||rt.fromCharData([0,Lc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?Tt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?Tt(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Oi=t*re,s.content=this._data[Oi+0],s.fg=this._data[Oi+1],s.bg=this._data[Oi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=Tt(s):n&2097151?(this._combined[t]=Tt(n&2097151)+Tt(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new rt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new rt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*$r<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*$r<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*$r<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new mh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Tt(l):At;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function eg(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=hi(u,m,t),g=1,p=0;for(;g<u.length;){let v=hi(u,g,t),y=v-p,x=s-f,k=Math.min(y,x);u[m].copyCellsFrom(u[g],p,f,k,!1),f+=k,f===s&&(m++,f=0),p+=k,p===v&&(g++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let _=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)_++;_>0&&(a.push(l+u.length-_),a.push(_)),l+=u.length-1}return a}function tg(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function sg(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function ig(e,t,s){let i=[],n=e.map((h,c)=>hi(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=hi(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function hi(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var ph=class _h{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=_h._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),os(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ph._nextId=1;var rg=ph,Pe={},Xt=Pe.B;Pe[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Pe.A={"#":"£"};Pe.B=void 0;Pe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pe.C=Pe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pe.E=Pe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pe.H=Pe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var rl=4294967295,nl=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ne.clone(),this.savedCharset=Xt,this.markers=[],this._nullCell=rt.fromCharData([0,Lc,1,0]),this._whitespaceCell=rt.fromCharData([0,At,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new rr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new il(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 er),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 er),this._whitespaceCell}getBlankLine(e,t){return new Qs(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>rl?rl:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ne);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 il(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Ne),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Qs(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Qs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),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 o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=eg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ne),s);if(i.length>0){let n=tg(this.lines,i);sg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Ne),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Qs(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ne),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let k=this.ybase+this.y;if(k>=a&&k<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=ig(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let g=[];for(let k=0;k<m;k++){let N=this.getBlankLine(Ne,!0);g.push(N)}g.length>0&&(n.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let p=u.length-1,_=u[p];_===0&&(p--,_=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let k=Math.min(y,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-k,_-k,k,!0),_-=k,_===0&&(p--,_=u[p]),y-=k,y===0){v--;let N=Math.max(v,0);y=hi(h,N,this._cols)}}for(let k=0;k<h.length;k++)u[k]<e&&h[k].setCell(u[k],i);let x=m-f;for(;x-- >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+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(_--,m.newLines[v]);_++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(_,l[c--]);let g=0;for(let _=a.length-1;_>=0;_--)a[_].index+=g,this.lines.onInsertEmitter.fire(a[_]),g+=a[_].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new rg(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},ng=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),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 nl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new nl(!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)}},gh=2,xh=1,In=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,gh),this.rows=Math.max(e.rawOptions.rows||0,xh),this.buffers=this._register(new ng(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};In=we([H(0,Ue)],In);var vs={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:ir,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},og=["normal","bold","100","200","300","400","500","600","700","800","900"],ag=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...vs};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=vs[e]),!lg(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=vs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=og.includes(t)?t:vs[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 lg(e){return e==="block"||e==="underline"||e==="bar"}function ei(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ei(e[i],t-1);return s}var ol=Object.freeze({insertMode:!1}),al=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Fn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ei(ol),this.decPrivateModes=ei(al)}reset(){this.modes=ei(ol),this.decPrivateModes=ei(al)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Fn=we([H(0,We),H(1,Oc),H(2,Ue)],Fn);var ll={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 Ir(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Fr=String.fromCharCode,cl={DEFAULT:e=>{let t=[Ir(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Fr(t[0])}${Fr(t[1])}${Fr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ir(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ir(e,!0)};${e.x};${e.y}${t}`}},Hn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(ll))this.addProtocol(i,ll[i]);for(let i of Object.keys(cl))this.addEncoding(i,cl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Hn=we([H(0,We),H(1,ds),H(2,Ue)],Hn);var Hr=[[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]],cg=[[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]],De;function hg(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var dg=class{constructor(){if(this.version="6",!De){De=new Uint8Array(65536),De.fill(1),De[0]=0,De.fill(0,1,32),De.fill(0,127,160),De.fill(2,4352,4448),De[9001]=2,De[9002]=2,De.fill(2,11904,42192),De[12351]=1,De.fill(2,44032,55204),De.fill(2,63744,64256),De.fill(2,65040,65050),De.fill(2,65072,65136),De.fill(2,65280,65377),De.fill(2,65504,65511);for(let e=0;e<Hr.length;++e)De.fill(0,Hr[e][0],Hr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?De[e]:hg(e,cg)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=Jt.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return Jt.createPropertyValue(0,s,i)}},Jt=class qi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new dg;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=qi.extractWidth(l);qi.extractShouldJoin(l)&&(h-=qi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},ug=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 hl(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Ks=2147483647,fg=256,vh=class Wn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>fg)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Wn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new Wn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}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>Ks?Ks: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>Ks?Ks:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,Ks):t}},qs=[],mg=class{constructor(){this._state=0,this._active=qs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}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=qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||qs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",pr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=qs,this._id=-1,this._state=0}}},Ze=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=pr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Vs=[],pg=class{constructor(){this._handlers=Object.create(null),this._active=Vs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Vs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",pr(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._ident=0}},ti=new vh;ti.addParam(0);var dl=class{constructor(e){this._handler=e,this._data="",this._params=ti,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ti,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=pr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ti,this._data="",this._hitLimit=!1,s));return this._params=ti,this._data="",this._hitLimit=!1,t}},_g=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},it=160,gg=(function(){let e=new _g(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(it,0,2,0),e.add(it,8,5,8),e.add(it,6,0,6),e.add(it,11,0,11),e.add(it,13,13,13),e})(),xg=class extends ne{constructor(e=gg){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 vh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new mg),this._dcsParser=this._register(new pg),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:it)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<it){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=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=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<it){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},vg=/^([\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})$/,bg=/^[\da-f]+$/;function ul(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=vg.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),bg.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Wr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function yg(e,t=16){let[s,i,n]=e;return`rgb:${Wr(s,t)}/${Wr(i,t)}/${Wr(n,t)}`}var Sg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bt=131072,fl=10;function ml(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 pl=5e3,_l=0,wg=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new xg){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Hm,this._utf8Decoder=new Wm,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),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 Un(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(P.BEL,()=>this.bell()),this._parser.setExecuteHandler(P.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(P.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(P.BS,()=>this.backspace()),this._parser.setExecuteHandler(P.HT,()=>this.tab()),this._parser.setExecuteHandler(P.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(P.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ui.IND,()=>this.index()),this._parser.setExecuteHandler(Ui.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ui.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ze(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Ze(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Ze(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Ze(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Ze(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Ze(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Ze(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Ze(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Ze(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Ze(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Ze(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Ze(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Pe)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new dl((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),pl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${pl} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Bt&&(o=this._parseStack.position+Bt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Bt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Bt))),a||this._dirtyRowTracker.clearRange(),e.length>Bt)for(let c=o;c<e.length;c+=Bt){let u=c+Bt<e.length?c+Bt:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let g=t;g<s;++g){if(i=e[g],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=Jt.extractWidth(p);let _=Jt.extractShouldJoin(p),v=_?Jt.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Tt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof Qs&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(_&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>ml(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new dl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ze(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ne));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=Jt.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(P.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(P.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(P.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(P.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(P.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,Xt),this._charsetService.setgCharset(1,Xt),this._charsetService.setgCharset(2,Xt),this._charsetService.setgCharset(3,Xt);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||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(_,v)=>(a.triggerDataEvent(`${P.ESC}[${t?"":"?"}${_};${v}$y`),!0),g=_=>_?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,g(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,g(m.convertEol)):f(p,0):p===1?f(p,g(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,g(i.origin)):p===7?f(p,g(i.wraparound)):p===8?f(p,3):p===9?f(p,g(n==="X10")):p===12?f(p,g(m.cursorBlink)):p===25?f(p,g(!a.isCursorHidden)):p===45?f(p,g(i.reverseWraparound)):p===66?f(p,g(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,g(n==="VT200")):p===1002?f(p,g(n==="DRAG")):p===1003?f(p,g(n==="ANY")):p===1004?f(p,g(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,g(o==="SGR")):p===1015?f(p,4):p===1016?f(p,g(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,g(c===u)):p===2004?f(p,g(i.bracketedPasteMode)):p===2026?f(p,g(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=fi.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_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=Ne.fg,e.bg=Ne.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ne.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ne.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ne.fg&16777215,i.bg&=-67108864,i.bg|=Ne.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${P.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ne.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ml(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(`${P.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>fl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>fl&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(gl(o))if(n==="?")t.push({type:0,index:o});else{let a=ul(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=ul(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);gl(n)&&t.push({type:2,index:n})}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,Xt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Sg[e[0]],Pe[e[1]]||Xt),!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=Ne.clone(),this._eraseAttrDataInternal=Ne.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 rt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${P.ESC}${a}${P.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Un=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&&(_l=e,e=t,t=_l),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Un=we([H(0,We)],Un);function gl(e){return 0<=e&&e<256}var Cg=5e7,xl=12,kg=50,Ng=class extends ne{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 O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Cg)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=xl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=xl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>kg&&(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()}},Kn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Kn=we([H(0,We)],Kn);var vl=!1,jg=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Rs),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new J_,this.optionsService=this._register(new ag(e)),this._instantiationService.setService(Ue,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(In)),this._instantiationService.setService(We,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($n)),this._instantiationService.setService(Oc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Fn)),this._instantiationService.setService(ds,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(Ac,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Jt)),this._instantiationService.setService(Vm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ug),this._instantiationService.setService(qm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Kn),this._instantiationService.setService($c,this._oscLinkService),this._inputHandler=this._register(new wg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.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 Ng((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),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&&!vl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),vl=!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,gh),t=Math.max(t,xh),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(hl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(hl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},Eg={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 Rg(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(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?n.key=P.ESC+"OA":n.key=P.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=P.ESC+"OD":n.key=P.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=P.ESC+"OC":n.key=P.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=P.ESC+"OB":n.key=P.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":P.DEL,e.altKey&&(n.key=P.ESC+n.key);break;case 9:if(e.shiftKey){n.key=P.ESC+"[Z";break}n.key=P.HT,n.cancel=!0;break;case 13:n.key=e.altKey?P.ESC+P.CR:P.CR,n.cancel=!0;break;case 27:n.key=P.ESC,e.altKey&&(n.key=P.ESC+P.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"D":t?n.key=P.ESC+"OD":n.key=P.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"C":t?n.key=P.ESC+"OC":n.key=P.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"A":t?n.key=P.ESC+"OA":n.key=P.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"B":t?n.key=P.ESC+"OB":n.key=P.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=P.ESC+"[2~");break;case 46:o?n.key=P.ESC+"[3;"+(o+1)+"~":n.key=P.ESC+"[3~";break;case 36:o?n.key=P.ESC+"[1;"+(o+1)+"H":t?n.key=P.ESC+"OH":n.key=P.ESC+"[H";break;case 35:o?n.key=P.ESC+"[1;"+(o+1)+"F":t?n.key=P.ESC+"OF":n.key=P.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=P.ESC+"[5;"+(o+1)+"~":n.key=P.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=P.ESC+"[6;"+(o+1)+"~":n.key=P.ESC+"[6~";break;case 112:o?n.key=P.ESC+"[1;"+(o+1)+"P":n.key=P.ESC+"OP";break;case 113:o?n.key=P.ESC+"[1;"+(o+1)+"Q":n.key=P.ESC+"OQ";break;case 114:o?n.key=P.ESC+"[1;"+(o+1)+"R":n.key=P.ESC+"OR";break;case 115:o?n.key=P.ESC+"[1;"+(o+1)+"S":n.key=P.ESC+"OS";break;case 116:o?n.key=P.ESC+"[15;"+(o+1)+"~":n.key=P.ESC+"[15~";break;case 117:o?n.key=P.ESC+"[17;"+(o+1)+"~":n.key=P.ESC+"[17~";break;case 118:o?n.key=P.ESC+"[18;"+(o+1)+"~":n.key=P.ESC+"[18~";break;case 119:o?n.key=P.ESC+"[19;"+(o+1)+"~":n.key=P.ESC+"[19~";break;case 120:o?n.key=P.ESC+"[20;"+(o+1)+"~":n.key=P.ESC+"[20~";break;case 121:o?n.key=P.ESC+"[21;"+(o+1)+"~":n.key=P.ESC+"[21~";break;case 122:o?n.key=P.ESC+"[23;"+(o+1)+"~":n.key=P.ESC+"[23~";break;case 123:o?n.key=P.ESC+"[24;"+(o+1)+"~":n.key=P.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=P.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=P.DEL:e.keyCode===219?n.key=P.ESC:e.keyCode===220?n.key=P.FS:e.keyCode===221&&(n.key=P.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=Eg[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=P.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=P.ESC+c}else if(e.keyCode===32)n.key=P.ESC+(e.ctrlKey?P.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=P.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=P.US),e.key==="@"&&(n.key=P.NUL));break}return n}var ke=0,Dg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new rr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new rr,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((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ke=this._search(t),ke===-1)||this._getKey(this._array[ke])!==t)return!1;do if(this._array[ke]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do t(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Ur=0,bl=0,Pg=class extends ne{constructor(){super(),this._decorations=new Dg(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Mg(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Ur=n.options.x??0,bl=Ur+(n.options.width??1),e>=Ur&&e<bl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},Mg=class extends Wt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),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=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Lg=1e3,Bg=class{constructor(e,t=Lg){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_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)}},yl=20,nr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Bg(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
226
226
|
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Y(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ve(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<yl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
227
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===yl+1&&(this._liveRegion.textContent+=dn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let g=c<f.length?f[c]:f.slice(-1)[0]+1;return g>=this._terminal.cols&&(++m,g=0),{row:m,column:g}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};nr=we([H(1,mo),H(2,jt),H(3,Et)],nr);var qn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;os(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&zg(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,os(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};qn=we([H(1,po),H(2,Et),H(3,We),H(4,Fc)],qn);function zg(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 Ag=class extends Eg{constructor(e={}){super(e),this._linkifier=this._register(new Ds),this.browser=oh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ds),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(Mg),this._instantiationService.setService(pi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(N_),this._instantiationService.setService(Fc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(fn)),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($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${P.ESC}]${i};${Sg(n)}${rh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=je.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=je.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(nr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.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(P.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",t=>{this.hasSelection()&&Fm(t,this._selectionService)}));let e=t=>Hm(t,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",e)),this._register(Y(this.element,"paste",e)),ah?this._register(Y(this.element,"mousedown",t=>{t.button===2&&Pa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",t=>{Pa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wo&&this._register(Y(this.element,"auxclick",t=>{t.button===1&&Mc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Y(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Y(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;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"),((n=this.element)==null?void 0:n.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(Y(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",hn.get()),hh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(C_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(jt,this._coreBrowserService),this._register(Y(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bn,this._document,this._helperContainer),this._instantiationService.setService(_r,this._charSizeService),this._themeService=this._instantiationService.createInstance(On),this._instantiationService.setService(Ms,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(sr),this._instantiationService.setService(Ic,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(zn,this.rows,this.screenElement)),this._instantiationService.setService(Et,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Pn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Tn),this._instantiationService.setService(po,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(qn,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(Rn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(An,this.element,this.screenElement,i)),this._instantiationService.setService(Xm,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Dn,this.screenElement)),this._register(Y(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(nr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ln,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Y(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=P.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Pc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=Dg(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===P.ETX||s.key===P.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Og(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ne));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(P.ESC+"[I"):this.coreService.triggerDataEvent(P.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Og(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var $g=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Ig=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 rt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Sl=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 Ig(t)}getNullCell(){return new rt}},Fg=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Sl(this._core.buffers.normal,"normal"),this._alternate=new Sl(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)}},Hg=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Wg=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}},Ug=["cols","rows"],ht=0,Kg=class extends ne{constructor(e){super(),this._core=this._register(new Ag(e)),this._addonManager=this._register(new $g),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(Ug.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 Hg(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Wg(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 Fg(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
227
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===yl+1&&(this._liveRegion.textContent+=dn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let g=c<f.length?f[c]:f.slice(-1)[0]+1;return g>=this._terminal.cols&&(++m,g=0),{row:m,column:g}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};nr=we([H(1,mo),H(2,jt),H(3,Et)],nr);var qn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;os(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Tg(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,os(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};qn=we([H(1,po),H(2,Et),H(3,We),H(4,Fc)],qn);function Tg(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 zg=class extends jg{constructor(e={}){super(e),this._linkifier=this._register(new Rs),this.browser=oh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Rs),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(Pg),this._instantiationService.setService(mi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(k_),this._instantiationService.setService(Fc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(fn)),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($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${P.ESC}]${i};${yg(n)}${rh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=je.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=je.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(nr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.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(P.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",t=>{this.hasSelection()&&Im(t,this._selectionService)}));let e=t=>Fm(t,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",e)),this._register(Y(this.element,"paste",e)),ah?this._register(Y(this.element,"mousedown",t=>{t.button===2&&Pa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",t=>{Pa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wo&&this._register(Y(this.element,"auxclick",t=>{t.button===1&&Mc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Y(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Y(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;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"),((n=this.element)==null?void 0:n.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(Y(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",hn.get()),hh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(w_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(jt,this._coreBrowserService),this._register(Y(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Bn,this._document,this._helperContainer),this._instantiationService.setService(_r,this._charSizeService),this._themeService=this._instantiationService.createInstance(On),this._instantiationService.setService(Ps,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(sr),this._instantiationService.setService(Ic,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(zn,this.rows,this.screenElement)),this._instantiationService.setService(Et,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Pn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Tn),this._instantiationService.setService(po,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(qn,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(Rn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(An,this.element,this.screenElement,i)),this._instantiationService.setService(Ym,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Dn,this.screenElement)),this._register(Y(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(nr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(tr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ln,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Y(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=P.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Pc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=Rg(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===P.ETX||s.key===P.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Ag(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ne));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(P.ESC+"[I"):this.coreService.triggerDataEvent(P.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Ag(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Og=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},$g=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 rt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Sl=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 $g(t)}getNullCell(){return new rt}},Ig=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Sl(this._core.buffers.normal,"normal"),this._alternate=new Sl(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)}},Fg=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Hg=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}},Wg=["cols","rows"],ht=0,Ug=class extends ne{constructor(e){super(),this._core=this._register(new zg(e)),this._addonManager=this._register(new Og),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(Wg.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 Fg(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Hg(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 Ig(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
228
228
|
`,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 hn.get()},set promptLabel(e){hn.set(e)},get tooMuchOutput(){return dn.get()},set tooMuchOutput(e){dn.set(e)}}}_verifyIntegers(...e){for(ht of e)if(ht===1/0||isNaN(ht)||ht%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ht of e)if(ht&&(ht===1/0||isNaN(ht)||ht%1!==0||ht<0))throw new Error("This API only accepts positive integers")}};/**
|
|
229
229
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
230
230
|
* @license MIT
|
|
@@ -236,7 +236,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
236
236
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
237
237
|
* http://bellard.org/jslinux/
|
|
238
238
|
* Copyright (c) 2011 Fabrice Bellard
|
|
239
|
-
*/var
|
|
239
|
+
*/var Kg=2,qg=1,Vg=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 m;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:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=n-h-t;return{cols:Math.max(Kg,Math.floor(u/e.css.cell.width)),rows:Math.max(qg,Math.floor(c/e.css.cell.height))}}};/**
|
|
240
240
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
241
241
|
* @license MIT
|
|
242
242
|
*
|
|
@@ -247,21 +247,21 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
247
247
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
248
248
|
* http://bellard.org/jslinux/
|
|
249
249
|
* Copyright (c) 2011 Fabrice Bellard
|
|
250
|
-
*/var
|
|
250
|
+
*/var Gg=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=Xg.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:n}=t;this._options.hover(s,i,n)}},t))}};function Yg(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Xg=class Vi{static computeLink(t,s,i,n){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Vi._getWindowedLineStrings(t-1,i),h=a.join(""),c,u=[];for(;c=o.exec(h);){let m=c[0];if(!Yg(m))continue;let[f,g]=Vi._mapStrIdx(i,l,0,c.index),[p,_]=Vi._mapStrIdx(i,f,g,m.length);if(f===-1||g===-1||p===-1||_===-1)continue;let v={start:{x:g+1,y:f+1},end:{x:_,y:p+1}};u.push({range:v,text:m,activate:n})}return u}static _getWindowedLineStrings(t,s){let i,n=t,o=t,a=0,l="",h=[];if(i=s.buffer.active.getLine(t)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--n))&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););h.reverse()}for(h.push(c),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),l.indexOf(" ")===-1););}return[h,n]}static _mapStrIdx(t,s,i,n){let o=t.buffer.active,a=o.getNullCell(),l=i;for(;n;){let h=o.getLine(s);if(!h)return[-1,-1];for(let c=l;c<h.length;++c){h.getCell(c,a);let u=a.getChars();if(a.getWidth()&&(n-=u.length||1,c===h.length-1&&u==="")){let m=o.getLine(s+1);m&&m.isWrapped&&(m.getCell(0,a),a.getWidth()===2&&(n+=1))}if(n<0)return[s,c]}s++,l=0}return[s,l]}},Jg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Zg(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Qg=class{constructor(e=Zg,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||Jg;this._linkProvider=this._terminal.registerLinkProvider(new Gg(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const wl=10,ex=1e3,tx=3e4;function sx({sessionId:e,isActive:t}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),o=d.useRef(null),a=d.useRef(null),l=d.useRef(!0),h=d.useRef(0),c=d.useCallback(()=>{const m=o.current,f=i.current;m&&m.readyState===WebSocket.OPEN&&f&&m.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},[]),u=d.useCallback(()=>{if(!l.current)return;o.current&&(o.current.onclose=null,o.current.onerror=null,o.current.close(),o.current=null);const f=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal/${e}`,g=new WebSocket(f);o.current=g,g.onopen=()=>{h.current=0;const p=i.current;p&&p.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const _=n.current;if(_&&p){try{_.fit()}catch{}c()}},g.onmessage=p=>{try{const _=JSON.parse(p.data);_.type==="output"&&i.current?i.current.write(_.data):_.type==="error"&&i.current&&i.current.writeln(`\x1B[31m${_.data}\x1B[0m`)}catch{i.current&&i.current.write(p.data)}},g.onclose=p=>{if(!l.current)return;const _=i.current;if(p.code===4e3){_&&_.writeln(`\r
|
|
251
251
|
\x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const v=h.current;if(v>=wl){_&&_.writeln(`\r
|
|
252
|
-
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(
|
|
253
|
-
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${wl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},g.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new Kg({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),g=new Gg,p=new ex;f.loadAddon(g),f.loadAddon(p),f.open(m),i.current=f,n.current=g;try{g.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let _=null;const v=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const Cl={file_created:{icon:dr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Z,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Xl,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:kt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:Ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:Ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Kl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:es,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ot,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Ul,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function kl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function rx({event:e,isLast:t,onFileClick:s}){const i=Cl[e.type]||Cl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(nt,{size:10}),kl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(nt,{size:10}),kl(e.timestamp)]})]})})]})}const Kr=20,Nl=10;function nx({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Kr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Wl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Kr&&n,l=a?e.slice(-Nl):e,h=a?e.length-Nl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(lr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Kr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ls,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(rx,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const jl=[{id:"terminal",label:"Terminal",icon:es,alwaysShow:!0},{id:"activity",label:"Activity",icon:Md,alwaysShow:!0},{id:"build",label:"Build Log",icon:ju},{id:"agents",label:"Agents",icon:Ld},{id:"quality",label:"Quality",icon:ql}];function ox({status:e}){switch(e){case"pass":return r.jsx(Ut,{size:14,className:"text-success"});case"fail":return r.jsx(ft,{size:14,className:"text-danger"});default:return r.jsx(nt,{size:14,className:"text-muted"})}}function ax({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(_d,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function lx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(ql,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ox,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function cx({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var _;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,g=e&&e.length>0,p=jl.filter(v=>!!(v.alwaysShow||v.id==="build"&&(g||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=jl.find(v=>v.id===c))==null?void 0:_.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(ix,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Rd,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(ax,{agents:s}),c==="activity"&&r.jsx(nx,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(lx,{checklist:i})]})]})}const El={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function hx({context:e="general",className:t=""}){const s=El[e]||El.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(ui,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const qr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Jd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Bd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ii},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:ts},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:kt}];function dx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=qr.findIndex(x=>x.id===e),g=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,_=Math.max(0,s-t),v=Math.ceil(p*_),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${g}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:qr.map((x,k)=>{const N=k<f,w=k===f,R=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${N?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${N?"phase-icon-complete":""}`,children:N?r.jsx(kt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(R,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(R,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":N?"text-success":"text-muted/50"}`,children:x.label}),k<qr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${N?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(hx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Zt,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(nt,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Jl,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Vr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function ux({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
|
|
252
|
+
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(ex*Math.pow(2,v),tx);h.current=v+1,_&&_.writeln(`\r
|
|
253
|
+
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${wl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},g.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new Ug({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),g=new Vg,p=new Qg;f.loadAddon(g),f.loadAddon(p),f.open(m),i.current=f,n.current=g;try{g.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let _=null;const v=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const Cl={file_created:{icon:dr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Z,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Xl,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:kt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:Ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:Ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Kl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:es,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ot,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Ul,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function kl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function ix({event:e,isLast:t,onFileClick:s}){const i=Cl[e.type]||Cl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(nt,{size:10}),kl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(nt,{size:10}),kl(e.timestamp)]})]})})]})}const Kr=20,Nl=10;function rx({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Kr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Wl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Kr&&n,l=a?e.slice(-Nl):e,h=a?e.length-Nl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(lr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Kr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ls,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(ix,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const jl=[{id:"terminal",label:"Terminal",icon:es,alwaysShow:!0},{id:"activity",label:"Activity",icon:Pd,alwaysShow:!0},{id:"build",label:"Build Log",icon:Nu},{id:"agents",label:"Agents",icon:Md},{id:"quality",label:"Quality",icon:ql}];function nx({status:e}){switch(e){case"pass":return r.jsx(Ut,{size:14,className:"text-success"});case"fail":return r.jsx(ft,{size:14,className:"text-danger"});default:return r.jsx(nt,{size:14,className:"text-muted"})}}function ox({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(pd,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function ax({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(ql,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(nx,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function lx({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var _;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,g=e&&e.length>0,p=jl.filter(v=>!!(v.alwaysShow||v.id==="build"&&(g||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=jl.find(v=>v.id===c))==null?void 0:_.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(sx,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Ed,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(ox,{agents:s}),c==="activity"&&r.jsx(rx,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(ax,{checklist:i})]})]})}const El={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function cx({context:e="general",className:t=""}){const s=El[e]||El.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(di,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const qr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Xd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Ld},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:si},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:ts},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:kt}];function hx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=qr.findIndex(x=>x.id===e),g=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,_=Math.max(0,s-t),v=Math.ceil(p*_),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${g}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:qr.map((x,k)=>{const N=k<f,w=k===f,R=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${N?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${N?"phase-icon-complete":""}`,children:N?r.jsx(kt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(R,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(R,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":N?"text-success":"text-muted/50"}`,children:x.label}),k<qr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${N?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(cx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Zt,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(nt,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Jl,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Vr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function dx({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
|
|
254
254
|
focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
|
|
255
|
-
placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ss,{size:10})]}),r.jsx(ue,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(Ps,{size:12}),a]})]})}function fx(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(es,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ss,{size:10})]})]})}function mx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(ue,{variant:"danger",size:"sm",icon:Hu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsx(r.Fragment,{children:e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsxs(ue,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:["Connect ",e.name]})}),n&&r.jsx(ux,{platform:e,onConnect:c})]}):r.jsx(fx,{})})]})}function px({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await K.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const _=await K.connectVercel(p);_.success&&(i(v=>({...v,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),u=d.useCallback(async p=>{const _=await K.connectNetlify(p);_.success&&(i(v=>({...v,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),m=d.useCallback(async p=>{await K.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const _={...s,[p]:{connected:!1}};t==null||t(_)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(ui,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const g=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[g," of ",Vr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(Ct,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Vr.map(p=>{const _=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${_.connected?`Connected as ${_.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${_.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(Ct,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(Ps,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Vr.map(p=>r.jsx(mx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const _x=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:en,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:en,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function gx({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(ue,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(ui,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(en,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Zn,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ss,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Ps,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(ue,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function xx({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await K.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(ue,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(ui,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Zn,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Ps,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(ue,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function vx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await K.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx($t,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(rc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(px,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:_x.map(u=>r.jsx(gx,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(xx,{sessionId:e,disabled:l})]})})}const bh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),St=bh?"Cmd":"Ctrl",Rl=[{keys:[`${St}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${St}+P`],label:"Quick open file",category:"navigation"},{keys:[`${St}+,`],label:"Open settings",category:"navigation"},{keys:[`${St}+S`],label:"Save file",category:"editor"},{keys:[`${St}+Z`],label:"Undo",category:"editor"},{keys:[`${St}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${St}+B`],label:"Start / stop build",category:"build"},{keys:[`${St}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${St}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],bx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},yx=["navigation","editor","build","general"];function Sx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=bh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function wx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Rl;const a=s.toLowerCase();return Rl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(gd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[yx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:bx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.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 Cx({onClick:e}){return r.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:"?"})}const yh="pl_recent_commands",kx=5;function Sh(){try{const e=localStorage.getItem(yh);return e?JSON.parse(e):[]}catch{return[]}}function Gr(e){try{const t=Sh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(yh,JSON.stringify(t.slice(0,kx)))}catch{}}function Nx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Z,ts:Z,tsx:Z,jsx:Z,py:Z,go:Z,rs:Z,rb:Z,sh:Z,html:sc,css:to,json:eo,md:cr}[t]||so}function jx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Dl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function Ex({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),g=d.useRef(null),p=d.useRef(null),_=xd(e);vd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=g.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>Sh().map(j=>s.find(C=>C.id===j)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(j=>({cmd:j,indices:[]}));const S=[];for(const j of s){const C=jx(o,j.label);if(C){const B=C[0]*10+(C[C.length-1]-C[0]);S.push({cmd:j,indices:C,score:B})}}return S.sort((j,C)=>j.score-C.score),S.map(j=>({cmd:j.cmd,indices:j.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),k=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await K.searchFiles(i,o);u(S.filter(j=>j.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const N=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return N&&v.forEach((j,C)=>S.push({type:"recent",index:C})),k.forEach((j,C)=>S.push({type:"command",index:C})),x.length>0&&x.forEach((j,C)=>S.push({type:"setting",index:C})),c.forEach((j,C)=>S.push({type:"file",index:C})),S},[N,v,k,x,c]),R=w.length;d.useEffect(()=>{h(0)},[o]);const T=d.useCallback(S=>{const j=w[S];if(j){if(j.type==="recent"){const C=v[j.index];C&&(Gr(C.id),C.action(),t())}else if(j.type==="command"){const C=k[j.index];C&&(Gr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="setting"){const C=x[j.index];C&&(Gr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="file"){const C=c[j.index];C&&n&&(n(C.path,C.name),t())}}},[w,v,k,x,c,n,t]),W=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(j=>Math.min(j+1,R-1))):S.key==="ArrowUp"?(S.preventDefault(),h(j=>Math.max(j-1,0))):S.key==="Enter"&&R>0?T(l):S.key==="Escape"&&t()},[R,l,T,t]);if(!e)return null;let G=0;const U=()=>G++,A=k.length>0,M=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:_,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(ts,{size:18,className:"text-muted"}),r.jsx("input",{ref:g,value:o,onChange:S=>a(S.target.value),onKeyDown:W,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[N&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(nt,{size:10})," Recent"]}),v.map((S,j)=>{const C=U(),B=S.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),k.map((S,j)=>{const C=U(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Dl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),M&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,j)=>{const C=U(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Dl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,j)=>{const C=U(),B=S.type==="directory"?io:Nx(S.name);return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),R===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Rx=d.lazy(()=>Xn(()=>import("./GitHubIssuesPanel-Bb_2EF_6.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(e=>({default:e.GitHubIssuesPanel}))),Dx=d.lazy(()=>Xn(()=>import("./GitHubPRsPanel-DYOecXRG.js"),__vite__mapDeps([31,1,2,3,32,4,5,33,12,14,17,9,10,11,13,15,16,8,18,19,20,21,22,23,24,7,25,26,27,28,29,30])).then(e=>({default:e.GitHubPRsPanel}))),Px=d.lazy(()=>Xn(()=>Promise.resolve().then(()=>Yx),void 0).then(e=>({default:e.CICDPanel}))),Mx=3e4,Lx={modified:r.jsx(Z,{size:13,className:"text-yellow-500"}),added:r.jsx(dr,{size:13,className:"text-green-500"}),deleted:r.jsx(Qn,{size:13,className:"text-red-400"}),renamed:r.jsx(Z,{size:13,className:"text-blue-400"}),untracked:r.jsx(ic,{size:13,className:"text-muted"})},Bx={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Tx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Zl,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Pl({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Lx[e.status]||r.jsx(ic,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Bx[e.status]||"?"})]})}function zx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[g,p]=d.useState(""),[_,v]=d.useState(!1),[y,x]=d.useState(null),[k,N]=d.useState(!1),[w,R]=d.useState(""),[T,W]=d.useState(!1),[G,U]=d.useState(!1),[A,M]=d.useState(""),[E,L]=d.useState(""),[S,j]=d.useState(!1),[C,B]=d.useState(null),[X,ae]=d.useState(!1),q=d.useCallback(async()=>{u(!0),f(null);try{const[D,le,ge]=await Promise.all([K.git.status(e),K.git.log(e),K.git.branches(e)]);n(D),a(le),h(ge)}catch(D){f(D instanceof Error?D.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{q()},[q]);const Q=async()=>{if(!(!g.trim()||_)){v(!0),x(null);try{const D=await K.git.commit(e,g.trim());x(`Committed: ${D.hash}`),p(""),await q()}catch(D){x(`Error: ${D instanceof Error?D.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||T)){W(!0);try{await K.git.createBranch(e,w.trim()),R(""),N(!1),await q()}catch(D){f(D instanceof Error?D.message:"Branch creation failed")}W(!1)}},he=async D=>{try{await K.git.checkoutBranch(e,D),await q()}catch(le){f(le instanceof Error?le.message:"Checkout failed")}},de=async()=>{ae(!0);try{await K.git.push(e),await q()}catch(D){f(D instanceof Error?D.message:"Push failed")}ae(!1)},z=async()=>{if(!(!A.trim()||S)){j(!0),B(null);try{const D=await K.git.pr(e,A.trim(),E.trim());B(D.url),M(""),L(""),U(!1)}catch(D){B(`Error: ${D instanceof Error?D.message:"PR creation failed"}`)}j(!1)}},V=(i==null?void 0:i.files.filter(D=>D.staged))||[],J=(i==null?void 0:i.files.filter(D=>!D.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(Ps,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(ue,{size:"sm",variant:"secondary",icon:Ct,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Ut,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(Ct,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Z,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:nt},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(D=>r.jsxs("button",{onClick:()=>s(D.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===D.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(D.icon,{size:12}),D.label,D.count!==void 0&&D.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:D.count})]},D.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ut,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[V.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",V.length,")"]}),V.map((D,le)=>r.jsx(Pl,{file:D},`s-${le}`))]}),J.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",J.length,")"]}),J.map((D,le)=>r.jsx(Pl,{file:D},`u-${le}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:g,onChange:D=>p(D.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{size:"sm",icon:Zl,onClick:Q,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(ue,{size:"sm",variant:"secondary",icon:ac,onClick:de,loading:X,disabled:X,children:"Push"}),r.jsx(ue,{size:"sm",variant:"ghost",icon:sn,onClick:()=>U(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),C&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:C.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:C}):r.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:C})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:D=>M(D.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:D=>L(D.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ue,{size:"sm",icon:sn,onClick:z,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(ue,{size:"sm",variant:"ghost",onClick:()=>U(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(nt,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((D,le)=>r.jsx(Tx,{commit:D},le))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>N(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(ur,{size:12}),"New Branch"]})}),k&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:D=>R(D.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:D=>{D.key==="Enter"&&ie()}}),r.jsx(ue,{size:"sm",onClick:ie,disabled:!w.trim()||T,loading:T,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(D=>!D.remote).map((D,le)=>r.jsxs("button",{onClick:()=>!D.current&&he(D.name),disabled:D.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${D.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:D.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${D.current?"text-primary font-semibold":"text-ink"}`,children:D.name}),D.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${le}`)),l.filter(D=>D.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(D=>D.remote).map((D,le)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:D.name})]},`r-${le}`))]})]})]})]})]})}function Yr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Xr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await K.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(lu,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(ue,{size:"sm",icon:ac,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Ax({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const _=await K.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Mx)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([K.getGitHubIssues(e,"open",1),K.getGitHubPRs(e,"open",1),K.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(k=>k.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,g=[{id:"changes",label:"Changes",icon:Z,requiresRemote:!1},{id:"issues",label:"Issues",icon:Yd,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:sn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:It,count:l.actions,requiresRemote:!0}],p=g;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(_=>{const v=_.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(_.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===_.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(_.icon,{size:12}),_.label,_.count!==void 0&&_.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:_.count})]},_.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(rc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(zx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx(Rx,{sessionId:e})}):r.jsx(Xr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx(Dx,{sessionId:e})}):r.jsx(Xr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Px,{sessionId:e})})}):r.jsx(Xr,{sessionId:e,onPushed:u}))]})]})}function Ox({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const _=await K.getCheckpoints(e);i(_),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const _=setInterval(f,15e3);return()=>clearInterval(_)},[f]);const g=d.useCallback(async _=>{if(a)return;const v=s.find(x=>x.id===_);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
|
|
255
|
+
placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ss,{size:10})]}),r.jsx(ue,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(Ds,{size:12}),a]})]})}function ux(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(es,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ss,{size:10})]})]})}function fx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(ue,{variant:"danger",size:"sm",icon:Fu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsx(r.Fragment,{children:e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsxs(ue,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:["Connect ",e.name]})}),n&&r.jsx(dx,{platform:e,onConnect:c})]}):r.jsx(ux,{})})]})}function mx({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await K.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const _=await K.connectVercel(p);_.success&&(i(v=>({...v,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),u=d.useCallback(async p=>{const _=await K.connectNetlify(p);_.success&&(i(v=>({...v,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),m=d.useCallback(async p=>{await K.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const _={...s,[p]:{connected:!1}};t==null||t(_)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(di,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const g=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[g," of ",Vr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(Ct,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Vr.map(p=>{const _=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${_.connected?`Connected as ${_.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${_.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(Ct,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(Ds,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Vr.map(p=>r.jsx(fx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const px=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:en,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:en,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function _x({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(ue,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(di,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(en,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Zn,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ss,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Ds,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(ue,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function gx({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await K.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(ue,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(di,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Zn,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Ds,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(ue,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function xx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await K.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx($t,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(rc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(mx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:px.map(u=>r.jsx(_x,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(gx,{sessionId:e,disabled:l})]})})}const bh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),St=bh?"Cmd":"Ctrl",Rl=[{keys:[`${St}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${St}+P`],label:"Quick open file",category:"navigation"},{keys:[`${St}+,`],label:"Open settings",category:"navigation"},{keys:[`${St}+S`],label:"Save file",category:"editor"},{keys:[`${St}+Z`],label:"Undo",category:"editor"},{keys:[`${St}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${St}+B`],label:"Start / stop build",category:"build"},{keys:[`${St}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${St}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],vx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},bx=["navigation","editor","build","general"];function yx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=bh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function Sx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Rl;const a=s.toLowerCase();return Rl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_d,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[bx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:vx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.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 wx({onClick:e}){return r.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:"?"})}const yh="pl_recent_commands",Cx=5;function Sh(){try{const e=localStorage.getItem(yh);return e?JSON.parse(e):[]}catch{return[]}}function Gr(e){try{const t=Sh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(yh,JSON.stringify(t.slice(0,Cx)))}catch{}}function kx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Z,ts:Z,tsx:Z,jsx:Z,py:Z,go:Z,rs:Z,rb:Z,sh:Z,html:sc,css:to,json:eo,md:cr}[t]||so}function Nx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Dl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function jx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),g=d.useRef(null),p=d.useRef(null),_=gd(e);xd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=g.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>Sh().map(j=>s.find(C=>C.id===j)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(j=>({cmd:j,indices:[]}));const S=[];for(const j of s){const C=Nx(o,j.label);if(C){const B=C[0]*10+(C[C.length-1]-C[0]);S.push({cmd:j,indices:C,score:B})}}return S.sort((j,C)=>j.score-C.score),S.map(j=>({cmd:j.cmd,indices:j.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),k=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await K.searchFiles(i,o);u(S.filter(j=>j.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const N=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return N&&v.forEach((j,C)=>S.push({type:"recent",index:C})),k.forEach((j,C)=>S.push({type:"command",index:C})),x.length>0&&x.forEach((j,C)=>S.push({type:"setting",index:C})),c.forEach((j,C)=>S.push({type:"file",index:C})),S},[N,v,k,x,c]),R=w.length;d.useEffect(()=>{h(0)},[o]);const T=d.useCallback(S=>{const j=w[S];if(j){if(j.type==="recent"){const C=v[j.index];C&&(Gr(C.id),C.action(),t())}else if(j.type==="command"){const C=k[j.index];C&&(Gr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="setting"){const C=x[j.index];C&&(Gr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="file"){const C=c[j.index];C&&n&&(n(C.path,C.name),t())}}},[w,v,k,x,c,n,t]),W=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(j=>Math.min(j+1,R-1))):S.key==="ArrowUp"?(S.preventDefault(),h(j=>Math.max(j-1,0))):S.key==="Enter"&&R>0?T(l):S.key==="Escape"&&t()},[R,l,T,t]);if(!e)return null;let G=0;const U=()=>G++,A=k.length>0,M=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:_,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(ts,{size:18,className:"text-muted"}),r.jsx("input",{ref:g,value:o,onChange:S=>a(S.target.value),onKeyDown:W,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[N&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(nt,{size:10})," Recent"]}),v.map((S,j)=>{const C=U(),B=S.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),k.map((S,j)=>{const C=U(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Dl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),M&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,j)=>{const C=U(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Dl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,j)=>{const C=U(),B=S.type==="directory"?io:kx(S.name);return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),R===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Ex=d.lazy(()=>Xn(()=>import("./GitHubIssuesPanel-TLudouS-.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(e=>({default:e.GitHubIssuesPanel}))),Rx=d.lazy(()=>Xn(()=>import("./GitHubPRsPanel-bjj0yQTk.js"),__vite__mapDeps([31,1,2,3,32,4,5,33,12,14,17,9,10,11,13,15,16,8,18,19,20,21,22,23,24,7,25,26,27,28,29,30])).then(e=>({default:e.GitHubPRsPanel}))),Dx=d.lazy(()=>Xn(()=>Promise.resolve().then(()=>Gx),void 0).then(e=>({default:e.CICDPanel}))),Px=3e4,Mx={modified:r.jsx(Z,{size:13,className:"text-yellow-500"}),added:r.jsx(dr,{size:13,className:"text-green-500"}),deleted:r.jsx(Qn,{size:13,className:"text-red-400"}),renamed:r.jsx(Z,{size:13,className:"text-blue-400"}),untracked:r.jsx(ic,{size:13,className:"text-muted"})},Lx={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Bx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Zl,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Pl({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Mx[e.status]||r.jsx(ic,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Lx[e.status]||"?"})]})}function Tx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[g,p]=d.useState(""),[_,v]=d.useState(!1),[y,x]=d.useState(null),[k,N]=d.useState(!1),[w,R]=d.useState(""),[T,W]=d.useState(!1),[G,U]=d.useState(!1),[A,M]=d.useState(""),[E,L]=d.useState(""),[S,j]=d.useState(!1),[C,B]=d.useState(null),[X,ae]=d.useState(!1),q=d.useCallback(async()=>{u(!0),f(null);try{const[D,le,ge]=await Promise.all([K.git.status(e),K.git.log(e),K.git.branches(e)]);n(D),a(le),h(ge)}catch(D){f(D instanceof Error?D.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{q()},[q]);const Q=async()=>{if(!(!g.trim()||_)){v(!0),x(null);try{const D=await K.git.commit(e,g.trim());x(`Committed: ${D.hash}`),p(""),await q()}catch(D){x(`Error: ${D instanceof Error?D.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||T)){W(!0);try{await K.git.createBranch(e,w.trim()),R(""),N(!1),await q()}catch(D){f(D instanceof Error?D.message:"Branch creation failed")}W(!1)}},he=async D=>{try{await K.git.checkoutBranch(e,D),await q()}catch(le){f(le instanceof Error?le.message:"Checkout failed")}},de=async()=>{ae(!0);try{await K.git.push(e),await q()}catch(D){f(D instanceof Error?D.message:"Push failed")}ae(!1)},z=async()=>{if(!(!A.trim()||S)){j(!0),B(null);try{const D=await K.git.pr(e,A.trim(),E.trim());B(D.url),M(""),L(""),U(!1)}catch(D){B(`Error: ${D instanceof Error?D.message:"PR creation failed"}`)}j(!1)}},V=(i==null?void 0:i.files.filter(D=>D.staged))||[],J=(i==null?void 0:i.files.filter(D=>!D.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(Ds,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(ue,{size:"sm",variant:"secondary",icon:Ct,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Ut,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(Ct,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Z,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:nt},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(D=>r.jsxs("button",{onClick:()=>s(D.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===D.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(D.icon,{size:12}),D.label,D.count!==void 0&&D.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:D.count})]},D.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ut,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[V.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",V.length,")"]}),V.map((D,le)=>r.jsx(Pl,{file:D},`s-${le}`))]}),J.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",J.length,")"]}),J.map((D,le)=>r.jsx(Pl,{file:D},`u-${le}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:g,onChange:D=>p(D.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{size:"sm",icon:Zl,onClick:Q,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(ue,{size:"sm",variant:"secondary",icon:ac,onClick:de,loading:X,disabled:X,children:"Push"}),r.jsx(ue,{size:"sm",variant:"ghost",icon:sn,onClick:()=>U(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),C&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:C.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:C}):r.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:C})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:D=>M(D.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:D=>L(D.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ue,{size:"sm",icon:sn,onClick:z,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(ue,{size:"sm",variant:"ghost",onClick:()=>U(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(nt,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((D,le)=>r.jsx(Bx,{commit:D},le))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>N(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(ur,{size:12}),"New Branch"]})}),k&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:D=>R(D.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:D=>{D.key==="Enter"&&ie()}}),r.jsx(ue,{size:"sm",onClick:ie,disabled:!w.trim()||T,loading:T,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(D=>!D.remote).map((D,le)=>r.jsxs("button",{onClick:()=>!D.current&&he(D.name),disabled:D.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${D.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:D.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${D.current?"text-primary font-semibold":"text-ink"}`,children:D.name}),D.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${le}`)),l.filter(D=>D.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(D=>D.remote).map((D,le)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:D.name})]},`r-${le}`))]})]})]})]})]})}function Yr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Xr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await K.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(au,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(ue,{size:"sm",icon:ac,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function zx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const _=await K.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Px)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([K.getGitHubIssues(e,"open",1),K.getGitHubPRs(e,"open",1),K.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(k=>k.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(Ct,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,g=[{id:"changes",label:"Changes",icon:Z,requiresRemote:!1},{id:"issues",label:"Issues",icon:Gd,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:sn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:It,count:l.actions,requiresRemote:!0}],p=g;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(_=>{const v=_.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(_.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===_.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(_.icon,{size:12}),_.label,_.count!==void 0&&_.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:_.count})]},_.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(rc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Tx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx(Ex,{sessionId:e})}):r.jsx(Xr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx(Rx,{sessionId:e})}):r.jsx(Xr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Yr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Dx,{sessionId:e})})}):r.jsx(Xr,{sessionId:e,onPushed:u}))]})]})}function Ax({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const _=await K.getCheckpoints(e);i(_),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const _=setInterval(f,15e3);return()=>clearInterval(_)},[f]);const g=d.useCallback(async _=>{if(a)return;const v=s.find(x=>x.id===_);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
|
|
256
256
|
|
|
257
|
-
This will revert files to this checkpoint state.`))){l(_);try{await K.restoreCheckpoint(e,_),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(rn,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=_=>{if(!_)return"";try{return new Date(_).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(rn,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((_,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>g(_.id),onMouseEnter:()=>c(_.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${_.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===_.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==_.id?"opacity-50":""}`,title:`${_.description} -- Click to restore`}),h===_.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:_.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[_.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(nt,{size:10}),p(_.timestamp)]}),_.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Z,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),_.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",_.iteration]})]}),!_.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(Ql,{size:10}),"Click to restore"]}),_.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},_.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function $x({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Ix({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(dr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(iu,{size:14,className:"text-danger"}):r.jsx(Z,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(hr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(ur,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(ec,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx($x,{line:c},`${h}-${u}`))]},h))})]})}function Fx({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(g=>{const p=new Set(g);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Z,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(ur,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(ec,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,g)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${g===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:_=>_.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Ix,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(tc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Ut,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Vd,{size:14}),"Accept All"]})]})]})]})}function Gi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function Hx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Wx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const Co={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:nt,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:fr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Vl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:Ji,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:tc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Gl,label:"Skipped"}};function wh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Ch(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function ko({status:e}){const t=Co[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Ux({step:e}){const t=Wx(e),s=Co[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Ch(e.startedAt,e.completedAt)}),r.jsx(ko,{status:t})]})}function Kx({job:e}){const[t,s]=d.useState(!1),i=Hx(e),n=Co[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ls,{size:14,className:"text-[#939084]"}):r.jsx(hr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Ch(e.startedAt,e.completedAt)}),r.jsx(ko,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Ux,{step:o},o.number))})]})}function qx({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await K.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(fr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Vx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Gi(e),g=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const _=await K.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){c(_ instanceof Error?_.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const _=!s;i(_),_&&g()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ls,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(hr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(ko,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:wh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ss,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(fr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(_=>r.jsx(Kx,{job:_},_.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(es,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(qx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Gx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var g;const[n,o]=d.useState(((g=t[0])==null?void 0:g.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await K.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(ue,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(ue,{size:"sm",icon:It,onClick:f,loading:h,children:"Dispatch"})]})]})}function kh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[g,p]=d.useState(null),_=d.useRef(null),v=t.some(R=>R.status==="in_progress"||R.status==="queued"||R.status==="waiting"||R.status==="requested"||R.status==="pending"),y=d.useCallback(async(R=!1)=>{if(e){R&&h(!0),u(null);try{const T=await K.getWorkflowRuns(e);s(T),a(""),p(new Date)}catch(T){const W=T instanceof Error?T.message:String(T);W.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):W.includes("not authenticated")||W.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):W.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:W})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const R=await K.getWorkflows(e);n(R.filter(T=>T.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[v,e,y]);const k=t.filter(R=>Gi(R)==="success").length,N=t.filter(R=>Gi(R)==="failed").length,w=t.filter(R=>{const T=Gi(R);return T==="running"||T==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[g&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(oc,{size:10}),wh(g.toISOString())]}),r.jsx(ue,{size:"sm",variant:"ghost",icon:Ct,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(ue,{size:"sm",icon:It,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Gx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ot,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ss,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Vl,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(Ji,{size:12}),N," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(fr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(R=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},R))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(R=>r.jsx(Vx,{run:R,sessionId:e},R.databaseId))})]})}const Yx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:kh},Symbol.toStringTag,{value:"Module"}));function Xx({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(kt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Jx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let _="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(_="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(_="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:_,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:_})]})}function Zx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Qx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Z,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Z,color:"text-yellow-500",label:"JSX"},ts:{icon:Z,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Z,color:"text-blue-400",label:"TSX"},py:{icon:Z,color:"text-green-600",label:"Python"},html:{icon:Z,color:"text-orange-500",label:"HTML"},css:{icon:to,color:"text-purple-500",label:"CSS"},json:{icon:eo,color:"text-green-500",label:"JSON"},md:{icon:cr,color:"text-muted",label:"Markdown"},go:{icon:Z,color:"text-cyan-600",label:"Go"},rs:{icon:Z,color:"text-orange-600",label:"Rust"}}[t]||{icon:so,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function ev(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Ml(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function tv({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[g,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const N=()=>f(ev(n));N();const w=setInterval(N,5e3);return()=>clearInterval(w)},[n]);const _=d.useCallback(async()=>{const N=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Ml(h)}`:"",u?`
|
|
257
|
+
This will revert files to this checkpoint state.`))){l(_);try{await K.restoreCheckpoint(e,_),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(rn,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=_=>{if(!_)return"";try{return new Date(_).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(rn,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((_,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>g(_.id),onMouseEnter:()=>c(_.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${_.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===_.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==_.id?"opacity-50":""}`,title:`${_.description} -- Click to restore`}),h===_.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:_.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[_.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(nt,{size:10}),p(_.timestamp)]}),_.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Z,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),_.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",_.iteration]})]}),!_.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(Ql,{size:10}),"Click to restore"]}),_.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},_.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function Ox({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function $x({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(dr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(su,{size:14,className:"text-danger"}):r.jsx(Z,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(hr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(ur,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(ec,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx(Ox,{line:c},`${h}-${u}`))]},h))})]})}function Ix({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(g=>{const p=new Set(g);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Z,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(ur,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(ec,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,g)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${g===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:_=>_.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx($x,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(tc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Ut,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(qd,{size:14}),"Accept All"]})]})]})]})}function Gi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function Fx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Hx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const Co={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:nt,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:fr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Vl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:Ji,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:tc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Gl,label:"Skipped"}};function wh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Ch(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function ko({status:e}){const t=Co[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Wx({step:e}){const t=Hx(e),s=Co[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Ch(e.startedAt,e.completedAt)}),r.jsx(ko,{status:t})]})}function Ux({job:e}){const[t,s]=d.useState(!1),i=Fx(e),n=Co[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ls,{size:14,className:"text-[#939084]"}):r.jsx(hr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Ch(e.startedAt,e.completedAt)}),r.jsx(ko,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Wx,{step:o},o.number))})]})}function Kx({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await K.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(fr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function qx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Gi(e),g=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const _=await K.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){c(_ instanceof Error?_.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const _=!s;i(_),_&&g()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ls,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(hr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(ko,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:wh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ss,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(fr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(_=>r.jsx(Ux,{job:_},_.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(es,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Kx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Vx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var g;const[n,o]=d.useState(((g=t[0])==null?void 0:g.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await K.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(ue,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(ue,{size:"sm",icon:It,onClick:f,loading:h,children:"Dispatch"})]})]})}function kh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[g,p]=d.useState(null),_=d.useRef(null),v=t.some(R=>R.status==="in_progress"||R.status==="queued"||R.status==="waiting"||R.status==="requested"||R.status==="pending"),y=d.useCallback(async(R=!1)=>{if(e){R&&h(!0),u(null);try{const T=await K.getWorkflowRuns(e);s(T),a(""),p(new Date)}catch(T){const W=T instanceof Error?T.message:String(T);W.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):W.includes("not authenticated")||W.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):W.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:W})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const R=await K.getWorkflows(e);n(R.filter(T=>T.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[v,e,y]);const k=t.filter(R=>Gi(R)==="success").length,N=t.filter(R=>Gi(R)==="failed").length,w=t.filter(R=>{const T=Gi(R);return T==="running"||T==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[g&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(oc,{size:10}),wh(g.toISOString())]}),r.jsx(ue,{size:"sm",variant:"ghost",icon:Ct,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(ue,{size:"sm",icon:It,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Vx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ot,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ss,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Vl,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(Ji,{size:12}),N," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(fr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(R=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},R))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(R=>r.jsx(qx,{run:R,sessionId:e},R.databaseId))})]})}const Gx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:kh},Symbol.toStringTag,{value:"Module"}));function Yx({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(kt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Xx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let _="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(_="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(_="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:_,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:_})]})}function Jx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Zx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Z,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Z,color:"text-yellow-500",label:"JSX"},ts:{icon:Z,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Z,color:"text-blue-400",label:"TSX"},py:{icon:Z,color:"text-green-600",label:"Python"},html:{icon:Z,color:"text-orange-500",label:"HTML"},css:{icon:to,color:"text-purple-500",label:"CSS"},json:{icon:eo,color:"text-green-500",label:"JSON"},md:{icon:cr,color:"text-muted",label:"Markdown"},go:{icon:Z,color:"text-cyan-600",label:"Go"},rs:{icon:Z,color:"text-orange-600",label:"Rust"}}[t]||{icon:so,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Qx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Ml(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function ev({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[g,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const N=()=>f(Qx(n));N();const w=setInterval(N,5e3);return()=>clearInterval(w)},[n]);const _=d.useCallback(async()=>{const N=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Ml(h)}`:"",u?`
|
|
258
258
|
Project: ${u.substring(0,100)}${u.length>100?"...":""}`:"",`
|
|
259
259
|
https://autonomi.dev`].filter(Boolean).join(`
|
|
260
|
-
`);try{await navigator.clipboard.writeText(N),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Qx(t),y=v.icon,x=h?h*5:0,k=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ad,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(oc,{size:11}),r.jsxs("span",{children:["Built in ",Ml(h)]}),k&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(Zt,{size:10,className:"inline"})," ",k,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:_,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:g?r.jsxs(r.Fragment,{children:[r.jsx(Ut,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(ro,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Vn=[{id:"desktop",label:"Desktop",icon:bd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Bu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Mu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function sv({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Vn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function iv(){const[e,t]=d.useState("desktop"),s=Vn.find(i=>i.id===e)||Vn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const rv=[75,100,125];function nv({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:rv.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function ov({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const g=o+l*17+a*31&65535;n[a][l]=g%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function av(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Kd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function lv({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Ut,{size:14,className:"text-success"}):r.jsx(Zn,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function cv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(nc,{size:14}):r.jsx(nn,{size:14})})}function Ll({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(Ps,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(ls,{size:12}):r.jsx(lr,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function hv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Dd,{size:14,className:s||t?"animate-spin-once":""})})}function Bl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function dv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(ov,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const Tl={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function uv(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function Nh(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>uv(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(yd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
260
|
+
`);try{await navigator.clipboard.writeText(N),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Zx(t),y=v.icon,x=h?h*5:0,k=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(zd,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(oc,{size:11}),r.jsxs("span",{children:["Built in ",Ml(h)]}),k&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(Zt,{size:10,className:"inline"})," ",k,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:_,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:g?r.jsxs(r.Fragment,{children:[r.jsx(Ut,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(ro,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Vn=[{id:"desktop",label:"Desktop",icon:vd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Lu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Pu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function tv({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Vn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function sv(){const[e,t]=d.useState("desktop"),s=Vn.find(i=>i.id===e)||Vn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const iv=[75,100,125];function rv({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:iv.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function nv({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const g=o+l*17+a*31&65535;n[a][l]=g%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function ov(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Ud,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function av({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Ut,{size:14,className:"text-success"}):r.jsx(Zn,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function lv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(nc,{size:14}):r.jsx(nn,{size:14})})}function Ll({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(Ds,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(ls,{size:12}):r.jsx(lr,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function cv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Rd,{size:14,className:s||t?"animate-spin-once":""})})}function Bl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function hv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(nv,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const Tl={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function dv(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function uv(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>dv(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(bd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
261
261
|
border rounded-pill transition-all duration-200 cursor-pointer
|
|
262
262
|
${Tl[m.category]||Tl.create}
|
|
263
263
|
`,children:[m.label,r.jsx(Jn,{size:10,className:"opacity-50"})]},`${m.label}-${f}`))})]})}function Gt(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function fv(e){const t=[],s=[],i=[];for(const n of e.split(`
|
|
264
|
-
`))n.startsWith("__FILE_CHANGE__")?s.push(n.replace("__FILE_CHANGE__","")):n.startsWith("__COMMAND__")?i.push(n.replace("__COMMAND__","")):t.push(n);return{textLines:t,fileChanges:s,commands:i}}function mv({msgIndex:e}){const[t,s]=d.useState(null),i=n=>{s(t===n?null:n)};return r.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[r.jsx("button",{onClick:()=>i("up"),className:`p-1 rounded transition-colors ${t==="up"?"text-primary bg-primary/10":"text-muted/40 hover:text-primary hover:bg-primary/5"}`,title:"Helpful response","aria-label":"Thumbs up",children:r.jsx(
|
|
264
|
+
`))n.startsWith("__FILE_CHANGE__")?s.push(n.replace("__FILE_CHANGE__","")):n.startsWith("__COMMAND__")?i.push(n.replace("__COMMAND__","")):t.push(n);return{textLines:t,fileChanges:s,commands:i}}function mv({msgIndex:e}){const[t,s]=d.useState(null),i=n=>{s(t===n?null:n)};return r.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[r.jsx("button",{onClick:()=>i("up"),className:`p-1 rounded transition-colors ${t==="up"?"text-primary bg-primary/10":"text-muted/40 hover:text-primary hover:bg-primary/5"}`,title:"Helpful response","aria-label":"Thumbs up",children:r.jsx(Ou,{size:12})}),r.jsx("button",{onClick:()=>i("down"),className:`p-1 rounded transition-colors ${t==="down"?"text-red-400 bg-red-400/10":"text-muted/40 hover:text-red-400 hover:bg-red-400/5"}`,title:"Not helpful","aria-label":"Thumbs down",children:r.jsx(zu,{size:12})})]})}const Gn=[{id:"@file",label:"@file",description:"Reference a file in your project",icon:Z},{id:"@template",label:"@template",description:"Reference a template",icon:yd},{id:"@docs",label:"@docs",description:"Reference documentation",icon:Jr}];function pv({visible:e,filter:t,onSelect:s,onClose:i,selectedIndex:n}){if(!e)return null;const o=Gn.filter(a=>a.label.toLowerCase().includes(t.toLowerCase()));return o.length===0?null:r.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-1 bg-card border border-border rounded-lg shadow-lg py-1 z-50",children:[r.jsx("div",{className:"px-3 py-1",children:r.jsxs("span",{className:"text-[10px] text-muted font-semibold uppercase tracking-wider flex items-center gap-1",children:[r.jsx(Fd,{size:10}),"Mentions"]})}),o.map((a,l)=>{const h=a.icon;return r.jsxs("button",{onClick:()=>s(a.label),className:`w-full flex items-center gap-2 px-3 py-2 text-xs transition-colors text-left ${l===n?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(h,{size:14,className:l===n?"text-primary":"text-muted"}),r.jsx("span",{className:"font-medium",children:a.label}),r.jsx("span",{className:"text-muted text-[11px]",children:a.description})]},a.id)})]})}function _v(){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]}),r.jsx("span",{className:"text-[11px] text-muted italic",children:"Loki is thinking..."})]})}function gv({msg:e,msgIndex:t}){var l;const[s,i]=d.useState(!1),n=d.useMemo(()=>e.role==="system"?fv(e.content):null,[e.role,e.content]);if(e.role==="user")return r.jsx("div",{className:"flex justify-end",children:r.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-primary/10 text-ink",children:[e.imageUrl&&r.jsxs("div",{className:"mb-2",children:[r.jsx("img",{src:e.imageUrl,alt:e.imageName||"Uploaded image",className:"max-w-full max-h-48 rounded border border-border object-contain"}),e.imageName&&r.jsx("span",{className:"text-[10px] text-muted mt-0.5 block",children:e.imageName})]}),r.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:e.content})]})});const o=n?n.textLines.join(`
|
|
265
265
|
`).trim():e.content,a=o.split(`
|
|
266
266
|
`).length>30;return r.jsxs("div",{className:"flex justify-start gap-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.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:[n&&n.commands.length>0&&r.jsx("div",{className:"mb-2 space-y-0.5",children:n.commands.map((h,c)=>r.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:[r.jsx(es,{size:10,className:"text-muted/60 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:h})]},c))}),r.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[a&&!s?o.split(`
|
|
267
267
|
`).slice(0,30).join(`
|
|
@@ -272,16 +272,16 @@ https://autonomi.dev`].filter(Boolean).join(`
|
|
|
272
272
|
`);o(Ee=>Gt(Ee,ee=>ee.role==="system"&&ee.isStreaming?{content:ge}:{}))}J>=150&&(D={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(!D.complete);o(ge=>Gt(ge,Ee=>Ee.role==="system"?{isStreaming:!1,content:D.output_lines.join(`
|
|
273
273
|
`)||"Done.",filesChanged:D.files_changed,returncode:D.returncode}:{})),((le=D.files_changed)==null?void 0:le.length)>0&&s&&s(D.files_changed)},[e,s]),ie=d.useCallback(async z=>{var J;const V=new AbortController;w.current=V,R.current=z,g(!0);try{const D=K.chatStreamUrl(e,z),le=await fetch(D,{signal:V.signal});if(!le.ok||!le.body)throw new Error(`Stream failed: ${le.status}`);const ge=le.body.getReader(),Ee=new TextDecoder;let ee="";for(;;){const{done:fe,value:_e}=await ge.read();if(fe)break;ee+=Ee.decode(_e,{stream:!0});const Ce=ee.split(`
|
|
274
274
|
|
|
275
|
-
`);ee=Ce.pop()||"";for(const
|
|
276
|
-
`);let us="",et="";for(const ce of
|
|
277
|
-
`+ce:ce}:{}))}catch{}else if(us==="complete"&&et)try{const{returncode:ce,files_changed:ot}=JSON.parse(et);o(at=>Gt(at,fs=>fs.role==="system"&&fs.isStreaming?{isStreaming:!1,filesChanged:ot,returncode:ce,content:fs.content||"Done."}:{})),(ot==null?void 0:ot.length)>0&&s&&s(ot)}catch{}else if(us==="error"&&et)try{const{error:ce}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{isStreaming:!1,content:`Error: ${ce}`}:{}))}catch{}}}}catch(D){if(D instanceof DOMException&&D.name==="AbortError")return;await Q(z)}finally{g(!1),m(!1),w.current=null,R.current=null,(J=k.current)==null||J.focus()}},[e,s,Q]),he=async()=>{var ee;const z=a.trim();if(!z&&!p||u)return;let V,J,D="";if(p){y(!0);try{const fe=await K.chatImageUpload(e,p.file);V=p.previewUrl,J=fe.filename,D=`[Attached image: ${fe.filename} (id: ${fe.image_id})] Make it look like this. `}catch{}y(!1)}const le=D+(z||"Make changes based on this screenshot."),ge={role:"user",content:z||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:V,imageName:J},Ee={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(fe=>[...fe,ge,Ee]),l(""),_(null),m(!0);try{const fe=n.filter(Ce=>Ce.role==="user"||Ce.role==="system"&&!Ce.isStreaming&&Ce.content).slice(-10).map(Ce=>({role:Ce.role==="user"?"user":"assistant",content:Ce.content})),{task_id:_e}=await K.chatStart(e,le,h,fe.length>0?fe:void 0);await ie(_e)}catch(fe){o(_e=>Gt(_e,Ce=>Ce.role==="system"&&Ce.isStreaming?{isStreaming:!1,content:`Error: ${fe instanceof Error?fe.message:"Request failed"}`}:{})),m(!1),(ee=k.current)==null||ee.focus()}};return r.jsxs("div",{ref:T,className:`flex flex-col h-full relative ${U?"ring-2 ring-primary ring-inset":""}`,onDragOver:B,onDragLeave:X,onDrop:ae,children:[U&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(oa,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((z,V)=>r.jsx(gv,{msg:z,msgIndex:V},V)),f&&r.jsx(_v,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(Zi,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(z=>z.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Wl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(de=i.find(z=>z.fix_status==="fixing"))==null?void 0:de.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(z=>r.jsx("button",{onClick:()=>c(z),title:xv[z],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===z?"bg-primary text-white":"text-muted hover:text-ink"}`,children:z},z))}),p&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:"Pending upload",className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:G,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image",children:r.jsx(ft,{size:10})})]}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[150px]",children:p.file.name}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),!f&&r.jsx(Nh,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:z=>l(z),className:"mb-2"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:N,type:"file",accept:"image/*",className:"hidden",onChange:z=>{var J;const V=(J=z.target.files)==null?void 0:J[0];V&&W(V),z.target.value=""}}),r.jsx("button",{onClick:()=>{var z;return(z=N.current)==null?void 0:z.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)",children:r.jsx(oa,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(pv,{visible:M,filter:L,selectedIndex:j,onSelect:z=>{var D;const V=a.lastIndexOf("@"),J=V>=0?a.slice(0,V):a;l(J+z+" "),E(!1),C(0),(D=k.current)==null||D.focus()},onClose:()=>E(!1)}),r.jsx("textarea",{ref:k,value:a,onChange:z=>{const V=z.target.value;l(V);const J=V.lastIndexOf("@");if(J>=0){const D=V.slice(J);/^@\w*$/.test(D)?(E(!0),S(D),C(0)):E(!1)}else E(!1)},onKeyDown:z=>{if(M){if(z.key==="ArrowDown"){z.preventDefault(),C(V=>Math.min(V+1,Gn.length-1));return}if(z.key==="ArrowUp"){z.preventDefault(),C(V=>Math.max(V-1,0));return}if(z.key==="Tab"||z.key==="Enter"&&!z.shiftKey){z.preventDefault();const V=Gn.filter(J=>J.label.toLowerCase().includes(L.toLowerCase()));if(V[j]){const J=a.lastIndexOf("@"),D=J>=0?a.slice(0,J):a;l(D+V[j].label+" "),E(!1),C(0)}return}if(z.key==="Escape"){E(!1);return}}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),he())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(ue,{size:"sm",icon:Zi,onClick:q,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(ue,{size:"sm",icon:Ru,onClick:he,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function bv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function jh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function zl({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=jh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function yv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=bv(e),o=jh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(zl,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(zl,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(Ul,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Yi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Xi(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Sv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function ys({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function Cv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[Xi(e.durationSecs)," | ",Yi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function kv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:g=""}){const[p,_]=d.useState(!0),v=wv(h),y=Math.max(...a.map(k=>k.durationSecs),1),x=()=>{const k=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${Xi(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Yi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(N=>` ${N.label}: ${Xi(N.durationSecs)} (${Math.round(N.percentage)}%)`)].join(`
|
|
278
|
-
`);f==null||f(k)};return r.jsxs("div",{className:`card overflow-hidden ${g}`,children:[r.jsxs("button",{onClick:()=>_(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Zr,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(lr,{size:16}):r.jsx(ls,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(
|
|
275
|
+
`);ee=Ce.pop()||"";for(const Ge of Ce){if(!Ge.trim())continue;const Ls=Ge.split(`
|
|
276
|
+
`);let us="",et="";for(const ce of Ls)ce.startsWith("event:")?us=ce.slice(6).trim():ce.startsWith("data:")&&(et=ce.slice(5).trim());if(us==="output"&&et)try{const{line:ce}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{content:at.content?at.content+`
|
|
277
|
+
`+ce:ce}:{}))}catch{}else if(us==="complete"&&et)try{const{returncode:ce,files_changed:ot}=JSON.parse(et);o(at=>Gt(at,fs=>fs.role==="system"&&fs.isStreaming?{isStreaming:!1,filesChanged:ot,returncode:ce,content:fs.content||"Done."}:{})),(ot==null?void 0:ot.length)>0&&s&&s(ot)}catch{}else if(us==="error"&&et)try{const{error:ce}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{isStreaming:!1,content:`Error: ${ce}`}:{}))}catch{}}}}catch(D){if(D instanceof DOMException&&D.name==="AbortError")return;await Q(z)}finally{g(!1),m(!1),w.current=null,R.current=null,(J=k.current)==null||J.focus()}},[e,s,Q]),he=async()=>{var ee;const z=a.trim();if(!z&&!p||u)return;let V,J,D="";if(p){y(!0);try{const fe=await K.chatImageUpload(e,p.file);V=p.previewUrl,J=fe.filename,D=`[Attached image: ${fe.filename} (id: ${fe.image_id})] Make it look like this. `}catch{}y(!1)}const le=D+(z||"Make changes based on this screenshot."),ge={role:"user",content:z||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:V,imageName:J},Ee={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(fe=>[...fe,ge,Ee]),l(""),_(null),m(!0);try{const fe=n.filter(Ce=>Ce.role==="user"||Ce.role==="system"&&!Ce.isStreaming&&Ce.content).slice(-10).map(Ce=>({role:Ce.role==="user"?"user":"assistant",content:Ce.content})),{task_id:_e}=await K.chatStart(e,le,h,fe.length>0?fe:void 0);await ie(_e)}catch(fe){o(_e=>Gt(_e,Ce=>Ce.role==="system"&&Ce.isStreaming?{isStreaming:!1,content:`Error: ${fe instanceof Error?fe.message:"Request failed"}`}:{})),m(!1),(ee=k.current)==null||ee.focus()}};return r.jsxs("div",{ref:T,className:`flex flex-col h-full relative ${U?"ring-2 ring-primary ring-inset":""}`,onDragOver:B,onDragLeave:X,onDrop:ae,children:[U&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(oa,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((z,V)=>r.jsx(gv,{msg:z,msgIndex:V},V)),f&&r.jsx(_v,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(Zi,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(z=>z.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Wl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(de=i.find(z=>z.fix_status==="fixing"))==null?void 0:de.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(z=>r.jsx("button",{onClick:()=>c(z),title:xv[z],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===z?"bg-primary text-white":"text-muted hover:text-ink"}`,children:z},z))}),p&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:"Pending upload",className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:G,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image",children:r.jsx(ft,{size:10})})]}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[150px]",children:p.file.name}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),!f&&r.jsx(uv,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:z=>l(z),className:"mb-2"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:N,type:"file",accept:"image/*",className:"hidden",onChange:z=>{var J;const V=(J=z.target.files)==null?void 0:J[0];V&&W(V),z.target.value=""}}),r.jsx("button",{onClick:()=>{var z;return(z=N.current)==null?void 0:z.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)",children:r.jsx(oa,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(pv,{visible:M,filter:L,selectedIndex:j,onSelect:z=>{var D;const V=a.lastIndexOf("@"),J=V>=0?a.slice(0,V):a;l(J+z+" "),E(!1),C(0),(D=k.current)==null||D.focus()},onClose:()=>E(!1)}),r.jsx("textarea",{ref:k,value:a,onChange:z=>{const V=z.target.value;l(V);const J=V.lastIndexOf("@");if(J>=0){const D=V.slice(J);/^@\w*$/.test(D)?(E(!0),S(D),C(0)):E(!1)}else E(!1)},onKeyDown:z=>{if(M){if(z.key==="ArrowDown"){z.preventDefault(),C(V=>Math.min(V+1,Gn.length-1));return}if(z.key==="ArrowUp"){z.preventDefault(),C(V=>Math.max(V-1,0));return}if(z.key==="Tab"||z.key==="Enter"&&!z.shiftKey){z.preventDefault();const V=Gn.filter(J=>J.label.toLowerCase().includes(L.toLowerCase()));if(V[j]){const J=a.lastIndexOf("@"),D=J>=0?a.slice(0,J):a;l(D+V[j].label+" "),E(!1),C(0)}return}if(z.key==="Escape"){E(!1);return}}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),he())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(ue,{size:"sm",icon:Zi,onClick:q,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(ue,{size:"sm",icon:Eu,onClick:he,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function bv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function Nh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function zl({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=Nh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function yv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=bv(e),o=Nh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(zl,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(zl,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(Ul,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Yi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Xi(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Sv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function bs({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function Cv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[Xi(e.durationSecs)," | ",Yi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function kv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:g=""}){const[p,_]=d.useState(!0),v=wv(h),y=Math.max(...a.map(k=>k.durationSecs),1),x=()=>{const k=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${Xi(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Yi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(N=>` ${N.label}: ${Xi(N.durationSecs)} (${Math.round(N.percentage)}%)`)].join(`
|
|
278
|
+
`);f==null||f(k)};return r.jsxs("div",{className:`card overflow-hidden ${g}`,children:[r.jsxs("button",{onClick:()=>_(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Zr,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(lr,{size:16}):r.jsx(ls,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(bs,{icon:Z,label:"Files",value:String(e+t),subtext:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(bs,{icon:Qr,label:"Lines of Code",value:Sv(s),iconColor:"text-info"}),r.jsx(bs,{icon:si,label:"Tests",value:String(i),subtext:`${Math.round(n*100)}% passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(bs,{icon:Zt,label:"Tokens Used",value:Yi(o),iconColor:"text-warning"}),r.jsx(bs,{icon:nt,label:"Build Time",value:Xi(l),subtext:`${u} iterations`,iconColor:"text-muted"}),r.jsx(bs,{icon:Sd,label:"Quality",value:`${h}`,subtext:v.label,iconColor:v.color})]}),r.jsxs("div",{className:"flex items-center justify-between bg-hover/40 rounded-card px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ad,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsxs("span",{className:"text-sm font-bold font-mono text-ink",children:["$",c.toFixed(2)]})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Od,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Time Breakdown"})]}),r.jsx("div",{className:"space-y-1.5",children:a.map(k=>r.jsx(Cv,{phase:k,maxDuration:y},k.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Zt,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Token Distribution"})]}),r.jsx("div",{className:"flex h-3 rounded-full overflow-hidden bg-border",children:a.map(k=>{const N={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${N[k.phase]||"bg-primary"}`,style:{width:`${k.percentage}%`},title:`${k.label}: ${Yi(k.tokenCount)} tokens (${Math.round(k.percentage)}%)`},k.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(k=>{const N={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${N[k.phase]||"bg-primary"}`}),k.label]},k.phase)})})]}),f&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:x,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
279
279
|
text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(ro,{size:12}),"Share Insights"]})})]})]})}const Al=[1,2,5];function Nv(e){const t=[];let s=0;const i=600,n=["planning","building","testing","reviewing","complete"],o=e.phases.length>0?e.phases:n;for(const a of o){if(t.push({timestamp:s,type:"phase_change",label:`Phase: ${a}`,phase:a}),s+=i,a==="building")for(const l of e.files.filter(h=>h.type==="file"))t.push({timestamp:s,type:"file_created",label:l.path,detail:l.path}),s+=i*.4;if(a==="testing"||a==="reviewing")for(const l of e.qualityGates){const h=l.status==="pass"?"gate_pass":"gate_fail";t.push({timestamp:s,type:h,label:l.label,phase:a}),s+=i*.3}}for(let a=1;a<=e.totalIterations;a++){const l=a/e.totalIterations*s;t.push({timestamp:l,type:"iteration",label:`Iteration ${a}/${e.totalIterations}`})}return t.sort((a,l)=>a.timestamp-l.timestamp),t}function jv({path:e,visible:t,delay:s}){const i=e.split("/"),n=i[i.length-1],o=i.length-1;return r.jsxs("div",{className:`flex items-center gap-1.5 py-0.5 transition-all duration-500 ${t?"opacity-100 translate-x-0":"opacity-0 -translate-x-4"}`,style:{paddingLeft:`${o*16+8}px`,transitionDelay:`${s}ms`},children:[r.jsx(Z,{size:12,className:"text-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:n})]})}function Ev({sessionId:e,files:t,phases:s,checkpoints:i,qualityGates:n,totalIterations:o,onShare:a}){var S,j;const[l,h]=d.useState(!1),[c,u]=d.useState(0),[m,f]=d.useState(0),[g,p]=d.useState(!1),_=d.useRef(null),v=d.useRef(0),y=d.useRef([]);y.current.length===0&&(y.current=Nv({files:t,phases:s,qualityGates:n,totalIterations:o}));const x=y.current.length>0?y.current[y.current.length-1].timestamp+600:1,k=y.current.filter(C=>C.timestamp<=m),N=new Set(k.filter(C=>C.type==="file_created").map(C=>C.detail)),w=((S=[...k].reverse().find(C=>C.type==="phase_change"))==null?void 0:S.phase)||"idle",R=k.filter(C=>C.type==="gate_pass").length,T=k.filter(C=>C.type==="gate_fail").length,W=((j=[...k].reverse().find(C=>C.type==="iteration"))==null?void 0:j.label)||"",G=Al[c],U=d.useCallback(C=>{v.current===0&&(v.current=C);const B=(C-v.current)*G;v.current=C,f(X=>{const ae=X+B;return ae>=x?(h(!1),x):ae}),_.current=requestAnimationFrame(U)},[G,x]);d.useEffect(()=>(l?(v.current=0,_.current=requestAnimationFrame(U)):_.current&&cancelAnimationFrame(_.current),()=>{_.current&&cancelAnimationFrame(_.current)}),[l,U]);const A=()=>{h(!1),f(0)},M=C=>{f(Number(C.target.value))},E=()=>{const C=[`Build Replay: Session ${e}`,`Total iterations: ${o}`,`Files created: ${t.filter(B=>B.type==="file").length}`,`Quality gates: ${R} passed, ${T} failed`,`Phases: ${s.join(" > ")}`].join(`
|
|
280
280
|
`);a==null||a(C)},L=x>0?m/x*100:0;return g?r.jsxs("div",{className:"card overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Replay"}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("button",{onClick:()=>p(!1),className:"text-xs text-muted hover:text-ink transition-colors",children:"Collapse"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0 min-h-[240px]",children:[r.jsxs("div",{className:"border-r border-border p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"File Tree"}),t.filter(C=>C.type==="file").length===0?r.jsx("div",{className:"text-xs text-muted py-4 text-center",children:"No files to display"}):t.filter(C=>C.type==="file").map((C,B)=>r.jsx(jv,{path:C.path,visible:N.has(C.path),delay:B*30},C.path))]}),r.jsxs("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"Activity"}),r.jsx("div",{className:"space-y-1",children:k.slice(-20).map((C,B)=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[C.type==="file_created"&&r.jsx(Z,{size:11,className:"text-primary flex-shrink-0"}),C.type==="phase_change"&&r.jsx(nt,{size:11,className:"text-info flex-shrink-0"}),C.type==="gate_pass"&&r.jsx(kt,{size:11,className:"text-success flex-shrink-0"}),C.type==="gate_fail"&&r.jsx(kt,{size:11,className:"text-danger flex-shrink-0"}),C.type==="iteration"&&r.jsx(Gl,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:`truncate ${C.type==="phase_change"?"font-semibold text-ink":C.type==="gate_fail"?"text-danger":"text-secondary"}`,children:C.label})]},`${C.timestamp}-${B}`))})]})]}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-hover/50 border-t border-border text-xs text-muted",children:[r.jsx("span",{className:"font-medium text-ink capitalize",children:w}),r.jsxs("span",{children:[N.size," files"]}),r.jsxs("span",{className:"text-success",children:[R," passed"]}),T>0&&r.jsxs("span",{className:"text-danger",children:[T," failed"]}),W&&r.jsx("span",{className:"font-mono",children:W})]}),r.jsxs("div",{className:"px-4 py-2 border-t border-border",children:[r.jsx("div",{className:"relative w-full h-1.5 bg-border rounded-full overflow-hidden mb-2",children:r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal rounded-full transition-all duration-100",style:{width:`${L}%`}})}),r.jsx("input",{type:"range",min:0,max:x,value:m,onChange:M,className:"w-full h-1 opacity-0 absolute cursor-pointer",style:{marginTop:"-14px"}})]}),r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>h(!l),className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:l?"Pause":"Play",children:l?r.jsx(Yl,{size:16}):r.jsx(It,{size:16})}),r.jsx("button",{onClick:A,className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(Ql,{size:14})}),r.jsxs("button",{onClick:()=>u((c+1)%Al.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[G,"x"]})]}),r.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(ro,{size:12}),"Share Replay"]})]})]}):r.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(It,{size:14}),"Replay Build"]})}function Rv(e){const t=e.toLowerCase().trim(),s=[];let i;const n=t.match(/where (?:is|are) (?:the )?(.+?)(?:\?|$)/);n&&s.push(...n[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(l=>!["the","a","an","my","all"].includes(l)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l))),(t.includes("api endpoint")||t.includes("route")||t.includes("handler"))&&(i="api",s.length===0&&s.push("app.get","app.post","router","@app.route","endpoint")),(t.includes("database")||t.includes("db connection")||t.includes("schema"))&&s.length===0&&s.push("database","connection","schema","model","migration"),(t.includes("login")||t.includes("auth")||t.includes("authentication"))&&s.length===0&&s.push("auth","login","session","token","password"),(t.includes("test")||t.includes("spec"))&&(i="test",s.length===0&&s.push("describe","it(","test(","expect")),(t.includes("style")||t.includes("css")||t.includes("theme"))&&(i="css",s.length===0&&s.push("style","theme","color","font")),(t.includes("config")||t.includes("configuration")||t.includes("settings"))&&s.length===0&&s.push("config","settings","env","options"),s.length===0&&s.push(...t.split(/\s+/).filter(l=>l.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(l))),{terms:s,filePattern:i}}function Dv(e,t){let s=0;const i=e.path.toLowerCase(),n=e.name.toLowerCase();for(const o of t){const a=o.toLowerCase();n===a?s+=100:n.includes(a)?s+=60:i.includes(a)&&(s+=30)}return s+=Math.max(0,20-e.path.split("/").length*2),s}const Pv=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function Mv({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[l,h]=d.useState(!1),[c,u]=d.useState(!1),[m,f]=d.useState(!1),g=d.useRef(null),p=d.useRef(null),_=d.useCallback(async w=>{if(!w.trim()||!e){a([]),f(!1);return}h(!0),f(!0);try{const{terms:R}=Rv(w),T=R.join(" "),G=(await K.searchFiles(e,T)).map(U=>({path:U.path,name:U.name,relevanceScore:Dv(U,R)}));G.sort((U,A)=>A.relevanceScore-U.relevanceScore),a(G.slice(0,15))}catch{a([])}finally{h(!1)}},[e]),v=w=>{n(w),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>_(w),400)},y=w=>{w.preventDefault(),p.current&&clearTimeout(p.current),_(i)},x=()=>{var w;n(""),a([]),f(!1),(w=g.current)==null||w.focus()},k=w=>{n(w),_(w)};d.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const N=w=>w.includes(".test.")||w.includes(".spec.")?"text-teal":w.endsWith(".css")||w.endsWith(".scss")?"text-pink":w.endsWith(".json")||w.endsWith(".yaml")?"text-warning":w.endsWith(".md")?"text-muted":"text-primary";return r.jsxs("div",{className:`card overflow-hidden ${s}`,children:[r.jsxs("div",{className:"px-4 pt-4 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ts,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Code Search"})]}),r.jsx("p",{className:"text-[11px] text-muted mb-3",children:'Search in natural language -- "Where is the login function?"'}),r.jsxs("form",{onSubmit:y,className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:g,type:"text",value:i,onChange:w=>v(w.target.value),onFocus:()=>u(!0),onBlur:()=>setTimeout(()=>u(!1),200),placeholder:"Ask about your code...",className:`w-full pl-9 pr-8 py-2 text-sm bg-hover/50 border border-border rounded-card
|
|
281
281
|
focus:border-primary focus:ring-1 focus:ring-primary/20 outline-none
|
|
282
282
|
text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:x,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:14})})]})]}),!m&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:Pv.map(w=>r.jsx("button",{onClick:()=>k(w),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
|
|
283
|
-
px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(
|
|
283
|
+
px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(di,{size:14,className:"animate-spin"}),"Searching..."]}),m&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,R)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
|
|
284
284
|
hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
|
|
285
|
-
group cursor-pointer`,children:[r.jsx(Z,{size:14,className:N(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(hu,{size:10}),w.lineNumber]}),r.jsx(Jn,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${R}`))]})})]})}const or={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},ar={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Lv(e,t,s){const i=or[t]||or.claude,n=ar[e]||ar.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const _=Math.round(h*p.pct),v=_*.4,y=_*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:_}}),u=c.reduce((p,_)=>p+_.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),g=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Ol(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Bv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Lv(e,t,i),u=or[t]||or.claude,m=ar[e]||ar.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Jl,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Ol(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(nt,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(zd,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(lr,{size:12}):r.jsx(ls,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(g=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:g.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Ol(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ot,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(ue,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(ue,{variant:"primary",size:"sm",onClick:n,icon:Zt,children:"Start Build"})]})]})}function Tv({sessionId:e}){return r.jsx(kh,{sessionId:e})}function Yn(e,t,s){var o;if(t==="directory")return s?r.jsx(tn,{size:14}):r.jsx(io,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Z,{size:14,className:"text-yellow-600"}),ts:r.jsx(Z,{size:14,className:"text-blue-500"}),tsx:r.jsx(Z,{size:14,className:"text-blue-400"}),jsx:r.jsx(Z,{size:14,className:"text-yellow-500"}),py:r.jsx(Z,{size:14,className:"text-green-600"}),html:r.jsx(sc,{size:14,className:"text-orange-500"}),css:r.jsx(to,{size:14,className:"text-purple-500"}),json:r.jsx(eo,{size:14,className:"text-green-500"}),md:r.jsx(cr,{size:14,className:"text-muted"}),go:r.jsx(Z,{size:14,className:"text-cyan-600"}),rs:r.jsx(Z,{size:14,className:"text-orange-600"}),rb:r.jsx(Z,{size:14,className:"text-red-500"}),sh:r.jsx(Z,{size:14,className:"text-green-600"})}[i]||r.jsx(so,{size:14})}function zv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Eh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Eh(s.children,t);if(i!==void 0)return i}}}function Rh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Dh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const g=new Set(f);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(ls,{size:14}):r.jsx(hr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Yn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Rh(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(ft,{size:12})})]}),c&&u&&h.children&&r.jsx(Dh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Ph(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Ph(i.children,i.path+"/"));return s}function Av(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await K.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const g=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await K.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await K.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},_=y=>{m(x=>{const k=new Set(x);return k.has(y)?k.delete(y):k.add(y),k})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(Nr,{variant:"text",width:"180px",height:"16px"}),r.jsx(Nr,{variant:"block",width:"100%",height:"60px"}),r.jsx(Nr,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ot,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.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."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>_(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Td,{size:14}):r.jsx(Ss,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(Qn,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.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"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.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"})]}),r.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(ur,{size:14}),"Add"]})]})]})]})})}function Ov({session:e,onClose:t}){var Qo;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,g]=d.useState("code"),[p,_]=d.useState(!1),[v,y]=d.useState(!1),[x,k]=d.useState(e),N=d.useRef(null),[w,R]=d.useState([]),[T,W]=d.useState(!1),[G,U]=d.useState(""),A=d.useRef(null),M=d.useRef(null),[E,L]=d.useState(0),[S,j]=d.useState(null),[C,B]=d.useState(!0),[X,ae]=d.useState(!0),[q,Q]=d.useState(!1),[ie,he]=d.useState("overview"),de=57374,[z,V]=d.useState(null),J=d.useCallback(()=>{Q(b=>{const I=!b;return B(!I),ae(!I),I})},[]),[D,le]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[ge,Ee]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[ee,fe]=d.useState(null),[_e,Ce]=d.useState(null),[Ke,Bs]=d.useState(!1),[us,et]=d.useState(!1),[ce,ot]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[at,fs]=d.useState(!1),[Ts,xi]=d.useState(null),zs=d.useRef(null),[Mh,No]=d.useState(!1),[Lh,jo]=d.useState([]),[Eo,As]=d.useState(null),[Bh,vr]=d.useState(!1),[Th,vi]=d.useState(!1),[zh,Os]=d.useState(!1),[bi,Ro]=d.useState("files"),{history:Do,recordTokens:Po}=Zx(),[Ah,Oh]=d.useState(null),[Mo,$h]=d.useState({line:1,column:1}),[Ih,Lo]=d.useState(0),{device:Fh,setDevice:Hh,frameClass:Bo}=iv(),[br,Wh]=d.useState(100),[To,Uh]=d.useState(!1),[yi,yr]=d.useState(!1),[zo,Iv]=d.useState([]),ms=d.useRef(null),[Kh,Ao]=d.useState(0),{subscribe:Oo}=Cd(),Ye=d.useCallback(async()=>{try{const b=await K.getSessionDetail(x.id);k(b)}catch{}},[x.id]),$o=d.useCallback(async()=>{try{await K.stopSession(),Bs(!1),et(!1)}catch{}},[]),qh=d.useCallback(async()=>{try{await K.pauseSession(),et(!0)}catch{}},[]),Vh=d.useCallback(async()=>{try{await K.resumeSession(),et(!1)}catch{}},[]),Io=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await K.getStatus();Bs(F.running),et(F.paused),F.provider&&Ee(F.provider);const te=F.phase||"idle";if(te!==Io.current&&te!=="idle"){const Xe=new Date().toISOString(),Dt={planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},bt={planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Fs=[{id:`phase-${Date.now()}`,type:"phase_change",message:Dt[te]||`Phase: ${te}`,timestamp:Xe}];bt[te]&&Fs.push({id:`narration-${Date.now()}`,type:"narration",message:bt[te],timestamp:Xe}),jo(Ei=>[...Ei,...Fs]),Io.current=te}ot({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const qe=F.tokens_used;qe!=null&&Po(qe)}catch{}};b();const I=setInterval(b,Ke?3e3:1e4);return()=>clearInterval(I)},[Ke,Po]),d.useEffect(()=>{if(!(_e!=null&&_e.loading))return;const b=setInterval(()=>{Ce(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[_e==null?void 0:_e.loading]);const[se,Gh]=d.useState(null);d.useEffect(()=>{K.getPreviewInfo(x.id).then(Gh).catch(()=>{})},[x.id]);const[$,Si]=d.useState(null),[$s,Fo]=d.useState(!1),[Ho,Wo]=d.useState(!1),[Uo,wi]=d.useState(null),[Kt,Yh]=d.useState("");d.useEffect(()=>{const b=Oo("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),qe=F.paths.map((Xe,Dt)=>{var Ei;const bt=(Ei=F.event_types)==null?void 0:Ei[Dt],Fs=bt==="created"||bt==="IN_CREATE";return{id:`file-${Date.now()}-${Dt}`,type:Fs?"file_created":"file_modified",message:Fs?`Created ${Xe.split("/").pop()}`:`Modified ${Xe.split("/").pop()}`,timestamp:te,filePath:Xe}});if(jo(Xe=>[...Xe,...qe]),fs(!0),zs.current&&clearTimeout(zs.current),zs.current=setTimeout(()=>fs(!1),2e3),Ye(),s&&F.paths.some(Dt=>Dt===s||s.endsWith(Dt))&&xi(s),f==="preview"){const Xe=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&Xe.some(bt=>$.framework.toLowerCase().includes(bt))||L(bt=>bt+1)}});return()=>{b(),zs.current&&clearTimeout(zs.current)}},[Oo,s,f,$==null?void 0:$.running,Ye]);const Xh=d.useCallback(async()=>{if(!(!Ts||!x.id)){try{const b=await K.getSessionFileContent(x.id,Ts);l(b.content),c(b.content),_(!1),R(I=>I.map(F=>F.path===Ts?{...F,content:b.content,modified:!1}:F))}catch{}xi(null)}},[Ts,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await K.devserver.status(x.id);b||Si(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${de}/health`).then(b=>V(b.ok)).catch(()=>V(!1))},[f]);const ps=d.useCallback(async b=>{Fo(!0),wi(null);try{const I=await K.devserver.start(x.id,b);if(I.status==="error")wi(I.message||"Failed to start dev server");else{const F=await K.devserver.status(x.id);Si(F)}}catch(I){wi(I instanceof Error?I.message:"Failed to start dev server")}Fo(!1)},[x.id]),Ko=d.useRef(!1);d.useEffect(()=>{Ko.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||$s||(Ko.current=!0,ps(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,$s,ps]);const Jh=d.useCallback(async()=>{try{await K.devserver.stop(x.id);const b=await K.devserver.status(x.id);Si(b)}catch{}},[x.id]),Zh=d.useCallback(async()=>{Wo(!0);try{const b=await K.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(Xe=>setTimeout(Xe,2e3)),te=await K.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const qe=await K.devserver.status(x.id);Si(qe)}}catch(b){wi(b instanceof Error?b.message:"Fix failed")}Wo(!1)},[x.id]),_s=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,Qh=(se==null?void 0:se.preview_url)||`/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,ed=_s||Qh,[Ci,qo]=d.useState([]),[xt,ki]=d.useState(0);d.useEffect(()=>{const b=_s||(se==null?void 0:se.preview_url);b&&(qo([b]),ki(0))},[_s,se==null?void 0:se.preview_url]);const vt=Ci[xt]||ed,[Vo,Sr]=d.useState(vt),td=d.useCallback((b,I,F,te)=>{b.preventDefault(),j({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),sd=d.useCallback(()=>{xt>0&&(ki(b=>b-1),L(b=>b+1))},[xt]),id=d.useCallback(()=>{xt<Ci.length-1&&(ki(b=>b+1),L(b=>b+1))},[xt,Ci.length]),rd=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&_s)try{I=`${new URL(_s).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}qo(F=>[...F.slice(0,xt+1),I]),ki(F=>F+1),L(F=>F+1)},[xt,_s,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(vt,window.location.origin);Sr(b.pathname+b.search+b.hash||"/")}catch{Sr(vt)}},[vt]);const Ni=d.useCallback(async()=>{Ce({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.reviewProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),ji=d.useCallback(async()=>{Ce({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.testProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),wr=d.useCallback(async()=>{Ce({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.explainProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Cr=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await K.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),_(!1)),await Ye()}catch(te){const qe=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${qe}`)}},[x.id,s,Ye]),nd=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:Ss,onClick:()=>{Ni()}},{label:"Generate Tests",icon:ii,onClick:()=>{ji()}},{label:"Explain",icon:Jr,onClick:()=>{wr()}},{label:"Delete",icon:Qn,onClick:()=>{Cr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:Ss,onClick:()=>{Ni()}},{label:"Run Tests",icon:ii,onClick:()=>{ji()}}],[Ni,ji,wr,Cr]),Rt=d.useCallback(async(b,I)=>{xi(null),p&&s&&h!==null&&R(te=>te.map(qe=>qe.path===s?{...qe,content:h,modified:!0}:qe));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),_(F.modified);return}i(b),o(I),m(!0),_(!1);try{const te=x.id?await K.getSessionFileContent(x.id,b):await K.getFileContent(b);l(te.content),c(te.content),R(qe=>[...qe,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),kr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await K.saveSessionFile(x.id,s,h),l(h),_(!1),Oh(Date.now()),R(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Go=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(R(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),_(te.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&kr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),W(F=>!F),U("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),No(F=>!F)),I.key==="Escape"&&T&&W(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,kr,T]),d.useEffect(()=>{T&&A.current&&A.current.focus()},[T]);const Yo=Ph(x.files),Is=G?Yo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Yo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Rt(b.path,b.name)},[]);const od=d.useCallback(b=>{b!==void 0&&(c(b),_(b!==a),Lo(b.split(`
|
|
286
|
-
`).length))},[a]),ad=d.useCallback(b=>{N.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{$h({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&Lo(F.getLineCount())}},[]),ld=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await K.createSessionFile(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,Ye]),cd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await K.createSessionDirectory(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,Ye]),Xo=d.useCallback(async()=>{try{const b=await K.previewChanges(x.id,"preview current changes");As(b)}catch{}},[x.id]),hd=d.useCallback(()=>{As(null),Ye()},[Ye]),dd=d.useCallback(b=>{As(null),Ye()},[Ye]),ud=d.useCallback(()=>{As(null)},[]),Jo=s?Eh(x.files,s):void 0,fd=((Qo=n.split(".").pop())==null?void 0:Qo.toUpperCase())||"",{showHelp:md,setShowHelp:Zo}=Sx({onToggleBuild:()=>{Ke&&$o()}}),pd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:Ss,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:Qr,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:es,action:()=>ae(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:jr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:$t,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:ra,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Z,action:()=>{W(!0),U("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:nn,action:()=>J()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:na,action:()=>B(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Xo()},{id:"insights",label:"Build Insights",category:"command",icon:Zr,action:()=>g("insights")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:ts,action:()=>Os(!0)}],[g,J,Xo]),gs=d.useMemo(()=>{if(!Ke)return"idle";const b=(ce.phase||x.status||"").toLowerCase();return b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Ke,ce.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.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"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Do.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Jx,{tokenHistory:Do})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>B(b=>!b),title:C?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:C?r.jsx(na,{size:16}):r.jsx(ku,{size:16})}),r.jsx("button",{onClick:()=>ae(b=>!b),title:X?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:X?r.jsx(yu,{size:16}):r.jsx(wu,{size:16})}),r.jsx("button",{onClick:J,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(nc,{size:16}):r.jsx(nn,{size:16})})]}),!Ke&&r.jsx(ue,{variant:"primary",size:"sm",icon:It,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No PRD found for this project. Go to Home to start a new build.");return}vi(!0)},title:"Start build for this project",children:"Build"}),!Ke&&gs==="complete"&&r.jsx(ue,{variant:"ghost",size:"sm",icon:rn,onClick:()=>vr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Pt,{icon:ts,label:"Natural language search",size:"sm",onClick:()=>Os(!0)}),Ke&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[us?r.jsx(ue,{variant:"ghost",size:"sm",icon:It,onClick:Vh,title:"Resume build",children:"Resume"}):r.jsx(ue,{variant:"ghost",size:"sm",icon:Yl,onClick:qh,title:"Pause build",children:"Pause"}),r.jsx(ue,{variant:"danger",size:"sm",icon:Zi,onClick:$o,title:"Stop build",children:"Stop"})]}),r.jsx(Pt,{icon:Ss,label:"Review project",size:"sm",onClick:Ni,disabled:!!(_e!=null&&_e.loading)}),r.jsx(Pt,{icon:ii,label:"Run tests",size:"sm",onClick:ji,disabled:!!(_e!=null&&_e.loading)}),r.jsx(Pt,{icon:Jr,label:"Explain project",size:"sm",onClick:wr,disabled:!!(_e!=null&&_e.loading)}),r.jsx(ue,{variant:"secondary",size:"sm",icon:$t,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(Cx,{onClick:()=>Zo(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(dx,{phase:gs,iteration:ce.iteration,maxIterations:ce.maxIterations,cost:ce.cost,startTime:ce.startTime,isRunning:Ke})}),Ke&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(yv,{gatePassRate:.8,testCoverage:ce.iteration>2?60:20,iteration:ce.iteration,maxIterations:ce.maxIterations,phase:gs,compact:!0})})]}),r.jsx(Ox,{sessionId:x.id,onRestore:Ye}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(ln,{orientation:"vertical",children:[r.jsx(Js,{defaultSize:70,minSize:40,children:r.jsxs(ln,{orientation:"horizontal",className:"h-full",children:[C&&r.jsx(Js,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Ro("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${bi==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(io,{size:14}),"Files",at&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Ro("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${bi==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Kl,{size:14}),"Chat"]}),bi==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:ld,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:[r.jsx(dr,{size:12})," New"]}),r.jsxs("button",{onClick:cd,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:[r.jsx(Pd,{size:12})," New"]})]})]}),bi==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Dh,{nodes:x.files,selectedPath:s,onSelect:Rt,onDelete:Cr,onContextMenu:td}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(tn,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[r.jsx(Nh,{projectState:Ke?"building":gs==="complete"?"completed":x.files.length===0?"empty":"idle",hasSession:!!x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phase:gs,onSelect:()=>{},className:"border-b border-border"}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(vv,{sessionId:x.id,defaultMode:D})})]})]})}),C&&r.jsx(cn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Js,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.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:Qr},{id:"preview",label:"Preview",icon:Ss},{id:"deploy",label:"Deploy",icon:$t},{id:"config",label:"Config",icon:ra},{id:"secrets",label:"Secrets",icon:mu},{id:"prd",label:"PRD",icon:cr},{id:"dashboard",label:"Dashboard",icon:jr},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:Zr}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>g(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Rt(b.path,b.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 ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Yn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Go(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Go(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(ft,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Jo!=null?Rh(Jo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:fd}),p&&r.jsx("button",{onClick:kr,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"})]}),Ts===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(Ct,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Xh,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"}),r.jsx("button",{onClick:()=>xi(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"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(kd,{}):r.jsx($i,{name:"Editor",children:r.jsx(Qf,{value:h??"",language:zv(n),theme:"vs",onChange:od,onMount:ad,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}}})})}),r.jsx(tv,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:Ah,lineCount:Ih,cursorLine:Mo.line,cursorColumn:Mo.column,buildTime:ce.phase==="complete"&&ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Z,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.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"&&r.jsx($i,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${To?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{icon:Nd,label:"Back",size:"sm",onClick:sd,disabled:xt<=0}),r.jsx(Pt,{icon:Jn,label:"Forward",size:"sm",onClick:id,disabled:xt>=Ci.length-1}),r.jsx(hv,{onClick:()=>{yr(!0),L(b=>b+1)}}),r.jsx("input",{value:Vo,onChange:b=>Sr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&rd(Vo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(sv,{selectedDevice:Fh,onDeviceChange:Hh,containerWidth:Kh}),r.jsx(nv,{zoom:br,onZoomChange:Wh}),r.jsx(lv,{url:vt}),r.jsx(av,{}),r.jsx(dv,{url:vt}),r.jsx(Pt,{icon:ss,label:"Open in new tab",size:"sm",onClick:()=>window.open(vt,"_blank")}),r.jsx(cv,{isFullscreen:To,onToggle:()=>Uh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Jh,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:[r.jsx(Zi,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[yi&&r.jsx(Bl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${yi?"hidden":""}`,children:r.jsx("div",{className:`${Bo} h-full preview-zoom-${br}`,children:r.jsx("iframe",{ref:M,src:vt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{yr(!1),ms.current&&Ao(ms.current.clientWidth)}},E)})}),r.jsx(Ll,{messages:zo})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[yi&&r.jsx(Bl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${yi?"hidden":""}`,children:r.jsx("div",{className:`${Bo} h-full preview-zoom-${br}`,children:r.jsx("iframe",{ref:M,src:vt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{yr(!1),ms.current&&Ao(ms.current.clientWidth)}},E)})}),r.jsx(Ll,{messages:zo})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx(Id,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Xl,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(es,{size:28,className:"text-primary"}):r.jsx(tn,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>ps(se.dev_command||void 0),disabled:$s,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:[r.jsx(It,{size:12}),$s?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Kt,onChange:b=>Yh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Kt.trim()&&ps(Kt.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"}),r.jsx("button",{onClick:()=>Kt.trim()&&ps(Kt.trim()),disabled:$s||!Kt.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"})]})]})]}),Uo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Uo})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Zh,disabled:Ho,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:Ho?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>ps(se.dev_command||Kt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.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:$.output.slice(-10).join(`
|
|
287
|
-
`)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:ge})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Ee(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),K.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${ge===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{le(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${D===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.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"&&r.jsx(Av,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No PRD found for this project."})]})}),f==="deploy"&&r.jsx(vx,{sessionId:x.id}),f==="dashboard"&&(z===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(jr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.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."}),r.jsx("button",{onClick:async()=>{V(null);try{const b=await fetch(`http://127.0.0.1:${de}/health`);V(b.ok)}catch{V(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.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(b=>r.jsx("button",{onClick:()=>he(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${de}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ss,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${de}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(Ax,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Tv,{sessionId:e.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):0,qualityScore:0,totalCost:ce.cost,iterations:ce.iteration,provider:ge})})]})]})})]})}),X&&r.jsx(cn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),X&&r.jsx(Js,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx($i,{name:"ActivityPanel",children:r.jsx(cx,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:D,buildEvents:Lh,onFileClick:b=>Rt(b,b.split("/").pop()||b)})})})]})}),(_e==null?void 0:_e.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[_e.type==="review"?"Reviewing project":_e.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[_e.elapsed,"s"]})]})}),ee&&r.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:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Pt,{icon:ft,label:"Close",size:"sm",onClick:()=>fe(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ee})]}),S&&r.jsx(zm,{x:S.x,y:S.y,items:nd(S),onClose:()=>j(null)}),T&&r.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:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>U(b.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:b=>{b.key==="Enter"&&Is.length>0&&(Rt(Is[0].path,Is[0].name),W(!1)),b.key==="Escape"&&W(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Is.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Rt(b.path,b.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:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Yn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),Is.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(wx,{open:md,onClose:()=>Zo(!1)}),r.jsx(Ex,{isOpen:Mh,onClose:()=>No(!1),commands:pd,sessionId:x.id,onFileSelect:Rt}),Eo&&r.jsx(Fx,{data:Eo,onAcceptAll:hd,onAcceptSelected:dd,onReject:ud,onClose:()=>As(null)}),r.jsx(Xx,{phase:gs,buildTime:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0}),Bh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>vr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>vr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Ev,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:ce.iteration||ce.maxIterations})})]})}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Os(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>Os(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx(Mv,{sessionId:x.id,onOpenFile:(b,I)=>{Rt(b,b.split("/").pop()||b),Os(!1)},className:"p-4"})]})}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>vi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Bv,{complexity:D==="quick"?"simple":D==="max"?"complex":"standard",provider:ge,estimatedIterations:ce.maxIterations,onConfirm:async()=>{vi(!1);try{const b=x.prd||"";await K.startSession({prd:b,provider:ge,projectDir:x.path}),Bs(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>vi(!1)})})})]})}function $v(){const{sessionId:e}=jd(),t=Ed(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),K.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.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"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx($i,{name:"ProjectWorkspace",children:r.jsx(Ov,{session:s,onClose:()=>t("/")})})})})}const vb=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"}));export{Yd as C,sn as G,fr as L,vb as P,Ru as S};
|
|
285
|
+
group cursor-pointer`,children:[r.jsx(Z,{size:14,className:N(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(cu,{size:10}),w.lineNumber]}),r.jsx(Jn,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${R}`))]})})]})}const or={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},ar={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Lv(e,t,s){const i=or[t]||or.claude,n=ar[e]||ar.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const _=Math.round(h*p.pct),v=_*.4,y=_*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:_}}),u=c.reduce((p,_)=>p+_.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),g=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Ol(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Bv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Lv(e,t,i),u=or[t]||or.claude,m=ar[e]||ar.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Jl,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Ol(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(nt,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Td,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(lr,{size:12}):r.jsx(ls,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(g=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:g.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Ol(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ot,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(ue,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(ue,{variant:"primary",size:"sm",onClick:n,icon:Zt,children:"Start Build"})]})]})}function Tv({sessionId:e}){return r.jsx(kh,{sessionId:e})}function Yn(e,t,s){var o;if(t==="directory")return s?r.jsx(tn,{size:14}):r.jsx(io,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Z,{size:14,className:"text-yellow-600"}),ts:r.jsx(Z,{size:14,className:"text-blue-500"}),tsx:r.jsx(Z,{size:14,className:"text-blue-400"}),jsx:r.jsx(Z,{size:14,className:"text-yellow-500"}),py:r.jsx(Z,{size:14,className:"text-green-600"}),html:r.jsx(sc,{size:14,className:"text-orange-500"}),css:r.jsx(to,{size:14,className:"text-purple-500"}),json:r.jsx(eo,{size:14,className:"text-green-500"}),md:r.jsx(cr,{size:14,className:"text-muted"}),go:r.jsx(Z,{size:14,className:"text-cyan-600"}),rs:r.jsx(Z,{size:14,className:"text-orange-600"}),rb:r.jsx(Z,{size:14,className:"text-red-500"}),sh:r.jsx(Z,{size:14,className:"text-green-600"})}[i]||r.jsx(so,{size:14})}function zv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function jh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=jh(s.children,t);if(i!==void 0)return i}}}function Eh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Rh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const g=new Set(f);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(ls,{size:14}):r.jsx(hr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Yn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Eh(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(ft,{size:12})})]}),c&&u&&h.children&&r.jsx(Rh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Dh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Dh(i.children,i.path+"/"));return s}function Av(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await K.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const g=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await K.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await K.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},_=y=>{m(x=>{const k=new Set(x);return k.has(y)?k.delete(y):k.add(y),k})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(Nr,{variant:"text",width:"180px",height:"16px"}),r.jsx(Nr,{variant:"block",width:"100%",height:"60px"}),r.jsx(Nr,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ot,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.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."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>_(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Bd,{size:14}):r.jsx(ys,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(Qn,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.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"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.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"})]}),r.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(ur,{size:14}),"Add"]})]})]})]})})}function Ov({session:e,onClose:t}){var Qo;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,g]=d.useState("code"),[p,_]=d.useState(!1),[v,y]=d.useState(!1),[x,k]=d.useState(e),N=d.useRef(null),[w,R]=d.useState([]),[T,W]=d.useState(!1),[G,U]=d.useState(""),A=d.useRef(null),M=d.useRef(null),[E,L]=d.useState(0),[S,j]=d.useState(null),[C,B]=d.useState(!0),[X,ae]=d.useState(!0),[q,Q]=d.useState(!1),[ie,he]=d.useState("overview"),de=57374,[z,V]=d.useState(null),J=d.useCallback(()=>{Q(b=>{const I=!b;return B(!I),ae(!I),I})},[]),[D,le]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[ge,Ee]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[ee,fe]=d.useState(null),[_e,Ce]=d.useState(null),[Ge,Ls]=d.useState(!1),[us,et]=d.useState(!1),[ce,ot]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[at,fs]=d.useState(!1),[Bs,gi]=d.useState(null),Ts=d.useRef(null),[Ph,No]=d.useState(!1),[Mh,jo]=d.useState([]),[Eo,zs]=d.useState(null),[Lh,vr]=d.useState(!1),[Bh,xi]=d.useState(!1),[Th,As]=d.useState(!1),[vi,Ro]=d.useState("files"),{history:Do,recordTokens:Po}=Jx(),[zh,Ah]=d.useState(null),[Mo,Oh]=d.useState({line:1,column:1}),[$h,Lo]=d.useState(0),{device:Ih,setDevice:Fh,frameClass:Bo}=sv(),[br,Hh]=d.useState(100),[To,Wh]=d.useState(!1),[bi,yr]=d.useState(!1),[zo,Iv]=d.useState([]),ms=d.useRef(null),[Uh,Ao]=d.useState(0),{subscribe:Oo}=wd(),Ye=d.useCallback(async()=>{try{const b=await K.getSessionDetail(x.id);k(b)}catch{}},[x.id]),$o=d.useCallback(async()=>{try{await K.stopSession(),Ls(!1),et(!1)}catch{}},[]),Kh=d.useCallback(async()=>{try{await K.pauseSession(),et(!0)}catch{}},[]),qh=d.useCallback(async()=>{try{await K.resumeSession(),et(!1)}catch{}},[]),Io=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await K.getStatus();Ls(F.running),et(F.paused),F.provider&&Ee(F.provider);const te=F.phase||"idle";if(te!==Io.current&&te!=="idle"){const Xe=new Date().toISOString(),Dt={planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},bt={planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Is=[{id:`phase-${Date.now()}`,type:"phase_change",message:Dt[te]||`Phase: ${te}`,timestamp:Xe}];bt[te]&&Is.push({id:`narration-${Date.now()}`,type:"narration",message:bt[te],timestamp:Xe}),jo(Ei=>[...Ei,...Is]),Io.current=te}ot({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const Ke=F.tokens_used;Ke!=null&&Po(Ke)}catch{}};b();const I=setInterval(b,Ge?3e3:1e4);return()=>clearInterval(I)},[Ge,Po]),d.useEffect(()=>{if(!(_e!=null&&_e.loading))return;const b=setInterval(()=>{Ce(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[_e==null?void 0:_e.loading]);const[se,Vh]=d.useState(null);d.useEffect(()=>{K.getPreviewInfo(x.id).then(Vh).catch(()=>{})},[x.id]);const[$,yi]=d.useState(null),[Os,Fo]=d.useState(!1),[Ho,Wo]=d.useState(!1),[Uo,Si]=d.useState(null),[Kt,Gh]=d.useState("");d.useEffect(()=>{const b=Oo("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ke=F.paths.map((Xe,Dt)=>{var Ei;const bt=(Ei=F.event_types)==null?void 0:Ei[Dt],Is=bt==="created"||bt==="IN_CREATE";return{id:`file-${Date.now()}-${Dt}`,type:Is?"file_created":"file_modified",message:Is?`Created ${Xe.split("/").pop()}`:`Modified ${Xe.split("/").pop()}`,timestamp:te,filePath:Xe}});if(jo(Xe=>[...Xe,...Ke]),fs(!0),Ts.current&&clearTimeout(Ts.current),Ts.current=setTimeout(()=>fs(!1),2e3),Ye(),s&&F.paths.some(Dt=>Dt===s||s.endsWith(Dt))&&gi(s),f==="preview"){const Xe=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&Xe.some(bt=>$.framework.toLowerCase().includes(bt))||L(bt=>bt+1)}});return()=>{b(),Ts.current&&clearTimeout(Ts.current)}},[Oo,s,f,$==null?void 0:$.running,Ye]);const Yh=d.useCallback(async()=>{if(!(!Bs||!x.id)){try{const b=await K.getSessionFileContent(x.id,Bs);l(b.content),c(b.content),_(!1),R(I=>I.map(F=>F.path===Bs?{...F,content:b.content,modified:!1}:F))}catch{}gi(null)}},[Bs,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await K.devserver.status(x.id);b||yi(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${de}/health`).then(b=>V(b.ok)).catch(()=>V(!1))},[f]);const ps=d.useCallback(async b=>{Fo(!0),Si(null);try{const I=await K.devserver.start(x.id,b);if(I.status==="error")Si(I.message||"Failed to start dev server");else{const F=await K.devserver.status(x.id);yi(F)}}catch(I){Si(I instanceof Error?I.message:"Failed to start dev server")}Fo(!1)},[x.id]),Ko=d.useRef(!1);d.useEffect(()=>{Ko.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||Os||(Ko.current=!0,ps(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,Os,ps]);const Xh=d.useCallback(async()=>{try{await K.devserver.stop(x.id);const b=await K.devserver.status(x.id);yi(b)}catch{}},[x.id]),Jh=d.useCallback(async()=>{Wo(!0);try{const b=await K.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(Xe=>setTimeout(Xe,2e3)),te=await K.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const Ke=await K.devserver.status(x.id);yi(Ke)}}catch(b){Si(b instanceof Error?b.message:"Fix failed")}Wo(!1)},[x.id]),_s=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,Zh=(se==null?void 0:se.preview_url)||`/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,Qh=_s||Zh,[wi,qo]=d.useState([]),[xt,Ci]=d.useState(0);d.useEffect(()=>{const b=_s||(se==null?void 0:se.preview_url);b&&(qo([b]),Ci(0))},[_s,se==null?void 0:se.preview_url]);const vt=wi[xt]||Qh,[Vo,Sr]=d.useState(vt),ed=d.useCallback((b,I,F,te)=>{b.preventDefault(),j({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),td=d.useCallback(()=>{xt>0&&(Ci(b=>b-1),L(b=>b+1))},[xt]),sd=d.useCallback(()=>{xt<wi.length-1&&(Ci(b=>b+1),L(b=>b+1))},[xt,wi.length]),id=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&_s)try{I=`${new URL(_s).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}qo(F=>[...F.slice(0,xt+1),I]),Ci(F=>F+1),L(F=>F+1)},[xt,_s,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(vt,window.location.origin);Sr(b.pathname+b.search+b.hash||"/")}catch{Sr(vt)}},[vt]);const ki=d.useCallback(async()=>{Ce({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.reviewProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Ni=d.useCallback(async()=>{Ce({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.testProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),wr=d.useCallback(async()=>{Ce({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await K.explainProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Cr=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await K.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),_(!1)),await Ye()}catch(te){const Ke=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ke}`)}},[x.id,s,Ye]),rd=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:ys,onClick:()=>{ki()}},{label:"Generate Tests",icon:si,onClick:()=>{Ni()}},{label:"Explain",icon:Jr,onClick:()=>{wr()}},{label:"Delete",icon:Qn,onClick:()=>{Cr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:ys,onClick:()=>{ki()}},{label:"Run Tests",icon:si,onClick:()=>{Ni()}}],[ki,Ni,wr,Cr]),Rt=d.useCallback(async(b,I)=>{gi(null),p&&s&&h!==null&&R(te=>te.map(Ke=>Ke.path===s?{...Ke,content:h,modified:!0}:Ke));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),_(F.modified);return}i(b),o(I),m(!0),_(!1);try{const te=x.id?await K.getSessionFileContent(x.id,b):await K.getFileContent(b);l(te.content),c(te.content),R(Ke=>[...Ke,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),kr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await K.saveSessionFile(x.id,s,h),l(h),_(!1),Ah(Date.now()),R(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Go=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(R(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),_(te.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&kr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),W(F=>!F),U("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),No(F=>!F)),I.key==="Escape"&&T&&W(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,kr,T]),d.useEffect(()=>{T&&A.current&&A.current.focus()},[T]);const Yo=Dh(x.files),$s=G?Yo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Yo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Rt(b.path,b.name)},[]);const nd=d.useCallback(b=>{b!==void 0&&(c(b),_(b!==a),Lo(b.split(`
|
|
286
|
+
`).length))},[a]),od=d.useCallback(b=>{N.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{Oh({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&Lo(F.getLineCount())}},[]),ad=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await K.createSessionFile(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,Ye]),ld=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await K.createSessionDirectory(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,Ye]),Xo=d.useCallback(async()=>{try{const b=await K.previewChanges(x.id,"preview current changes");zs(b)}catch{}},[x.id]),cd=d.useCallback(()=>{zs(null),Ye()},[Ye]),hd=d.useCallback(b=>{zs(null),Ye()},[Ye]),dd=d.useCallback(()=>{zs(null)},[]),Jo=s?jh(x.files,s):void 0,ud=((Qo=n.split(".").pop())==null?void 0:Qo.toUpperCase())||"",{showHelp:fd,setShowHelp:Zo}=yx({onToggleBuild:()=>{Ge&&$o()}}),md=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:ys,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:Qr,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:es,action:()=>ae(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:jr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:$t,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:ra,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Z,action:()=>{W(!0),U("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:nn,action:()=>J()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:na,action:()=>B(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Xo()},{id:"insights",label:"Build Insights",category:"command",icon:Zr,action:()=>g("insights")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:ts,action:()=>As(!0)}],[g,J,Xo]),ji=d.useMemo(()=>{if(!Ge)return"idle";const b=(ce.phase||x.status||"").toLowerCase();return b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Ge,ce.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.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"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Do.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Xx,{tokenHistory:Do})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>B(b=>!b),title:C?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:C?r.jsx(na,{size:16}):r.jsx(Cu,{size:16})}),r.jsx("button",{onClick:()=>ae(b=>!b),title:X?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:X?r.jsx(bu,{size:16}):r.jsx(Su,{size:16})}),r.jsx("button",{onClick:J,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(nc,{size:16}):r.jsx(nn,{size:16})})]}),!Ge&&r.jsx(ue,{variant:"primary",size:"sm",icon:It,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No PRD found for this project. Go to Home to start a new build.");return}xi(!0)},title:"Start build for this project",children:"Build"}),!Ge&&ji==="complete"&&r.jsx(ue,{variant:"ghost",size:"sm",icon:rn,onClick:()=>vr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Pt,{icon:ts,label:"Natural language search",size:"sm",onClick:()=>As(!0)}),Ge&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[us?r.jsx(ue,{variant:"ghost",size:"sm",icon:It,onClick:qh,title:"Resume build",children:"Resume"}):r.jsx(ue,{variant:"ghost",size:"sm",icon:Yl,onClick:Kh,title:"Pause build",children:"Pause"}),r.jsx(ue,{variant:"danger",size:"sm",icon:Zi,onClick:$o,title:"Stop build",children:"Stop"})]}),r.jsx(Pt,{icon:ys,label:"Review project",size:"sm",onClick:ki,disabled:!!(_e!=null&&_e.loading)}),r.jsx(Pt,{icon:si,label:"Run tests",size:"sm",onClick:Ni,disabled:!!(_e!=null&&_e.loading)}),r.jsx(Pt,{icon:Jr,label:"Explain project",size:"sm",onClick:wr,disabled:!!(_e!=null&&_e.loading)}),r.jsx(ue,{variant:"secondary",size:"sm",icon:$t,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(wx,{onClick:()=>Zo(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(hx,{phase:ji,iteration:ce.iteration,maxIterations:ce.maxIterations,cost:ce.cost,startTime:ce.startTime,isRunning:Ge})}),Ge&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(yv,{gatePassRate:.8,testCoverage:ce.iteration>2?60:20,iteration:ce.iteration,maxIterations:ce.maxIterations,phase:ji,compact:!0})})]}),r.jsx(Ax,{sessionId:x.id,onRestore:Ye}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(ln,{orientation:"vertical",children:[r.jsx(Xs,{defaultSize:70,minSize:40,children:r.jsxs(ln,{orientation:"horizontal",className:"h-full",children:[C&&r.jsx(Xs,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Ro("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${vi==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(io,{size:14}),"Files",at&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Ro("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${vi==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Kl,{size:14}),"Chat"]}),vi==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:ad,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:[r.jsx(dr,{size:12})," New"]}),r.jsxs("button",{onClick:ld,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:[r.jsx(Dd,{size:12})," New"]})]})]}),vi==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Rh,{nodes:x.files,selectedPath:s,onSelect:Rt,onDelete:Cr,onContextMenu:ed}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(tn,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(vv,{sessionId:x.id,defaultMode:D})})})]})}),C&&r.jsx(cn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Xs,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.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:Qr},{id:"preview",label:"Preview",icon:ys},{id:"deploy",label:"Deploy",icon:$t},{id:"config",label:"Config",icon:ra},{id:"secrets",label:"Secrets",icon:fu},{id:"prd",label:"PRD",icon:cr},{id:"dashboard",label:"Dashboard",icon:jr},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:Zr}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>g(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Rt(b.path,b.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 ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Yn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Go(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Go(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(ft,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Jo!=null?Eh(Jo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:ud}),p&&r.jsx("button",{onClick:kr,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"})]}),Bs===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(Ct,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Yh,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"}),r.jsx("button",{onClick:()=>gi(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"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(Cd,{}):r.jsx($i,{name:"Editor",children:r.jsx(Zf,{value:h??"",language:zv(n),theme:"vs",onChange:nd,onMount:od,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}}})})}),r.jsx(ev,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:zh,lineCount:$h,cursorLine:Mo.line,cursorColumn:Mo.column,buildTime:ce.phase==="complete"&&ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Z,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.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"&&r.jsx($i,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${To?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{icon:kd,label:"Back",size:"sm",onClick:td,disabled:xt<=0}),r.jsx(Pt,{icon:Jn,label:"Forward",size:"sm",onClick:sd,disabled:xt>=wi.length-1}),r.jsx(cv,{onClick:()=>{yr(!0),L(b=>b+1)}}),r.jsx("input",{value:Vo,onChange:b=>Sr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&id(Vo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(tv,{selectedDevice:Ih,onDeviceChange:Fh,containerWidth:Uh}),r.jsx(rv,{zoom:br,onZoomChange:Hh}),r.jsx(av,{url:vt}),r.jsx(ov,{}),r.jsx(hv,{url:vt}),r.jsx(Pt,{icon:ss,label:"Open in new tab",size:"sm",onClick:()=>window.open(vt,"_blank")}),r.jsx(lv,{isFullscreen:To,onToggle:()=>Wh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Xh,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:[r.jsx(Zi,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[bi&&r.jsx(Bl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${bi?"hidden":""}`,children:r.jsx("div",{className:`${Bo} h-full preview-zoom-${br}`,children:r.jsx("iframe",{ref:M,src:vt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{yr(!1),ms.current&&Ao(ms.current.clientWidth)}},E)})}),r.jsx(Ll,{messages:zo})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[bi&&r.jsx(Bl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${bi?"hidden":""}`,children:r.jsx("div",{className:`${Bo} h-full preview-zoom-${br}`,children:r.jsx("iframe",{ref:M,src:vt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{yr(!1),ms.current&&Ao(ms.current.clientWidth)}},E)})}),r.jsx(Ll,{messages:zo})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx($d,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Xl,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(es,{size:28,className:"text-primary"}):r.jsx(tn,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>ps(se.dev_command||void 0),disabled:Os,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:[r.jsx(It,{size:12}),Os?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Kt,onChange:b=>Gh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Kt.trim()&&ps(Kt.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"}),r.jsx("button",{onClick:()=>Kt.trim()&&ps(Kt.trim()),disabled:Os||!Kt.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"})]})]})]}),Uo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Uo})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Jh,disabled:Ho,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:Ho?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>ps(se.dev_command||Kt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.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:$.output.slice(-10).join(`
|
|
287
|
+
`)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:ge})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Ee(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),K.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${ge===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{le(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${D===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.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"&&r.jsx(Av,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No PRD found for this project."})]})}),f==="deploy"&&r.jsx(xx,{sessionId:x.id}),f==="dashboard"&&(z===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(jr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.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."}),r.jsx("button",{onClick:async()=>{V(null);try{const b=await fetch(`http://127.0.0.1:${de}/health`);V(b.ok)}catch{V(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.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(b=>r.jsx("button",{onClick:()=>he(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${de}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ss,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${de}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(zx,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Tv,{sessionId:e.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):0,qualityScore:0,totalCost:ce.cost,iterations:ce.iteration,provider:ge})})]})]})})]})}),X&&r.jsx(cn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),X&&r.jsx(Xs,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx($i,{name:"ActivityPanel",children:r.jsx(lx,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:D,buildEvents:Mh,onFileClick:b=>Rt(b,b.split("/").pop()||b)})})})]})}),(_e==null?void 0:_e.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[_e.type==="review"?"Reviewing project":_e.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[_e.elapsed,"s"]})]})}),ee&&r.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:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Pt,{icon:ft,label:"Close",size:"sm",onClick:()=>fe(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ee})]}),S&&r.jsx(Tm,{x:S.x,y:S.y,items:rd(S),onClose:()=>j(null)}),T&&r.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:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>U(b.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:b=>{b.key==="Enter"&&$s.length>0&&(Rt($s[0].path,$s[0].name),W(!1)),b.key==="Escape"&&W(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[$s.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Rt(b.path,b.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:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Yn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),$s.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(Sx,{open:fd,onClose:()=>Zo(!1)}),r.jsx(jx,{isOpen:Ph,onClose:()=>No(!1),commands:md,sessionId:x.id,onFileSelect:Rt}),Eo&&r.jsx(Ix,{data:Eo,onAcceptAll:cd,onAcceptSelected:hd,onReject:dd,onClose:()=>zs(null)}),r.jsx(Yx,{phase:ji,buildTime:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0}),Lh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>vr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>vr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Ev,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:ce.iteration||ce.maxIterations})})]})}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>As(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>As(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx(Mv,{sessionId:x.id,onOpenFile:(b,I)=>{Rt(b,b.split("/").pop()||b),As(!1)},className:"p-4"})]})}),Bh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>xi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Bv,{complexity:D==="quick"?"simple":D==="max"?"complex":"standard",provider:ge,estimatedIterations:ce.maxIterations,onConfirm:async()=>{xi(!1);try{const b=x.prd||"";await K.startSession({prd:b,provider:ge,projectDir:x.path}),Ls(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>xi(!1)})})})]})}function $v(){const{sessionId:e}=Nd(),t=jd(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),K.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.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"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx($i,{name:"ProjectWorkspace",children:r.jsx(Ov,{session:s,onClose:()=>t("/")})})})})}const vb=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"}));export{Gd as C,sn as G,fr as L,vb as P,Eu as S};
|