loki-mode 10.5.0 → 10.5.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/dashboard/requirements.txt +3 -3
- package/docs/INSTALLATION.md +1 -1
- package/docs/v10/BOARD.md +73 -50
- package/docs/v10/DECISIONS.md +14 -0
- package/docs/v10/MEDIUM-ANALYSIS.md +165 -0
- package/docs/v10/METRICS.md +42 -0
- package/docs/v10/PROGRESS.md +19 -0
- package/docs/v10/SCORECARD-PLAN.md +250 -0
- package/loki-ts/dist/loki.js +213 -213
- package/mcp/__init__.py +1 -1
- package/mcp/requirements.txt +1 -1
- package/package.json +1 -1
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-UqksX-2j.js → AdminPage-DootQsDP.js} +1 -1
- package/web-app/dist/assets/{Avatar-DL9GAm3o.js → Avatar-BEh-AUI_.js} +1 -1
- package/web-app/dist/assets/{Badge-Dcje8mq7.js → Badge-xhAWVqTk.js} +1 -1
- package/web-app/dist/assets/{Button-CrSiFEeN.js → Button-DPHlrUW7.js} +1 -1
- package/web-app/dist/assets/{CockpitPage-pQmCWfIh.js → CockpitPage-QuYj3Nrx.js} +1 -1
- package/web-app/dist/assets/{ComparePage-DdNXRO4U.js → ComparePage-D_JaNxyU.js} +1 -1
- package/web-app/dist/assets/{ErrorBoundary-DllIrxM_.js → ErrorBoundary-xoqc9Ypk.js} +1 -1
- package/web-app/dist/assets/{EvidenceReceiptPanel-BZmSdXKX.js → EvidenceReceiptPanel-WfoGkBw1.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-L-JdQNH7.js → GitHubIssuesPanel-DpSh68Vr.js} +1 -1
- package/web-app/dist/assets/{GitHubPRsPanel-BmASy439.js → GitHubPRsPanel-PsM0TRCK.js} +1 -1
- package/web-app/dist/assets/{HomePage-CfqeIZPV.js → HomePage-DGNkRAE2.js} +2 -2
- package/web-app/dist/assets/{LoginPage-DkFVMTDS.js → LoginPage-CDZTufhc.js} +1 -1
- package/web-app/dist/assets/{MagicPage-hEQNcZ3A.js → MagicPage-nBvtlxPD.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-2064AnFh.js → MetricsPage-Btvb_sUN.js} +1 -1
- package/web-app/dist/assets/{NotFoundPage-BxPHH3gH.js → NotFoundPage-zrHK2Qo5.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-B93Nt-kS.js → ProjectPage-oilUogSN.js} +72 -72
- package/web-app/dist/assets/{ProjectsPage-BhaHPEd7.js → ProjectsPage-DEeRukgB.js} +1 -1
- package/web-app/dist/assets/{SettingsPage-Cqq9SCLd.js → SettingsPage-Dw_uFXXA.js} +1 -1
- package/web-app/dist/assets/{ShowcasePage-DPEOv9rh.js → ShowcasePage-DucUH7_M.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-CkuuJB1N.js → SystemSettingsPage-DSHQjPUw.js} +1 -1
- package/web-app/dist/assets/{TeamsPage-QF7urKuv.js → TeamsPage-CPCicvyD.js} +1 -1
- package/web-app/dist/assets/{TemplatesPage-wkI45c7P.js → TemplatesPage-BfICx9k6.js} +1 -1
- package/web-app/dist/assets/{TerminalOutput-4vSkFBSp.js → TerminalOutput-CDLcTRF0.js} +1 -1
- package/web-app/dist/assets/{activity-BiGRY_Fo.js → activity-DYrOuAG7.js} +1 -1
- package/web-app/dist/assets/{bell-BLYyCwzQ.js → bell-D9uSrwuN.js} +1 -1
- package/web-app/dist/assets/{bot-RKm3KktS.js → bot-C6Bn5s1m.js} +1 -1
- package/web-app/dist/assets/{check-C7qOmK8l.js → check-BmJB2Xqr.js} +1 -1
- package/web-app/dist/assets/{chevron-left-Dtko1B8i.js → chevron-left-C-S6ysEt.js} +1 -1
- package/web-app/dist/assets/{circle-alert-XO6K8jaq.js → circle-alert-BSasJfUu.js} +1 -1
- package/web-app/dist/assets/{clock-BYv008se.js → clock-a7_-OWs3.js} +1 -1
- package/web-app/dist/assets/{cloud-DTHdCtFF.js → cloud-DrX9DhXi.js} +1 -1
- package/web-app/dist/assets/{code-xml-tGMeHsgl.js → code-xml-BKuuaYjb.js} +1 -1
- package/web-app/dist/assets/{database-BuVrz6Xv.js → database-TMGZ6D6w.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-BSGlReww.js → dollar-sign-CFAcj-wt.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-2uqgSIoQ.js → file-code-corner-BH8h7Yza.js} +1 -1
- package/web-app/dist/assets/{file-plus-BFGGouZ1.js → file-plus-DLDkZZXo.js} +1 -1
- package/web-app/dist/assets/{globe-DNW-N2dC.js → globe-Ll1o1Ycp.js} +1 -1
- package/web-app/dist/assets/{hammer-B6Ngruab.js → hammer-CKex5IZg.js} +1 -1
- package/web-app/dist/assets/index-BxNfb8ay.js +435 -0
- package/web-app/dist/assets/{layers-Bo5CyvwJ.js → layers-BJpeiurx.js} +1 -1
- package/web-app/dist/assets/{loader-circle-Bg8IiGhM.js → loader-circle-PWbcF4Lv.js} +1 -1
- package/web-app/dist/assets/{lock-DQ3OZU3R.js → lock-Bpz4x4fe.js} +1 -1
- package/web-app/dist/assets/{package-B75R3o4e.js → package-B15vCu0K.js} +1 -1
- package/web-app/dist/assets/{plus-DxR5rSag.js → plus-C0tChz04.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-DW4oTyXT.js → refresh-cw-BoJvJUHu.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-CLvwZ8g6.js → rotate-ccw-CkYRMcmp.js} +1 -1
- package/web-app/dist/assets/{scroll-text-CjRVS3NW.js → scroll-text-DrZFCdjT.js} +1 -1
- package/web-app/dist/assets/{server-DcAfROIl.js → server-Bu3prV7g.js} +1 -1
- package/web-app/dist/assets/{shield-alert-D_HQvK1o.js → shield-alert-Ct8WKcbl.js} +1 -1
- package/web-app/dist/assets/{thumbs-up-DEGIjHwe.js → thumbs-up-BXTieWXh.js} +1 -1
- package/web-app/dist/assets/{trash-2-Y_5JJyBC.js → trash-2-j8kPf0Rp.js} +1 -1
- package/web-app/dist/assets/{trending-down-D5F185e6.js → trending-down-6uNQaJHx.js} +1 -1
- package/web-app/dist/assets/{trending-up-Cm4ID9qE.js → trending-up-DsnJz2rA.js} +1 -1
- package/web-app/dist/assets/{upload-D4GrCRRP.js → upload-CcR9H3Sn.js} +1 -1
- package/web-app/dist/assets/{usePolling-uwpHN9Hw.js → usePolling-8bOCgNQG.js} +1 -1
- package/web-app/dist/assets/{user-DF7XMcwt.js → user-uSKOq9lh.js} +1 -1
- package/web-app/dist/index.html +1 -1
- package/web-app/requirements.txt +6 -6
- package/web-app/dist/assets/index-Ch5kxAL_.js +0 -435
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-
|
|
2
|
-
var
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-DpSh68Vr.js","assets/index-BxNfb8ay.js","assets/index-Cx7e1d6w.css","assets/Button-DPHlrUW7.js","assets/thumbs-up-BXTieWXh.js","assets/refresh-cw-BoJvJUHu.js","assets/circle-alert-BSasJfUu.js","assets/user-uSKOq9lh.js","assets/loader-circle-PWbcF4Lv.js","assets/rotate-ccw-CkYRMcmp.js","assets/GitHubPRsPanel-PsM0TRCK.js","assets/chevron-left-C-S6ysEt.js","assets/shield-alert-Ct8WKcbl.js","assets/file-code-corner-BH8h7Yza.js","assets/clock-a7_-OWs3.js","assets/check-BmJB2Xqr.js","assets/ErrorBoundary-xoqc9Ypk.js","assets/TerminalOutput-CDLcTRF0.js","assets/lock-Bpz4x4fe.js","assets/package-B15vCu0K.js","assets/file-plus-DLDkZZXo.js","assets/activity-DYrOuAG7.js","assets/scroll-text-DrZFCdjT.js","assets/bot-C6Bn5s1m.js","assets/hammer-CKex5IZg.js","assets/dollar-sign-CFAcj-wt.js","assets/globe-Ll1o1Ycp.js","assets/trash-2-j8kPf0Rp.js","assets/upload-CcR9H3Sn.js","assets/plus-C0tChz04.js","assets/code-xml-BKuuaYjb.js","assets/trending-up-DsnJz2rA.js","assets/layers-BJpeiurx.js","assets/trending-down-6uNQaJHx.js","assets/server-Bu3prV7g.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var aa=e=>{throw TypeError(e)};var la=(e,t,s)=>t.has(e)||aa("Cannot "+s);var Ks=(e,t,s)=>(la(e,t,"read from private field"),s?s.call(e):t.get(e)),ca=(e,t,s)=>t.has(e)?aa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ha=(e,t,s,i)=>(la(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as le,r as d,W as Ts,j as r,e as rn,f as Zl,g as mr,h as xs,I as Ed,T as Tt,R as Xt,i as fs,M as Ql,k as sr,l as vs,S as ec,U as Dd,X as vt,m as ms,Z as zs,a as V,E as ps,G as Ie,K as Rd,n as Ld,o as Pd,F as gi,P as ds,_ as so,p as pr,q as tc,s as Md,t as Bd,v as Td,A as io,L as zd,B as Zs,w as nn,x as Ad,d as Id,y as Rs,z as da,D as ua,H as Od,J as sc,N as oi,O as $d,u as Fd}from"./index-BxNfb8ay.js";import{R as Hd,S as ir,P as ic,E as Ui}from"./ErrorBoundary-xoqc9Ypk.js";import{B as he}from"./Button-DPHlrUW7.js";import{T as Wd,F as Ud}from"./TerminalOutput-CDLcTRF0.js";import{P as rc}from"./package-B15vCu0K.js";import{F as ee}from"./file-code-corner-BH8h7Yza.js";import{F as _r}from"./file-plus-DLDkZZXo.js";import{C as ft}from"./clock-a7_-OWs3.js";import{A as Kd}from"./activity-DYrOuAG7.js";import{S as qd}from"./scroll-text-DrZFCdjT.js";import{B as Vd}from"./bot-C6Bn5s1m.js";import{C as es}from"./check-BmJB2Xqr.js";import{L as xi}from"./loader-circle-PWbcF4Lv.js";import{H as Gd}from"./hammer-CKex5IZg.js";import{D as nc}from"./dollar-sign-CFAcj-wt.js";import{R as St}from"./refresh-cw-BoJvJUHu.js";import{C as bs}from"./circle-alert-BSasJfUu.js";import{G as on}from"./globe-Ll1o1Ycp.js";import{C as ro,T as no,F as an}from"./trash-2-j8kPf0Rp.js";import{C as Yd,G as ln,a as oc,F as ac,H as rr,M as lc,T as Xd}from"./thumbs-up-BXTieWXh.js";import{U as cc}from"./upload-CcR9H3Sn.js";import{P as gr}from"./plus-C0tChz04.js";import{R as hc,E as Jd}from"./rotate-ccw-CkYRMcmp.js";import{C as cn}from"./code-xml-BKuuaYjb.js";import{T as Zd}from"./trending-up-DsnJz2rA.js";import{L as Qd}from"./layers-BJpeiurx.js";import{T as eu}from"./trending-down-6uNQaJHx.js";import{S as tu}from"./server-Bu3prV7g.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 su=[["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"}]],iu=le("at-sign",su);/**
|
|
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 ru=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],dc=le("ban",ru);/**
|
|
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 nu=[["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"}]],ou=le("camera",nu);/**
|
|
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 au=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],lu=le("check-check",au);/**
|
|
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 cu=[["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"}]],hu=le("compass",cu);/**
|
|
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 du=[["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"}]],oo=le("file-braces",du);/**
|
|
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 uu=[["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"}]],uc=le("file-code",uu);/**
|
|
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 fu=[["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"}]],ao=le("file-type",fu);/**
|
|
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 mu=[["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"}]],pu=le("file-x",mu);/**
|
|
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 _u=[["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"}]],lo=le("file",_u);/**
|
|
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 gu=[["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"}]],co=le("folder",gu);/**
|
|
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 xu=[["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"}]],vu=le("github",xu);/**
|
|
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 bu=[["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"}]],yu=le("hash",bu);/**
|
|
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 Su=[["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"}]],fa=le("image",Su);/**
|
|
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 wu=[["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"}]],Cu=le("key-round",wu);/**
|
|
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 ku=[["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"}]],Mr=le("layout-dashboard",ku);/**
|
|
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 Nu=[["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"}]],fc=le("link",Nu);/**
|
|
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 ju=[["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"}]],xr=le("loader",ju);/**
|
|
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 Eu=[["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"}]],hn=le("maximize-2",Eu);/**
|
|
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 Du=[["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"}]],mc=le("minimize-2",Du);/**
|
|
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 Ru=[["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"}]],Lu=le("panel-bottom-close",Ru);/**
|
|
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 Pu=[["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"}]],Mu=le("panel-bottom-open",Pu);/**
|
|
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 Bu=[["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"}]],Tu=le("panel-left-open",Bu);/**
|
|
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 zu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Au=le("save",zu);/**
|
|
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 Iu=[["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"}]],Ou=le("send",Iu);/**
|
|
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 $u=[["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"}]],pc=le("share-2",$u);/**
|
|
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 Fu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Hu=le("smartphone",Fu);/**
|
|
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 Wu=[["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"}]],Uu=le("tablet",Wu);/**
|
|
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 Ku=[["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"}]],ai=le("test-tube-diagonal",Ku);/**
|
|
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 qu=[["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"}]],Vu=le("thumbs-down",qu);/**
|
|
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 Gu=[["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"}]],_c=le("timer",Gu);/**
|
|
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
|
|
163
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
162
|
+
*/const Yu=[["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"}]],Xu=le("unplug",Yu);function ma(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 Ju(e){if(Array.isArray(e))return e}function Zu(e,t,s){return(t=of(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Qu(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,n,o,a,c=[],h=!0,l=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(h=(i=o.call(s)).done)&&(c.push(i.value),c.length!==t);h=!0);}catch(f){l=!0,n=f}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(l)throw n}}return c}}function ef(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
163
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pa(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 _a(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?pa(Object(s),!0).forEach(function(i){Zu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):pa(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function tf(e,t){if(e==null)return{};var s,i,n=sf(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 sf(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 rf(e,t){return Ju(e)||Qu(e,t)||af(e,t)||ef()}function nf(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 of(e){var t=nf(e,"string");return typeof t=="symbol"?t:t+""}function af(e,t){if(e){if(typeof e=="string")return ma(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)?ma(e,t):void 0}}function lf(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function ga(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 xa(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ga(Object(s),!0).forEach(function(i){lf(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ga(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function cf(){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 Qs(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,c=new Array(a),h=0;h<a;h++)c[h]=arguments[h];return t.apply(s,[].concat(n,c))}}}function nr(e){return{}.toString.call(e).includes("Object")}function hf(e){return!Object.keys(e).length}function di(e){return typeof e=="function"}function df(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function uf(e,t){return nr(t)||Jt("changeType"),Object.keys(t).some(function(s){return!df(e,s)})&&Jt("changeField"),t}function ff(e){di(e)||Jt("selectorType")}function mf(e){di(e)||nr(e)||Jt("handlerType"),nr(e)&&Object.values(e).some(function(t){return!di(t)})&&Jt("handlersType")}function pf(e){e||Jt("initialIsRequired"),nr(e)||Jt("initialType"),hf(e)&&Jt("initialContent")}function _f(e,t){throw new Error(e[t]||e.default)}var gf={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"},Jt=Qs(_f)(gf),Bi={changes:uf,selector:ff,handler:mf,initial:pf};function xf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Bi.initial(e),Bi.handler(t);var s={current:e},i=Qs(yf)(s,t),n=Qs(bf)(s),o=Qs(Bi.changes)(e),a=Qs(vf)(s);function c(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return Bi.selector(l),l(s.current)}function h(l){cf(i,n,o,a)(l)}return[c,h]}function vf(e,t){return di(t)?t(e.current):t}function bf(e,t){return e.current=xa(xa({},e.current),t),t}function yf(e,t,s){return di(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 Sf={create:xf},wf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Cf(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,c=new Array(a),h=0;h<a;h++)c[h]=arguments[h];return t.apply(s,[].concat(n,c))}}}function kf(e){return{}.toString.call(e).includes("Object")}function Nf(e){return e||va("configIsRequired"),kf(e)||va("configType"),e.urls?(jf(),{paths:{vs:e.urls.monacoBase}}):e}function jf(){console.warn(gc.deprecation)}function Ef(e,t){throw new Error(e[t]||e.default)}var gc={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!
|
|
164
164
|
You are using deprecated way of configuration.
|
|
165
165
|
|
|
166
166
|
Instead of using
|
|
@@ -169,7 +169,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
169
169
|
monaco.config({ paths: { vs: '...' } })
|
|
170
170
|
|
|
171
171
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
172
|
-
`},ga=xf(Sf)(mc),wf={config:bf},Cf=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 pc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],pc(e[s],t[s]))}),ma(ma({},e),t)}var kf={type:"cancelation",msg:"operation is manually canceled"};function Lr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(kf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var Nf=["monaco"],jf=_f.create({config:gf,isInitialized:!1,resolve:null,reject:null,monaco:null}),_c=Ju(jf,2),xi=_c[0],vr=_c[1];function Ef(e){var t=wf.config(e),s=t.monaco,i=Yu(t,Nf);vr(function(n){return{config:pc(n.config,i),monaco:s}})}function Df(){var e=xi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(vr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Lr(Br);if(window.monaco&&window.monaco.editor)return gc(window.monaco),e.resolve(window.monaco),Lr(Br);Cf(Rf,Mf)(Lf)}return Lr(Br)}function Rf(e){return document.body.appendChild(e)}function Pf(e){var t=document.createElement("script");return e&&(t.src=e),t}function Mf(e){var t=xi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Pf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Lf(){var e=xi(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;gc(i),e.resolve(i)},function(s){e.reject(s)})}function gc(e){xi().monaco||vr({monaco:e})}function Bf(){return xi(function(e){var t=e.monaco;return t})}var Br=new Promise(function(e,t){return vr({resolve:e,reject:t})}),xc={config:Ef,init:Df,__getMonacoInstance:Bf},Tf={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Tr=Tf,zf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Af=zf;function Of({children:e}){return Ms.createElement("div",{style:Af.container},e)}var $f=Of,If=$f;function Ff({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ms.createElement("section",{style:{...Tr.wrapper,width:e,height:t},...a},!s&&Ms.createElement(If,null,i),Ms.createElement("div",{ref:n,style:{...Tr.fullWidth,...!s&&Tr.hide},className:o}))}var Hf=Ff,vc=d.memo(Hf);function Wf(e){d.useEffect(e,[])}var bc=Wf;function Uf(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var nt=Uf;function li(){}function Ds(e,t,s,i){return Kf(e,i)||qf(e,t,s,i)}function Kf(e,t){return e.editor.getModel(yc(e,t))}function qf(e,t,s,i){return e.editor.createModel(t,s,i?yc(e,i):void 0)}function yc(e,t){return e.Uri.parse(t)}function Vf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:f="Loading...",options:p={},height:u="100%",width:g="100%",className:m,wrapperProps:_={},beforeMount:x=li,onMount:y=li}){let[b,k]=d.useState(!1),[S,w]=d.useState(!0),j=d.useRef(null),B=d.useRef(null),M=d.useRef(null),Y=d.useRef(y),X=d.useRef(x),$=d.useRef(!1);bc(()=>{let E=xc.init();return E.then(P=>(B.current=P)&&w(!1)).catch(P=>(P==null?void 0:P.type)!=="cancelation"&&console.error("Monaco initialization: error:",P)),()=>j.current?L():E.cancel()}),nt(()=>{if(j.current&&B.current){let E=j.current.getOriginalEditor(),P=Ds(B.current,e||"",i||s||"text",o||"");P!==E.getModel()&&E.setModel(P)}},[o],b),nt(()=>{if(j.current&&B.current){let E=j.current.getModifiedEditor(),P=Ds(B.current,t||"",n||s||"text",a||"");P!==E.getModel()&&E.setModel(P)}},[a],b),nt(()=>{let E=j.current.getModifiedEditor();E.getOption(B.current.editor.EditorOption.readOnly)?E.setValue(t||""):t!==E.getValue()&&(E.executeEdits("",[{range:E.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),E.pushUndoStop())},[t],b),nt(()=>{var E,P;(P=(E=j.current)==null?void 0:E.getModel())==null||P.original.setValue(e||"")},[e],b),nt(()=>{let{original:E,modified:P}=j.current.getModel();B.current.editor.setModelLanguage(E,i||s||"text"),B.current.editor.setModelLanguage(P,n||s||"text")},[s,i,n],b),nt(()=>{var E;(E=B.current)==null||E.editor.setTheme(c)},[c],b),nt(()=>{var E;(E=j.current)==null||E.updateOptions(p)},[p],b);let D=d.useCallback(()=>{var U;if(!B.current)return;X.current(B.current);let E=Ds(B.current,e||"",i||s||"text",o||""),P=Ds(B.current,t||"",n||s||"text",a||"");(U=j.current)==null||U.setModel({original:E,modified:P})},[s,t,n,e,i,o,a]),N=d.useCallback(()=>{var E;!$.current&&M.current&&(j.current=B.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...p}),D(),(E=B.current)==null||E.editor.setTheme(c),k(!0),$.current=!0)},[p,c,D]);d.useEffect(()=>{b&&Y.current(j.current,B.current)},[b]),d.useEffect(()=>{!S&&!b&&N()},[S,b,N]);function L(){var P,U,C,H;let E=(P=j.current)==null?void 0:P.getModel();l||((U=E==null?void 0:E.original)==null||U.dispose()),h||((C=E==null?void 0:E.modified)==null||C.dispose()),(H=j.current)==null||H.dispose()}return Ms.createElement(vc,{width:g,height:u,isEditorReady:b,loading:f,_ref:M,className:m,wrapperProps:_})}var Gf=Vf;d.memo(Gf);function Yf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Xf=Yf,Bi=new Map;function Jf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:f={},saveViewState:p=!0,keepCurrentModel:u=!1,width:g="100%",height:m="100%",className:_,wrapperProps:x={},beforeMount:y=li,onMount:b=li,onChange:k,onValidate:S=li}){let[w,j]=d.useState(!1),[B,M]=d.useState(!0),Y=d.useRef(null),X=d.useRef(null),$=d.useRef(null),D=d.useRef(b),N=d.useRef(y),L=d.useRef(),E=d.useRef(i),P=Xf(o),U=d.useRef(!1),C=d.useRef(!1);bc(()=>{let K=xc.init();return K.then(Q=>(Y.current=Q)&&M(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>X.current?F():K.cancel()}),nt(()=>{var Q,ie,de,ue;let K=Ds(Y.current,e||i||"",t||n||"",o||s||"");K!==((Q=X.current)==null?void 0:Q.getModel())&&(p&&Bi.set(P,(ie=X.current)==null?void 0:ie.saveViewState()),(de=X.current)==null||de.setModel(K),p&&((ue=X.current)==null||ue.restoreViewState(Bi.get(o))))},[o],w),nt(()=>{var K;(K=X.current)==null||K.updateOptions(c)},[c],w),nt(()=>{!X.current||i===void 0||(X.current.getOption(Y.current.editor.EditorOption.readOnly)?X.current.setValue(i):i!==X.current.getValue()&&(C.current=!0,X.current.executeEdits("",[{range:X.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),X.current.pushUndoStop(),C.current=!1))},[i],w),nt(()=>{var Q,ie;let K=(Q=X.current)==null?void 0:Q.getModel();K&&n&&((ie=Y.current)==null||ie.editor.setModelLanguage(K,n))},[n],w),nt(()=>{var K;l!==void 0&&((K=X.current)==null||K.revealLine(l))},[l],w),nt(()=>{var K;(K=Y.current)==null||K.editor.setTheme(a)},[a],w);let H=d.useCallback(()=>{var K;if(!(!$.current||!Y.current)&&!U.current){N.current(Y.current);let Q=o||s,ie=Ds(Y.current,i||e||"",t||n||"",Q||"");X.current=(K=Y.current)==null?void 0:K.editor.create($.current,{model:ie,automaticLayout:!0,...c},f),p&&X.current.restoreViewState(Bi.get(Q)),Y.current.editor.setTheme(a),l!==void 0&&X.current.revealLine(l),j(!0),U.current=!0}},[e,t,s,i,n,o,c,f,p,a,l]);d.useEffect(()=>{w&&D.current(X.current,Y.current)},[w]),d.useEffect(()=>{!B&&!w&&H()},[B,w,H]),E.current=i,d.useEffect(()=>{var K,Q;w&&k&&((K=L.current)==null||K.dispose(),L.current=(Q=X.current)==null?void 0:Q.onDidChangeModelContent(ie=>{C.current||k(X.current.getValue(),ie)}))},[w,k]),d.useEffect(()=>{if(w){let K=Y.current.editor.onDidChangeMarkers(Q=>{var de;let ie=(de=X.current.getModel())==null?void 0:de.uri;if(ie&&Q.find(ue=>ue.path===ie.path)){let ue=Y.current.editor.getModelMarkers({resource:ie});S==null||S(ue)}});return()=>{K==null||K.dispose()}}return()=>{}},[w,S]);function F(){var K,Q;(K=L.current)==null||K.dispose(),u?p&&Bi.set(o,X.current.saveViewState()):(Q=X.current.getModel())==null||Q.dispose(),X.current.dispose()}return Ms.createElement(vc,{width:g,height:m,isEditorReady:w,loading:h,_ref:$,className:_,wrapperProps:x})}var Zf=Jf,Qf=d.memo(Zf),em=Qf;function tm(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function sm(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function im(e){return e/100*window.innerHeight}function rm(e){return e/100*window.innerWidth}function nm(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 Qs({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=nm(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=sm(t,n);break}case"em":{i=tm(t,n);break}case"vh":{i=im(n);break}case"vw":{i=rm(n);break}}return i}function et(e){return parseFloat(e.toFixed(3))}function zs({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 hn(e){const{panels:t}=e,s=zs({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 f=Qs({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=et(f/s*100)}let l;if(o.defaultSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=et(f/s*100)}let h=0;if(o.minSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.minSize});h=et(f/s*100)}let c=100;if(o.maxSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.maxSize});c=et(f/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 me(e,t="Assertion error"){if(!e)throw Error(t)}function dn(e,t){return Array.from(t).sort(e==="horizontal"?om:am)}function om(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function am(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function Sc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function wc(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 lm({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}=wc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return me(n,"No rect found"),n}let Ti;function cm(){return Ti===void 0&&(typeof matchMedia=="function"?Ti=!!matchMedia("(pointer:coarse)").matches:Ti=!1),Ti}function Cc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=dn(s,Array.from(t.children).filter(Sc).map(m=>({element:m}))).map(({element:m})=>m),a=[];let l=!1,h=!1,c=-1,f=-1,p=0,u,g=[];{let m=-1;for(const _ of o)_.hasAttribute("data-panel")&&(m++,_.ariaDisabled===null&&(p++,c===-1&&(c=m),f=m))}if(p>1){let m=-1;for(const _ of o)if(_.hasAttribute("data-panel")){m++;const x=i.find(y=>y.element===_);if(x){if(u){const y=u.element.getBoundingClientRect(),b=_.getBoundingClientRect();let k;if(h){const S=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(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(g.length){case 0:{k=[S,w];break}case 1:{const j=g[0],B=lm({orientation:s,rects:[y,b],targetRect:j.element.getBoundingClientRect()});k=[j,B===y?w:S];break}default:{k=g;break}}}else g.length?k=g:k=[s==="horizontal"?new DOMRect(y.right,b.top,b.left-y.right,b.height):new DOMRect(b.left,y.bottom,b.width,b.top-y.bottom)];for(const S of k){let w="width"in S?S:S.element.getBoundingClientRect();const j=cm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<j){const M=j-w.width;w=new DOMRect(w.x-M/2,w.y,w.width+M,w.height)}if(w.height<j){const M=j-w.height;w=new DOMRect(w.x,w.y-M/2,w.width,w.height+M)}const B=m<=c||m>f;!l&&!B&&a.push({group:e,groupSize:zs({group:e}),panels:[u,x],separator:"width"in S?void 0:S,rect:w}),l=!1}}h=!1,u=x,g=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(l=!0);const x=n.find(y=>y.element===_);x?g.push(x):(u=void 0,g=[])}else h=!0}return a}var Wt,Kl;let kc=(Kl=class{constructor(){aa(this,Wt,{})}addListener(t,s){const i=Us(this,Wt)[t];return i===void 0?Us(this,Wt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Us(this,Wt)[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(){la(this,Wt,{})}removeListener(t,s){const i=Us(this,Wt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},Wt=new WeakMap,Kl),xt=new Map;const Nc=new kc;function hm(e){xt=new Map(xt),xt.delete(e)}function xa(e,t){for(const[s]of xt)if(s.id===e)return s}function Vt(e,t){for(const[s,i]of xt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function gs(){return xt}function lo(e,t){return Nc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Pt(e,t){const s=xt.get(e);xt=new Map(xt),xt.set(e,t),Nc.emit("groupChange",{group:e,prev:s,next:t})}function dm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=wc(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 um(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function fm(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:ya(e),b:ya(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();me(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:ba(va(s.a)),b:ba(va(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 mm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function pm(e){const t=getComputedStyle(jc(e)??e).display;return t==="flex"||t==="inline-flex"}function _m(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||pm(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"||mm.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function va(e){let t=e.length;for(;t--;){const s=e[t];if(me(s,"Missing node"),_m(s))return s}return null}function ba(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ya(e){const t=[];for(;e;)t.push(e),e=jc(e);return t}function jc(e){const{parentNode:t}=e;return um(t)?t.host:t}function gm(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 xm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!Sc(s)||s.contains(e)||e.contains(s))return!0;if(fm(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(gm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function co(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=Cc(n),a=dm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&xm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function vm(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 Ve(e,t,s=0){return Math.abs(et(e)-et(t))<=s}function _t(e,t){return Ve(e,t)?0:e>t?1:-1}function Rs({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(_t(i,h)<0)if(o){const c=(n+h)/2;_t(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=et(i),i}function ui({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(Ve(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[f,p]=i;me(f!=null,"Invalid first pivot index"),me(p!=null,"Invalid second pivot index");let u=0;switch(o){case"keyboard":{{const _=e<0?p:f,x=s[_];me(x,`Panel constraints not found for index ${_}`);const{collapsedSize:y=0,collapsible:b,minSize:k=0}=x;if(b){const S=l[_];if(me(S!=null,`Previous layout not found for panel index ${_}`),Ve(S,y)){const w=k-S;_t(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const _=e<0?f:p,x=s[_];me(x,`No panel constraints found for index ${_}`);const{collapsedSize:y=0,collapsible:b,minSize:k=0}=x;if(b){const S=l[_];if(me(S!=null,`Previous layout not found for panel index ${_}`),Ve(S,k)){const w=S-y;_t(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const _=e<0?p:f,x=s[_];me(x,`Panel constraints not found for index ${_}`);const y=l[_],{collapsible:b,collapsedSize:k,minSize:S}=x;if(b&&_t(y,S)<0)if(e>0){const w=S-k,j=w/2,B=y+e;_t(B,S)<0&&(e=_t(e,j)<=0?0:w)}else{const w=S-k,j=100-w/2,B=y-e;_t(B,S)<0&&(e=_t(100+e,j)>0?0:-w)}break}}{const _=e<0?1:-1;let x=e<0?p:f,y=0;for(;;){const k=l[x];me(k!=null,`Previous layout not found for panel index ${x}`);const S=Rs({overrideDisabledPanels:a,panelConstraints:s[x],prevSize:k,size:100})-k;if(y+=S,x+=_,x<0||x>=s.length)break}const b=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-b:b}{let _=e<0?f:p;for(;_>=0&&_<s.length;){const x=Math.abs(e)-Math.abs(u),y=l[_];me(y!=null,`Previous layout not found for panel index ${_}`);const b=y-x,k=Rs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:y,size:b});if(!Ve(y,k)&&(u+=y-k,c[_]=k,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(vm(h,c))return n;{const _=e<0?p:f,x=l[_];me(x!=null,`Previous layout not found for panel index ${_}`);const y=x+u,b=Rs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:x,size:y});if(c[_]=b,!Ve(b,y)){let k=y-b,S=e<0?p:f;for(;S>=0&&S<s.length;){const w=c[S];me(w!=null,`Previous layout not found for panel index ${S}`);const j=w+k,B=Rs({overrideDisabledPanels:a,panelConstraints:s[S],prevSize:w,size:j});if(Ve(w,B)||(k-=B-w,c[S]=B),Ve(k,0))break;e>0?S--:S++}}}const g=Object.values(c).reduce((_,x)=>x+_,0);if(!Ve(g,100,.1))return n;const m=Object.keys(n);return c.reduce((_,x,y)=>(_[m[y]]=x,_),{})}function cs(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||_t(e[s],t[s])!==0)return!1;return!0}function hs({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(!Ve(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];me(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];me(h!=null,`No layout data found for index ${l}`);const c=i[l];me(c!=null,`No layout data found for index ${l}`);const f=Rs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=f&&(o+=c-f,i[l]=f)}if(!Ve(o,0))for(let l=0;l<t.length;l++){const h=i[l];me(h!=null,`No layout data found for index ${l}`);const c=h+o,f=Rs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==f&&(o-=f-h,i[l]=f,Ve(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Ec({groupId:e,panelId:t}){const s=()=>{const l=gs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:f,layout:p,groupSize:u,separatorToPanels:g}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:f,group:h,groupSize:u,layout:p,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:f,group:p,groupSize:u,layout:g,separatorToPanels:m}=s(),_=p.panels.findIndex(k=>k.id===t),x=_===p.panels.length-1,y=ui({delta:x?h-l:l-h,initialLayout:g,panelConstraints:f,pivotIndices:x?[_-1,_]:[_,_+1],prevLayout:g,trigger:"imperative-api"}),b=hs({layout:y,panelConstraints:f});cs(g,b)||Pt(p,{defaultLayoutDeferred:c,derivedPanelConstraints:f,groupSize:u,layout:b,separatorToPanels:m})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),f=o();l&&f!==h&&(c.expandToSize=f,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:f}=n(),p=o();if(l&&p===h){let u=f.expandToSize??c;u===0&&(u=1),a(u)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),f=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:f}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&Ve(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),f=zs({group:h}),p=Qs({groupSize:f,panelElement:c,styleProp:l}),u=et(p/f*100);a(u)}}}function Sa(e){if(e.defaultPrevented)return;const t=gs();co(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=Ec({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ui(e){const t=gs();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 Dc({groupId:e}){const t=()=>{const s=gs();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=hs({layout:s,panelConstraints:n});return i?l:(cs(l,c)||Pt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function Zt(e,t){const s=Ui(e),i=Vt(s.id,!0),n=s.separators.find(f=>f.element===e);me(n,"Matching separator not found");const o=i.separatorToPanels.get(n);me(o,"Matching panels not found");const a=o.map(f=>s.panels.indexOf(f)),l=Dc({groupId:s.id}).getLayout(),h=ui({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=hs({layout:h,panelConstraints:i.derivedPanelConstraints});cs(l,c)||Pt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function wa(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ui(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&Zt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&Zt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&Zt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&Zt(t,-5);break}case"End":{e.preventDefault(),Zt(t,100);break}case"Enter":{e.preventDefault();const i=Ui(t),n=Vt(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(u=>u.element===t);me(h,"Matching separator not found");const c=l.get(h);me(c,"Matching panels not found");const f=c[0],p=o.find(u=>u.panelId===f.id);if(me(p,"Panel metadata not found"),p.collapsible){const u=a[f.id],g=p.collapsedSize===u?i.mutableState.expandedPanelSizes[f.id]??p.minSize:p.collapsedSize;Zt(t,g-u)}break}case"F6":{e.preventDefault();const i=Ui(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);me(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(),Zt(t,-100);break}}}let Bs={cursorFlags:0,state:"inactive"};const ho=new kc;function ds(){return Bs}function bm(e){return ho.addListener("change",e)}function ym(e){const t=Bs,s={...Bs};s.cursorFlags=e,Bs=s,ho.emit("change",{prev:t,next:s})}function Ts(e){const t=Bs;Bs=e,ho.emit("change",{prev:t,next:e})}function Ca(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=gs(),s=co(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)}),Ts({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const Sm=e=>e,zr=()=>{},Rc=1,Pc=2,Mc=4,Lc=8,ka=3,Na=12;let zi;function ja(){return zi===void 0&&(zi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(zi=!0)),zi}function wm({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&&ja()){const o=(e&Rc)!==0,a=(e&Pc)!==0,l=(e&Mc)!==0,h=(e&Lc)!==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 ja()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const Ea=new WeakMap;function uo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=Ea.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ds();switch(i.state){case"active":case"hover":{const n=wm({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}}Ea.set(e,{prevStyle:t,styleSheet:s})}function Bc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:f,groupSize:p}=c,{orientation:u,panels:g}=f,{disableCursor:m}=f.mutableState;let _=0;o?u==="horizontal"?_=(t.clientX-o.x)/p*100:_=(t.clientY-o.y)/p*100:u==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const x=i.get(f),y=n.get(f);if(!x||!y)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:k,groupSize:S,layout:w,separatorToPanels:j}=y;if(k&&w&&j){const B=ui({delta:_,initialLayout:x,panelConstraints:k,pivotIndices:c.panels.map(M=>g.indexOf(M)),prevLayout:w,trigger:"mouse-or-touch"});if(cs(B,w)){if(_!==0&&!m)switch(u){case"horizontal":{l|=_<0?Rc:Pc;break}case"vertical":{l|=_<0?Mc:Lc;break}}}else Pt(c.group,{defaultLayoutDeferred:b,derivedPanelConstraints:k,groupSize:S,layout:B,separatorToPanels:j})}});let h=0;t.movementX===0?h|=a&ka:h|=l&ka,t.movementY===0?h|=a&Na:h|=l&Na,ym(h),uo(e)}function Da(e){const t=gs(),s=ds();switch(s.state){case"active":Bc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Ra(e){if(e.defaultPrevented)return;const t=ds(),s=gs();switch(t.state){case"active":{if(e.buttons===0){Ts({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Vt(i.group.id,!0);Pt(i.group,n)});return}Bc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=co(e,s);i.length===0?t.state!=="inactive"&&Ts({cursorFlags:0,state:"inactive"}):Ts({cursorFlags:0,hitRegions:i,state:"hover"}),uo(e.currentTarget);break}}}function Pa(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ds().state){case"hover":Ts({cursorFlags:0,state:"inactive"})}}function Ma(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ds();switch(t.state){case"active":Ts({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uo(e.currentTarget),t.hitRegions.forEach(s=>{const i=Vt(s.group.id,!0);Pt(s.group,i)}),e.preventDefault())}}function La(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=et(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=et((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function Cm(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=zs({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:et(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function km(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 Nm({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 p of e.panels){const u=i[p.id]??0;switch(p.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=u/100*s,m=et(g/t*100);l.set(p.id,m),n+=m;break}case"preserve-relative-size":default:{h.push(p.id),o+=u;break}}}if(!a||h.length===0)return i;const c=100-n,f={...i};if(l.forEach((p,u)=>{f[u]=p}),o>0)for(const p of h){const u=i[p]??0;f[p]=et(u/o*c)}else{const p=et(c/h.length);for(const u of h)f[u]=p}return f}function jm(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 Cs=new Map;function Em(e){let t=!0;me(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(m=>{for(const _ of m){const{borderBoxSize:x,target:y}=_;if(y===e.element){if(t){const b=zs({group:e});if(b===0)return;const k=Vt(e.id);if(!k)return;const S=hn(e),w=k.defaultLayoutDeferred?La(S):k.layout,j=Nm({group:e,nextGroupSize:b,prevGroupSize:k.groupSize,prevLayout:w}),B=hs({layout:j,panelConstraints:S});if(!k.defaultLayoutDeferred&&cs(k.layout,B)&&km(k.derivedPanelConstraints,S)&&k.groupSize===b)return;Pt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:b,layout:B,separatorToPanels:k.separatorToPanels})}}else Cm(e,y,x)}});o.observe(e.element),e.panels.forEach(m=>{me(!i.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.onResize&&o.observe(m.element)});const a=zs({group:e}),l=hn(e),h=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(jm(e.panels,c)||(c=void 0));const f=e.mutableState.layouts[h]??c??La(l),p=hs({layout:f,panelConstraints:l}),u=e.element.ownerDocument;Cs.set(u,(Cs.get(u)??0)+1);const g=new Map;return Cc(e).forEach(m=>{m.separator&&g.set(m.separator,m.panels)}),Pt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:p,separatorToPanels:g}),e.separators.forEach(m=>{me(!n.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.element.addEventListener("keydown",wa)}),Cs.get(u)===1&&(u.addEventListener("dblclick",Sa,!0),u.addEventListener("pointerdown",Ca,!0),u.addEventListener("pointerleave",Da),u.addEventListener("pointermove",Ra),u.addEventListener("pointerout",Pa),u.addEventListener("pointerup",Ma,!0)),function(){t=!1,Cs.set(u,Math.max(0,(Cs.get(u)??0)-1)),hm(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",wa)}),Cs.get(u)||(u.removeEventListener("dblclick",Sa,!0),u.removeEventListener("pointerdown",Ca,!0),u.removeEventListener("pointerleave",Da),u.removeEventListener("pointermove",Ra),u.removeEventListener("pointerout",Pa),u.removeEventListener("pointerup",Ma,!0)),o.disconnect()}}function Dm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function fo(e){const t=d.useId();return`${e??t}`}const xs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ci(e){const t=d.useRef(e);return xs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function mo(...e){return ci(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function po(e){const t=d.useRef({...e});return xs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Tc=d.createContext(null);function Rm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:Sm});d.useImperativeHandle(t,()=>s.current,[]),xs(()=>{Object.assign(s.current,Dc({groupId:e}))})}function un({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:f="horizontal",resizeTargetMinimumSize:p={coarse:20,fine:10},style:u,...g}){const m=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=ci($=>{cs(m.current.onLayoutChange,$)||(m.current.onLayoutChange=$,h==null||h($))}),x=ci($=>{cs(m.current.onLayoutChanged,$)||(m.current.onLayoutChanged=$,c==null||c($))}),y=fo(l),b=d.useRef(null),[k,S]=Dm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:p,separators:[]}),j=mo(b,o);Rm(y,a);const B=ci(($,D)=>{const N=ds(),L=xa($),E=Vt($);if(E){let P=!1;switch(N.state){case"active":{P=N.hitRegions.some(U=>U.group===L);break}}return{flexGrow:E.layout[D]??1,pointerEvents:P?"none":void 0}}return{flexGrow:(s==null?void 0:s[D])??1}}),M=po({defaultLayout:s,disableCursor:i}),Y=d.useMemo(()=>({get disableCursor(){return!!M.disableCursor},getPanelStyles:B,id:y,orientation:f,registerPanel:$=>{const D=w.current;return D.panels=dn(f,[...D.panels,$]),S(),()=>{D.panels=D.panels.filter(N=>N!==$),S()}},registerSeparator:$=>{const D=w.current;return D.separators=dn(f,[...D.separators,$]),S(),()=>{D.separators=D.separators.filter(N=>N!==$),S()}},togglePanelDisabled:($,D)=>{const N=w.current.panels.find(P=>P.id===$);N&&(N.panelConstraints.disabled=D);const L=xa(y),E=Vt(y);L&&E&&Pt(L,{...E,derivedPanelConstraints:hn(L)})},toggleSeparatorDisabled:($,D)=>{const N=w.current.separators.find(L=>L.id===$);N&&(N.disabled=D)}}),[B,y,S,f,M]),X=d.useRef(null);return xs(()=>{const $=b.current;if($===null)return;const D=w.current;let N;if(M.defaultLayout!==void 0&&Object.keys(M.defaultLayout).length===D.panels.length){N={};for(const F of D.panels){const K=M.defaultLayout[F.id];K!==void 0&&(N[F.id]=K)}}const L={disabled:!!n,element:$,id:y,mutableState:{defaultLayout:N,disableCursor:!!M.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:f,panels:D.panels,resizeTargetMinimumSize:D.resizeTargetMinimumSize,separators:D.separators};X.current=L;const E=Em(L),{defaultLayoutDeferred:P,derivedPanelConstraints:U,layout:C}=Vt(L.id,!0);!P&&U.length>0&&(_(C),x(C));const H=lo(y,F=>{const{defaultLayoutDeferred:K,derivedPanelConstraints:Q,layout:ie}=F.next;if(K||Q.length===0)return;const de=L.panels.map(({id:ce})=>ce).join(",");L.mutableState.layouts[de]=ie,Q.forEach(ce=>{if(ce.collapsible){const{layout:ge}=F.prev??{};if(ge){const Fe=Ve(ce.collapsedSize,ie[ce.panelId]),z=Ve(ce.collapsedSize,ge[ce.panelId]);Fe&&!z&&(L.mutableState.expandedPanelSizes[ce.panelId]=ge[ce.panelId])}}});const ue=ds().state!=="active";_(ie),ue&&x(ie)});return()=>{X.current=null,E(),H()}},[n,y,x,_,f,k,M]),d.useEffect(()=>{const $=X.current;$&&($.mutableState.defaultLayout=s,$.mutableState.disableCursor=!!i)}),r.jsx(Tc.Provider,{value:Y,children:r.jsx("div",{...g,className:t,"data-group":!0,"data-testid":y,id:y,ref:j,style:{height:"100%",width:"100%",overflow:"hidden",...u,display:"flex",flexDirection:f==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:f==="horizontal"?"pan-y":"pan-x"},children:e})})}un.displayName="Group";function _o(){const e=d.useContext(Tc);return me(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Pm(e,t){const{id:s}=_o(),i=d.useRef({collapse:zr,expand:zr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:zr});d.useImperativeHandle(t,()=>i.current,[]),xs(()=>{Object.assign(i.current,Ec({groupId:s,panelId:e}))})}function ei({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:f="0%",onResize:p,panelRef:u,style:g,...m}){const _=!!h,x=fo(h),y=po({disabled:o}),b=d.useRef(null),k=mo(b,a),{getPanelStyles:S,id:w,orientation:j,registerPanel:B,togglePanelDisabled:M}=_o(),Y=p!==null,X=ci((D,N,L)=>{p==null||p(D,h,L)});xs(()=>{const D=b.current;if(D!==null){const N={element:D,id:x,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:Y?X:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:f}};return B(N)}},[l,s,i,n,Y,x,_,c,f,X,B,y]),d.useEffect(()=>{M(x,!!o)},[o,x,M]),Pm(x,u);const $=d.useSyncExternalStore(D=>lo(w,D),()=>JSON.stringify(S(w,x)),()=>JSON.stringify(S(w,x)));return r.jsx("div",{...m,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":x,id:x,ref:k,style:{...Mm,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse($)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:j==="horizontal"?"pan-y":"pan-x"},children:e})})}ei.displayName="Panel";const Mm={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Lm({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,f=[i,i+1];o=hs({layout:ui({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e}),panelConstraints:t})[s],n=hs({layout:ui({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function fn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=fo(n),h=po({disabled:s}),[c,f]=d.useState({}),[p,u]=d.useState("inactive"),g=d.useRef(null),m=mo(g,i),{disableCursor:_,id:x,orientation:y,registerSeparator:b,toggleSeparatorDisabled:k}=_o(),S=y==="horizontal"?"vertical":"horizontal";xs(()=>{const j=g.current;if(j!==null){const B={disabled:h.disabled,element:j,id:l},M=b(B),Y=bm($=>{u($.next.state!=="inactive"&&$.next.hitRegions.some(D=>D.separator===B)?$.next.state:"inactive")}),X=lo(x,$=>{const{derivedPanelConstraints:D,layout:N,separatorToPanels:L}=$.next,E=L.get(B);if(E){const P=E[0],U=E.indexOf(P);f(Lm({layout:N,panelConstraints:D,panelId:P.id,panelIndex:U}))}});return()=>{Y(),X(),M()}}},[x,l,b,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":S,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":p,"data-testid":l,id:l,ref:m,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}fn.displayName="Separator";const Bm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Tm={sm:"w-7 h-7",md:"w-8 h-8"},zm={sm:14,md:16};function Ot({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",Bm[i],Tm[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:zm[s]})})}function Am({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=f=>{a.current&&!a.current.contains(f.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var f,p;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(u=>{var m;const g=(u+1)%s.length;return(m=l.current[g])==null||m.focus(),g});break;case"ArrowUp":c.preventDefault(),o(u=>{var m;const g=(u-1+s.length)%s.length;return(m=l.current[g])==null||m.focus(),g});break;case"Home":c.preventDefault(),o(0),(f=l.current[0])==null||f.focus();break;case"End":c.preventDefault(),o(s.length-1),(p=l.current[s.length-1])==null||p.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,f)=>{const p=c.icon,u=c.variant==="danger";return r.jsxs("button",{ref:g=>{l.current[f]=g},role:"menuitem",tabIndex:n===f?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",u?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(p,{size:14}),c.label]},c.label)})})}/**
|
|
172
|
+
`},va=Cf(Ef)(gc),Df={config:Nf},Rf=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 xc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],xc(e[s],t[s]))}),_a(_a({},e),t)}var Lf={type:"cancelation",msg:"operation is manually canceled"};function Br(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(Lf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var Pf=["monaco"],Mf=Sf.create({config:wf,isInitialized:!1,resolve:null,reject:null,monaco:null}),vc=rf(Mf,2),vi=vc[0],vr=vc[1];function Bf(e){var t=Df.config(e),s=t.monaco,i=tf(t,Pf);vr(function(n){return{config:xc(n.config,i),monaco:s}})}function Tf(){var e=vi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(vr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Br(Tr);if(window.monaco&&window.monaco.editor)return bc(window.monaco),e.resolve(window.monaco),Br(Tr);Rf(zf,If)(Of)}return Br(Tr)}function zf(e){return document.body.appendChild(e)}function Af(e){var t=document.createElement("script");return e&&(t.src=e),t}function If(e){var t=vi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Af("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Of(){var e=vi(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;bc(i),e.resolve(i)},function(s){e.reject(s)})}function bc(e){vi().monaco||vr({monaco:e})}function $f(){return vi(function(e){var t=e.monaco;return t})}var Tr=new Promise(function(e,t){return vr({resolve:e,reject:t})}),yc={config:Bf,init:Tf,__getMonacoInstance:$f},Ff={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},zr=Ff,Hf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Wf=Hf;function Uf({children:e}){return Ts.createElement("div",{style:Wf.container},e)}var Kf=Uf,qf=Kf;function Vf({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ts.createElement("section",{style:{...zr.wrapper,width:e,height:t},...a},!s&&Ts.createElement(qf,null,i),Ts.createElement("div",{ref:n,style:{...zr.fullWidth,...!s&&zr.hide},className:o}))}var Gf=Vf,Sc=d.memo(Gf);function Yf(e){d.useEffect(e,[])}var wc=Yf;function Xf(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var ot=Xf;function li(){}function Ps(e,t,s,i){return Jf(e,i)||Zf(e,t,s,i)}function Jf(e,t){return e.editor.getModel(Cc(e,t))}function Zf(e,t,s,i){return e.editor.createModel(t,s,i?Cc(e,i):void 0)}function Cc(e,t){return e.Uri.parse(t)}function Qf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:c=!1,keepCurrentModifiedModel:h=!1,theme:l="light",loading:f="Loading...",options:m={},height:u="100%",width:g="100%",className:p,wrapperProps:_={},beforeMount:x=li,onMount:y=li}){let[v,k]=d.useState(!1),[w,D]=d.useState(!0),N=d.useRef(null),T=d.useRef(null),L=d.useRef(null),U=d.useRef(y),Y=d.useRef(x),X=d.useRef(!1);wc(()=>{let S=yc.init();return S.then(j=>(T.current=j)&&D(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>N.current?P():S.cancel()}),ot(()=>{if(N.current&&T.current){let S=N.current.getOriginalEditor(),j=Ps(T.current,e||"",i||s||"text",o||"");j!==S.getModel()&&S.setModel(j)}},[o],v),ot(()=>{if(N.current&&T.current){let S=N.current.getModifiedEditor(),j=Ps(T.current,t||"",n||s||"text",a||"");j!==S.getModel()&&S.setModel(j)}},[a],v),ot(()=>{let S=N.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],v),ot(()=>{var S,j;(j=(S=N.current)==null?void 0:S.getModel())==null||j.original.setValue(e||"")},[e],v),ot(()=>{let{original:S,modified:j}=N.current.getModel();T.current.editor.setModelLanguage(S,i||s||"text"),T.current.editor.setModelLanguage(j,n||s||"text")},[s,i,n],v),ot(()=>{var S;(S=T.current)==null||S.editor.setTheme(l)},[l],v),ot(()=>{var S;(S=N.current)==null||S.updateOptions(m)},[m],v);let M=d.useCallback(()=>{var z;if(!T.current)return;Y.current(T.current);let S=Ps(T.current,e||"",i||s||"text",o||""),j=Ps(T.current,t||"",n||s||"text",a||"");(z=N.current)==null||z.setModel({original:S,modified:j})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!X.current&&L.current&&(N.current=T.current.editor.createDiffEditor(L.current,{automaticLayout:!0,...m}),M(),(S=T.current)==null||S.editor.setTheme(l),k(!0),X.current=!0)},[m,l,M]);d.useEffect(()=>{v&&U.current(N.current,T.current)},[v]),d.useEffect(()=>{!w&&!v&&E()},[w,v,E]);function P(){var j,z,C,I;let S=(j=N.current)==null?void 0:j.getModel();c||((z=S==null?void 0:S.original)==null||z.dispose()),h||((C=S==null?void 0:S.modified)==null||C.dispose()),(I=N.current)==null||I.dispose()}return Ts.createElement(Sc,{width:g,height:u,isEditorReady:v,loading:f,_ref:L,className:p,wrapperProps:_})}var em=Qf;d.memo(em);function tm(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var sm=tm,Ti=new Map;function im({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:c,loading:h="Loading...",options:l={},overrideServices:f={},saveViewState:m=!0,keepCurrentModel:u=!1,width:g="100%",height:p="100%",className:_,wrapperProps:x={},beforeMount:y=li,onMount:v=li,onChange:k,onValidate:w=li}){let[D,N]=d.useState(!1),[T,L]=d.useState(!0),U=d.useRef(null),Y=d.useRef(null),X=d.useRef(null),M=d.useRef(v),E=d.useRef(y),P=d.useRef(),S=d.useRef(i),j=sm(o),z=d.useRef(!1),C=d.useRef(!1);wc(()=>{let K=yc.init();return K.then(Z=>(U.current=Z)&&L(!1)).catch(Z=>(Z==null?void 0:Z.type)!=="cancelation"&&console.error("Monaco initialization: error:",Z)),()=>Y.current?O():K.cancel()}),ot(()=>{var Z,ne,ce,oe;let K=Ps(U.current,e||i||"",t||n||"",o||s||"");K!==((Z=Y.current)==null?void 0:Z.getModel())&&(m&&Ti.set(j,(ne=Y.current)==null?void 0:ne.saveViewState()),(ce=Y.current)==null||ce.setModel(K),m&&((oe=Y.current)==null||oe.restoreViewState(Ti.get(o))))},[o],D),ot(()=>{var K;(K=Y.current)==null||K.updateOptions(l)},[l],D),ot(()=>{!Y.current||i===void 0||(Y.current.getOption(U.current.editor.EditorOption.readOnly)?Y.current.setValue(i):i!==Y.current.getValue()&&(C.current=!0,Y.current.executeEdits("",[{range:Y.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),Y.current.pushUndoStop(),C.current=!1))},[i],D),ot(()=>{var Z,ne;let K=(Z=Y.current)==null?void 0:Z.getModel();K&&n&&((ne=U.current)==null||ne.editor.setModelLanguage(K,n))},[n],D),ot(()=>{var K;c!==void 0&&((K=Y.current)==null||K.revealLine(c))},[c],D),ot(()=>{var K;(K=U.current)==null||K.editor.setTheme(a)},[a],D);let I=d.useCallback(()=>{var K;if(!(!X.current||!U.current)&&!z.current){E.current(U.current);let Z=o||s,ne=Ps(U.current,i||e||"",t||n||"",Z||"");Y.current=(K=U.current)==null?void 0:K.editor.create(X.current,{model:ne,automaticLayout:!0,...l},f),m&&Y.current.restoreViewState(Ti.get(Z)),U.current.editor.setTheme(a),c!==void 0&&Y.current.revealLine(c),N(!0),z.current=!0}},[e,t,s,i,n,o,l,f,m,a,c]);d.useEffect(()=>{D&&M.current(Y.current,U.current)},[D]),d.useEffect(()=>{!T&&!D&&I()},[T,D,I]),S.current=i,d.useEffect(()=>{var K,Z;D&&k&&((K=P.current)==null||K.dispose(),P.current=(Z=Y.current)==null?void 0:Z.onDidChangeModelContent(ne=>{C.current||k(Y.current.getValue(),ne)}))},[D,k]),d.useEffect(()=>{if(D){let K=U.current.editor.onDidChangeMarkers(Z=>{var ce;let ne=(ce=Y.current.getModel())==null?void 0:ce.uri;if(ne&&Z.find(oe=>oe.path===ne.path)){let oe=U.current.editor.getModelMarkers({resource:ne});w==null||w(oe)}});return()=>{K==null||K.dispose()}}return()=>{}},[D,w]);function O(){var K,Z;(K=P.current)==null||K.dispose(),u?m&&Ti.set(o,Y.current.saveViewState()):(Z=Y.current.getModel())==null||Z.dispose(),Y.current.dispose()}return Ts.createElement(Sc,{width:g,height:p,isEditorReady:D,loading:h,_ref:X,className:_,wrapperProps:x})}var rm=im,nm=d.memo(rm),om=nm;function ho(e){const t=d.useId();return`${e??t}`}const mt=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ci(e){const t=d.useRef(e);return mt(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function uo(...e){return ci(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function me(e,t="Assertion error"){if(!e)throw Error(t)}d.createContext(null);let zi;function am(){return zi===void 0&&(typeof matchMedia=="function"?zi=!!matchMedia("(pointer:coarse)").matches:zi=!1),zi}function lm({expandHitTargets:e,axis:t,rect:s}){const i=e?am()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(s.width<i){const n=i-s.width;s=new DOMRect(s.x-n/2,s.y,s.width+n,s.height)}if(s.height<i){const n=i-s.height;s=new DOMRect(s.x,s.y-n/2,s.width,s.height+n)}return s}function cm(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,"%"]}}}var Gt,Gl;let kc=(Gl=class{constructor(){ca(this,Gt,{})}addListener(t,s){const i=Ks(this,Gt)[t];return i===void 0?Ks(this,Gt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Ks(this,Gt)[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 c=0;c<a.length;c++){const h=a[c];try{h.call(null,s)}catch(l){o===null&&(n=!0,o=l)}}if(n)throw o}}removeAllListeners(){ha(this,Gt,{})}removeListener(t,s){const i=Ks(this,Gt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},Gt=new WeakMap,Gl),Ne={cursorFlags:0,state:"inactive"};const fo=new kc;function zt(){return Ne}function Nc(e){return fo.addListener("change",e)}function hm(e,t=[],s,i=!1){const n=Ne,o={...Ne};o.cursorFlags=e,o.state==="active"&&(o.didPointerMove||(o.didPointerMove=i),o.previews=t,s&&(o.previewLayoutMap=s)),Ne=o,fo.emit("change",{prev:n,next:o})}function wt(e){const t=Ne;Ne=e,t.state==="active"&&e.state!=="active"&&t.didPointerMove&&t.hitRegions.forEach(({separator:s})=>{s&&s.element.ownerDocument.activeElement===s.element&&s.element.blur()}),fo.emit("change",{prev:t,next:e})}function dm(e){Ne.state!=="active"||!Ne.previews.some(t=>t.separator===e)||wt({...Ne,previews:Ne.previews.map(t=>t.separator===e?{...t}:t)})}function um(e){if(Ne.state==="inactive")return!1;const t=Ne.hitRegions.filter(i=>i.axis!==e),s=Ne.state==="active"&&Ne.previews.some(i=>i.axis===e);if(t.length===Ne.hitRegions.length&&!s)return!1;if(t.length===0)wt({cursorFlags:0,state:"inactive"});else if(Ne.state==="active"){const i=new Map(Ne.initialLayoutMap),n=new Map(Ne.previewLayoutMap);i.delete(e),n.delete(e),wt({...Ne,cursorFlags:0,hitRegions:t,initialLayoutMap:i,previewLayoutMap:n,previews:Ne.previews.filter(o=>o.axis!==e)})}else wt({...Ne,hitRegions:t});return!0}const fm=e=>e,Ar=()=>{},jc=1,Ec=2,Dc=4,Rc=8,ba=3,ya=12;let Ai;function Sa(){return Ai===void 0&&(Ai=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ai=!0)),Ai}function mm({cursorFlags:e,axes: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&jc)!==0,a=(e&Ec)!==0,c=(e&Dc)!==0,h=(e&Rc)!==0;if(o)return c?"se-resize":h?"ne-resize":"e-resize";if(a)return c?"sw-resize":h?"nw-resize":"w-resize";if(c)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 ui(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:s}=wa.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(s):e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]));const i=zt();switch(i.state){case"active":case"hover":{const n=mm({cursorFlags:i.cursorFlags,axes:i.hitRegions.map(a=>a.axis),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 As({axis:e}){const{layoutStrategy:t,orientation:s,items:i}=e;return t?t.calculateAvailableSize():i.reduce((n,o)=>(n+=s==="horizontal"?o.element.offsetWidth:o.element.offsetHeight,n),0)}function dn(e,t){return Array.from(t).sort((s,i)=>{const n=e==="horizontal"?pm(s,i):_m(s,i);if(n!==0)return n;const o=s.element.compareDocumentPosition(i.element);return o&Node.DOCUMENT_POSITION_DISCONNECTED?0:o&Node.DOCUMENT_POSITION_FOLLOWING?-1:o&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function pm(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function _m(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function un(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Lc(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 gm({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:c,y:h}=Lc(i,a),l=e==="horizontal"?c:h;l<o&&(o=l,n=a)}return me(n,"No rect found"),n}function mo({expandHitTargets:e=!0,axis:t,includeDisabled:s=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:s});const{element:i,orientation:n,items:o,separators:a}=t,c=dn(n,Array.from(i.children).filter(un).filter(y=>!y.hasAttribute("data-resize-preview")).map(y=>({element:y}))).map(({element:y})=>y),h=[];let l=!1,f=!1,m=-1,u,g=-1,p=0,_,x=[];{let y=-1;for(const v of c)v.hasAttribute("data-panel")&&(y++,v.hasAttribute("data-disabled")||(p++,m===-1&&(m=y),g=y))}if(s||p>1){let y=-1;for(const v of c)if(v.hasAttribute("data-panel")){y++;const k=o.find(w=>w.element===v);if(k){if(_){const w=_.element.getBoundingClientRect(),D=v.getBoundingClientRect();let N;if(f){const T=n==="horizontal"?new DOMRect(w.right,w.top,0,w.height):new DOMRect(w.left,w.bottom,w.width,0),L=n==="horizontal"?new DOMRect(D.left,D.top,0,D.height):new DOMRect(D.left,D.top,D.width,0);switch(x.length){case 0:{N=[T,L];break}case 1:{const U=x[0],Y=gm({orientation:n,rects:[w,D],targetRect:U.element.getBoundingClientRect()});N=[U,Y===w?L:T];break}default:{N=x;break}}}else x.length?N=x:N=[n==="horizontal"?new DOMRect(w.right,D.top,D.left-w.right,D.height):new DOMRect(D.left,w.bottom,D.width,D.top-w.bottom)];for(const T of N){const L=lm({expandHitTargets:e,axis:t,rect:"width"in T?T:T.element.getBoundingClientRect()}),U=y<=m||y>g;(s||!l&&!U)&&(u??(u=As({axis:t})),h.push({axis:t,axisSize:u,items:[_,k],separator:"width"in T?void 0:T,rect:L})),l=!1}}f=!1,_=k,x=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(l=!0);const k=a.find(w=>w.element===v);k?x.push(k):(_=void 0,x=[])}else f=!0}return h}function xm(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function vm(e,t){const s=getComputedStyle(e.ownerDocument.documentElement),i=parseFloat(s.fontSize);return t*i}function bm(e){return e/100*window.innerHeight}function ym(e){return e/100*window.innerWidth}function Ls({axisSize:e,itemElement:t,styleProp:s}){let i;const[n,o]=cm(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=vm(t,n);break}case"em":{i=xm(t,n);break}case"vh":{i=bm(n);break}case"vw":{i=ym(n);break}}return i}function Ue(e){return parseFloat(e.toFixed(3))}function fn(e){const{items:t}=e,s=As({axis:e});return s===0?t.map(i=>({groupResizeBehavior:i.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:i.constraintProps.collapsible===!0,defaultSize:void 0,disabled:i.constraintProps.disabled,minSize:0,maxSize:100,itemId:i.id})):t.map(i=>{const{element:n,constraintProps:o}=i;let a=0;if(o.collapsedSize!==void 0){const m=Ls({axisSize:s,itemElement:n,styleProp:o.collapsedSize});a=Ue(m/s*100)}let c;if(o.collapsedThreshold!==void 0){const m=Ls({axisSize:s,itemElement:n,styleProp:o.collapsedThreshold});c=Ue(m/s*100)}let h;if(o.defaultSize!==void 0){const m=Ls({axisSize:s,itemElement:n,styleProp:o.defaultSize});h=Ue(m/s*100)}let l=0;if(o.minSize!==void 0){const m=Ls({axisSize:s,itemElement:n,styleProp:o.minSize});l=Ue(m/s*100)}let f=100;if(o.maxSize!==void 0){const m=Ls({axisSize:s,itemElement:n,styleProp:o.maxSize});f=Ue(m/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsedThreshold:c,collapsible:o.collapsible===!0,defaultSize:h,disabled:o.disabled,minSize:l,maxSize:f,itemId:i.id}})}let bt=new Map;const Pc=new kc;function Sm(e){bt=new Map(bt),bt.delete(e)}function Mc(e,t){for(const[s]of bt)if(s.id===e)return s}function Zt(e,t){for(const[s,i]of bt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function ss(){return bt}function po(e,t){return Pc.addListener("axisChange",s=>{s.axis.id===e&&t(s)})}function Nt(e,t,s){const i=bt.get(e);bt=new Map(bt),bt.set(e,t),Pc.emit("axisChange",{axis:e,isUserInteraction:(s==null?void 0:s.isUserInteraction)===!0,prev:i,next:t})}function wm(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 Be(e,t,s=0){return Math.abs(Ue(e)-Ue(t))<=s}function xt(e,t){return Be(e,t)?0:e>t?1:-1}function Ms({overrideDisabledItems:e,itemConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsedThreshold:o,collapsible:a,disabled:c,maxSize:h=100,minSize:l=0}=t;if(c&&!e)return s;if(xt(i,l)<0)if(a){const f=o??(l-n)/2,m=xt(s,n)<=0,u=m?n+f:l-f,g=xt(i,u);xt(i,n)<=0||g<0||o!==void 0&&m&&g===0?i=n:i=l}else i=l;return i=Math.min(h,i),i=Ue(i),i}function fi({delta:e,initialLayout:t,itemConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(Be(e,0))return t;const a=o==="imperative-api",c=s.map(({itemId:p})=>t[p]),h=s.map(({itemId:p})=>n[p]),l=[...c],[f,m]=i;me(f!=null,"Invalid first pivot index"),me(m!=null,"Invalid second pivot index");let u=0;switch(o){case"keyboard":{{const p=e<0?m:f,_=s[p];me(_,`Panel constraints not found for index ${p}`);const{collapsedSize:x=0,collapsible:y,minSize:v=0}=_;if(y){const k=c[p];if(me(k!=null,`Previous layout not found for panel index ${p}`),Be(k,x)){const w=v-k;xt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const p=e<0?f:m,_=s[p];me(_,`No panel constraints found for index ${p}`);const{collapsedSize:x=0,collapsible:y,minSize:v=0}=_;if(y){const k=c[p];if(me(k!=null,`Previous layout not found for panel index ${p}`),Be(k,v)){const w=k-x;xt(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const p=e<0?m:f,_=s[p];me(_,`Panel constraints not found for index ${p}`);const x=c[p],{collapsedSize:y,collapsedThreshold:v,collapsible:k,minSize:w}=_;if(k&&xt(x,w)<0){const D=w-y,N=v??D/2,T=x+Math.abs(e);if(xt(T,w)<0){const L=xt(Math.abs(e),N),U=v===void 0&&e<0;L>0||L===0&&U?e=e<0?-D:D:e=0}}break}}{const p=e<0?1:-1;let _=e<0?m:f,x=0;for(;;){const v=c[_];me(v!=null,`Previous layout not found for panel index ${_}`);const k=Ms({overrideDisabledItems:a,itemConstraints:s[_],prevSize:v,size:100})-v;if(x+=k,_+=p,_<0||_>=s.length)break}const y=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-y:y}{let p=e<0?f:m;for(;p>=0&&p<s.length;){const _=Math.abs(e)-Math.abs(u),x=c[p];me(x!=null,`Previous layout not found for panel index ${p}`);const y=x-_,v=Ms({overrideDisabledItems:a,itemConstraints:s[p],prevSize:x,size:y});if(!Be(x,v)&&(u+=x-v,l[p]=v,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(wm(h,l))return n;{const p=e<0?m:f,_=c[p];me(_!=null,`Previous layout not found for panel index ${p}`);const x=_+u,y=Ms({overrideDisabledItems:a,itemConstraints:s[p],prevSize:_,size:x});if(l[p]=y,!Be(y,x)){let v=x-y,k=e<0?m:f;for(;k>=0&&k<s.length;){const w=l[k];me(w!=null,`Previous layout not found for panel index ${k}`);const D=w+v,N=Ms({overrideDisabledItems:a,itemConstraints:s[k],prevSize:w,size:D});if(Be(w,N)||(v-=N-w,l[k]=N),Be(v,0))break;e>0?k--:k++}}}const g=Object.values(l).reduce((p,_)=>_+p,0);return Be(g,100,.1)?l.reduce((p,_,x)=>(p[s[x].itemId]=_,p),{}):n}function Ct(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||xt(e[s],t[s])!==0)return!1;return!0}function _o({commit:e,document:t,event:s,hitRegions:i,initialLayoutMap:n,mountedAxes:o,pointerDownAtPoint:a,prevCursorFlags:c}){let h=0;const l=zt();let f=l.state==="active"?l.previews:[];const m=new Map(l.state==="active"?l.previewLayoutMap:void 0);i.forEach(p=>{const{axis:_,axisSize:x}=p,{orientation:y,items:v}=_;if(e&&_.resizePreviewMode!=="separator")return;const{disableCursor:k}=_.mutableState;let w=0;a?y==="horizontal"?w=(s.clientX-a.x)/x*100:w=(s.clientY-a.y)/x*100:y==="horizontal"?w=s.clientX<0?-100:100:w=s.clientY<0?-100:100;const D=n.get(_),N=o.get(_);if(!D||!N)return;const{defaultLayoutDeferred:T,derivedItemConstraints:L,axisSize:U,layout:Y,separatorToItems:X}=N;if(L&&Y&&X){const M=_.resizePreviewMode==="separator"?m.get(_)??Y:Y,E=fi({delta:w,initialLayout:D,itemConstraints:L,pivotIndices:p.items.map(P=>v.indexOf(P)),prevLayout:M,trigger:"mouse-or-touch"});if(_.resizePreviewMode==="separator"&&!e&&!Ct(E,M)){m.set(_,E);let P=0;const S=v.map(j=>(P+=E[j.id]-D[j.id],P*(x/100)));f=f.map(j=>{if(j.axis!==_)return j;const z=S[j.itemIndex];return z===j.offset?j:{...j,offset:z}})}if(Ct(E,M)&&w!==0&&!k)switch(y){case"horizontal":{h|=w<0?jc:Ec;break}case"vertical":{h|=w<0?Dc:Rc;break}}(_.resizePreviewMode!=="separator"||e)&&!Ct(E,Y)&&Nt(p.axis,{defaultLayoutDeferred:T,derivedItemConstraints:L,axisSize:U,layout:E,requestedAxisSize:U,requestedLayout:E,separatorToItems:X})}});let u=0;s.movementX===0?u|=c&ba:u|=h&ba,s.movementY===0?u|=c&ya:u|=h&ya;const g=l.state==="active"&&(s.clientX!==l.pointerDownAtPoint.x||s.clientY!==l.pointerDownAtPoint.y);hm(u,f,m,g),ui(t)}function Bc(e,t){const s=zt(),i=ss();let n=!1;switch(s.state){case"active":_o({commit:!0,document:e,event:t,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedAxes:i,pointerDownAtPoint:s.pointerDownAtPoint,prevCursorFlags:s.cursorFlags}),wt({cursorFlags:0,state:"inactive"}),s.hitRegions.length>0&&(ui(e),n=!0,s.hitRegions.forEach(o=>{if(!i.has(o.axis))return;const a=Zt(o.axis.id,!0);Nt(o.axis,a,{isUserInteraction:!0})}))}return n}function Ca(e){e.defaultPrevented||Bc(e.currentTarget,e)}function Cm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=Lc(s,o.rect);switch(e){case"horizontal":{(a.x<n.x||a.x===n.x&&a.y<=n.y)&&(i=o,n=a);break}case"vertical":{(a.y<n.y||a.y===n.y&&a.x<=n.x)&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function km(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Nm(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:ja(e),b:ja(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();me(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:Na(ka(s.a)),b:Na(ka(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let c=o.length;for(;c--;){const h=o[c];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const jm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Em(e){const t=getComputedStyle(Tc(e)??e).display;return t==="flex"||t==="inline-flex"}function Dm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Em(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"||jm.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function ka(e){let t=e.length;for(;t--;){const s=e[t];if(me(s,"Missing node"),Dm(s))return s}return null}function Na(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ja(e){const t=[];for(;e;)t.push(e),e=Tc(e);return t}function Tc(e){const{parentNode:t}=e;return km(t)?t.host:t}function Rm(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 Lm(e){try{return e.matches(":modal")}catch{return!1}}function Pm({axisElement:e,hitRegion:t,pointerEventTarget:s}){if(un(s)){const i=s.closest("dialog");if(i&&!i.contains(e)&&Lm(i))return!1}if(!un(s)||s.contains(e)||e.contains(s))return!0;if(Nm(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(Rm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function go(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=mo({axis:n}),a=Cm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Pm({axisElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function ts({layout:e,itemConstraints:t}){const s=t.map(({itemId:a})=>e[a]),i=[...s],n=i.reduce((a,c)=>a+c,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(a=>`${a}%`).join(", ")}`);if(!Be(n,100)&&i.length>0)for(let a=0;a<t.length;a++){const c=i[a];me(c!=null,`No layout data found for index ${a}`);const h=100/n*c;i[a]=h}let o=0;for(let a=0;a<t.length;a++){const c=s[a];me(c!=null,`No layout data found for index ${a}`);const h=i[a];me(h!=null,`No layout data found for index ${a}`);const l=Ms({overrideDisabledItems:!0,itemConstraints:t[a],prevSize:c,size:h});h!=l&&(o+=h-l,i[a]=l)}if(!Be(o,0))for(let a=0;a<t.length;a++){const c=i[a];me(c!=null,`No layout data found for index ${a}`);const h=c+o,l=Ms({overrideDisabledItems:!0,itemConstraints:t[a],prevSize:c,size:h});if(c!==l&&(o-=l-c,i[a]=l,Be(o,0)))break}return i.reduce((a,c,h)=>(a[t[h].itemId]=c,a),{})}function zc({axisId:e,itemId:t}){const s=()=>{const h=ss();for(const[l,{defaultLayoutDeferred:f,derivedItemConstraints:m,layout:u,axisSize:g,separatorToItems:p}]of h)if(l.id===e)return{defaultLayoutDeferred:f,derivedItemConstraints:m,axis:l,axisSize:g,layout:u,separatorToItems:p};throw Error(`Group ${e} not found`)},i=()=>{const h=s().derivedItemConstraints.find(l=>l.itemId===t);if(h!==void 0)return h;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const h=s().axis.items.find(l=>l.id===t);if(h!==void 0)return h;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const h=s().layout[t];if(h!==void 0)return h;throw Error(`Layout not found for Panel ${t}`)},a=({nextSize:h,items:l,prevLayout:f,derivedItemConstraints:m})=>{const u=o(),g=l.findIndex(x=>x.id===t),p=g===0,_=g===l.length-1;if(_&&h<u&&(p||l.slice(0,g).every((x,y)=>{const v=m[y];return(v==null?void 0:v.collapsible)&&Be(v.collapsedSize,f[v.itemId])}))){const x=l.slice(0,g).reduce((y,v)=>y+f[v.id],0);return{...f,[t]:Ue(100-x)}}return fi({delta:_?u-h:h-u,initialLayout:f,itemConstraints:m,pivotIndices:_?[g-1,g]:[g,g+1],prevLayout:f,trigger:"imperative-api"})},c=h=>{const l=o();if(h===l)return;const{defaultLayoutDeferred:f,derivedItemConstraints:m,axis:u,axisSize:g,layout:p,separatorToItems:_}=s(),x=a({nextSize:h,items:u.items,prevLayout:p,derivedItemConstraints:m}),y=ts({layout:x,itemConstraints:m});Ct(p,y)||Nt(u,{defaultLayoutDeferred:f,derivedItemConstraints:m,axisSize:g,layout:y,requestedAxisSize:g,requestedLayout:y,separatorToItems:_})};return{collapse:()=>{const{collapsible:h,collapsedSize:l}=i(),{mutableValues:f}=n(),m=o();h&&m!==l&&(f.expandToSize=m,c(l))},expand:()=>{const{collapsible:h,collapsedSize:l,minSize:f}=i(),{mutableValues:m}=n(),u=o();if(h&&u===l){let g=m.expandToSize??f;g===0&&(g=1),c(g)}},getSize:()=>{const{axis:h}=s(),l=o(),{element:f}=n(),m=h.layoutStrategy?h.layoutStrategy.getItemSizeInPixels(t):h.orientation==="horizontal"?f.offsetWidth:f.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:h,collapsedSize:l}=i(),f=o();return h&&Be(l,f)},resize:h=>{const{axis:l}=s(),{element:f}=n(),m=As({axis:l}),u=Ls({axisSize:m,itemElement:f,styleProp:h}),g=Ue(u/m*100);c(g)}}}function Ea(e){if(e.defaultPrevented)return;const t=ss();go(e,t).forEach(s=>{if(s.separator&&!s.separator.disableDoubleClick){const i=s.items.find(n=>n.constraintProps.defaultSize!==void 0);if(i){const n=i.constraintProps.defaultSize,o=zc({axisId:s.axis.id,itemId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ac(e){const t=ss();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 Ic({axisId:e}){const t=()=>{const s=ss();for(const[i,n]of s)if(i.id===e)return{axis: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,derivedItemConstraints:n,axis:o,axisSize:a,layout:c,separatorToItems:h}=t(),l=ts({layout:s,itemConstraints:n});return i?c:(Ct(c,l)||Nt(o,{defaultLayoutDeferred:i,derivedItemConstraints:n,axisSize:a,layout:l,requestedAxisSize:a,requestedLayout:l,separatorToItems:h}),l)}}}function ns(e,t){const s=Ac(e),i=Zt(s.id,!0),n=s.separators.find(f=>f.element===e);me(n,"Matching separator not found");const o=i.separatorToItems.get(n);me(o,"Matching panels not found");const a=o.map(f=>s.items.indexOf(f)),c=Ic({axisId:s.id}).getLayout(),h=fi({delta:t,initialLayout:c,itemConstraints:i.derivedItemConstraints,pivotIndices:a,prevLayout:c,trigger:"keyboard"}),l=ts({layout:h,itemConstraints:i.derivedItemConstraints});Ct(c,l)||Nt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedItemConstraints:i.derivedItemConstraints,axisSize:i.axisSize,layout:l,requestedAxisSize:i.axisSize,requestedLayout:l,separatorToItems:i.separatorToItems},{isUserInteraction:!0})}function Da(e){var i;if(e.defaultPrevented)return;const t=e.currentTarget,s=Ac(t);if(!(s.disabled||(i=s.separators.find(n=>n.element===t))!=null&&i.disabled))switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&ns(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&ns(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&ns(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&ns(t,-5);break}case"End":{e.preventDefault(),ns(t,100);break}case"Enter":{e.preventDefault();const n=Zt(s.id,!0),{derivedItemConstraints:o,layout:a,separatorToItems:c}=n,h=s.separators.find(u=>u.element===t);me(h,"Matching separator not found");const l=c.get(h);me(l,"Matching panels not found");const f=l[0],m=o.find(u=>u.itemId===f.id);if(me(m,"Panel metadata not found"),m.collapsible){const u=a[f.id],g=m.collapsedSize===u?s.mutableState.expandedItemSizes[f.id]??m.minSize:m.collapsedSize;ns(t,g-u)}break}case"F6":{e.preventDefault();const n=s.separators.map(c=>c.element),o=Array.from(n).findIndex(c=>c===e.currentTarget);me(o!==null,"Index not found");const a=e.shiftKey?o>0?o-1:n.length-1:o+1<n.length?o+1:0;n[a].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),ns(t,-100);break}}}function Mm(e,t){const{element:s,orientation:i,items:n}=e,o=s.getBoundingClientRect(),a=i==="horizontal";return mo({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:c,rect:h,separator:l},f)=>{const m=n.indexOf(c[0]),u=a?h.left+h.width/2:h.top+h.height/2;return{active:t.some(g=>{if(g.axis!==e||g.items[0]!==c[0])return!1;if(l||g.separator)return g.separator===l;const p=a?g.rect.left+g.rect.width/2:g.rect.top+g.rect.height/2;return Be(u,p)}),axis:e,key:l?`separator-${l.id}`:`panel-${c[0].id}-${f}`,offset:0,itemIndex:m,rect:new DOMRect((a&&!l?u:h.left)-o.left-s.clientLeft+s.scrollLeft,(!a&&!l?u:h.top)-o.top-s.clientTop+s.scrollTop,a&&!l?0:h.width,!a&&!l?0:h.height),separator:l}})}function Ra(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ss(),s=go(e,t);if(s.length===0)return;const i=new Map;let n=!1;s.forEach(a=>{a.separator&&(n||(n=!0,a.separator.element.focus({focusVisible:!1,preventScroll:!0})));const c=t.get(a.axis);c&&i.set(a.axis,c.layout)});const o=Array.from(i.keys()).flatMap(a=>a.resizePreviewMode==="separator"?Mm(a,s):[]);wt({cursorFlags:0,didPointerMove:!1,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},previewLayoutMap:new Map(i),previews:o,state:"active"}),e.preventDefault()}function La(e){const t=ss(),s=zt();switch(s.state){case"active":_o({commit:!1,document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedAxes:t,prevCursorFlags:s.cursorFlags})}}function Pa(e){var i,n;if(e.defaultPrevented)return;const t=zt(),s=ss();switch(t.state){case"active":{if(e.buttons===0){t.previewLayoutMap.forEach((o,a)=>{const c=s.get(a);a.resizePreviewMode==="separator"&&c&&!Ct(o,c.layout)&&Nt(a,{...c,layout:o,requestedAxisSize:c.axisSize,requestedLayout:o})}),wt({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{if(!s.has(o.axis))return;const a=Zt(o.axis.id,!0);Nt(o.axis,a,{isUserInteraction:!0})}),ui(e.currentTarget);return}for(const o of t.hitRegions)if(o.separator){const{element:a}=o.separator;a.isConnected&&!((i=a.hasPointerCapture)!=null&&i.call(a,e.pointerId))&&((n=a.setPointerCapture)==null||n.call(a,e.pointerId))}_o({commit:!1,document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedAxes:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=go(e,s);o.length===0?t.state!=="inactive"&&wt({cursorFlags:0,state:"inactive"}):wt({cursorFlags:0,hitRegions:o,state:"hover"}),ui(e.currentTarget);break}}}function Ma(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(zt().state){case"hover":wt({cursorFlags:0,state:"inactive"})}}function Ba(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||Bc(e.currentTarget,e)&&e.preventDefault()}function Bm(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Ue(o.defaultSize);s+=a,i[o.itemId]=a}else i[o.itemId]=void 0;const n=e.length-t;if(n!==0){const o=Ue((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.itemId]=o)}return i}function Tm(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}function Ta({axis:e,itemConstraints:t}){const s=e.items.map(({id:n})=>n).join(","),i=e.mutableState.defaultLayout;return e.mutableState.layouts[s]??(i&&Tm(e.items,i)?i:Bm(t))}function za({itemIds:e,layout:t}){return ts({layout:t,itemConstraints:e.map(s=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:s,maxSize:100,minSize:0}))})}function zm(e,t,s){if(!s[0])return;const i=e.items.find(h=>h.element===t);if(!i||!i.onResize)return;const n=As({axis:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,c={asPercentage:Ue(o/n*100),inPixels:o};i.mutableValues.prevSize=c,i.onResize(c,i.id,a)}function Oc(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 Am(e,t){return e.length!==t.length?!1:e.every((s,i)=>Oc(s,t[i]))}function Im({axis:e,nextAxisSize:t,prevAxisSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const c=new Map,h=[];for(const m of e.items){const u=i[m.id]??0;switch(m.constraintProps.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=u/100*s,p=Ue(g/t*100);c.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=u;break}}}if(!a||h.length===0)return i;const l=100-n,f={...i};if(c.forEach((m,u)=>{f[u]=m}),o>0)for(const m of h){const u=i[m]??0;f[m]=Ue(u/o*l)}else{const m=Ue(l/h.length);for(const u of h)f[u]=m}return f}const Ns=new Map;function Om(e){let t=!0;me(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(u=>{for(const g of u){const{borderBoxSize:p,target:_}=g;if(_===e.element){if(t){const x=As({axis:e});if(x===0)return;const y=Zt(e.id);if(!y)return;const v=fn(e);let k=y.requestedAxisSize,w=y.requestedLayout;y.defaultLayoutDeferred&&(k=x,w=za({itemIds:e.items.map(({id:T})=>T),layout:Ta({axis:e,itemConstraints:v})}));const D=Im({axis:e,nextAxisSize:x,prevAxisSize:k,prevLayout:w}),N=ts({layout:D,itemConstraints:v});if(!y.defaultLayoutDeferred&&Ct(y.layout,N)&&Am(y.derivedItemConstraints,v)&&y.axisSize===x)continue;Nt(e,{defaultLayoutDeferred:!1,derivedItemConstraints:v,axisSize:x,layout:N,requestedAxisSize:k,requestedLayout:w,separatorToItems:y.separatorToItems})}}else zm(e,_,p)}});o.observe(e.element),e.items.forEach(u=>{me(!i.has(u.id),`Panel ids must be unique; id "${u.id}" was used more than once`),i.add(u.id),u.onResize&&o.observe(u.element)});const a=As({axis:e}),c=fn(e),h=Ta({axis:e,itemConstraints:c}),l=ts({layout:h,itemConstraints:c}),f=e.element.ownerDocument;Ns.set(f,(Ns.get(f)??0)+1);const m=new Map;return mo({axis:e,includeDisabled:!0}).forEach(u=>{u.separator&&m.set(u.separator,u.items)}),Nt(e,{defaultLayoutDeferred:a===0,derivedItemConstraints:c,axisSize:a,layout:l,requestedAxisSize:a,requestedLayout:za({itemIds:e.items.map(({id:u})=>u),layout:h}),separatorToItems:m}),e.separators.forEach(u=>{me(!n.has(u.id),`Separator ids must be unique; id "${u.id}" was used more than once`),n.add(u.id),u.element.addEventListener("keydown",Da)}),Ns.get(f)===1&&(f.addEventListener("contextmenu",Ca,!0),f.addEventListener("dblclick",Ea,!0),f.addEventListener("pointerdown",Ra,!0),f.addEventListener("pointerleave",La),f.addEventListener("pointermove",Pa),f.addEventListener("pointerout",Ma),f.addEventListener("pointerup",Ba,!0)),function(){t=!1,Ns.set(f,Math.max(0,(Ns.get(f)??0)-1)),Sm(e),um(e)&&ui(f),e.separators.forEach(u=>{u.element.removeEventListener("keydown",Da)}),Ns.get(f)||(f.removeEventListener("contextmenu",Ca,!0),f.removeEventListener("dblclick",Ea,!0),f.removeEventListener("pointerdown",Ra,!0),f.removeEventListener("pointerleave",La),f.removeEventListener("pointermove",Pa),f.removeEventListener("pointerout",Ma),f.removeEventListener("pointerup",Ba,!0)),o.disconnect()}}function $m({derivedItemConstraints:e,axis:t,layout:s,prevLayout:i,requestedLayout:n}){const o=t.items.map(({id:a})=>a).join(",");t.mutableState.layouts[o]=n,i&&e.forEach(a=>{if(a.collapsible){const c=Be(a.collapsedSize,s[a.itemId]),h=Be(a.collapsedSize,i[a.itemId]);c&&!h&&(t.mutableState.expandedItemSizes[a.itemId]=i[a.itemId])}})}function Fm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function xo(e){const t=d.useRef({...e});return mt(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const $c=d.createContext(null);function Hm({layout:e,itemConstraints:t,itemId:s,itemIndex:i}){let n,o;const a=e[s],c=t.find(h=>h.itemId===s);if(c){const h=c.maxSize,l=c.collapsible?c.collapsedSize:c.minSize,f=[i,i+1];o=ts({layout:fi({delta:l-a,initialLayout:e,itemConstraints:t,pivotIndices:f,prevLayout:e}),itemConstraints:t})[s],n=ts({layout:fi({delta:h-a,initialLayout:e,itemConstraints:t,pivotIndices:f,prevLayout:e}),itemConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function Wm({attributes:e,axisId:t,axisOrientation:s,children:i,className:n,disableCursor:o,disabled:a,disableDoubleClick:c,elementRef:h,id:l,isSharedHitRegion:f,preview:m,registerSeparator:u,requiredStyle:g,style:p,styleDefaults:_,tabIndex:x=0,updateSeparatorProps:y}){const v=xo({disabled:a,disableDoubleClick:c,children:i,className:n,preview:m,style:p}),[k,w]=d.useState({}),[D,N]=d.useState("inactive"),[T,L]=d.useState(!1),U=d.useRef(null),Y=d.useRef(null),X=uo(U,h),M=s==="horizontal"?"vertical":"horizontal";mt(()=>{const S=U.current;if(S!==null){const j={disabled:v.disabled,disableDoubleClick:v.disableDoubleClick,element:S,id:l,get children(){return v.children},get className(){return v.className},get preview(){return v.preview},get style(){return v.style}};Y.current=j;const z=u(j),C=Nc(O=>{N(O.next.state!=="inactive"&&O.next.hitRegions.some(K=>K.separator===j||((f==null?void 0:f(K))??!1))?O.next.state:"inactive")}),I=po(t,O=>{const{derivedItemConstraints:K,layout:Z,separatorToItems:ne}=O.next,ce=ne.get(j);if(ce){const oe=ce[0],_e=K.findIndex(De=>De.itemId===oe.id),{layoutStrategy:ue}=O.axis;w({...Hm({layout:Z,itemConstraints:K,itemId:oe.id,itemIndex:_e}),...(ue==null?void 0:ue.getItemAriaControls)&&{valueControls:ue.getItemAriaControls(oe.id)}})}});return()=>{Y.current=null,C(),I(),z()}}},[t,l,f,u,v]),mt(()=>{const S=Y.current;S&&dm(S)},[m]),d.useEffect(()=>{y(l,{disabled:a,disableDoubleClick:c})},[a,c,l,y]);let E;a&&!o&&(E="not-allowed");let P;if(a)P="disabled";else switch(D){case"active":{P="active";break}default:T?P="focus":P=D}return r.jsx("div",{...e,"aria-controls":k.valueControls,"aria-disabled":a||void 0,"aria-orientation":M,"aria-valuemax":k.valueMax,"aria-valuemin":k.valueMin,"aria-valuenow":k.valueNow,children:i,className:n,"data-separator":P,"data-testid":l,id:l,onBlur:()=>L(!1),onFocus:()=>L(!0),ref:X,role:"separator",style:{..._,cursor:E,...p,...g,touchAction:"none"},tabIndex:a?void 0:x})}function Um({separator:e}){const{element:t}=e,s=d.useRef(null);return mt(()=>{const i=t.cloneNode(!0),n=[t,...t.querySelectorAll("*")],o=[i,...i.querySelectorAll("*")],a=t.ownerDocument.defaultView;return n.forEach((c,h)=>{const l=o[h];if(l instanceof a.HTMLElement||l instanceof a.SVGElement){const f=a.getComputedStyle(c);for(let m=0;m<f.length;m++){const u=f.item(m);l.style.setProperty(u,f.getPropertyValue(u))}}l.removeAttribute("data-testid"),l.removeAttribute("id")}),Object.assign(i.style,{boxSizing:"border-box",height:"100%",margin:"0",position:"static",transform:"none",width:"100%"}),s.current.appendChild(i),()=>i.remove()},[t]),r.jsx("div",{ref:s,style:{height:"100%",opacity:.65,pointerEvents:"none",width:"100%"}})}function br(){const e=d.useContext($c);return me(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Fc(e){const{registerOverlay:t}=br(),s=d.useRef(e);Oc(s.current,e)||(s.current=e);const i=s.current;return mt(()=>t(i),[t,i]),null}Fc.displayName="SeparatorOverlay";function Km({active:e,orientation:t,style:s,...i}){let n;switch(t){case"horizontal":{n={height:"100%",minWidth:"1px"};break}case"vertical":{n={minHeight:"1px",width:"100%"};break}}return r.jsx("div",{...i,"data-separator-overlay":e?"active":"inactive",style:{...n,...s,flexShrink:0,pointerEvents:"none"}})}function qm({overlay:e,preview:t}){const{axis:s,offset:i,rect:n,separator:o}=t,a=s.orientation==="horizontal";let c=o==null?void 0:o.preview,h=e;return d.isValidElement(c)&&c.type===Fc&&(h=c.props,c=void 0),c==null&&(h?c=r.jsx(Km,{...h,active:t.active,orientation:s.orientation}):o&&(c=r.jsx(Um,{separator:o}))),r.jsx("div",{"aria-hidden":"true","data-resize-preview":!0,inert:!0,style:{height:n.height,left:n.left,pointerEvents:"none",position:"absolute",top:n.top,transform:a?`translateX(${i}px)`:`translateY(${i}px)`,width:n.width},children:c})}function Vm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:fm});d.useImperativeHandle(t,()=>s.current,[]),mt(()=>{Object.assign(s.current,Ic({axisId:e}))})}function Gm({groupId:e,resizePreviewMode:t}){const[s,i]=d.useState([]),n=d.useRef(s);return mt(()=>{const o=c=>{const h=Mc(e),l=t==="separator"&&c.state==="active"?c.previews.filter(m=>m.axis===h&&(m.active||!Be(m.offset,0))):[],f=n.current;f.length===l.length&&l.every((m,u)=>m===f[u])||(n.current=l,i(l))};if(t!=="separator"){o(zt());return}const a=Nc(({next:c})=>o(c));return o(zt()),a},[e,t]),s}function mn({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:c,onLayoutChange:h,onLayoutChanged:l,orientation:f="horizontal",resizePreviewMode:m="panel",resizeTargetMinimumSize:u={coarse:20,fine:10},style:g,...p}){const _=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),x=ci(S=>{Ct(_.current.onLayoutChange,S)||(_.current.onLayoutChange=S,h==null||h(S))}),y=ci((S,j,z)=>{Ct(_.current.onLayoutChanged,S)||(_.current.onLayoutChanged=S,l==null||l(S,{isUserInteraction:j,requestedLayout:z}))}),v=ho(c),[k,w]=d.useState(),D=Gm({groupId:v,resizePreviewMode:m}),N=d.useRef(null),[T,L]=Fm(),U=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),Y=uo(N,o);Vm(v,a);const X=ci((S,j)=>{const z=Zt(S);if(z)return{flexGrow:z.layout[j]??1};if(s!=null&&s[j])return{flexGrow:s==null?void 0:s[j]}}),M=xo({defaultLayout:s,disableCursor:i,resizeTargetMinimumSize:u}),E=d.useMemo(()=>({get disableCursor(){return!!M.disableCursor},getPanelStyles:X,id:v,orientation:f,registerPanel:S=>{const j=U.current;return j.panels=dn(f,[...j.panels,S]),L(),()=>{j.panels=j.panels.filter(z=>z!==S),L()}},registerOverlay:S=>(w(S),()=>{w(void 0)}),registerSeparator:S=>{const j=U.current;return j.separators=dn(f,[...j.separators,S]),L(),()=>{j.separators=j.separators.filter(z=>z!==S),L()}},updatePanelProps:(S,{disabled:j})=>{const z=U.current.panels.find(O=>O.id===S);z&&(z.constraintProps.disabled=j);const C=Mc(v),I=Zt(v);C&&I&&Nt(C,{...I,derivedItemConstraints:fn(C)})},updateSeparatorProps:(S,{disabled:j,disableDoubleClick:z})=>{const C=U.current.separators.find(I=>I.id===S);C&&(C.disabled=j,C.disableDoubleClick=z)}}),[X,v,L,f,M]),P=d.useRef(null);return mt(()=>{const S=N.current;if(S===null)return;const j=U.current;let z;if(M.defaultLayout!==void 0&&Object.keys(M.defaultLayout).length===j.panels.length){z={};for(const oe of j.panels){const _e=M.defaultLayout[oe.id];_e!==void 0&&(z[oe.id]=_e)}}const C={disabled:!!n,element:S,id:v,mutableState:{defaultLayout:z,disableCursor:!!M.disableCursor,expandedItemSizes:U.current.lastExpandedPanelSizes,layouts:U.current.layouts},orientation:f,items:j.panels,resizePreviewMode:m,get resizeTargetMinimumSize(){return M.resizeTargetMinimumSize},separators:j.separators};P.current=C;const I=Om(C),{defaultLayoutDeferred:O,derivedItemConstraints:K,layout:Z,requestedLayout:ne}=Zt(C.id,!0);!O&&K.length>0&&(x(Z),y(Z,!1,ne));const ce=po(v,oe=>{var J;const{defaultLayoutDeferred:_e,derivedItemConstraints:ue,layout:De,requestedLayout:A}=oe.next;if(_e||ue.length===0)return;$m({derivedItemConstraints:ue,axis:C,layout:De,prevLayout:(J=oe.prev)==null?void 0:J.layout,requestedLayout:A});const pe=zt(),B=pe.state!=="active"||!pe.hitRegions.some(G=>G.axis===C);x(De),B&&y(De,oe.isUserInteraction,A)});return()=>{P.current=null,I(),ce()}},[n,v,y,x,f,T,m,M]),d.useEffect(()=>{const S=P.current;S&&(S.mutableState.defaultLayout=s,S.mutableState.disableCursor=!!i)}),r.jsx($c.Provider,{value:E,children:r.jsxs("div",{...p,className:t,"data-group":!0,"data-testid":v,id:v,ref:Y,style:{height:"100%",width:"100%",overflow:"hidden",position:m==="separator"?"relative":void 0,...g,display:"flex",flexDirection:f==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:f==="horizontal"?"pan-y":"pan-x"},children:[e,D.map(S=>r.jsx(qm,{overlay:k,preview:S},S.key))]})})}mn.displayName="Group";function Ym(e,t){const{id:s}=br(),i=d.useRef({collapse:Ar,expand:Ar,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Ar});d.useImperativeHandle(t,()=>i.current,[]),mt(()=>{Object.assign(i.current,zc({axisId:s,itemId:e}))})}function ei({children:e,className:t,collapsedSize:s="0%",collapsedThreshold:i,collapsible:n=!1,defaultSize:o,disabled:a,elementRef:c,groupResizeBehavior:h="preserve-relative-size",id:l,maxSize:f="100%",minSize:m="0%",onResize:u,panelRef:g,style:p,..._}){const x=!!l,y=ho(l),v=xo({disabled:a}),k=d.useRef(null),w=uo(k,c),{getPanelStyles:D,id:N,orientation:T,registerPanel:L,updatePanelProps:U}=br(),Y=u!==null,X=ci((S,j,z)=>{u==null||u(S,l,z)});mt(()=>{const S=k.current;if(S!==null){const j={element:S,id:y,idIsStable:x,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:Y?X:void 0,constraintProps:{groupResizeBehavior:h,collapsedSize:s,collapsedThreshold:i,collapsible:n,defaultSize:o,disabled:v.disabled,maxSize:f,minSize:m}};return L(j)}},[h,s,i,n,o,Y,y,x,f,m,X,L,v]),d.useEffect(()=>{U(y,{disabled:a})},[a,y,U]),Ym(y,g);const M=()=>{const S=D(N,y);if(S)return JSON.stringify(S)},E=d.useSyncExternalStore(S=>po(N,S),M,M);let P;return E?P=JSON.parse(E):o!==void 0?P={flexGrow:void 0,flexShrink:void 0,flexBasis:o}:P={flexGrow:1},r.jsx("div",{..._,"data-disabled":a||void 0,"data-panel":!0,"data-testid":y,id:y,ref:w,style:{...Xm,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...P},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:T==="horizontal"?"pan-y":"pan-x"},children:e})})}ei.displayName="Panel";const Xm={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0},Jm={flexBasis:"auto"},Zm={flexGrow:0,flexShrink:0};function pn({children:e,className:t,disabled:s,disableDoubleClick:i,elementRef:n,id:o,preview:a,style:c,...h}){const l=ho(o),{disableCursor:f,id:m,orientation:u,registerSeparator:g,updateSeparatorProps:p}=br();return r.jsx(Wm,{attributes:h,axisId:m,axisOrientation:u,className:t,disableCursor:f,disabled:s,disableDoubleClick:i,elementRef:n,id:l,preview:a,registerSeparator:g,requiredStyle:Zm,style:c,styleDefaults:Jm,updateSeparatorProps:p,children:e})}pn.displayName="Separator";const Qm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},ep={sm:"w-7 h-7",md:"w-8 h-8"},tp={sm:14,md:16};function Wt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:c}){return r.jsx("button",{type:"button","aria-label":t,title:c??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Qm[i],ep[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:tp[s]})})}function sp({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),c=d.useRef([]);d.useEffect(()=>{var l;(l=c.current[0])==null||l.focus()},[]),d.useEffect(()=>{const l=f=>{a.current&&!a.current.contains(f.target)&&i()};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[i]);const h=d.useCallback(l=>{var f,m;switch(l.key){case"Escape":l.preventDefault(),i();break;case"ArrowDown":l.preventDefault(),o(u=>{var p;const g=(u+1)%s.length;return(p=c.current[g])==null||p.focus(),g});break;case"ArrowUp":l.preventDefault(),o(u=>{var p;const g=(u-1+s.length)%s.length;return(p=c.current[g])==null||p.focus(),g});break;case"Home":l.preventDefault(),o(0),(f=c.current[0])==null||f.focus();break;case"End":l.preventDefault(),o(s.length-1),(m=c.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((l,f)=>{const m=l.icon,u=l.variant==="danger";return r.jsxs("button",{ref:g=>{c.current[f]=g},role:"menuitem",tabIndex:n===f?0:-1,onClick:()=>{l.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",u?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(m,{size:14}),l.label]},l.label)})})}/**
|
|
173
173
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
174
174
|
* @license MIT
|
|
175
175
|
*
|
|
@@ -180,22 +180,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
180
180
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
181
181
|
* http://bellard.org/jslinux/
|
|
182
182
|
* Copyright (c) 2011 Fabrice Bellard
|
|
183
|
-
*/var
|
|
183
|
+
*/var Hc=Object.defineProperty,ip=Object.getOwnPropertyDescriptor,rp=(e,t)=>{for(var s in t)Hc(e,s,{get:t[s],enumerable:!0})},Ce=(e,t,s,i)=>{for(var n=i>1?void 0:i?ip(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&&Hc(t,s,n),n},q=(e,t)=>(s,i)=>t(s,i,e),Aa="Terminal input",_n={get:()=>Aa,set:e=>Aa=e},Ia="Too much output to announce, navigate to rows manually to read",gn={get:()=>Ia,set:e=>Ia=e};function np(e){return e.replace(/\r?\n/g,"\r")}function op(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function ap(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function lp(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Wc(n,t,s,i)}}function Wc(e,t,s,i){e=np(e),e=op(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Uc(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 Oa(e,t,s,i,n){Uc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Vt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function yr(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 cp=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 c=e.charCodeAt(o);56320<=c&&c<=57343?t[i++]=(a-55296)*1024+c-56320+65536:(t[i++]=a,t[i++]=c);continue}a!==65279&&(t[i++]=a)}return i}},hp=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,c,h=0,l=0;if(this.interim[0]){let u=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let p=0,_;for(;(_=this.interim[++p]&63)&&p<4;)g<<=6,g|=_;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=x-p;for(;l<y;){if(l>=s)return 0;if(_=e[l++],(_&192)!==128){l--,u=!0;break}else this.interim[p++]=_,g<<=6,g|=_&63}u||(x===2?g<128?l--:t[i++]=g:x===3?g<2048||g>=55296&&g<=57343||g===65279||(t[i++]=g):g<65536||g>1114111||(t[i++]=g)),this.interim.fill(0)}let f=s-4,m=l;for(;m<s;){for(;m<f&&!((n=e[m])&128)&&!((o=e[m+1])&128)&&!((a=e[m+2])&128)&&!((c=e[m+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=c,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(c=e[m++],(c&192)!==128){m--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|c&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Kc="",Yt=" ",bi=class qc{constructor(){this.fg=0,this.bg=0,this.extended=new or}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 qc;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}},or=class Vc{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 Vc(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dt=class Gc extends bi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new or,this.combinedData=""}static fromCharData(t){let s=new Gc;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?Vt(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()]}},$a="di$target",xn="di$dependencies",Ir=new Map;function dp(e){return e[xn]||[]}function Oe(e){if(Ir.has(e))return Ir.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");up(t,s,n)};return t._id=e,Ir.set(e,t),t}function up(e,t,s){t[$a]===t?t[xn].push({id:e,index:s}):(t[xn]=[{id:e,index:s}],t[$a]=t)}var Xe=Oe("BufferService"),Yc=Oe("CoreMouseService"),ys=Oe("CoreService"),fp=Oe("CharsetService"),vo=Oe("InstantiationService"),Xc=Oe("LogService"),Je=Oe("OptionsService"),Jc=Oe("OscLinkService"),mp=Oe("UnicodeService"),yi=Oe("DecorationService"),vn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var f;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new dt,a=s.getTrimmedLength(),c=-1,h=-1,l=!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,c=o.extended.urlId;continue}else l=o.extended.urlId!==c;else h!==-1&&(l=!0);if(l||h!==-1&&m===a-1){let u=(f=this._oscLinkService.getLinkData(c))==null?void 0:f.uri;if(u){let g={start:{x:h+1,y:e},end:{x:m+(!l&&m===a-1?1:0),y:e}},p=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let _=new URL(u);["http:","https:"].includes(_.protocol)||(p=!0)}catch{p=!0}p||i.push({text:u,range:g,activate:(_,x)=>n?n.activate(_,x,g):pp(_,x),hover:(_,x)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,_,x,g)},leave:(_,x)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,_,x,g)}})}l=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,c=o.extended.urlId):(h=-1,c=-1)}}t(i)}};vn=Ce([q(0,Xe),q(1,Je),q(2,Jc)],vn);function pp(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
184
184
|
|
|
185
|
-
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
|
|
185
|
+
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 Sr=Oe("CharSizeService"),At=Oe("CoreBrowserService"),bo=Oe("MouseService"),It=Oe("RenderService"),_p=Oe("SelectionService"),Zc=Oe("CharacterJoinerService"),Os=Oe("ThemeService"),Qc=Oe("LinkProviderService"),gp=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Fa.isErrorNoTelemetry(e)?new Fa(e.message+`
|
|
186
186
|
|
|
187
187
|
`+e.stack):new Error(e.message+`
|
|
188
188
|
|
|
189
|
-
`+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)}},Qm=new Zm;function Ki(e){ep(e)||Qm.onUnexpectedError(e)}var xn="Canceled";function ep(e){return e instanceof tp?!0:e instanceof Error&&e.name===xn&&e.message===xn}var tp=class extends Error{constructor(){super(xn),this.name=this.message}};function sp(e){return new Error(`Illegal argument: ${e}`)}var Oa=class vn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vn)return t;let s=new vn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},bn=class Gc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Gc.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var ip;(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})(ip||(ip={}));function rp(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Yc;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(S){yield S}e.single=n;function o(S){return t(S)?S:n(S)}e.wrap=o;function a(S){return S||s}e.from=a;function*l(S){for(let w=S.length-1;w>=0;w--)yield S[w]}e.reverse=l;function h(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(S){return S[Symbol.iterator]().next().value}e.first=c;function f(S,w){let j=0;for(let B of S)if(w(B,j++))return!0;return!1}e.some=f;function p(S,w){for(let j of S)if(w(j))return j}e.find=p;function*u(S,w){for(let j of S)w(j)&&(yield j)}e.filter=u;function*g(S,w){let j=0;for(let B of S)yield w(B,j++)}e.map=g;function*m(S,w){let j=0;for(let B of S)yield*w(B,j++)}e.flatMap=m;function*_(...S){for(let w of S)yield*w}e.concat=_;function x(S,w,j){let B=j;for(let M of S)B=w(B,M);return B}e.reduce=x;function*y(S,w,j=S.length){for(w<0&&(w+=S.length),j<0?j+=S.length:j>S.length&&(j=S.length);w<j;w++)yield S[w]}e.slice=y;function b(S,w=Number.POSITIVE_INFINITY){let j=[];if(w===0)return[j,S];let B=S[Symbol.iterator]();for(let M=0;M<w;M++){let Y=B.next();if(Y.done)return[j,e.empty()];j.push(Y.value)}return[j,{[Symbol.iterator](){return B}}]}e.consume=b;async function k(S){let w=[];for await(let j of S)w.push(j);return Promise.resolve(w)}e.asyncToArray=k})(Yc||(Yc={}));function us(e){if(Yc.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 np(...e){return ve(()=>us(e))}function ve(e){return{dispose:rp(()=>{e()})}}var Xc=class Jc{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{us(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?Jc.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)}};Xc.DISABLE_DISPOSED_WARNING=!1;var Gt=Xc,ne=class{constructor(){this._store=new Gt,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 As=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}},Dt=typeof window=="object"?window:globalThis,yn=class Sn{constructor(t){this.element=t,this.next=Sn.Undefined,this.prev=Sn.Undefined}};yn.Undefined=new yn(void 0);var ye=yn,$a=class{constructor(){this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ye.Undefined}clear(){let e=this._first;for(;e!==ye.Undefined;){let t=e.next;e.prev=ye.Undefined,e.next=ye.Undefined,e=t}this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new ye(e);if(this._first===ye.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!==ye.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ye.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ye.Undefined&&e.next!==ye.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ye.Undefined&&e.next===ye.Undefined?(this._first=ye.Undefined,this._last=ye.Undefined):e.next===ye.Undefined?(this._last=this._last.prev,this._last.next=ye.Undefined):e.prev===ye.Undefined&&(this._first=this._first.next,this._first.prev=ye.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ye.Undefined;)yield e.element,e=e.next}},op=globalThis.performance&&typeof globalThis.performance.now=="function",ap=class Zc{static create(t){return new Zc(t)}constructor(t){this._now=op&&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(D,N){return p(D,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function s(D){return(N,L=null,E)=>{let P=!1,U;return U=D(C=>{if(!P)return U?U.dispose():P=!0,N.call(L,C)},null,E),P&&U.dispose(),U}}e.once=s;function i(D,N,L){return c((E,P=null,U)=>D(C=>E.call(P,N(C)),null,U),L)}e.map=i;function n(D,N,L){return c((E,P=null,U)=>D(C=>{N(C),E.call(P,C)},null,U),L)}e.forEach=n;function o(D,N,L){return c((E,P=null,U)=>D(C=>N(C)&&E.call(P,C),null,U),L)}e.filter=o;function a(D){return D}e.signal=a;function l(...D){return(N,L=null,E)=>{let P=np(...D.map(U=>U(C=>N.call(L,C))));return f(P,E)}}e.any=l;function h(D,N,L,E){let P=L;return i(D,U=>(P=N(P,U),P),E)}e.reduce=h;function c(D,N){let L,E={onWillAddFirstListener(){L=D(P.fire,P)},onDidRemoveLastListener(){L==null||L.dispose()}},P=new O(E);return N==null||N.add(P),P.event}function f(D,N){return N instanceof Array?N.push(D):N&&N.add(D),D}function p(D,N,L=100,E=!1,P=!1,U,C){let H,F,K,Q=0,ie,de={leakWarningThreshold:U,onWillAddFirstListener(){H=D(ce=>{Q++,F=N(F,ce),E&&!K&&(ue.fire(F),F=void 0),ie=()=>{let ge=F;F=void 0,K=void 0,(!E||Q>1)&&ue.fire(ge),Q=0},typeof L=="number"?(clearTimeout(K),K=setTimeout(ie,L)):K===void 0&&(K=0,queueMicrotask(ie))})},onWillRemoveListener(){P&&Q>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,H.dispose()}},ue=new O(de);return C==null||C.add(ue),ue.event}e.debounce=p;function u(D,N=0,L){return e.debounce(D,(E,P)=>E?(E.push(P),E):[P],N,void 0,!0,void 0,L)}e.accumulate=u;function g(D,N=(E,P)=>E===P,L){let E=!0,P;return o(D,U=>{let C=E||!N(U,P);return E=!1,P=U,C},L)}e.latch=g;function m(D,N,L){return[e.filter(D,N,L),e.filter(D,E=>!N(E),L)]}e.split=m;function _(D,N=!1,L=[],E){let P=L.slice(),U=D(F=>{P?P.push(F):H.fire(F)});E&&E.add(U);let C=()=>{P==null||P.forEach(F=>H.fire(F)),P=null},H=new O({onWillAddFirstListener(){U||(U=D(F=>H.fire(F)),E&&E.add(U))},onDidAddFirstListener(){P&&(N?setTimeout(C):C())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return E&&E.add(H),H.event}e.buffer=_;function x(D,N){return(L,E,P)=>{let U=N(new b);return D(function(C){let H=U.evaluate(C);H!==y&&L.call(E,H)},void 0,P)}}e.chain=x;let y=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(L=>(N(L),L)),this}filter(N){return this.steps.push(L=>N(L)?L:y),this}reduce(N,L){let E=L;return this.steps.push(P=>(E=N(E,P),E)),this}latch(N=(L,E)=>L===E){let L=!0,E;return this.steps.push(P=>{let U=L||!N(P,E);return L=!1,E=P,U?P:y}),this}evaluate(N){for(let L of this.steps)if(N=L(N),N===y)break;return N}}function k(D,N,L=E=>E){let E=(...H)=>C.fire(L(...H)),P=()=>D.on(N,E),U=()=>D.removeListener(N,E),C=new O({onWillAddFirstListener:P,onDidRemoveLastListener:U});return C.event}e.fromNodeEventEmitter=k;function S(D,N,L=E=>E){let E=(...H)=>C.fire(L(...H)),P=()=>D.addEventListener(N,E),U=()=>D.removeEventListener(N,E),C=new O({onWillAddFirstListener:P,onDidRemoveLastListener:U});return C.event}e.fromDOMEventEmitter=S;function w(D){return new Promise(N=>s(D)(N))}e.toPromise=w;function j(D){let N=new O;return D.then(L=>{N.fire(L)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=j;function B(D,N){return D(L=>N.fire(L))}e.forward=B;function M(D,N,L){return N(L),D(E=>N(E))}e.runAndSubscribe=M;class Y{constructor(N,L){this._observable=N,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new O(E),L&&L.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,L){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function X(D,N){return new Y(D,N).emitter.event}e.fromObservable=X;function $(D){return(N,L,E)=>{let P=0,U=!1,C={beginUpdate(){P++},endUpdate(){P--,P===0&&(D.reportChanges(),U&&(U=!1,N.call(L)))},handlePossibleChange(){},handleChange(){U=!0}};D.addObserver(C),D.reportChanges();let H={dispose(){D.removeObserver(C)}};return E instanceof Gt?E.add(H):Array.isArray(E)&&E.push(H),H}}e.fromObservableLight=$})($e||($e={}));var wn=class Cn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Cn._idPool++}`,Cn.all.add(this)}start(t){this._stopWatch=new ap,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}}};wn.all=new Set,wn._idPool=0;var lp=wn,cp=-1,Qc=class eh{constructor(t,s,i=(eh._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 up(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}};Qc._idPool=1;var hp=Qc,dp=class th{constructor(t){this.value=t}static create(){let t=new Error;return new th(t.stack??"")}print(){console.warn(this.value.split(`
|
|
189
|
+
`+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)}},xp=new gp;function Ki(e){vp(e)||xp.onUnexpectedError(e)}var bn="Canceled";function vp(e){return e instanceof bp?!0:e instanceof Error&&e.name===bn&&e.message===bn}var bp=class extends Error{constructor(){super(bn),this.name=this.message}};function yp(e){return new Error(`Illegal argument: ${e}`)}var Fa=class yn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof yn)return t;let s=new yn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Sn=class eh extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,eh.prototype)}};function it(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 wp(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var th;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(w){yield w}e.single=n;function o(w){return t(w)?w:n(w)}e.wrap=o;function a(w){return w||s}e.from=a;function*c(w){for(let D=w.length-1;D>=0;D--)yield w[D]}e.reverse=c;function h(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(w){return w[Symbol.iterator]().next().value}e.first=l;function f(w,D){let N=0;for(let T of w)if(D(T,N++))return!0;return!1}e.some=f;function m(w,D){for(let N of w)if(D(N))return N}e.find=m;function*u(w,D){for(let N of w)D(N)&&(yield N)}e.filter=u;function*g(w,D){let N=0;for(let T of w)yield D(T,N++)}e.map=g;function*p(w,D){let N=0;for(let T of w)yield*D(T,N++)}e.flatMap=p;function*_(...w){for(let D of w)yield*D}e.concat=_;function x(w,D,N){let T=N;for(let L of w)T=D(T,L);return T}e.reduce=x;function*y(w,D,N=w.length){for(D<0&&(D+=w.length),N<0?N+=w.length:N>w.length&&(N=w.length);D<N;D++)yield w[D]}e.slice=y;function v(w,D=Number.POSITIVE_INFINITY){let N=[];if(D===0)return[N,w];let T=w[Symbol.iterator]();for(let L=0;L<D;L++){let U=T.next();if(U.done)return[N,e.empty()];N.push(U.value)}return[N,{[Symbol.iterator](){return T}}]}e.consume=v;async function k(w){let D=[];for await(let N of w)D.push(N);return Promise.resolve(D)}e.asyncToArray=k})(th||(th={}));function _s(e){if(th.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 Cp(...e){return ve(()=>_s(e))}function ve(e){return{dispose:wp(()=>{e()})}}var sh=class ih{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{_s(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?ih.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)}};sh.DISABLE_DISPOSED_WARNING=!1;var Qt=sh,re=class{constructor(){this._store=new Qt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};re.None=Object.freeze({dispose(){}});var Is=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}},Bt=typeof window=="object"?window:globalThis,wn=class Cn{constructor(t){this.element=t,this.next=Cn.Undefined,this.prev=Cn.Undefined}};wn.Undefined=new wn(void 0);var ye=wn,Ha=class{constructor(){this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ye.Undefined}clear(){let e=this._first;for(;e!==ye.Undefined;){let t=e.next;e.prev=ye.Undefined,e.next=ye.Undefined,e=t}this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new ye(e);if(this._first===ye.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!==ye.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ye.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ye.Undefined&&e.next!==ye.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ye.Undefined&&e.next===ye.Undefined?(this._first=ye.Undefined,this._last=ye.Undefined):e.next===ye.Undefined?(this._last=this._last.prev,this._last.next=ye.Undefined):e.prev===ye.Undefined&&(this._first=this._first.next,this._first.prev=ye.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ye.Undefined;)yield e.element,e=e.next}},kp=globalThis.performance&&typeof globalThis.performance.now=="function",Np=class rh{static create(t){return new rh(t)}constructor(t){this._now=kp&&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}},He;(e=>{e.None=()=>re.None;function t(M,E){return m(M,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(M){return(E,P=null,S)=>{let j=!1,z;return z=M(C=>{if(!j)return z?z.dispose():j=!0,E.call(P,C)},null,S),j&&z.dispose(),z}}e.once=s;function i(M,E,P){return l((S,j=null,z)=>M(C=>S.call(j,E(C)),null,z),P)}e.map=i;function n(M,E,P){return l((S,j=null,z)=>M(C=>{E(C),S.call(j,C)},null,z),P)}e.forEach=n;function o(M,E,P){return l((S,j=null,z)=>M(C=>E(C)&&S.call(j,C),null,z),P)}e.filter=o;function a(M){return M}e.signal=a;function c(...M){return(E,P=null,S)=>{let j=Cp(...M.map(z=>z(C=>E.call(P,C))));return f(j,S)}}e.any=c;function h(M,E,P,S){let j=P;return i(M,z=>(j=E(j,z),j),S)}e.reduce=h;function l(M,E){let P,S={onWillAddFirstListener(){P=M(j.fire,j)},onDidRemoveLastListener(){P==null||P.dispose()}},j=new F(S);return E==null||E.add(j),j.event}function f(M,E){return E instanceof Array?E.push(M):E&&E.add(M),M}function m(M,E,P=100,S=!1,j=!1,z,C){let I,O,K,Z=0,ne,ce={leakWarningThreshold:z,onWillAddFirstListener(){I=M(_e=>{Z++,O=E(O,_e),S&&!K&&(oe.fire(O),O=void 0),ne=()=>{let ue=O;O=void 0,K=void 0,(!S||Z>1)&&oe.fire(ue),Z=0},typeof P=="number"?(clearTimeout(K),K=setTimeout(ne,P)):K===void 0&&(K=0,queueMicrotask(ne))})},onWillRemoveListener(){j&&Z>0&&(ne==null||ne())},onDidRemoveLastListener(){ne=void 0,I.dispose()}},oe=new F(ce);return C==null||C.add(oe),oe.event}e.debounce=m;function u(M,E=0,P){return e.debounce(M,(S,j)=>S?(S.push(j),S):[j],E,void 0,!0,void 0,P)}e.accumulate=u;function g(M,E=(S,j)=>S===j,P){let S=!0,j;return o(M,z=>{let C=S||!E(z,j);return S=!1,j=z,C},P)}e.latch=g;function p(M,E,P){return[e.filter(M,E,P),e.filter(M,S=>!E(S),P)]}e.split=p;function _(M,E=!1,P=[],S){let j=P.slice(),z=M(O=>{j?j.push(O):I.fire(O)});S&&S.add(z);let C=()=>{j==null||j.forEach(O=>I.fire(O)),j=null},I=new F({onWillAddFirstListener(){z||(z=M(O=>I.fire(O)),S&&S.add(z))},onDidAddFirstListener(){j&&(E?setTimeout(C):C())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return S&&S.add(I),I.event}e.buffer=_;function x(M,E){return(P,S,j)=>{let z=E(new v);return M(function(C){let I=z.evaluate(C);I!==y&&P.call(S,I)},void 0,j)}}e.chain=x;let y=Symbol("HaltChainable");class v{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(P=>(E(P),P)),this}filter(E){return this.steps.push(P=>E(P)?P:y),this}reduce(E,P){let S=P;return this.steps.push(j=>(S=E(S,j),S)),this}latch(E=(P,S)=>P===S){let P=!0,S;return this.steps.push(j=>{let z=P||!E(j,S);return P=!1,S=j,z?j:y}),this}evaluate(E){for(let P of this.steps)if(E=P(E),E===y)break;return E}}function k(M,E,P=S=>S){let S=(...I)=>C.fire(P(...I)),j=()=>M.on(E,S),z=()=>M.removeListener(E,S),C=new F({onWillAddFirstListener:j,onDidRemoveLastListener:z});return C.event}e.fromNodeEventEmitter=k;function w(M,E,P=S=>S){let S=(...I)=>C.fire(P(...I)),j=()=>M.addEventListener(E,S),z=()=>M.removeEventListener(E,S),C=new F({onWillAddFirstListener:j,onDidRemoveLastListener:z});return C.event}e.fromDOMEventEmitter=w;function D(M){return new Promise(E=>s(M)(E))}e.toPromise=D;function N(M){let E=new F;return M.then(P=>{E.fire(P)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=N;function T(M,E){return M(P=>E.fire(P))}e.forward=T;function L(M,E,P){return E(P),M(S=>E(S))}e.runAndSubscribe=L;class U{constructor(E,P){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new F(S),P&&P.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,P){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 Y(M,E){return new U(M,E).emitter.event}e.fromObservable=Y;function X(M){return(E,P,S)=>{let j=0,z=!1,C={beginUpdate(){j++},endUpdate(){j--,j===0&&(M.reportChanges(),z&&(z=!1,E.call(P)))},handlePossibleChange(){},handleChange(){z=!0}};M.addObserver(C),M.reportChanges();let I={dispose(){M.removeObserver(C)}};return S instanceof Qt?S.add(I):Array.isArray(S)&&S.push(I),I}}e.fromObservableLight=X})(He||(He={}));var kn=class Nn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Nn._idPool++}`,Nn.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}}};kn.all=new Set,kn._idPool=0;var jp=kn,Ep=-1,nh=class oh{constructor(t,s,i=(oh._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(),c=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(c),console.warn(o);let h=new Lp(c,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}};nh._idPool=1;var Dp=nh,Rp=class ah{constructor(t){this.value=t}static create(){let t=new Error;return new ah(t.stack??"")}print(){console.warn(this.value.split(`
|
|
190
190
|
`).slice(2).join(`
|
|
191
|
-
`))}},up=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},fp=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},mp=0,Or=class{constructor(e){this.value=e,this.id=mp++}},pp=2,_p,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new hp((t==null?void 0:t.onListenerError)??Ki,((i=this._options)==null?void 0:i.leakWarningThreshold)??cp):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new lp(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,f,p;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new fp(`${u}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ki)(m),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new Or(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=dp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Or?(this._deliveryQueue??(this._deliveryQueue=new gp),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,(p=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||p.call(f,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Gt?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*pp<=s.length){let c=0;for(let f=0;f<s.length;f++)s[f]?s[c++]=s[f]: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)||Ki;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 Or)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}},gp=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}},kn=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}};kn.INSTANCE=new kn;var vo=kn;function xp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}vo.INSTANCE.onDidChangeZoomLevel;function vp(e){return vo.INSTANCE.getZoomFactor(e)}vo.INSTANCE.onDidChangeFullscreen;var $s=typeof navigator=="object"?navigator.userAgent:"",Nn=$s.indexOf("Firefox")>=0,bp=$s.indexOf("AppleWebKit")>=0,bo=$s.indexOf("Chrome")>=0,yp=!bo&&$s.indexOf("Safari")>=0;$s.indexOf("Electron/")>=0;$s.indexOf("Android")>=0;var $r=!1;if(typeof Dt.matchMedia=="function"){let e=Dt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Dt.matchMedia("(display-mode: fullscreen)");$r=e.matches,xp(Dt,e,({matches:s})=>{$r&&t.matches||($r=s)})}var Ps="en",jn=!1,En=!1,qi=!1,sh=!1,Ai,Vi=Ps,Ia=Ps,Sp,dt,ns=globalThis,Oe,ql;typeof ns.vscode<"u"&&typeof ns.vscode.process<"u"?Oe=ns.vscode.process:typeof process<"u"&&typeof((ql=process==null?void 0:process.versions)==null?void 0:ql.node)=="string"&&(Oe=process);var Vl,wp=typeof((Vl=Oe==null?void 0:Oe.versions)==null?void 0:Vl.electron)=="string",Cp=wp&&(Oe==null?void 0:Oe.type)==="renderer",Gl;if(typeof Oe=="object"){jn=Oe.platform==="win32",En=Oe.platform==="darwin",qi=Oe.platform==="linux",qi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ai=Ps,Vi=Ps;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ai=t.userLocale,Ia=t.osLocale,Vi=t.resolvedLanguage||Ps,Sp=(Gl=t.languagePack)==null?void 0:Gl.translationsConfigFile}catch{}sh=!0}else typeof navigator=="object"&&!Cp?(dt=navigator.userAgent,jn=dt.indexOf("Windows")>=0,En=dt.indexOf("Macintosh")>=0,(dt.indexOf("Macintosh")>=0||dt.indexOf("iPad")>=0||dt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qi=dt.indexOf("Linux")>=0,(dt==null?void 0:dt.indexOf("Mobi"))>=0,Vi=globalThis._VSCODE_NLS_LANGUAGE||Ps,Ai=navigator.language.toLowerCase(),Ia=Ai):console.error("Unable to resolve platform.");var ih=jn,yt=En,kp=qi,Fa=sh,St=dt,$t=Vi,Np;(e=>{function t(){return $t}e.value=t;function s(){return $t.length===2?$t==="en":$t.length>=3?$t[0]==="e"&&$t[1]==="n"&&$t[2]==="-":!1}e.isDefaultVariant=s;function i(){return $t==="en"}e.isDefault=i})(Np||(Np={}));var jp=typeof ns.postMessage=="function"&&!ns.importScripts;(()=>{if(jp){let e=[];ns.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}),ns.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Ep=!!(St&&St.indexOf("Chrome")>=0);St&&St.indexOf("Firefox")>=0;!Ep&&St&&St.indexOf("Safari")>=0;St&&St.indexOf("Edg/")>=0;St&&St.indexOf("Android")>=0;var ks=typeof navigator=="object"?navigator:{};Fa||document.queryCommandSupported&&document.queryCommandSupported("copy")||ks&&ks.clipboard&&ks.clipboard.writeText,Fa||ks&&ks.clipboard&&ks.clipboard.readText;var yo=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}},Ir=new yo,Ha=new yo,Wa=new yo,Dp=new Array(230),rh;(e=>{function t(l){return Ir.keyCodeToStr(l)}e.toString=t;function s(l){return Ir.strToKeyCode(l)}e.fromString=s;function i(l){return Ha.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Wa.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Ha.strToKeyCode(l)||Wa.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 Ir.keyCodeToStr(l)}e.toElectronAccelerator=a})(rh||(rh={}));var Rp=class nh{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 nh&&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 Pp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Pp=class{constructor(e){if(e.length===0)throw sp("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 Mp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return rh.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Nn)switch(t){case 59:return 85;case 60:if(kp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yt)return 57;break}else if(bp&&(yt&&t===93||!yt&&t===92))return 57;return Dp[t]||0}var Lp=yt?256:2048,Bp=512,Tp=1024,zp=yt?2048:256,Ua=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=Mp(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|=Lp),this.altKey&&(t|=Bp),this.shiftKey&&(t|=Tp),this.metaKey&&(t|=zp),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)}},Ka=new WeakMap;function Ap(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Op=class{static getSameOriginWindowChain(e){let t=Ka.get(e);if(!t){t=[],Ka.set(e,t);let s=e,i;do i=Ap(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,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}}},Oi=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=Op.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},qa=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(bo){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?Nn&&!yt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")yp&&ih?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?Nn&&!yt?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()}},oh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),$p;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Ip?!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:oh})})($p||($p={}));var Ip=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?oh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},So=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 bn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bn("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Fp=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 bn("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}},Hp;(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})(Hp||(Hp={}));var Va=class lt{static fromArray(t){return new lt(s=>{s.emitMany(t)})}static fromPromise(t){return new lt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new lt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new lt(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 lt(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return lt.map(this,t)}static filter(t,s){return new lt(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return lt.filter(this,t)}static coalesce(t){return lt.filter(t,s=>!!s)}coalesce(){return lt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return lt.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())}};Va.EMPTY=Va.fromArray([]);var{getWindow:vt,getWindowId:Wp,onDidRegisterWindow:Up}=(function(){let e=new Map,t={window:Dt,disposables:new Gt};e.set(Dt.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 Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(Z(a,Pe.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:Dt},getDocument(a){return vt(a).document}}})(),Kp=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 Z(e,t,s,i){return new Kp(e,t,s,i)}var Ga=function(e,t,s,i){return Z(e,t,s,i)},wo,qp=class extends Fp{constructor(e){super(),this.defaultTarget=e&&vt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ya=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){Ki(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(Ya.sort),a.shift().execute();i.set(o,!1)};wo=(o,a,l=0)=>{let h=Wp(o),c=new Ya(a,l),f=e.get(h);return f||(f=[],e.set(h,f)),f.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Vp(e){let t=e.getBoundingClientRect(),s=vt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Pe={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"},Gp=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 hi(e){return new Gp(e)}var ah=class{constructor(){this._hooks=new Gt,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=vt(e)}this._hooks.add(Z(o,Pe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Z(o,Pe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Yp(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 pt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(pt||(pt={}));var ti=class Ie extends ne{constructor(){super(),this.dispatched=!1,this.targets=new $a,this.ignoreTargets=new $a,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Up,({window:t,disposables:s})=>{s.add(Z(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Z(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Z(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Dt,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 Dt||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(pt.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-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let f=this.newGestureEvent(pt.Tap,h.initialTarget);f.pageX=st(h.rollingPageX),f.pageY=st(h.rollingPageY),this.dispatchEvent(f)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let f=this.newGestureEvent(pt.Contextmenu,h.initialTarget);f.pageX=st(h.rollingPageX),f.pageY=st(h.rollingPageY),this.dispatchEvent(f)}else if(n===1){let f=st(h.rollingPageX),p=st(h.rollingPageY),u=st(h.rollingTimestamps)-h.rollingTimestamps[0],g=f-h.rollingPageX[0],m=p-h.rollingPageY[0],_=[...this.targets].filter(x=>h.initialTarget instanceof Node&&x.contains(h.initialTarget));this.inertia(t,_,i,Math.abs(g)/u,g>0?1:-1,f,Math.abs(m)/u,m>0?1:-1,p)}this.dispatchEvent(this.newGestureEvent(pt.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===pt.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===pt.Change||t.type===pt.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=wo(t,()=>{let f=Date.now(),p=f-i,u=0,g=0,m=!0;n+=Ie.SCROLL_FRICTION*p,l+=Ie.SCROLL_FRICTION*p,n>0&&(m=!1,u=o*n*p),l>0&&(m=!1,g=h*l*p);let _=this.newGestureEvent(pt.Change);_.translationX=u,_.translationY=g,s.forEach(x=>x.dispatchEvent(_)),m||this.inertia(t,s,f,n,o,a+u,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(pt.Change,a.initialTarget);l.translationX=o.pageX-st(a.rollingPageX),l.translationY=o.pageY-st(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)}};ti.SCROLL_FRICTION=-.005,ti.HOLD_DELAY=700,ti.CLEAR_TAP_COUNT_TIME=400,Ce([Yp],ti,"isTouchDevice",1);var Xp=ti,Co=class extends ne{onclick(e,t){this._register(Z(e,Pe.CLICK,s=>t(new Oi(vt(e),s))))}onmousedown(e,t){this._register(Z(e,Pe.MOUSE_DOWN,s=>t(new Oi(vt(e),s))))}onmouseover(e,t){this._register(Z(e,Pe.MOUSE_OVER,s=>t(new Oi(vt(e),s))))}onmouseleave(e,t){this._register(Z(e,Pe.MOUSE_LEAVE,s=>t(new Oi(vt(e),s))))}onkeydown(e,t){this._register(Z(e,Pe.KEY_DOWN,s=>t(new Ua(s))))}onkeyup(e,t){this._register(Z(e,Pe.KEY_UP,s=>t(new Ua(s))))}oninput(e,t){this._register(Z(e,Pe.INPUT,t))}onblur(e,t){this._register(Z(e,Pe.BLUR,t))}onfocus(e,t){this._register(Z(e,Pe.FOCUS,t))}onchange(e,t){this._register(Z(e,Pe.CHANGE,t))}ignoreGesture(e){return Xp.ignoreTarget(e)}},Xa=11,Jp=class extends Co{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=Xa+"px",this.domNode.style.height=Xa+"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 ah),this._register(Ga(this.bgDomNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ga(this.domNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new qp),this._pointerdownScheduleRepeatTimer=this._register(new So)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,vt(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()}},Zp=class Dn{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 Dn(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 Dn(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}}},Qp=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 Zp(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 Za(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=Za.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)))}},Ja=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Fr(e,t){let s=t-e;return function(i){return e+s*s_(i)}}function e_(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Za=class Rn{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),e_(Fr(t,n),Fr(o,s),.33)}return Fr(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 Ja(i,n,!1)}return new Ja(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Rn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Rn(t,s,n,i)}};function t_(e){return Math.pow(e,3)}function s_(e){return 1-t_(1-e)}var i_=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 So)}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":"")))}},r_=140,lh=class extends Co{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 i_(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ah),this._shouldRender=!0,this.domNode=hi(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(Z(this.domNode.domNode,Pe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Jp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=hi(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(Z(this.slider.domNode,Pe.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=Vp(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(ih&&a>r_){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()}},ch=class Pn{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 Pn(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))),f=(l-c)/(n-i),p=o*f;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:f,computedSliderPosition:Math.round(p)}}_refreshComputedValues(){let t=Pn._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)}},n_=class extends lh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ch(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}},o_=class extends lh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ch(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}},a_=500,Qa=50,l_=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Mn=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(bo){let s=vt(t.browserEvent),i=vp(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 l_(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),f=Math.max(n,a),p=Math.max(o,l);f%h===0&&p%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mn.INSTANCE=new Mn;var c_=Mn,h_=class extends Co{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=u_(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 o_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new n_(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=hi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=hi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=hi(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 So),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=us(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,yt&&(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 qa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=us(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new qa(s))};this._mouseWheelToDispose.push(Z(this._listenOnDomNode,Pe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=c_.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=!yt&&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 f=Qa*o,p=h.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(c,p)}if(a){let f=Qa*a,p=h.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(c,p)}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(),a_)}},d_=class extends h_{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 u_(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,yt&&(t.className+=" mac"),t}var Ln=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 Qp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>wo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new d_(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(`
|
|
192
|
-
`)})),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}};Ln=Ce([q(2,Ge),q(3,Mt),q(4,Wc),q(5,Os),q(6,Ye),q(7,Lt)],Ln);var Bn=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()}};Bn=Ce([q(1,Ge),q(2,Mt),q(3,bi),q(4,Lt)],Bn);var f_=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)}},ft={full:0,left:0,center:0,right:0},It={full:0,left:0,center:0,right:0},Ks={full:0,left:0,center:0,right:0},ar=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 f_,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 f;return(f=this._canvas)==null?void 0:f.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);It.full=this._canvas.width,It.left=e,It.center=t,It.right=e,this._refreshDrawHeightConstants(),Ks.full=1,Ks.left=1,Ks.center=1+It.left,Ks.right=1+It.left+It.center}_refreshDrawHeightConstants(){ft.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);ft.left=t,ft.center=t,ft.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.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(Ks[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ft[e.position||"full"]/2),It[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ft[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}))}};ar=Ce([q(2,Ge),q(3,bi),q(4,Lt),q(5,Ye),q(6,Os),q(7,Mt)],ar);var R;(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=`
|
|
193
|
-
`,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=""))(R||(R={}));var Gi;(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=""))(Gi||(Gi={}));var hh;(e=>e.ST=`${R.ESC}\\`)(hh||(hh={}));var Tn=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(`${R.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)}}};Tn=Ce([q(2,Ge),q(3,Ye),q(4,vs),q(5,Lt)],Tn);var Me=0,Le=0,Be=0,we=0,el={css:"#00000000",rgba:0},je;(e=>{function t(n,o,a,l){return l!==void 0?`#${Qt(n)}${Qt(o)}${Qt(a)}${Qt(l)}`:`#${Qt(n)}${Qt(o)}${Qt(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 _e;(e=>{function t(h,c){if(we=(c.rgba&255)/255,we===1)return{css:c.css,rgba:c.rgba};let f=c.rgba>>24&255,p=c.rgba>>16&255,u=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,_=h.rgba>>8&255;Me=g+Math.round((f-g)*we),Le=m+Math.round((p-m)*we),Be=_+Math.round((u-_)*we);let x=je.toCss(Me,Le,Be),y=je.toRgba(Me,Le,Be);return{css:x,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,f){let p=Yi.ensureContrastRatio(h.rgba,c.rgba,f);if(p)return je.toColor(p>>24&255,p>>16&255,p>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Me,Le,Be]=Yi.toChannels(c),{css:je.toCss(Me,Le,Be),rgba:c}}e.opaque=n;function o(h,c){return we=Math.round(c*255),[Me,Le,Be]=Yi.toChannels(h.rgba),{css:je.toCss(Me,Le,Be,we),rgba:je.toRgba(Me,Le,Be,we)}}e.opacity=o;function a(h,c){return we=h.rgba&255,o(h,we*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(_e||(_e={}));var Se;(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 Me=parseInt(n.slice(1,2).repeat(2),16),Le=parseInt(n.slice(2,3).repeat(2),16),Be=parseInt(n.slice(3,4).repeat(2),16),je.toColor(Me,Le,Be);case 5:return Me=parseInt(n.slice(1,2).repeat(2),16),Le=parseInt(n.slice(2,3).repeat(2),16),Be=parseInt(n.slice(3,4).repeat(2),16),we=parseInt(n.slice(4,5).repeat(2),16),je.toColor(Me,Le,Be,we);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 Me=parseInt(o[1]),Le=parseInt(o[2]),Be=parseInt(o[3]),we=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),je.toColor(Me,Le,Be,we);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),[Me,Le,Be,we]=t.getImageData(0,0,1,1).data,we!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:je.toRgba(Me,Le,Be,we),css:n}}e.toColor=i})(Se||(Se={}));var qe;(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),f=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),p=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+f*.7152+p*.0722}e.relativeLuminance2=s})(qe||(qe={}));var Yi;(e=>{function t(a,l){if(we=(l&255)/255,we===1)return l;let h=l>>24&255,c=l>>16&255,f=l>>8&255,p=a>>24&255,u=a>>16&255,g=a>>8&255;return Me=p+Math.round((h-p)*we),Le=u+Math.round((c-u)*we),Be=g+Math.round((f-g)*we),je.toRgba(Me,Le,Be)}e.blend=t;function s(a,l,h){let c=qe.relativeLuminance(a>>8),f=qe.relativeLuminance(l>>8);if(jt(c,f)<h){if(f<c){let g=i(a,l,h),m=jt(c,qe.relativeLuminance(g>>8));if(m<h){let _=n(a,l,h),x=jt(c,qe.relativeLuminance(_>>8));return m>x?g:_}return g}let p=n(a,l,h),u=jt(c,qe.relativeLuminance(p>>8));if(u<h){let g=i(a,l,h),m=jt(c,qe.relativeLuminance(g>>8));return u>m?p:g}return p}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,f=a>>16&255,p=a>>8&255,u=l>>24&255,g=l>>16&255,m=l>>8&255,_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));for(;_<h&&(u>0||g>0||m>0);)u-=Math.max(0,Math.ceil(u*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));return(u<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,f=a>>16&255,p=a>>8&255,u=l>>24&255,g=l>>16&255,m=l>>8&255,_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));for(;_<h&&(u<255||g<255||m<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));return(u<<24|g<<16|m<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Yi||(Yi={}));function Qt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var m_=class extends vi{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()]}},lr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ht}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 f=this._getJoinedRanges(i,a,o,t,n);for(let p=0;p<f.length;p++)s.push(f[p])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||Ut.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let f=0;f<c.length;f++)s.push(c[f])}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++)lr._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||Ut.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}};lr=Ce([q(0,Ge)],lr);function p_(e){return 57508<=e&&e<=57558}function __(e){return 9472<=e&&e<=9631}function g_(e){return p_(e)||__(e)}function x_(){return{css:{canvas:$i(),cell:$i()},device:{canvas:$i(),cell:$i(),char:{width:0,height:0,left:0,top:0}}}}function $i(){return{width:0,height:0}}var zn=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 ht,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,f){let p=[],u=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let _,x=0,y="",b=0,k=0,S=0,w=0,j=!1,B=0,M=!1,Y=0,X=0,$=[],D=c!==-1&&f!==-1;for(let N=0;N<m;N++){e.loadCell(N,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let E=!1,P=N>=X,U=N,C=this._workCell;if(u.length>0&&N===u[0][0]&&P){let G=u.shift(),oe=this._isCellInSelection(G[0],t);for(b=G[0]+1;b<G[1];b++)P&&(P=oe===this._isCellInSelection(b,t));P&&(P=!s||o<G[0]||o>=G[1]),P?(E=!0,C=new m_(this._workCell,e.translateToString(!0,G[0],G[1]),G[1]-G[0]),U=G[1]-1,L=C.getWidth()):X=G[1]}let H=this._isCellInSelection(N,t),F=s&&N===o,K=D&&N>=c&&N<=f,Q=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,G=>{Q=!0});let ie=C.getChars()||Ut;if(ie===" "&&(C.isUnderline()||C.isOverline())&&(ie=" "),Y=L*l-h.get(ie,C.isBold(),C.isItalic()),!_)_=this._document.createElement("span");else if(x&&(H&&M||!H&&!M&&C.bg===k)&&(H&&M&&g.selectionForeground||C.fg===S)&&C.extended.ext===w&&K===j&&Y===B&&!F&&!E&&!Q&&P){C.isInvisible()?y+=Ut:y+=ie,x++;continue}else x&&(_.textContent=y),_=this._document.createElement("span"),x=0,y="";if(k=C.bg,S=C.fg,w=C.extended.ext,j=K,B=Y,M=H,E&&o>=N&&o<=U&&(o=N),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized){if($.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&$.push("xterm-cursor-blink"),$.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":$.push("xterm-cursor-outline");break;case"block":$.push("xterm-cursor-block");break;case"bar":$.push("xterm-cursor-bar");break;case"underline":$.push("xterm-cursor-underline");break}}if(C.isBold()&&$.push("xterm-bold"),C.isItalic()&&$.push("xterm-italic"),C.isDim()&&$.push("xterm-dim"),C.isInvisible()?y=Ut:y=C.getChars()||Ut,C.isUnderline()&&($.push(`xterm-underline-${C.extended.underlineStyle}`),y===" "&&(y=" "),!C.isUnderlineColorDefault()))if(C.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${vi.toColorRGB(C.getUnderlineColor()).join(",")})`;else{let G=C.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&C.isBold()&&G<8&&(G+=8),_.style.textDecorationColor=g.ansi[G].css}C.isOverline()&&($.push("xterm-overline"),y===" "&&(y=" ")),C.isStrikethrough()&&$.push("xterm-strikethrough"),K&&(_.style.textDecoration="underline");let de=C.getFgColor(),ue=C.getFgColorMode(),ce=C.getBgColor(),ge=C.getBgColorMode(),Fe=!!C.isInverse();if(Fe){let G=de;de=ce,ce=G;let oe=ue;ue=ge,ge=oe}let z,xe,T=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,G=>{G.options.layer!=="top"&&T||(G.backgroundColorRGB&&(ge=50331648,ce=G.backgroundColorRGB.rgba>>8&16777215,z=G.backgroundColorRGB),G.foregroundColorRGB&&(ue=50331648,de=G.foregroundColorRGB.rgba>>8&16777215,xe=G.foregroundColorRGB),T=G.options.layer==="top")}),!T&&H&&(z=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,ce=z.rgba>>8&16777215,ge=50331648,T=!0,g.selectionForeground&&(ue=50331648,de=g.selectionForeground.rgba>>8&16777215,xe=g.selectionForeground)),T&&$.push("xterm-decoration-top");let J;switch(ge){case 16777216:case 33554432:J=g.ansi[ce],$.push(`xterm-bg-${ce}`);break;case 50331648:J=je.toColor(ce>>16,ce>>8&255,ce&255),this._addStyle(_,`background-color:#${tl((ce>>>0).toString(16),"0",6)}`);break;case 0:default:Fe?(J=g.foreground,$.push("xterm-bg-257")):J=g.background}switch(z||C.isDim()&&(z=_e.multiplyOpacity(J,.5)),ue){case 16777216:case 33554432:C.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(_,J,g.ansi[de],C,z,void 0)||$.push(`xterm-fg-${de}`);break;case 50331648:let G=je.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(_,J,G,C,z,xe)||this._addStyle(_,`color:#${tl(de.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,J,g.foreground,C,z,xe)||Fe&&$.push("xterm-fg-257")}$.length&&(_.className=$.join(" "),$.length=0),!F&&!E&&!Q&&P?x++:_.textContent=y,Y!==this.defaultSpacing&&(_.style.letterSpacing=`${Y}px`),p.push(_),N=U}return _&&x&&(_.textContent=y),p}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||g_(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=_e.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]}};zn=Ce([q(1,qc),q(2,Ye),q(3,Mt),q(4,vs),q(5,bi),q(6,Os)],zn);function tl(e,t,s){for(;e.length<s;)e=t+e;return e}var v_=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}},b_=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 y_(){return new b_}var Hr="xterm-dom-renderer-owner-",at="xterm-rows",Ii="xterm-fg-",sl="xterm-bg-",qs="xterm-focus",Fi="xterm-selection",S_=1,An=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,f,p,u,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=f,this._coreService=p,this._coreBrowserService=u,this._themeService=g,this._terminalClass=S_++,this._rowElements=[],this._selectionRenderModel=y_(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(at),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(Fi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=x_(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(zn,document),this._element.classList.add(Hr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(ve(()=>{this._element.classList.remove(Hr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new v_(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} .${at} 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} .${at} { 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} .${at} .xterm-dim { color: ${_e.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} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Ii}${o} { color: ${a.css}; }${this._terminalSelector} .${Ii}${o}.xterm-dim { color: ${_e.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${sl}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Ii}257 { color: ${_e.opaque(e.background).css}; }${this._terminalSelector} .${Ii}257.xterm-dim { color: ${_e.multiplyOpacity(_e.opaque(e.background),.5).css}; }${this._terminalSelector} .${sl}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(qs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(qs),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 f=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,f)),o!==a){let p=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,p))}}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,f=this._rowElements[h],p=s.lines.get(c);if(!f||!p)break;f.replaceChildren(...this._rowFactory.createRow(p,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Hr}${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),f=this._optionsService.rawOptions.cursorBlink,p=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let m=g+l.ydisp,_=this._rowElements[g],x=l.lines.get(m);if(!_||!x)break;_.replaceChildren(...this._rowFactory.createRow(x,m,m===h,p,u,c,f,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===i?t:n)-1:-1))}}};An=Ce([q(7,go),q(8,yr),q(9,Ye),q(10,Ge),q(11,vs),q(12,Mt),q(13,Os)],An);var On=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 C_(this._optionsService))}catch{this._measureStrategy=this._register(new w_(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())}};On=Ce([q(2,Ye)],On);var dh=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)}},w_=class extends dh{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}},C_=class extends dh{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}},k_=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 N_(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(Z(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Z(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}},N_=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new As),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=Z(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)}},j_=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 ko(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 E_(e,t,s,i,n,o,a,l,h){if(!o)return;let c=ko(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 $n=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return E_(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=ko(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])}}};$n=Ce([q(0,Lt),q(1,yr)],$n);var D_=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=[]}},uh={};$m(uh,{getSafariVersion:()=>P_,isChromeOS:()=>_h,isFirefox:()=>fh,isIpad:()=>M_,isIphone:()=>L_,isLegacyEdge:()=>R_,isLinux:()=>No,isMac:()=>cr,isNode:()=>Sr,isSafari:()=>mh,isWindows:()=>ph});var Sr=typeof process<"u"&&"title"in process,yi=Sr?"node":navigator.userAgent,Si=Sr?"node":navigator.platform,fh=yi.includes("Firefox"),R_=yi.includes("Edge"),mh=/^((?!chrome|android).)*safari/i.test(yi);function P_(){if(!mh)return 0;let e=yi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Si),M_=Si==="iPad",L_=Si==="iPhone",ph=["Windows","Win16","Win32","WinCE"].includes(Si),No=Si.indexOf("Linux")>=0,_h=/\bCrOS\b/.test(yi),gh=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()}},B_=class extends gh{_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())}}},T_=class extends gh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},hr=!Sr&&"requestIdleCallback"in window?T_:B_,z_=class{constructor(){this._queue=new hr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},In=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 As),this._pausedResizeTask=new z_,this._observerDisposable=this._register(new As),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 D_((c,f)=>this._renderRows(c,f),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new A_(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()}};In=Ce([q(2,Ye),q(3,yr),q(4,vs),q(5,bi),q(6,Ge),q(7,Mt),q(8,Os)],In);var A_=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function O_(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return F_(n,o,e,t,s,i)+wr(o,t,s,i)+H_(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",mi(Math.abs(n-e),fi(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=I_(o>t?e:n,s)+(l-1)*s.cols+1+$_(o>t?n:e);return mi(h,fi(a,i))}function $_(e,t){return e-1}function I_(e,t){return t.cols-e}function F_(e,t,s,i,n,o){return wr(t,i,n,o).length===0?"":mi(vh(e,t,e,t-fs(t,n),!1,n).length,fi("D",o))}function wr(e,t,s,i){let n=e-fs(e,s),o=t-fs(t,s),a=Math.abs(n-o)-W_(e,t,s);return mi(a,fi(xh(e,t),i))}function H_(e,t,s,i,n,o){let a;wr(t,i,n,o).length>0?a=i-fs(i,n):a=t;let l=i,h=U_(e,t,s,i,n,o);return mi(vh(e,a,s,l,h==="C",n).length,fi(h,o))}function W_(e,t,s){var a;let i=0,n=e-fs(e,s),o=t-fs(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=xh(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function fs(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 U_(e,t,s,i,n,o){let a;return wr(s,i,n,o).length>0?a=i-fs(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function xh(e,t){return e>t?"A":"B"}function vh(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 fi(e,t){let s=t?"O":"[";return R.ESC+s+e}function mi(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var K_=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 il(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 Wr=50,q_=15,V_=50,G_=500,Y_=" ",X_=new RegExp(Y_,"g"),Fn=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 ht,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 K_(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(X_," ")).join(ph?`\r
|
|
191
|
+
`))}},Lp=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Pp=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Mp=0,Or=class{constructor(e){this.value=e,this.id=Mp++}},Bp=2,Tp,F=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new Dp((t==null?void 0:t.onListenerError)??Ki,((i=this._options)==null?void 0:i.leakWarningThreshold)??Ep):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new jp(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 c,h,l,f,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new Pp(`${u}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Ki)(p),re.None}if(this._disposed)return re.None;s&&(t=t.bind(s));let n=new Or(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=Rp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Or?(this._deliveryQueue??(this._deliveryQueue=new zp),this._listeners=[this._listeners,n]):this._listeners.push(n):((l=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||l.call(h,this),this._listeners=n,(m=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||m.call(f,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Qt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,c,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=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||h.call(c,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*Bp<=s.length){let l=0;for(let f=0;f<s.length;f++)s[f]?s[l++]=s[f]:n&&(this._deliveryQueue.end--,l<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=l}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ki;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 Or)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}},zp=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}},jn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new F,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new F,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}};jn.INSTANCE=new jn;var yo=jn;function Ap(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}yo.INSTANCE.onDidChangeZoomLevel;function Ip(e){return yo.INSTANCE.getZoomFactor(e)}yo.INSTANCE.onDidChangeFullscreen;var $s=typeof navigator=="object"?navigator.userAgent:"",En=$s.indexOf("Firefox")>=0,Op=$s.indexOf("AppleWebKit")>=0,So=$s.indexOf("Chrome")>=0,$p=!So&&$s.indexOf("Safari")>=0;$s.indexOf("Electron/")>=0;$s.indexOf("Android")>=0;var $r=!1;if(typeof Bt.matchMedia=="function"){let e=Bt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Bt.matchMedia("(display-mode: fullscreen)");$r=e.matches,Ap(Bt,e,({matches:s})=>{$r&&t.matches||($r=s)})}var Bs="en",Dn=!1,Rn=!1,qi=!1,lh=!1,Ii,Vi=Bs,Wa=Bs,Fp,ut,us=globalThis,Fe,Yl;typeof us.vscode<"u"&&typeof us.vscode.process<"u"?Fe=us.vscode.process:typeof process<"u"&&typeof((Yl=process==null?void 0:process.versions)==null?void 0:Yl.node)=="string"&&(Fe=process);var Xl,Hp=typeof((Xl=Fe==null?void 0:Fe.versions)==null?void 0:Xl.electron)=="string",Wp=Hp&&(Fe==null?void 0:Fe.type)==="renderer",Jl;if(typeof Fe=="object"){Dn=Fe.platform==="win32",Rn=Fe.platform==="darwin",qi=Fe.platform==="linux",qi&&Fe.env.SNAP&&Fe.env.SNAP_REVISION,Fe.env.CI||Fe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ii=Bs,Vi=Bs;let e=Fe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ii=t.userLocale,Wa=t.osLocale,Vi=t.resolvedLanguage||Bs,Fp=(Jl=t.languagePack)==null?void 0:Jl.translationsConfigFile}catch{}lh=!0}else typeof navigator=="object"&&!Wp?(ut=navigator.userAgent,Dn=ut.indexOf("Windows")>=0,Rn=ut.indexOf("Macintosh")>=0,(ut.indexOf("Macintosh")>=0||ut.indexOf("iPad")>=0||ut.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qi=ut.indexOf("Linux")>=0,(ut==null?void 0:ut.indexOf("Mobi"))>=0,Vi=globalThis._VSCODE_NLS_LANGUAGE||Bs,Ii=navigator.language.toLowerCase(),Wa=Ii):console.error("Unable to resolve platform.");var ch=Dn,kt=Rn,Up=qi,Ua=lh,jt=ut,Ut=Vi,Kp;(e=>{function t(){return Ut}e.value=t;function s(){return Ut.length===2?Ut==="en":Ut.length>=3?Ut[0]==="e"&&Ut[1]==="n"&&Ut[2]==="-":!1}e.isDefaultVariant=s;function i(){return Ut==="en"}e.isDefault=i})(Kp||(Kp={}));var qp=typeof us.postMessage=="function"&&!us.importScripts;(()=>{if(qp){let e=[];us.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}),us.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Vp=!!(jt&&jt.indexOf("Chrome")>=0);jt&&jt.indexOf("Firefox")>=0;!Vp&&jt&&jt.indexOf("Safari")>=0;jt&&jt.indexOf("Edg/")>=0;jt&&jt.indexOf("Android")>=0;var js=typeof navigator=="object"?navigator:{};Ua||document.queryCommandSupported&&document.queryCommandSupported("copy")||js&&js.clipboard&&js.clipboard.writeText,Ua||js&&js.clipboard&&js.clipboard.readText;var wo=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}},Fr=new wo,Ka=new wo,qa=new wo,Gp=new Array(230),hh;(e=>{function t(c){return Fr.keyCodeToStr(c)}e.toString=t;function s(c){return Fr.strToKeyCode(c)}e.fromString=s;function i(c){return Ka.keyCodeToStr(c)}e.toUserSettingsUS=i;function n(c){return qa.keyCodeToStr(c)}e.toUserSettingsGeneral=n;function o(c){return Ka.strToKeyCode(c)||qa.strToKeyCode(c)}e.fromUserSettings=o;function a(c){if(c>=98&&c<=113)return null;switch(c){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Fr.keyCodeToStr(c)}e.toElectronAccelerator=a})(hh||(hh={}));var Yp=class dh{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 dh&&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 Xp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Xp=class{constructor(e){if(e.length===0)throw yp("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 Jp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return hh.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(En)switch(t){case 59:return 85;case 60:if(Up)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(kt)return 57;break}else if(Op&&(kt&&t===93||!kt&&t===92))return 57;return Gp[t]||0}var Zp=kt?256:2048,Qp=512,e_=1024,t_=kt?2048:256,Va=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=Jp(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|=Zp),this.altKey&&(t|=Qp),this.shiftKey&&(t|=e_),this.metaKey&&(t|=t_),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Yp(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ga=new WeakMap;function s_(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 i_=class{static getSameOriginWindowChain(e){let t=Ga.get(e);if(!t){t=[],Ga.set(e,t);let s=e,i;do i=s_(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 c=o.iframeElement.getBoundingClientRect();s+=c.top,i+=c.left}return{top:s,left:i}}},Oi=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=i_.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ya=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(So){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,c=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*c):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?En&&!kt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")$p&&ch?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*c):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?En&&!kt?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*c):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},uh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),r_;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof n_?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:He.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:uh})})(r_||(r_={}));var n_=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?uh:(this._emitter||(this._emitter=new F),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Co=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 Sn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Sn("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},o_=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 Sn("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}},a_;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(c=>c,c=>{n||(n=c)})));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})(a_||(a_={}));var Xa=class ct{static fromArray(t){return new ct(s=>{s.emitMany(t)})}static fromPromise(t){return new ct(async s=>{s.emitMany(await t)})}static fromPromises(t){return new ct(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new ct(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 F,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 He.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 ct(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return ct.map(this,t)}static filter(t,s){return new ct(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return ct.filter(this,t)}static coalesce(t){return ct.filter(t,s=>!!s)}coalesce(){return ct.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return ct.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())}};Xa.EMPTY=Xa.fromArray([]);var{getWindow:yt,getWindowId:l_,onDidRegisterWindow:c_}=(function(){let e=new Map,t={window:Bt,disposables:new Qt};e.set(Bt.vscodeWindowId,t);let s=new F,i=new F,n=new F;function o(a,c){return(typeof a=="number"?e.get(a):void 0)??(c?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return re.None;let c=new Qt,h={window:a,disposables:c.add(new Qt)};return e.set(a.vscodeWindowId,h),c.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),c.add(Q(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),c},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var l;let c=a;if((l=c==null?void 0:c.ownerDocument)!=null&&l.defaultView)return c.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Bt},getDocument(a){return yt(a).document}}})(),h_=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 Q(e,t,s,i){return new h_(e,t,s,i)}var Ja=function(e,t,s,i){return Q(e,t,s,i)},ko,d_=class extends o_{constructor(e){super(),this.defaultTarget=e&&yt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Za=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){Ki(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(Za.sort),a.shift().execute();i.set(o,!1)};ko=(o,a,c=0)=>{let h=l_(o),l=new Za(a,c),f=e.get(h);return f||(f=[],e.set(h,f)),f.push(l),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),l}})();function u_(e){let t=e.getBoundingClientRect(),s=yt(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"},f_=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=tt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=tt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=tt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=tt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=tt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=tt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=tt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=tt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=tt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=tt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=tt(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=tt(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=tt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=tt(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 tt(e){return typeof e=="number"?`${e}px`:e}function hi(e){return new f_(e)}var fh=class{constructor(){this._hooks=new Qt,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=yt(e)}this._hooks.add(Q(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Q(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function m_(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 gt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(gt||(gt={}));var ti=class We extends re{constructor(){super(),this.dispatched=!1,this.targets=new Ha,this.ignoreTargets=new Ha,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(He.runAndSubscribe(c_,({window:t,disposables:s})=>{s.add(Q(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Q(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Q(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Bt,disposables:this._store}))}static addTarget(t){if(!We.isTouchDevice())return re.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!We.isTouchDevice())return re.None;We.INSTANCE||(We.INSTANCE=new We);let s=We.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Bt||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(gt.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 c=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("move of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],l=Date.now()-h.initialTimeStamp;if(l<We.HOLD_DELAY&&Math.abs(h.initialPageX-it(h.rollingPageX))<30&&Math.abs(h.initialPageY-it(h.rollingPageY))<30){let f=this.newGestureEvent(gt.Tap,h.initialTarget);f.pageX=it(h.rollingPageX),f.pageY=it(h.rollingPageY),this.dispatchEvent(f)}else if(l>=We.HOLD_DELAY&&Math.abs(h.initialPageX-it(h.rollingPageX))<30&&Math.abs(h.initialPageY-it(h.rollingPageY))<30){let f=this.newGestureEvent(gt.Contextmenu,h.initialTarget);f.pageX=it(h.rollingPageX),f.pageY=it(h.rollingPageY),this.dispatchEvent(f)}else if(n===1){let f=it(h.rollingPageX),m=it(h.rollingPageY),u=it(h.rollingTimestamps)-h.rollingTimestamps[0],g=f-h.rollingPageX[0],p=m-h.rollingPageY[0],_=[...this.targets].filter(x=>h.initialTarget instanceof Node&&x.contains(h.initialTarget));this.inertia(t,_,i,Math.abs(g)/u,g>0?1:-1,f,Math.abs(p)/u,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(gt.End,h.initialTarget)),delete this.activeTouches[c.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===gt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>We.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===gt.Change||t.type===gt.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,c,h,l){this.handle=ko(t,()=>{let f=Date.now(),m=f-i,u=0,g=0,p=!0;n+=We.SCROLL_FRICTION*m,c+=We.SCROLL_FRICTION*m,n>0&&(p=!1,u=o*n*m),c>0&&(p=!1,g=h*c*m);let _=this.newGestureEvent(gt.Change);_.translationX=u,_.translationY=g,s.forEach(x=>x.dispatchEvent(_)),p||this.inertia(t,s,f,n,o,a+u,c,h,l+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],c=this.newGestureEvent(gt.Change,a.initialTarget);c.translationX=o.pageX-it(a.rollingPageX),c.translationY=o.pageY-it(a.rollingPageY),c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c),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)}};ti.SCROLL_FRICTION=-.005,ti.HOLD_DELAY=700,ti.CLEAR_TAP_COUNT_TIME=400,Ce([m_],ti,"isTouchDevice",1);var p_=ti,No=class extends re{onclick(e,t){this._register(Q(e,Me.CLICK,s=>t(new Oi(yt(e),s))))}onmousedown(e,t){this._register(Q(e,Me.MOUSE_DOWN,s=>t(new Oi(yt(e),s))))}onmouseover(e,t){this._register(Q(e,Me.MOUSE_OVER,s=>t(new Oi(yt(e),s))))}onmouseleave(e,t){this._register(Q(e,Me.MOUSE_LEAVE,s=>t(new Oi(yt(e),s))))}onkeydown(e,t){this._register(Q(e,Me.KEY_DOWN,s=>t(new Va(s))))}onkeyup(e,t){this._register(Q(e,Me.KEY_UP,s=>t(new Va(s))))}oninput(e,t){this._register(Q(e,Me.INPUT,t))}onblur(e,t){this._register(Q(e,Me.BLUR,t))}onfocus(e,t){this._register(Q(e,Me.FOCUS,t))}onchange(e,t){this._register(Q(e,Me.CHANGE,t))}ignoreGesture(e){return p_.ignoreTarget(e)}},Qa=11,__=class extends No{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=Qa+"px",this.domNode.style.height=Qa+"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 fh),this._register(Ja(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ja(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new d_),this._pointerdownScheduleRepeatTimer=this._register(new Co)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,yt(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()}},g_=class Ln{constructor(t,s,i,n,o,a,c){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,c=c|0),this.rawScrollLeft=n,this.rawScrollTop=c,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),c+o>a&&(c=a-o),c<0&&(c=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=c}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 Ln(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 Ln(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,c=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:c,scrollTopChanged:h}}},x_=class extends re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new F),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new g_(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 tl(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=tl.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)))}},el=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Hr(e,t){let s=t-e;return function(i){return e+s*y_(i)}}function v_(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var tl=class Pn{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),v_(Hr(t,n),Hr(o,s),.33)}return Hr(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 el(i,n,!1)}return new el(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Pn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Pn(t,s,n,i)}};function b_(e){return Math.pow(e,3)}function y_(e){return 1-b_(1-e)}var S_=class extends re{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Co)}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":"")))}},w_=140,mh=class extends No{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 fh),this._shouldRender=!0,this.domNode=hi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Q(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new __(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=hi(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(Q(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=u_(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(ch&&a>w_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let c=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(c))},()=>{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()}},ph=class Mn{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 Mn(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),c=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*c/n))),f=(c-l)/(n-i),m=o*f;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:f,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=Mn._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)}},C_=class extends mh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ph(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}},k_=class extends mh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ph(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,sl=50,j_=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Bn=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(So){let s=yt(t.browserEvent),i=Ip(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 j_(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),c=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),l=Math.max(Math.min(o,c),1),f=Math.max(n,a),m=Math.max(o,c);f%h===0&&m%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Bn.INSTANCE=new Bn;var E_=Bn,D_=class extends No{constructor(e,t,s){super(),this._onScroll=this._register(new F),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new F),this.onWillScroll=this._onWillScroll.event,this._options=L_(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 k_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new C_(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=hi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=hi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=hi(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 Co),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=_s(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,kt&&(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 Ya(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=_s(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Ya(s))};this._mouseWheelToDispose.push(Q(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=E_.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 c=!kt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||c)&&!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(),l={};if(o){let f=sl*o,m=h.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(l,m)}if(a){let f=sl*a,m=h.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(l,m)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),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_)}},R_=class extends D_{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 L_(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,kt&&(t.className+=" mac"),t}var Tn=class extends re{constructor(e,t,s,i,n,o,a,c){super(),this._bufferService=s,this._optionsService=a,this._renderService=c,this._onRequestScrollLines=this._register(new F),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new x_({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>ko(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new R_(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(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(He.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(He.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(`
|
|
192
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Tn=Ce([q(2,Xe),q(3,At),q(4,Yc),q(5,Os),q(6,Je),q(7,It)],Tn);var zn=class extends re{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()}};zn=Ce([q(1,Xe),q(2,At),q(3,yi),q(4,It)],zn);var P_=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)}},pt={full:0,left:0,center:0,right:0},Kt={full:0,left:0,center:0,right:0},qs={full:0,left:0,center:0,right:0},ar=class extends re{constructor(e,t,s,i,n,o,a,c){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=c,this._colorZoneStore=new P_,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var f;return(f=this._canvas)==null?void 0:f.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);Kt.full=this._canvas.width,Kt.left=e,Kt.center=t,Kt.right=e,this._refreshDrawHeightConstants(),qs.full=1,qs.left=1,qs.center=1+Kt.left,qs.right=1+Kt.left+Kt.center}_refreshDrawHeightConstants(){pt.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);pt.left=t,pt.center=t,pt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pt.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(qs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-pt[e.position||"full"]/2),Kt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+pt[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}))}};ar=Ce([q(2,Xe),q(3,yi),q(4,It),q(5,Je),q(6,Os),q(7,At)],ar);var R;(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=`
|
|
193
|
+
`,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=""))(R||(R={}));var Gi;(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=""))(Gi||(Gi={}));var _h;(e=>e.ST=`${R.ESC}\\`)(_h||(_h={}));var An=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(`${R.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)}}};An=Ce([q(2,Xe),q(3,Je),q(4,ys),q(5,It)],An);var Te=0,ze=0,Ae=0,we=0,il={css:"#00000000",rgba:0},Ee;(e=>{function t(n,o,a,c){return c!==void 0?`#${os(n)}${os(o)}${os(a)}${os(c)}`:`#${os(n)}${os(o)}${os(a)}`}e.toCss=t;function s(n,o,a,c=255){return(n<<24|o<<16|a<<8|c)>>>0}e.toRgba=s;function i(n,o,a,c){return{css:e.toCss(n,o,a,c),rgba:e.toRgba(n,o,a,c)}}e.toColor=i})(Ee||(Ee={}));var xe;(e=>{function t(h,l){if(we=(l.rgba&255)/255,we===1)return{css:l.css,rgba:l.rgba};let f=l.rgba>>24&255,m=l.rgba>>16&255,u=l.rgba>>8&255,g=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255;Te=g+Math.round((f-g)*we),ze=p+Math.round((m-p)*we),Ae=_+Math.round((u-_)*we);let x=Ee.toCss(Te,ze,Ae),y=Ee.toRgba(Te,ze,Ae);return{css:x,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,l,f){let m=Yi.ensureContrastRatio(h.rgba,l.rgba,f);if(m)return Ee.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let l=(h.rgba|255)>>>0;return[Te,ze,Ae]=Yi.toChannels(l),{css:Ee.toCss(Te,ze,Ae),rgba:l}}e.opaque=n;function o(h,l){return we=Math.round(l*255),[Te,ze,Ae]=Yi.toChannels(h.rgba),{css:Ee.toCss(Te,ze,Ae,we),rgba:Ee.toRgba(Te,ze,Ae,we)}}e.opacity=o;function a(h,l){return we=h.rgba&255,o(h,we*l/255)}e.multiplyOpacity=a;function c(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=c})(xe||(xe={}));var Se;(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 Te=parseInt(n.slice(1,2).repeat(2),16),ze=parseInt(n.slice(2,3).repeat(2),16),Ae=parseInt(n.slice(3,4).repeat(2),16),Ee.toColor(Te,ze,Ae);case 5:return Te=parseInt(n.slice(1,2).repeat(2),16),ze=parseInt(n.slice(2,3).repeat(2),16),Ae=parseInt(n.slice(3,4).repeat(2),16),we=parseInt(n.slice(4,5).repeat(2),16),Ee.toColor(Te,ze,Ae,we);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 Te=parseInt(o[1]),ze=parseInt(o[2]),Ae=parseInt(o[3]),we=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ee.toColor(Te,ze,Ae,we);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),[Te,ze,Ae,we]=t.getImageData(0,0,1,1).data,we!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ee.toRgba(Te,ze,Ae,we),css:n}}e.toColor=i})(Se||(Se={}));var Ye;(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,c=n/255,h=o/255,l=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+f*.7152+m*.0722}e.relativeLuminance2=s})(Ye||(Ye={}));var Yi;(e=>{function t(a,c){if(we=(c&255)/255,we===1)return c;let h=c>>24&255,l=c>>16&255,f=c>>8&255,m=a>>24&255,u=a>>16&255,g=a>>8&255;return Te=m+Math.round((h-m)*we),ze=u+Math.round((l-u)*we),Ae=g+Math.round((f-g)*we),Ee.toRgba(Te,ze,Ae)}e.blend=t;function s(a,c,h){let l=Ye.relativeLuminance(a>>8),f=Ye.relativeLuminance(c>>8);if(Pt(l,f)<h){if(f<l){let g=i(a,c,h),p=Pt(l,Ye.relativeLuminance(g>>8));if(p<h){let _=n(a,c,h),x=Pt(l,Ye.relativeLuminance(_>>8));return p>x?g:_}return g}let m=n(a,c,h),u=Pt(l,Ye.relativeLuminance(m>>8));if(u<h){let g=i(a,c,h),p=Pt(l,Ye.relativeLuminance(g>>8));return u>p?m:g}return m}}e.ensureContrastRatio=s;function i(a,c,h){let l=a>>24&255,f=a>>16&255,m=a>>8&255,u=c>>24&255,g=c>>16&255,p=c>>8&255,_=Pt(Ye.relativeLuminance2(u,g,p),Ye.relativeLuminance2(l,f,m));for(;_<h&&(u>0||g>0||p>0);)u-=Math.max(0,Math.ceil(u*.1)),g-=Math.max(0,Math.ceil(g*.1)),p-=Math.max(0,Math.ceil(p*.1)),_=Pt(Ye.relativeLuminance2(u,g,p),Ye.relativeLuminance2(l,f,m));return(u<<24|g<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,c,h){let l=a>>24&255,f=a>>16&255,m=a>>8&255,u=c>>24&255,g=c>>16&255,p=c>>8&255,_=Pt(Ye.relativeLuminance2(u,g,p),Ye.relativeLuminance2(l,f,m));for(;_<h&&(u<255||g<255||p<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),_=Pt(Ye.relativeLuminance2(u,g,p),Ye.relativeLuminance2(l,f,m));return(u<<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})(Yi||(Yi={}));function os(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Pt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var M_=class extends bi{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()]}},lr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new dt}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,c=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==h){if(l-n>1){let f=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<f.length;m++)s.push(f[m])}n=l,a=o,c=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||Yt.length}if(this._bufferService.cols-n>1){let l=this._getJoinedRanges(i,a,o,t,n);for(let f=0;f<l.length;f++)s.push(l[f])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(c){console.error(c)}for(let c=1;c<this._characterJoiners.length;c++)try{let h=this._characterJoiners[c].handler(o);for(let l=0;l<h.length;l++)lr._mergeRanges(a,h[l])}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 c=s;c<this._bufferService.cols;c++){let h=t.getWidth(c),l=t.getString(c).length||Yt.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=c,n=!0),a[1]<=o){if(a[1]=c,a=e[++i],!a)break;a[0]<=o?(a[0]=c,n=!0):n=!1}o+=l}}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}};lr=Ce([q(0,Xe)],lr);function B_(e){return 57508<=e&&e<=57558}function T_(e){return 9472<=e&&e<=9631}function z_(e){return B_(e)||T_(e)}function A_(){return{css:{canvas:$i(),cell:$i()},device:{canvas:$i(),cell:$i(),char:{width:0,height:0,left:0,top:0}}}}function $i(){return{width:0,height:0}}var In=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 dt,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,c,h,l,f){let m=[],u=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let _,x=0,y="",v=0,k=0,w=0,D=0,N=!1,T=0,L=!1,U=0,Y=0,X=[],M=l!==-1&&f!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let S=!1,j=E>=Y,z=E,C=this._workCell;if(u.length>0&&E===u[0][0]&&j){let G=u.shift(),ae=this._isCellInSelection(G[0],t);for(v=G[0]+1;v<G[1];v++)j&&(j=ae===this._isCellInSelection(v,t));j&&(j=!s||o<G[0]||o>=G[1]),j?(S=!0,C=new M_(this._workCell,e.translateToString(!0,G[0],G[1]),G[1]-G[0]),z=G[1]-1,P=C.getWidth()):Y=G[1]}let I=this._isCellInSelection(E,t),O=s&&E===o,K=M&&E>=l&&E<=f,Z=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,G=>{Z=!0});let ne=C.getChars()||Yt;if(ne===" "&&(C.isUnderline()||C.isOverline())&&(ne=" "),U=P*c-h.get(ne,C.isBold(),C.isItalic()),!_)_=this._document.createElement("span");else if(x&&(I&&L||!I&&!L&&C.bg===k)&&(I&&L&&g.selectionForeground||C.fg===w)&&C.extended.ext===D&&K===N&&U===T&&!O&&!S&&!Z&&j){C.isInvisible()?y+=Yt:y+=ne,x++;continue}else x&&(_.textContent=y),_=this._document.createElement("span"),x=0,y="";if(k=C.bg,w=C.fg,D=C.extended.ext,N=K,T=U,L=I,S&&o>=E&&o<=z&&(o=E),!this._coreService.isCursorHidden&&O&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&X.push("xterm-cursor-blink"),X.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(C.isBold()&&X.push("xterm-bold"),C.isItalic()&&X.push("xterm-italic"),C.isDim()&&X.push("xterm-dim"),C.isInvisible()?y=Yt:y=C.getChars()||Yt,C.isUnderline()&&(X.push(`xterm-underline-${C.extended.underlineStyle}`),y===" "&&(y=" "),!C.isUnderlineColorDefault()))if(C.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${bi.toColorRGB(C.getUnderlineColor()).join(",")})`;else{let G=C.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&C.isBold()&&G<8&&(G+=8),_.style.textDecorationColor=g.ansi[G].css}C.isOverline()&&(X.push("xterm-overline"),y===" "&&(y=" ")),C.isStrikethrough()&&X.push("xterm-strikethrough"),K&&(_.style.textDecoration="underline");let ce=C.getFgColor(),oe=C.getFgColorMode(),_e=C.getBgColor(),ue=C.getBgColorMode(),De=!!C.isInverse();if(De){let G=ce;ce=_e,_e=G;let ae=oe;oe=ue,ue=ae}let A,pe,B=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,G=>{G.options.layer!=="top"&&B||(G.backgroundColorRGB&&(ue=50331648,_e=G.backgroundColorRGB.rgba>>8&16777215,A=G.backgroundColorRGB),G.foregroundColorRGB&&(oe=50331648,ce=G.foregroundColorRGB.rgba>>8&16777215,pe=G.foregroundColorRGB),B=G.options.layer==="top")}),!B&&I&&(A=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,_e=A.rgba>>8&16777215,ue=50331648,B=!0,g.selectionForeground&&(oe=50331648,ce=g.selectionForeground.rgba>>8&16777215,pe=g.selectionForeground)),B&&X.push("xterm-decoration-top");let J;switch(ue){case 16777216:case 33554432:J=g.ansi[_e],X.push(`xterm-bg-${_e}`);break;case 50331648:J=Ee.toColor(_e>>16,_e>>8&255,_e&255),this._addStyle(_,`background-color:#${rl((_e>>>0).toString(16),"0",6)}`);break;case 0:default:De?(J=g.foreground,X.push("xterm-bg-257")):J=g.background}switch(A||C.isDim()&&(A=xe.multiplyOpacity(J,.5)),oe){case 16777216:case 33554432:C.isBold()&&ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ce+=8),this._applyMinimumContrast(_,J,g.ansi[ce],C,A,void 0)||X.push(`xterm-fg-${ce}`);break;case 50331648:let G=Ee.toColor(ce>>16&255,ce>>8&255,ce&255);this._applyMinimumContrast(_,J,G,C,A,pe)||this._addStyle(_,`color:#${rl(ce.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,J,g.foreground,C,A,pe)||De&&X.push("xterm-fg-257")}X.length&&(_.className=X.join(" "),X.length=0),!O&&!S&&!Z&&j?x++:_.textContent=y,U!==this.defaultSpacing&&(_.style.letterSpacing=`${U}px`),m.push(_),E=z}return _&&x&&(_.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||z_(i.getCode()))return!1;let a=this._getContrastCache(i),c;if(!n&&!o&&(c=a.getColor(t.rgba,s.rgba)),c===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);c=xe.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,c??null)}return c?(this._addStyle(e,`color:${c.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]}};In=Ce([q(1,Zc),q(2,Je),q(3,At),q(4,ys),q(5,yi),q(6,Os)],In);function rl(e,t,s){for(;e.length<s;)e=t+e;return e}var I_=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}},O_=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,c=Math.max(o,0),h=Math.min(a,e.rows-1);if(c>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=c,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 $_(){return new O_}var Wr="xterm-dom-renderer-owner-",lt="xterm-rows",Fi="xterm-fg-",nl="xterm-bg-",Vs="xterm-focus",Hi="xterm-selection",F_=1,On=class extends re{constructor(e,t,s,i,n,o,a,c,h,l,f,m,u,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=l,this._bufferService=f,this._coreService=m,this._coreBrowserService=u,this._themeService=g,this._terminalClass=F_++,this._rowElements=[],this._selectionRenderModel=$_(),this.onRequestRedraw=this._register(new F).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(lt),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(Hi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=A_(),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=c.createInstance(In,document),this._element.classList.add(Wr+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(Wr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new I_(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} .${lt} 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} .${lt} { 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} .${lt} .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} .${lt}.${Vs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${lt}.${Vs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${lt}.${Vs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${lt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Hi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Hi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Hi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Fi}${o} { color: ${a.css}; }${this._terminalSelector} .${Fi}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${nl}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Fi}257 { color: ${xe.opaque(e.background).css}; }${this._terminalSelector} .${Fi}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${nl}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(Vs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vs),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,c=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];c.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,l=o===n?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(o,h,l));let f=a-o-1;if(c.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,f)),o!==a){let m=n===a?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(c)}_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,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+s.ydisp,f=this._rowElements[h],m=s.lines.get(l);if(!f||!m)break;f.replaceChildren(...this._rowFactory.createRow(m,l,l===i,a,c,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Wr}${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 c=this._bufferService.buffer,h=c.ybase+c.y,l=Math.min(c.x,n-1),f=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let p=g+c.ydisp,_=this._rowElements[g],x=c.lines.get(p);if(!_||!x)break;_.replaceChildren(...this._rowFactory.createRow(x,p,p===h,m,u,l,f,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===i?t:n)-1:-1))}}};On=Ce([q(7,vo),q(8,Sr),q(9,Je),q(10,Xe),q(11,ys),q(12,At),q(13,Os)],On);var $n=class extends re{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new F),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new W_(this._optionsService))}catch{this._measureStrategy=this._register(new H_(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())}};$n=Ce([q(2,Je)],$n);var gh=class extends re{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},H_=class extends gh{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 gh{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}},U_=class extends re{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new K_(this._window)),this._onDprChange=this._register(new F),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new F),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(He.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Q(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Q(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},K_=class extends re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Is),this._onDprChange=this._register(new F),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=Q(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},q_=class extends re{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 jo(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 V_(e,t,s,i,n,o,a,c,h){if(!o)return;let l=jo(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(h?a/2:0))/a),l[1]=Math.ceil(l[1]/c),l[0]=Math.min(Math.max(l[0],1),i+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),n),l}var Fn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return V_(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=jo(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])}}};Fn=Ce([q(0,It),q(1,Sr)],Fn);var G_=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=[]}},xh={};rp(xh,{getSafariVersion:()=>X_,isChromeOS:()=>Sh,isFirefox:()=>vh,isIpad:()=>J_,isIphone:()=>Z_,isLegacyEdge:()=>Y_,isLinux:()=>Eo,isMac:()=>cr,isNode:()=>wr,isSafari:()=>bh,isWindows:()=>yh});var wr=typeof process<"u"&&"title"in process,Si=wr?"node":navigator.userAgent,wi=wr?"node":navigator.platform,vh=Si.includes("Firefox"),Y_=Si.includes("Edge"),bh=/^((?!chrome|android).)*safari/i.test(Si);function X_(){if(!bh)return 0;let e=Si.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(wi),J_=wi==="iPad",Z_=wi==="iPhone",yh=["Windows","Win16","Win32","WinCE"].includes(wi),Eo=wi.indexOf("Linux")>=0,Sh=/\bCrOS\b/.test(Si),wh=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()}},Q_=class extends wh{_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())}}},eg=class extends wh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},hr=!wr&&"requestIdleCallback"in window?eg:Q_,tg=class{constructor(){this._queue=new hr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Hn=class extends re{constructor(e,t,s,i,n,o,a,c,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=c,this._renderer=this._register(new Is),this._pausedResizeTask=new tg,this._observerDisposable=this._register(new Is),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 F),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new F),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new F),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new F),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new G_((l,f)=>this._renderRows(l,f),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new sg(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 l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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(l=>this._registerIntersectionObserver(l,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()}};Hn=Ce([q(2,Je),q(3,Sr),q(4,ys),q(5,yi),q(6,Xe),q(7,At),q(8,Os)],Hn);var sg=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 ig(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return og(n,o,e,t,s,i)+Cr(o,t,s,i)+ag(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",pi(Math.abs(n-e),mi(a,i));a=o>t?"D":"C";let c=Math.abs(o-t),h=ng(o>t?e:n,s)+(c-1)*s.cols+1+rg(o>t?n:e);return pi(h,mi(a,i))}function rg(e,t){return e-1}function ng(e,t){return t.cols-e}function og(e,t,s,i,n,o){return Cr(t,i,n,o).length===0?"":pi(kh(e,t,e,t-gs(t,n),!1,n).length,mi("D",o))}function Cr(e,t,s,i){let n=e-gs(e,s),o=t-gs(t,s),a=Math.abs(n-o)-lg(e,t,s);return pi(a,mi(Ch(e,t),i))}function ag(e,t,s,i,n,o){let a;Cr(t,i,n,o).length>0?a=i-gs(i,n):a=t;let c=i,h=cg(e,t,s,i,n,o);return pi(kh(e,a,s,c,h==="C",n).length,mi(h,o))}function lg(e,t,s){var a;let i=0,n=e-gs(e,s),o=t-gs(t,s);for(let c=0;c<Math.abs(n-o);c++){let h=Ch(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*c))!=null&&a.isWrapped&&i++}return i}function gs(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 cg(e,t,s,i,n,o){let a;return Cr(s,i,n,o).length>0?a=i-gs(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function Ch(e,t){return e>t?"A":"B"}function kh(e,t,s,i,n,o){let a=e,c=t,h="";for(;(a!==s||c!==i)&&c>=0&&c<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(c,!1,e,a),a=0,e=0,c++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(c,!1,0,e+1),a=o.cols-1,e=a,c--);return h+o.buffer.translateBufferLineToString(c,!1,e,a)}function mi(e,t){let s=t?"O":"[";return R.ESC+s+e}function pi(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var hg=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 ol(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 Ur=50,dg=15,ug=50,fg=500,mg=" ",pg=new RegExp(mg,"g"),Wn=class extends re{constructor(e,t,s,i,n,o,a,c,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=c,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new F),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new F),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new F),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new F),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new hg(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let 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 c=s.translateBufferLineToString(a,!0,n,o);i.push(c)}}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),c=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=c:i.push(c)}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(pg," ")).join(yh?`\r
|
|
194
194
|
`:`
|
|
195
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),No&&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=il(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=ko(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,-Wr),Wr),t/=Wr,t/Math.abs(t)+Math.round(t*(q_-1)))}shouldForceSelection(e){return cr?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(),V_)}_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&&!(cr&&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<G_&&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=O_(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,f=0,p=0,u=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let x=e[0],y=e[0];o.getWidth(x)===0&&(f++,x--),o.getWidth(y)===2&&(p++,y++);let b=o.getString(y).length;for(b>1&&(g+=b-1,h+=b-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(f++,x--):k>1&&(u+=k-1,l-=k-1),l--,x--}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?(p++,y++):k>1&&(g+=k-1,h+=k-1),h++,y++}}h++;let m=l+c-f+u,_=Math.min(this._bufferService.cols,h-l+f+p-u-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let x=n.lines.get(e[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let b=this._bufferService.cols-y.start;m-=b,_+=b}}}if(i&&m+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=n.lines.get(e[1]+1);if(x!=null&&x.isWrapped&&x.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(_+=y.length)}}return{start:m,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=il(s,this._bufferService.cols)}};Fn=Ce([q(3,Ge),q(4,vs),q(5,xo),q(6,Ye),q(7,Lt),q(8,Mt)],Fn);var rl=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={}}},nl=class{constructor(){this._color=new rl,this._css=new rl}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()}},Ee=Object.freeze((()=>{let e=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.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})()),ts=Se.toColor("#ffffff"),si=Se.toColor("#000000"),ol=Se.toColor("#ffffff"),al=si,Vs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},J_=ts,Hn=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new nl,this._halfContrastCache=new nl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ts,background:si,cursor:ol,cursorAccent:al,selectionForeground:void 0,selectionBackgroundTransparent:Vs,selectionBackgroundOpaque:_e.blend(si,Vs),selectionInactiveBackgroundTransparent:Vs,selectionInactiveBackgroundOpaque:_e.blend(si,Vs),scrollbarSliderBackground:_e.opacity(ts,.2),scrollbarSliderHoverBackground:_e.opacity(ts,.4),scrollbarSliderActiveBackground:_e.opacity(ts,.5),overviewRulerBorder:ts,ansi:Ee.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=fe(e.foreground,ts),t.background=fe(e.background,si),t.cursor=_e.blend(t.background,fe(e.cursor,ol)),t.cursorAccent=_e.blend(t.background,fe(e.cursorAccent,al)),t.selectionBackgroundTransparent=fe(e.selectionBackground,Vs),t.selectionBackgroundOpaque=_e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fe(e.selectionForeground,el):void 0,t.selectionForeground===el&&(t.selectionForeground=void 0),_e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_e.opacity(t.selectionBackgroundTransparent,.3)),_e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=fe(e.scrollbarSliderBackground,_e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fe(e.scrollbarSliderHoverBackground,_e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fe(e.scrollbarSliderActiveBackground,_e.opacity(t.foreground,.5)),t.overviewRulerBorder=fe(e.overviewRulerBorder,J_),t.ansi=Ee.slice(),t.ansi[0]=fe(e.black,Ee[0]),t.ansi[1]=fe(e.red,Ee[1]),t.ansi[2]=fe(e.green,Ee[2]),t.ansi[3]=fe(e.yellow,Ee[3]),t.ansi[4]=fe(e.blue,Ee[4]),t.ansi[5]=fe(e.magenta,Ee[5]),t.ansi[6]=fe(e.cyan,Ee[6]),t.ansi[7]=fe(e.white,Ee[7]),t.ansi[8]=fe(e.brightBlack,Ee[8]),t.ansi[9]=fe(e.brightRed,Ee[9]),t.ansi[10]=fe(e.brightGreen,Ee[10]),t.ansi[11]=fe(e.brightYellow,Ee[11]),t.ansi[12]=fe(e.brightBlue,Ee[12]),t.ansi[13]=fe(e.brightMagenta,Ee[13]),t.ansi[14]=fe(e.brightCyan,Ee[14]),t.ansi[15]=fe(e.brightWhite,Ee[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]=fe(e.extendedAnsi[i],Ee[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()}}};Hn=Ce([q(0,Ye)],Hn);function fe(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}var Z_=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)}},Q_=class{constructor(){this._services=new Z_,this._services.set(go,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=qm(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)}},eg={trace:0,debug:1,info:2,warn:3,error:4,off:5},tg="xterm.js: ",Wn=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=eg[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?"":tg)+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)}};Wn=Ce([q(0,Ye)],Wn);var ll=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 vi),Hi=0,Ur=2,ii=class bh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||ht.fromCharData([0,$c,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?Ht(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?Ht(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Hi=t*re,s.content=this._data[Hi+0],s.fg=this._data[Hi+1],s.bg=this._data[Hi+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]+=Ht(s):n&2097151?(this._combined[t]=Ht(n&2097151)+Ht(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 ht;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 ht;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*Ur<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*Ur<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ur<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 bh(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?Ht(l):Ut;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 sg(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 f=[e.get(l)];for(;h<e.length&&c.isWrapped;)f.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=f.length-1;continue}let p=0,u=pi(f,p,t),g=1,m=0;for(;g<f.length;){let x=pi(f,g,t),y=x-m,b=s-u,k=Math.min(y,b);f[p].copyCellsFrom(f[g],m,u,k,!1),u+=k,u===s&&(p++,u=0),m+=k,m===x&&(g++,m=0),u===0&&p!==0&&f[p-1].getWidth(s-1)===2&&(f[p].copyCellsFrom(f[p-1],s-1,u++,1,!1),f[p-1].setCell(s-1,n))}f[p].replaceCells(u,s,n);let _=0;for(let x=f.length-1;x>0&&(x>p||f[x].getTrimmedLength()===0);x--)_++;_>0&&(a.push(l+f.length-_),a.push(_)),l+=f.length-1}return a}function ig(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 rg(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 ng(e,t,s){let i=[],n=e.map((h,c)=>pi(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=pi(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let f=c?s-1:s;i.push(f),l+=f}return i}function pi(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 yh=class Sh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Sh._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(),us(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};yh._nextId=1;var og=yh,Re={},ss=Re.B;Re[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Re.A={"#":"£"};Re.B=void 0;Re[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Re.C=Re[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Re.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Re.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Re.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Re.E=Re[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Re.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Re.H=Re[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var cl=4294967295,hl=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=ss,this.markers=[],this._nullCell=ht.fromCharData([0,$c,1,0]),this._whitespaceCell=ht.fromCharData([0,Ut,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new hr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ll(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 or),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 or),this._whitespaceCell}getBlankLine(e,t){return new ii(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>cl?cl: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 ll(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 ii(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 ii(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=sg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ne),s);if(i.length>0){let n=ig(this.lines,i);rg(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 ii(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(),f=ng(h,this._cols,e),p=f.length-h.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+p):u=Math.max(0,this.lines.length-this.lines.maxLength+p);let g=[];for(let k=0;k<p;k++){let S=this.getBlankLine(Ne,!0);g.push(S)}g.length>0&&(n.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=f.length-1,_=f[m];_===0&&(m--,_=f[m]);let x=h.length-p-1,y=c;for(;x>=0;){let k=Math.min(y,_);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[x],y-k,_-k,k,!0),_-=k,_===0&&(m--,_=f[m]),y-=k,y===0){x--;let S=Math.max(x,0);y=pi(h,S,this._cols)}}for(let k=0;k<h.length;k++)f[k]<e&&h[k].setCell(f[k],i);let b=p-u;for(;b-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,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,f=0,p=n[f];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let u=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(p&&p.start>c+u){for(let x=p.newLines.length-1;x>=0;x--)this.lines.set(_--,p.newLines[x]);_++,a.push({index:c+1,amount:p.newLines.length}),u+=p.newLines.length,p=n[++f]}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 m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}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 og(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)}},ag=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 hl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new hl(!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)}},wh=2,Ch=1,Un=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,wh),this.rows=Math.max(e.rawOptions.rows||0,Ch),this.buffers=this._register(new ag(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))}};Un=Ce([q(0,Ye)],Un);var Ns={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:cr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},lg=["normal","bold","100","200","300","400","500","600","700","800","900"],cg=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...Ns};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 Ns))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Ns))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=Ns[e]),!hg(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ns[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=lg.includes(t)?t:Ns[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 hg(e){return e==="block"||e==="underline"||e==="bar"}function ri(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]&&ri(e[i],t-1);return s}var dl=Object.freeze({insertMode:!1}),ul=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Kn=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=ri(dl),this.decPrivateModes=ri(ul)}reset(){this.modes=ri(dl),this.decPrivateModes=ri(ul)}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))}};Kn=Ce([q(0,Ge),q(1,Uc),q(2,Ye)],Kn);var fl={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 Kr(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 qr=String.fromCharCode,ml={DEFAULT:e=>{let t=[Kr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${qr(t[0])}${qr(t[1])}${qr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.x};${e.y}${t}`}},qn=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(fl))this.addProtocol(i,fl[i]);for(let i of Object.keys(ml))this.addEncoding(i,ml[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)}};qn=Ce([q(0,Ge),q(1,vs),q(2,Ye)],qn);var Vr=[[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]],dg=[[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 ug(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 fg=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<Vr.length;++e)De.fill(0,Vr[e][0],Vr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?De[e]:ug(e,dg)?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=is.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return is.createPropertyValue(0,s,i)}},is=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new fg;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=Xi.extractWidth(l);Xi.extractShouldJoin(l)&&(h-=Xi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},mg=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 pl(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 Gs=2147483647,pg=256,kh=class Vn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>pg)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 Vn;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 Vn(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>Gs?Gs: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>Gs?Gs: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,Gs):t}},Ys=[],_g=class{constructor(){this._state=0,this._active=Ys,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=Ys}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=Ys,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ys,!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",br(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=Ys,this._id=-1,this._state=0}}},it=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+=br(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}},Xs=[],gg=class{constructor(){this._handlers=Object.create(null),this._active=Xs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xs}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=Xs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xs,!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",br(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=Xs,this._ident=0}},ni=new kh;ni.addParam(0);var _l=class{constructor(e){this._handler=e,this._data="",this._params=ni,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ni,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=br(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=ni,this._data="",this._hitLimit=!1,s));return this._params=ni,this._data="",this._hitLimit=!1,t}},xg=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}},ct=160,vg=(function(){let e=new xg(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(ct,0,2,0),e.add(ct,8,5,8),e.add(ct,6,0,6),e.add(ct,11,0,11),e.add(ct,13,13,13),e})(),bg=class extends ne{constructor(e=vg){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 kh,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 _g),this._dcsParser=this._register(new gg),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:ct)],n>>4){case 2:for(let u=l+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,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 f=this._escHandlers[this._collect<<8|i],p=f?f.length-1:-1;for(;p>=0&&(a=f[p](),a!==!0);p--)if(a instanceof Promise)return this._preserveStack(4,f,p,n,l),a;p<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=l+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i<ct){this._dcsParser.put(e,l,u),l=u-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,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 u=l+1;;u++)if(u>=t||(i=e[u])<32||i>127&&i<ct){this._oscParser.put(e,l,u),l=u-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,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}}},yg=/^([\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})$/,Sg=/^[\da-f]+$/;function gl(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=yg.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),Sg.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 Gr(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 wg(e,t=16){let[s,i,n]=e;return`rgb:${Gr(s,t)}/${Gr(i,t)}/${Gr(n,t)}`}var Cg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ft=131072,xl=10;function vl(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 bl=5e3,yl=0,kg=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new bg){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 Um,this._utf8Decoder=new Km,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 Gn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,f)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:f.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,f,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:f,data:p})}),this._parser.setDcsHandlerFallback((c,f,p)=>{f==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:f,payload:p})}),this._parser.setPrintHandler((c,f,p)=>this.print(c,f,p)),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(R.BEL,()=>this.bell()),this._parser.setExecuteHandler(R.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(R.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(R.BS,()=>this.backspace()),this._parser.setExecuteHandler(R.HT,()=>this.tab()),this._parser.setExecuteHandler(R.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(R.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new it(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new it(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new it(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new it(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new it(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new it(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new it(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new it(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new it(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new it(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new it(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new it(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 Re)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 _l((c,f)=>this.requestStatusString(c,f)))}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"),bl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${bl} 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>Ft&&(o=this._parseStack.position+Ft)}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<Ft&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ft))),a||this._dirtyRowTracker.clearRange(),e.length>Ft)for(let c=o;c<e.length;c+=Ft){let f=c+Ft<e.length?c+Ft:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(c,f),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,f),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,p))return this._preserveStack(i,n,p,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,f=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,f);let u=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 m=this._unicodeService.charProperties(i,u);n=is.extractWidth(m);let _=is.extractShouldJoin(m),x=_?is.extractWidth(u):0;if(u=m,a&&this._onA11yChar.fire(Ht(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-x>l){if(h){let y=p,b=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&p instanceof ii&&p.copyCellsFrom(y,b,0,x,!1);b<l;)y.setCellFromCodepoint(b++,0,1,f)}else if(this._activeBuffer.x=l-1,n===2)continue}if(_&&this._activeBuffer.x){let y=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let b=n-x;--b>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f);continue}if(c&&(p.insertCells(this._activeBuffer.x,n-x,this._activeBuffer.getNullCell(f)),p.getWidth(l-1)===2&&p.setCellFromCodepoint(l-1,0,1,f)),p.setCellFromCodepoint(this._activeBuffer.x++,i,n,f),n>0)for(;--n;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f)}this._parser.precedingJoinState=u,this._activeBuffer.x<l&&s-t>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,f),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>vl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new _l(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new it(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=is.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 f=o.codePointAt(c)||0;a[l++]=f,c+=f>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(R.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(R.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(R.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(R.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(R.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,ss),this._charsetService.setgCharset(1,ss),this._charsetService.setgCharset(2,ss),this._charsetService.setgCharset(3,ss);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:f}=l,p=this._optionsService.rawOptions,u=(_,x)=>(a.triggerDataEvent(`${R.ESC}[${t?"":"?"}${_};${x}$y`),!0),g=_=>_?1:2,m=e.params[0];return t?m===2?u(m,4):m===4?u(m,g(a.modes.insertMode)):m===12?u(m,3):m===20?u(m,g(p.convertEol)):u(m,0):m===1?u(m,g(i.applicationCursorKeys)):m===3?u(m,p.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?u(m,g(i.origin)):m===7?u(m,g(i.wraparound)):m===8?u(m,3):m===9?u(m,g(n==="X10")):m===12?u(m,g(p.cursorBlink)):m===25?u(m,g(!a.isCursorHidden)):m===45?u(m,g(i.reverseWraparound)):m===66?u(m,g(i.applicationKeypad)):m===67?u(m,4):m===1e3?u(m,g(n==="VT200")):m===1002?u(m,g(n==="DRAG")):m===1003?u(m,g(n==="ANY")):m===1004?u(m,g(i.sendFocus)):m===1005?u(m,4):m===1006?u(m,g(o==="SGR")):m===1015?u(m,4):m===1016?u(m,g(o==="SGR_PIXELS")):m===1048?u(m,1):m===47||m===1047||m===1049?u(m,g(c===f)):m===2004?u(m,g(i.bracketedPasteMode)):m===2026?u(m,g(i.synchronizedOutput)):u(m,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=vi.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(`${R.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.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(`${R.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(!vl(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(`${R.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>xl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>xl&&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(Sl(o))if(n==="?")t.push({type:0,index:o});else{let a=gl(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=gl(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]);Sl(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,ss),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Cg[e[0]],Re[e[1]]||ss),!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 ht;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(`${R.ESC}${a}${R.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)}},Gn=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&&(yl=e,e=t,t=yl),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Gn=Ce([q(0,Ge)],Gn);function Sl(e){return 0<=e&&e<256}var Ng=5e7,wl=12,jg=50,Eg=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>Ng)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>=wl?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>=wl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>jg&&(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()}},Yn=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)))}};Yn=Ce([q(0,Ge)],Yn);var Cl=!1,Dg=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new As),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 Q_,this.optionsService=this._register(new cg(e)),this._instantiationService.setService(Ye,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Un)),this._instantiationService.setService(Ge,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService(Uc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Kn)),this._instantiationService.setService(vs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qn)),this._instantiationService.setService(Wc,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(is)),this._instantiationService.setService(Ym,this.unicodeService),this._charsetService=this._instantiationService.createInstance(mg),this._instantiationService.setService(Gm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Yn),this._instantiationService.setService(Kc,this._oscLinkService),this._inputHandler=this._register(new kg(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 Eg((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&&!Cl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Cl=!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,wh),t=Math.max(t,Ch),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(pl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(pl(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 Pg(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=R.ESC+"OA":n.key=R.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=R.ESC+"OD":n.key=R.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=R.ESC+"OC":n.key=R.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=R.ESC+"OB":n.key=R.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":R.DEL,e.altKey&&(n.key=R.ESC+n.key);break;case 9:if(e.shiftKey){n.key=R.ESC+"[Z";break}n.key=R.HT,n.cancel=!0;break;case 13:n.key=e.altKey?R.ESC+R.CR:R.CR,n.cancel=!0;break;case 27:n.key=R.ESC,e.altKey&&(n.key=R.ESC+R.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"D":t?n.key=R.ESC+"OD":n.key=R.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"C":t?n.key=R.ESC+"OC":n.key=R.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"A":t?n.key=R.ESC+"OA":n.key=R.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"B":t?n.key=R.ESC+"OB":n.key=R.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=R.ESC+"[2~");break;case 46:o?n.key=R.ESC+"[3;"+(o+1)+"~":n.key=R.ESC+"[3~";break;case 36:o?n.key=R.ESC+"[1;"+(o+1)+"H":t?n.key=R.ESC+"OH":n.key=R.ESC+"[H";break;case 35:o?n.key=R.ESC+"[1;"+(o+1)+"F":t?n.key=R.ESC+"OF":n.key=R.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=R.ESC+"[5;"+(o+1)+"~":n.key=R.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=R.ESC+"[6;"+(o+1)+"~":n.key=R.ESC+"[6~";break;case 112:o?n.key=R.ESC+"[1;"+(o+1)+"P":n.key=R.ESC+"OP";break;case 113:o?n.key=R.ESC+"[1;"+(o+1)+"Q":n.key=R.ESC+"OQ";break;case 114:o?n.key=R.ESC+"[1;"+(o+1)+"R":n.key=R.ESC+"OR";break;case 115:o?n.key=R.ESC+"[1;"+(o+1)+"S":n.key=R.ESC+"OS";break;case 116:o?n.key=R.ESC+"[15;"+(o+1)+"~":n.key=R.ESC+"[15~";break;case 117:o?n.key=R.ESC+"[17;"+(o+1)+"~":n.key=R.ESC+"[17~";break;case 118:o?n.key=R.ESC+"[18;"+(o+1)+"~":n.key=R.ESC+"[18~";break;case 119:o?n.key=R.ESC+"[19;"+(o+1)+"~":n.key=R.ESC+"[19~";break;case 120:o?n.key=R.ESC+"[20;"+(o+1)+"~":n.key=R.ESC+"[20~";break;case 121:o?n.key=R.ESC+"[21;"+(o+1)+"~":n.key=R.ESC+"[21~";break;case 122:o?n.key=R.ESC+"[23;"+(o+1)+"~":n.key=R.ESC+"[23~";break;case 123:o?n.key=R.ESC+"[24;"+(o+1)+"~":n.key=R.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=R.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=R.DEL:e.keyCode===219?n.key=R.ESC:e.keyCode===220?n.key=R.FS:e.keyCode===221&&(n.key=R.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=R.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=R.ESC+c}else if(e.keyCode===32)n.key=R.ESC+(e.ctrlKey?R.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=R.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=R.US),e.key==="@"&&(n.key=R.NUL));break}return n}var ke=0,Mg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new hr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new hr,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}},Yr=0,kl=0,Lg=class extends ne{constructor(){super(),this._decorations=new Mg(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 Bg(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=>{Yr=n.options.x??0,kl=Yr+(n.options.width??1),e>=Yr&&e<kl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},Bg=class extends Gt{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=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Tg=1e3,zg=class{constructor(e,t=Tg){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)}},Nl=20,dr=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 zg(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(`
|
|
196
|
-
`))),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(
|
|
197
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Nl+1&&(this._liveRegion.textContent+=pn.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 f=h instanceof Text?h.parentNode:h,p=parseInt(f==null?void 0:f.getAttribute("aria-posinset"),10)-1;if(isNaN(p))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(f);if(!u)return console.warn("columns is null. Race condition?"),null;let g=c<u.length?u[c]:u.slice(-1)[0]+1;return g>=this._terminal.cols&&(++p,g=0),{row:p,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})`}};dr=Ce([q(1,go),q(2,Mt),q(3,Lt)],dr);var Xn=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;us(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(Z(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Z(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Z(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Z(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,f;if(this._isMouseOut)return;let h=l==null?void 0:l.map(p=>({link:p}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((f=this._activeProviderReplies)==null?void 0:f.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&&Ag(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,us(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}}};Xn=Ce([q(1,xo),q(2,Lt),q(3,Ge),q(4,Vc)],Xn);function Ag(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 Og=class extends Dg{constructor(e={}){super(e),this._linkifier=this._register(new As),this.browser=uh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new As),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(Lg),this._instantiationService.setService(bi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(j_),this._instantiationService.setService(Vc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gn)),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=_e.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${R.ESC}]${i};${wg(n)}${hh.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(dr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.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(R.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(Z(this.element,"copy",t=>{this.hasSelection()&&Hm(t,this._selectionService)}));let e=t=>Wm(t,this.textarea,this.coreService,this.optionsService);this._register(Z(this.textarea,"paste",e)),this._register(Z(this.element,"paste",e)),fh?this._register(Z(this.element,"mousedown",t=>{t.button===2&&za(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Z(this.element,"contextmenu",t=>{za(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),No&&this._register(Z(this.element,"auxclick",t=>{t.button===1&&Oc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Z(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Z(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Z(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Z(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Z(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Z(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Z(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(Z(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",mn.get()),_h||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(k_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Mt,this._coreBrowserService),this._register(Z(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Z(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(On,this._document,this._helperContainer),this._instantiationService.setService(yr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Hn),this._instantiationService.setService(Os,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lr),this._instantiationService.setService(qc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(In,this.rows,this.screenElement)),this._instantiationService.setService(Lt,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(Tn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance($n),this._instantiationService.setService(xo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Xn,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(Ln,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(Fn,this.element,this.screenElement,i)),this._instantiationService.setService(Jm,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(Bn,this.screenElement)),this._register(Z(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(dr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(An,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,f,p,u,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 m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(u=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:u.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<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(Z(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(Z(t,"wheel",o=>{var a,l,h,c,f;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,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return this.cancel(o,!0);let p=R.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(p,!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){Ac(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=Pg(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===R.ETX||s.key===R.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)&&($g(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var 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(R.ESC+"[I"):this.coreService.triggerDataEvent(R.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(`${R.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(`${R.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function $g(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Ig=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)}},Fg=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 ht)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},jl=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 Fg(t)}getNullCell(){return new ht}},Hg=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new jl(this._core.buffers.normal,"normal"),this._alternate=new jl(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)}},Wg=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)}},Ug=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}},Kg=["cols","rows"],mt=0,qg=class extends ne{constructor(e){super(),this._core=this._register(new Og(e)),this._addonManager=this._register(new Ig),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(Kg.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 Wg(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ug(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 Hg(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
|
|
198
|
-
`,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
|
|
195
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Eo&&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=ol(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=jo(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,-Ur),Ur),t/=Ur,t/Math.abs(t)+Math.round(t*(dg-1)))}shouldForceSelection(e){return cr?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(),ug)}_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&&!(cr&&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<fg&&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=ig(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),c=this._convertViewportColToCharacterIndex(o,e[0]),h=c,l=e[0]-c,f=0,m=0,u=0,g=0;if(a.charAt(c)===" "){for(;c>0&&a.charAt(c-1)===" ";)c--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let x=e[0],y=e[0];o.getWidth(x)===0&&(f++,x--),o.getWidth(y)===2&&(m++,y++);let v=o.getString(y).length;for(v>1&&(g+=v-1,h+=v-1);x>0&&c>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(f++,x--):k>1&&(u+=k-1,c-=k-1),c--,x--}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=c+l-f+u,_=Math.min(this._bufferService.cols,h-c+f+m-u-g);if(!(!t&&a.slice(c,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let x=n.lines.get(e[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let v=this._bufferService.cols-y.start;p-=v,_+=v}}}if(i&&p+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=n.lines.get(e[1]+1);if(x!=null&&x.isWrapped&&x.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=ol(s,this._bufferService.cols)}};Wn=Ce([q(3,Xe),q(4,ys),q(5,bo),q(6,Je),q(7,It),q(8,At)],Wn);var al=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={}}},ll=class{constructor(){this._color=new al,this._css=new al}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=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.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:Ee.toCss(i,n,o),rgba:Ee.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Ee.toCss(i,i,i),rgba:Ee.toRgba(i,i,i)})}return e})()),ls=Se.toColor("#ffffff"),si=Se.toColor("#000000"),cl=Se.toColor("#ffffff"),hl=si,Gs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},_g=ls,Un=class extends re{constructor(e){super(),this._optionsService=e,this._contrastCache=new ll,this._halfContrastCache=new ll,this._onChangeColors=this._register(new F),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ls,background:si,cursor:cl,cursorAccent:hl,selectionForeground:void 0,selectionBackgroundTransparent:Gs,selectionBackgroundOpaque:xe.blend(si,Gs),selectionInactiveBackgroundTransparent:Gs,selectionInactiveBackgroundOpaque:xe.blend(si,Gs),scrollbarSliderBackground:xe.opacity(ls,.2),scrollbarSliderHoverBackground:xe.opacity(ls,.4),scrollbarSliderActiveBackground:xe.opacity(ls,.5),overviewRulerBorder:ls,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=fe(e.foreground,ls),t.background=fe(e.background,si),t.cursor=xe.blend(t.background,fe(e.cursor,cl)),t.cursorAccent=xe.blend(t.background,fe(e.cursorAccent,hl)),t.selectionBackgroundTransparent=fe(e.selectionBackground,Gs),t.selectionBackgroundOpaque=xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fe(e.selectionForeground,il):void 0,t.selectionForeground===il&&(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=fe(e.scrollbarSliderBackground,xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fe(e.scrollbarSliderHoverBackground,xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fe(e.scrollbarSliderActiveBackground,xe.opacity(t.foreground,.5)),t.overviewRulerBorder=fe(e.overviewRulerBorder,_g),t.ansi=Re.slice(),t.ansi[0]=fe(e.black,Re[0]),t.ansi[1]=fe(e.red,Re[1]),t.ansi[2]=fe(e.green,Re[2]),t.ansi[3]=fe(e.yellow,Re[3]),t.ansi[4]=fe(e.blue,Re[4]),t.ansi[5]=fe(e.magenta,Re[5]),t.ansi[6]=fe(e.cyan,Re[6]),t.ansi[7]=fe(e.white,Re[7]),t.ansi[8]=fe(e.brightBlack,Re[8]),t.ansi[9]=fe(e.brightRed,Re[9]),t.ansi[10]=fe(e.brightGreen,Re[10]),t.ansi[11]=fe(e.brightYellow,Re[11]),t.ansi[12]=fe(e.brightBlue,Re[12]),t.ansi[13]=fe(e.brightMagenta,Re[13]),t.ansi[14]=fe(e.brightCyan,Re[14]),t.ansi[15]=fe(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]=fe(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()}}};Un=Ce([q(0,Je)],Un);function fe(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}var gg=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)}},xg=class{constructor(){this._services=new gg,this._services.set(vo,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=dp(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)}},vg={trace:0,debug:1,info:2,warn:3,error:4,off:5},bg="xterm.js: ",Kn=class extends re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=vg[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?"":bg)+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)}};Kn=Ce([q(0,Je)],Kn);var dl=class extends re{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new F),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new F),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new F),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}},ie=3,je=Object.freeze(new bi),Wi=0,Kr=2,ii=class Nh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ie);let n=s||dt.fromCharData([0,Kc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*ie+0],i=s&2097151;return[this._data[t*ie+1],s&2097152?this._combined[t]:i?Vt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ie+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ie+0]=t|2097152|s[2]<<22):this._data[t*ie+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ie+0]>>22}hasWidth(t){return this._data[t*ie+0]&12582912}getFg(t){return this._data[t*ie+1]}getBg(t){return this._data[t*ie+2]}hasContent(t){return this._data[t*ie+0]&4194303}getCodePoint(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ie+0]&2097152}getString(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t]:s&2097151?Vt(s&2097151):""}isProtected(t){return this._data[t*ie+2]&536870912}loadCell(t,s){return Wi=t*ie,s.content=this._data[Wi+0],s.fg=this._data[Wi+1],s.bg=this._data[Wi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ie+0]=s.content,this._data[t*ie+1]=s.fg,this._data[t*ie+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*ie+0]=s|i<<22,this._data[t*ie+1]=n.fg,this._data[t*ie+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*ie+0];n&2097152?this._combined[t]+=Vt(s):n&2097151?(this._combined[t]=Vt(n&2097151)+Vt(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*ie+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 dt;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 dt;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*Kr<this._data.buffer.byteLength;let i=t*ie;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let 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 c=parseInt(n[a],10);c>=t&&delete this._combined[c]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let c=parseInt(o[a],10);c>=t&&delete this._extendedAttrs[c]}}return this.length=t,i*4*Kr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Kr<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 Nh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303)return t+(this._data[t*ie+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303||this._data[t*ie+2]&50331648)return t+(this._data[t*ie+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let l=0;l<ie;l++)this._data[(i+h)*ie+l]=a[(s+h)*ie+l];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let l=0;l<ie;l++)this._data[(i+h)*ie+l]=a[(s+h)*ie+l];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let c=Object.keys(t._combined);for(let h=0;h<c.length;h++){let l=parseInt(c[h],10);l>=s&&(this._combined[l-s+i]=t._combined[l])}}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*ie+0],c=a&2097151,h=a&2097152?this._combined[s]:c?Vt(c):Yt;if(o+=h,n)for(let l=0;l<h.length;++l)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function yg(e,t,s,i,n,o){let a=[];for(let c=0;c<e.length-1;c++){let h=c,l=e.get(++h);if(!l.isWrapped)continue;let f=[e.get(c)];for(;h<e.length&&l.isWrapped;)f.push(l),l=e.get(++h);if(!o&&i>=c&&i<h){c+=f.length-1;continue}let m=0,u=_i(f,m,t),g=1,p=0;for(;g<f.length;){let x=_i(f,g,t),y=x-p,v=s-u,k=Math.min(y,v);f[m].copyCellsFrom(f[g],p,u,k,!1),u+=k,u===s&&(m++,u=0),p+=k,p===x&&(g++,p=0),u===0&&m!==0&&f[m-1].getWidth(s-1)===2&&(f[m].copyCellsFrom(f[m-1],s-1,u++,1,!1),f[m-1].setCell(s-1,n))}f[m].replaceCells(u,s,n);let _=0;for(let x=f.length-1;x>0&&(x>m||f[x].getTrimmedLength()===0);x--)_++;_>0&&(a.push(c+f.length-_),a.push(_)),c+=f.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 c=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:c}),a+=c-1,o+=c,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function wg(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 Cg(e,t,s){let i=[],n=e.map((h,l)=>_i(e,l,t)).reduce((h,l)=>h+l),o=0,a=0,c=0;for(;c<n;){if(n-c<s){i.push(n-c);break}o+=s;let h=_i(e,a,t);o>h&&(o-=h,a++);let l=e[a].getWidth(o-1)===2;l&&o--;let f=l?s-1:s;i.push(f),c+=f}return i}function _i(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 jh=class Eh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Eh._nextId++,this._onDispose=this.register(new F),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),_s(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};jh._nextId=1;var kg=jh,Pe={},cs=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 ul=4294967295,fl=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=je.clone(),this.savedCharset=cs,this.markers=[],this._nullCell=dt.fromCharData([0,Kc,1,0]),this._whitespaceCell=dt.fromCharData([0,Yt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new hr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new dl(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 or),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 or),this._whitespaceCell}getBlankLine(e,t){return new ii(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>ul?ul:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=je);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 dl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(je),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 ii(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 ii(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=yg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(je),s);if(i.length>0){let n=Sg(this.lines,i);wg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(je),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ii(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(je),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let h=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),h.unshift(c);if(!s){let k=this.ybase+this.y;if(k>=a&&k<a+h.length)continue}let l=h[h.length-1].getTrimmedLength(),f=Cg(h,this._cols,e),m=f.length-h.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+m):u=Math.max(0,this.lines.length-this.lines.maxLength+m);let g=[];for(let k=0;k<m;k++){let w=this.getBlankLine(je,!0);g.push(w)}g.length>0&&(n.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let p=f.length-1,_=f[p];_===0&&(p--,_=f[p]);let x=h.length-m-1,y=l;for(;x>=0;){let k=Math.min(y,_);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[x],y-k,_-k,k,!0),_-=k,_===0&&(p--,_=f[p]),y-=k,y===0){x--;let w=Math.max(x,0);y=_i(h,w,this._cols)}}for(let k=0;k<h.length;k++)f[k]<e&&h[k].setCell(f[k],i);let v=m-u;for(;v-- >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=[],c=[];for(let _=0;_<this.lines.length;_++)c.push(this.lines.get(_));let h=this.lines.length,l=h-1,f=0,m=n[f];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let u=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(m&&m.start>l+u){for(let x=m.newLines.length-1;x>=0;x--)this.lines.set(_--,m.newLines[x]);_++,a.push({index:l+1,amount:m.newLines.length}),u+=m.newLines.length,m=n[++f]}else this.lines.set(_,c[l--]);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 kg(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 re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new F),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 fl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new fl(!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)}},Dh=2,Rh=1,qn=class extends re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new F),this.onResize=this._onResize.event,this._onScroll=this._register(new F),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Dh),this.rows=Math.max(e.rawOptions.rows||0,Rh),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))}};qn=Ce([q(0,Je)],qn);var Es={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:cr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},jg=["normal","bold","100","200","300","400","500","600","700","800","900"],Eg=class extends re{constructor(e){super(),this._onOptionChange=this._register(new F),this.onOptionChange=this._onOptionChange.event;let t={...Es};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 Es))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Es))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=Es[e]),!Dg(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Es[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=jg.includes(t)?t:Es[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 Dg(e){return e==="block"||e==="underline"||e==="bar"}function ri(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]&&ri(e[i],t-1);return s}var ml=Object.freeze({insertMode:!1}),pl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new F),this.onData=this._onData.event,this._onUserInput=this._register(new F),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new F),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new F),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ri(ml),this.decPrivateModes=ri(pl)}reset(){this.modes=ri(ml),this.decPrivateModes=ri(pl)}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))}};Vn=Ce([q(0,Xe),q(1,Xc),q(2,Je)],Vn);var _l={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 qr(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 Vr=String.fromCharCode,gl={DEFAULT:e=>{let t=[qr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Vr(t[0])}${Vr(t[1])}${Vr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qr(e,!0)};${e.x};${e.y}${t}`}},Gn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new F),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(_l))this.addProtocol(i,_l[i]);for(let i of Object.keys(gl))this.addEncoding(i,gl[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)}};Gn=Ce([q(0,Xe),q(1,ys),q(2,Je)],Gn);var Gr=[[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]],Rg=[[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]],Le;function Lg(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 Pg=class{constructor(){if(this.version="6",!Le){Le=new Uint8Array(65536),Le.fill(1),Le[0]=0,Le.fill(0,1,32),Le.fill(0,127,160),Le.fill(2,4352,4448),Le[9001]=2,Le[9002]=2,Le.fill(2,11904,42192),Le[12351]=1,Le.fill(2,44032,55204),Le.fill(2,63744,64256),Le.fill(2,65040,65050),Le.fill(2,65072,65136),Le.fill(2,65280,65377),Le.fill(2,65504,65511);for(let e=0;e<Gr.length;++e)Le.fill(0,Gr[e][0],Gr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Le[e]:Lg(e,Rg)?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=hs.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return hs.createPropertyValue(0,s,i)}},hs=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new F,this.onChange=this._onChange.event;let t=new Pg;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 l=t.charCodeAt(o);56320<=l&&l<=57343?a=(a-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let c=this.charProperties(a,i),h=Xi.extractWidth(c);Xi.extractShouldJoin(c)&&(h-=Xi.extractWidth(i)),s+=h,i=c}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Mg=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 xl(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 Ys=2147483647,Bg=256,Lh=class Yn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Bg)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 Yn;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 Yn(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>Ys?Ys: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>Ys?Ys: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,Ys):t}},Xs=[],Tg=class{constructor(){this._state=0,this._active=Xs,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=Xs}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=Xs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Xs,!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",yr(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=Xs,this._id=-1,this._state=0}}},rt=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+=yr(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Js=[],zg=class{constructor(){this._handlers=Object.create(null),this._active=Js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",yr(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=Js,this._ident=0}},ni=new Lh;ni.addParam(0);var vl=class{constructor(e){this._handler=e,this._data="",this._params=ni,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ni,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=yr(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=ni,this._data="",this._hitLimit=!1,s));return this._params=ni,this._data="",this._hitLimit=!1,t}},Ag=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}},ht=160,Ig=(function(){let e=new Ag(4095),t=Array.apply(null,Array(256)).map((c,h)=>h),s=(c,h)=>t.slice(c,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(ht,0,2,0),e.add(ht,8,5,8),e.add(ht,6,0,6),e.add(ht,11,0,11),e.add(ht,13,13,13),e})(),Og=class extends re{constructor(e=Ig){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 Lh,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 Tg),this._dcsParser=this._register(new zg),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 c=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=c[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=c[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 c=o;c<t;++c){switch(i=e[c],n=this._transitions.table[this.currentState<<8|(i<160?i:ht)],n>>4){case 2:for(let u=c+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i<ht){this._printHandler(e,c,u),c=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ht){this._printHandler(e,c,u),c=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ht){this._printHandler(e,c,u),c=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ht){this._printHandler(e,c,u),c=u-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,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],l=h?h.length-1:-1;for(;l>=0&&(a=h[l](this._params),a!==!0);l--)if(a instanceof Promise)return this._preserveStack(3,h,l,n,c),a;l<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(++c<t&&(i=e[c])>47&&i<60);c--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let f=this._escHandlers[this._collect<<8|i],m=f?f.length-1:-1;for(;m>=0&&(a=f[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,f,m,n,c),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 u=c+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i<ht){this._dcsParser.put(e,c,u),c=u-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,c),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 u=c+1;;u++)if(u>=t||(i=e[u])<32||i>127&&i<ht){this._oscParser.put(e,c,u),c=u-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,c),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},$g=/^([\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})$/,Fg=/^[\da-f]+$/;function bl(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=$g.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),Fg.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 Yr(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 Hg(e,t=16){let[s,i,n]=e;return`rgb:${Yr(s,t)}/${Yr(i,t)}/${Yr(n,t)}`}var Wg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qt=131072,yl=10;function Sl(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 wl=5e3,Cl=0,Ug=class extends re{constructor(e,t,s,i,n,o,a,c,h=new Og){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=c,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cp,this._utf8Decoder=new hp,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone(),this._onRequestBell=this._register(new F),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new F),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new F),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new F),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new F),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new F),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new F),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new F),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new F),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new F),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new F),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new F),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new F),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 Xn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,f)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:f.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,f,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:f,data:m})}),this._parser.setDcsHandlerFallback((l,f,m)=>{f==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:f,payload:m})}),this._parser.setPrintHandler((l,f,m)=>this.print(l,f,m)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(R.BEL,()=>this.bell()),this._parser.setExecuteHandler(R.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(R.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(R.BS,()=>this.backspace()),this._parser.setExecuteHandler(R.HT,()=>this.tab()),this._parser.setExecuteHandler(R.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(R.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new rt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new rt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new rt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new rt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new rt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new rt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new rt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new rt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new rt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new rt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new rt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new rt(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in Pe)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new vl((l,f)=>this.requestStatusString(l,f)))}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"),wl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${wl} 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>qt&&(o=this._parseStack.position+qt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<qt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,qt))),a||this._dirtyRowTracker.clearRange(),e.length>qt)for(let l=o;l<e.length;l+=qt){let f=l+qt<e.length?l+qt:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(l,f),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,f),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,l),this._logSlowResolvingAsync(s),s}else if(!a){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,n,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let c=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(c,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,c=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,f=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,f);let u=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,u);n=hs.extractWidth(p);let _=hs.extractShouldJoin(p),x=_?hs.extractWidth(u):0;if(u=p,a&&this._onA11yChar.fire(Vt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-x>c){if(h){let y=m,v=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),x>0&&m instanceof ii&&m.copyCellsFrom(y,v,0,x,!1);v<c;)y.setCellFromCodepoint(v++,0,1,f)}else if(this._activeBuffer.x=c-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 v=n-x;--v>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,f);continue}if(l&&(m.insertCells(this._activeBuffer.x,n-x,this._activeBuffer.getNullCell(f)),m.getWidth(c-1)===2&&m.setCellFromCodepoint(c-1,0,1,f)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,f),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,f)}this._parser.precedingJoinState=u,this._activeBuffer.x<c&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,f),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>Sl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new vl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new rt(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(je));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=hs.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),c=0;for(let l=0;l<o.length;){let f=o.codePointAt(l)||0;a[c++]=f,l+=f>65535?2:1}let h=c;for(let l=1;l<s;++l)a.copyWithin(h,0,c),h+=c;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(R.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(R.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(R.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(R.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(R.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,cs),this._charsetService.setgCharset(1,cs),this._charsetService.setgCharset(2,cs),this._charsetService.setgCharset(3,cs);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:c,cols:h}=this._bufferService,{active:l,alt:f}=c,m=this._optionsService.rawOptions,u=(_,x)=>(a.triggerDataEvent(`${R.ESC}[${t?"":"?"}${_};${x}$y`),!0),g=_=>_?1:2,p=e.params[0];return t?p===2?u(p,4):p===4?u(p,g(a.modes.insertMode)):p===12?u(p,3):p===20?u(p,g(m.convertEol)):u(p,0):p===1?u(p,g(i.applicationCursorKeys)):p===3?u(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?u(p,g(i.origin)):p===7?u(p,g(i.wraparound)):p===8?u(p,3):p===9?u(p,g(n==="X10")):p===12?u(p,g(m.cursorBlink)):p===25?u(p,g(!a.isCursorHidden)):p===45?u(p,g(i.reverseWraparound)):p===66?u(p,g(i.applicationKeypad)):p===67?u(p,4):p===1e3?u(p,g(n==="VT200")):p===1002?u(p,g(n==="DRAG")):p===1003?u(p,g(n==="ANY")):p===1004?u(p,g(i.sendFocus)):p===1005?u(p,4):p===1006?u(p,g(o==="SGR")):p===1015?u(p,4):p===1016?u(p,g(o==="SGR_PIXELS")):p===1048?u(p,1):p===47||p===1047||p===1049?u(p,g(l===f)):p===2004?u(p,g(i.bracketedPasteMode)):p===2026?u(p,g(i.synchronizedOutput)):u(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=bi.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),c=0;do i[1]===5&&(n=1),i[o+c+1+n]=a[c];while(++c<a.length&&c+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=je.fg,e.bg=je.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|=je.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=je.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|=je.fg&16777215,i.bg&=-67108864,i.bg|=je.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${R.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.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(`${R.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=je.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(!Sl(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(`${R.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>yl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>yl&&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(kl(o))if(n==="?")t.push({type:0,index:o});else{let a=bl(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=bl(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]);kl(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,cs),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Wg[e[0]],Pe[e[1]]||cs),!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=je.clone(),this._eraseAttrDataInternal=je.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 dt;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(`${R.ESC}${a}${R.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)}},Xn=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&&(Cl=e,e=t,t=Cl),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Xn=Ce([q(0,Xe)],Xn);function kl(e){return 0<=e&&e<256}var Kg=5e7,Nl=12,qg=50,Vg=class extends re{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new F),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=c=>performance.now()-s>=Nl?setTimeout(()=>this._innerWrite(0,c)):this._innerWrite(s,c);n.catch(c=>(queueMicrotask(()=>{throw c}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Nl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>qg&&(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()}},Jn=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 c=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),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)))}};Jn=Ce([q(0,Xe)],Jn);var jl=!1,Gg=class extends re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Is),this._onBinary=this._register(new F),this.onBinary=this._onBinary.event,this._onData=this._register(new F),this.onData=this._onData.event,this._onLineFeed=this._register(new F),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new F),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new F),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new F),this._instantiationService=new xg,this.optionsService=this._register(new Eg(e)),this._instantiationService.setService(Je,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(qn)),this._instantiationService.setService(Xe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Kn)),this._instantiationService.setService(Xc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vn)),this._instantiationService.setService(ys,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gn)),this._instantiationService.setService(Yc,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(hs)),this._instantiationService.setService(mp,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Mg),this._instantiationService.setService(fp,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jn),this._instantiationService.setService(Jc,this._oscLinkService),this._inputHandler=this._register(new Ug(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(He.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(He.forward(this._bufferService.onResize,this._onResize)),this._register(He.forward(this.coreService.onData,this._onData)),this._register(He.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 Vg((t,s)=>this._inputHandler.parse(t,s))),this._register(He.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new F),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&&!jl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jl=!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,Dh),t=Math.max(t,Rh),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(xl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(xl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},Yg={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 Xg(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=R.ESC+"OA":n.key=R.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=R.ESC+"OD":n.key=R.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=R.ESC+"OC":n.key=R.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=R.ESC+"OB":n.key=R.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":R.DEL,e.altKey&&(n.key=R.ESC+n.key);break;case 9:if(e.shiftKey){n.key=R.ESC+"[Z";break}n.key=R.HT,n.cancel=!0;break;case 13:n.key=e.altKey?R.ESC+R.CR:R.CR,n.cancel=!0;break;case 27:n.key=R.ESC,e.altKey&&(n.key=R.ESC+R.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"D":t?n.key=R.ESC+"OD":n.key=R.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"C":t?n.key=R.ESC+"OC":n.key=R.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"A":t?n.key=R.ESC+"OA":n.key=R.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"B":t?n.key=R.ESC+"OB":n.key=R.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=R.ESC+"[2~");break;case 46:o?n.key=R.ESC+"[3;"+(o+1)+"~":n.key=R.ESC+"[3~";break;case 36:o?n.key=R.ESC+"[1;"+(o+1)+"H":t?n.key=R.ESC+"OH":n.key=R.ESC+"[H";break;case 35:o?n.key=R.ESC+"[1;"+(o+1)+"F":t?n.key=R.ESC+"OF":n.key=R.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=R.ESC+"[5;"+(o+1)+"~":n.key=R.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=R.ESC+"[6;"+(o+1)+"~":n.key=R.ESC+"[6~";break;case 112:o?n.key=R.ESC+"[1;"+(o+1)+"P":n.key=R.ESC+"OP";break;case 113:o?n.key=R.ESC+"[1;"+(o+1)+"Q":n.key=R.ESC+"OQ";break;case 114:o?n.key=R.ESC+"[1;"+(o+1)+"R":n.key=R.ESC+"OR";break;case 115:o?n.key=R.ESC+"[1;"+(o+1)+"S":n.key=R.ESC+"OS";break;case 116:o?n.key=R.ESC+"[15;"+(o+1)+"~":n.key=R.ESC+"[15~";break;case 117:o?n.key=R.ESC+"[17;"+(o+1)+"~":n.key=R.ESC+"[17~";break;case 118:o?n.key=R.ESC+"[18;"+(o+1)+"~":n.key=R.ESC+"[18~";break;case 119:o?n.key=R.ESC+"[19;"+(o+1)+"~":n.key=R.ESC+"[19~";break;case 120:o?n.key=R.ESC+"[20;"+(o+1)+"~":n.key=R.ESC+"[20~";break;case 121:o?n.key=R.ESC+"[21;"+(o+1)+"~":n.key=R.ESC+"[21~";break;case 122:o?n.key=R.ESC+"[23;"+(o+1)+"~":n.key=R.ESC+"[23~";break;case 123:o?n.key=R.ESC+"[24;"+(o+1)+"~":n.key=R.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=R.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=R.DEL:e.keyCode===219?n.key=R.ESC:e.keyCode===220?n.key=R.FS:e.keyCode===221&&(n.key=R.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let c=(a=Yg[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(c)n.key=R.ESC+c;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),n.key=R.ESC+l}else if(e.keyCode===32)n.key=R.ESC+(e.ctrlKey?R.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=R.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=R.US),e.key==="@"&&(n.key=R.NUL));break}return n}var ke=0,Jg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new hr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new hr,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}},Xr=0,El=0,Zg=class extends re{constructor(){super(),this._decorations=new Jg(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new F),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new F),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 Qg(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=>{Xr=n.options.x??0,El=Xr+(n.options.width??1),e>=Xr&&e<El&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},Qg=class extends Qt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new F),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new F),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=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ex=1e3,tx=class{constructor(e,t=ex){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)}},Dl=20,dr=class extends re{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let 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 tx(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(`
|
|
196
|
+
`))),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(Q(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<Dl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
197
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Dl+1&&(this._liveRegion.textContent+=gn.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=[],c=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(c.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=c,this._rowColumns.set(l,a)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}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,c;if(t===0?(a=s,c=this._rowElements.pop(),this._rowContainer.removeChild(c)):(a=this._rowElements.shift(),c=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),c.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 c;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:((c=i.textContent)==null?void 0:c.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:l})=>{let f=h instanceof Text?h.parentNode:h,m=parseInt(f==null?void 0:f.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(f);if(!u)return console.warn("columns is null. Race condition?"),null;let g=l<u.length?u[l]:u.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})`}};dr=Ce([q(1,vo),q(2,At),q(3,It)],dr);var Zn=class extends re{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 F),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new F),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;_s(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(Q(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Q(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Q(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Q(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let 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,c=>{var l,f;if(this._isMouseOut)return;let h=c==null?void 0:c.map(m=>({link:m}));(l=this._activeProviderReplies)==null||l.set(o,h),s=this._checkLinkProviderResult(o,e,s),((f=this._activeProviderReplies)==null?void 0:f.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],c=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 l=c;l<=h;l++){if(s.has(l)){n.splice(o--,1);break}s.add(l)}}}}_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(c=>this._linkAtPosition(c.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 c=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(c){s=!0,this._handleNewLink(c);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&&sx(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,_s(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}}};Zn=Ce([q(1,bo),q(2,It),q(3,Xe),q(4,Qc)],Zn);function sx(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 ix=class extends Gg{constructor(e={}){super(e),this._linkifier=this._register(new Is),this.browser=xh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Is),this._onCursorMove=this._register(new F),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new F),this.onKey=this._onKey.event,this._onRender=this._register(new F),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new F),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new F),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new F),this.onBell=this._onBell.event,this._onFocus=this._register(new F),this._onBlur=this._register(new F),this._onA11yCharEmitter=this._register(new F),this._onA11yTabEmitter=this._register(new F),this._onWillOpen=this._register(new F),this._setup(),this._decorationService=this._instantiationService.createInstance(Zg),this._instantiationService.setService(yi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(q_),this._instantiationService.setService(Qc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(vn)),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(He.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(He.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(He.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(He.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(`${R.ESC}]${i};${Hg(n)}${_h.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ee.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ee.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(dr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.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(R.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,c=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=c+"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(Q(this.element,"copy",t=>{this.hasSelection()&&ap(t,this._selectionService)}));let e=t=>lp(t,this.textarea,this.coreService,this.optionsService);this._register(Q(this.textarea,"paste",e)),this._register(Q(this.element,"paste",e)),vh?this._register(Q(this.element,"mousedown",t=>{t.button===2&&Oa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Q(this.element,"contextmenu",t=>{Oa(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Eo&&this._register(Q(this.element,"auxclick",t=>{t.button===1&&Uc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Q(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Q(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Q(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Q(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Q(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Q(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Q(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var 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(Q(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",_n.get()),Sh||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(U_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(At,this._coreBrowserService),this._register(Q(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Q(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance($n,this._document,this._helperContainer),this._instantiationService.setService(Sr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Un),this._instantiationService.setService(Os,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lr),this._instantiationService.setService(Zc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Hn,this.rows,this.screenElement)),this._instantiationService.setService(It,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(An,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Fn),this._instantiationService.setService(bo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Zn,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(Tn,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(Wn,this.element,this.screenElement,i)),this._instantiationService.setService(_p,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(He.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(zn,this.screenElement)),this._register(Q(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(dr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(On,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var l,f,m,u,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let c,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(c=3,o.button!==void 0&&(c=o.button<3?o.button:3)):c=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,c=o.button<3?o.button:3;break;case"mousedown":h=1,c=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,(u=(m=(f=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:f.device)==null?void 0:m.cell)==null?void 0:u.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=p<0?0:1,c=4;break;default:return!1}return h===void 0||c===void 0||c>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:c,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(Q(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(Q(t,"wheel",o=>{var a,c,h,l,f;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,(l=(h=(c=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:c.device)==null?void 0:h.cell)==null?void 0:l.height,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return this.cancel(o,!0);let m=R.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){Wc(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=Xg(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===R.ETX||s.key===R.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)&&(rx(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(je));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(R.ESC+"[I"):this.coreService.triggerDataEvent(R.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(`${R.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(`${R.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function rx(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var nx=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)}},ox=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 dt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Rl=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 ox(t)}getNullCell(){return new dt}},ax=class extends re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new F),this.onBufferChange=this._onBufferChange.event,this._normal=new Rl(this._core.buffers.normal,"normal"),this._alternate=new Rl(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)}},lx=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)}},cx=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}},hx=["cols","rows"],_t=0,dx=class extends re{constructor(e){super(),this._core=this._register(new ix(e)),this._addonManager=this._register(new nx),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(hx.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 lx(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new cx(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 ax(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
|
|
198
|
+
`,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 _n.get()},set promptLabel(e){_n.set(e)},get tooMuchOutput(){return gn.get()},set tooMuchOutput(e){gn.set(e)}}}_verifyIntegers(...e){for(_t of e)if(_t===1/0||isNaN(_t)||_t%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(_t of e)if(_t&&(_t===1/0||isNaN(_t)||_t%1!==0||_t<0))throw new Error("This API only accepts positive integers")}};/**
|
|
199
199
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
200
200
|
* @license MIT
|
|
201
201
|
*
|
|
@@ -206,7 +206,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
206
206
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
207
207
|
* http://bellard.org/jslinux/
|
|
208
208
|
* Copyright (c) 2011 Fabrice Bellard
|
|
209
|
-
*/var
|
|
209
|
+
*/var ux=2,fx=1,mx=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"))},c=a.top+a.bottom,h=a.right+a.left,l=i-c,f=n-h-t;return{cols:Math.max(ux,Math.floor(f/e.css.cell.width)),rows:Math.max(fx,Math.floor(l/e.css.cell.height))}}};/**
|
|
210
210
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
211
211
|
* @license MIT
|
|
212
212
|
*
|
|
@@ -217,40 +217,40 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
217
217
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
218
218
|
* http://bellard.org/jslinux/
|
|
219
219
|
* Copyright (c) 2011 Fabrice Bellard
|
|
220
|
-
*/var
|
|
221
|
-
\x1B[31m-- Terminal unavailable: `+(
|
|
222
|
-
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(
|
|
223
|
-
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${x+1}/${El})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&f()},y)},g.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const p=s.current;if(!p)return;const u=new qg({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 Yg,m=new tx;u.loadAddon(g),u.loadAddon(m),u.open(p),i.current=u,n.current=g;try{g.fit()}catch{}u.onData(y=>{const b=o.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"input",data:y}))}),f();let _=null;const x=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return x.observe(p),()=>{l.current=!1,x.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),u.dispose(),i.current=null,n.current=null}},[f,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const p=setTimeout(()=>{var u;try{(u=n.current)==null||u.fit(),c()}catch{}},50);return()=>clearTimeout(p)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const Dl={file_created:{icon:_r,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:ee,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:tc,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:ps,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Xl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:os,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Rt,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Sd,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Rl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function nx({event:e,isLast:t,onFileClick:s}){const i=Dl[e.type]||Dl.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(ut,{size:10}),Rl(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(ut,{size:10}),Rl(e.timestamp)]})]})})]})}const Xr=20,Pl=10;function ox({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>Xr},[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(Yl,{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>Xr&&n,l=a?e.slice(-Pl):e,h=a?e.length-Pl: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(mr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Xr&&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(ms,{size:12}),"Collapse older events"]}),l.map((c,f)=>r.jsx(nx,{event:c,isLast:f===l.length-1,onFileClick:t},c.id))]})}const Ml=[{id:"terminal",label:"Terminal",icon:os,alwaysShow:!0},{id:"activity",label:"Activity",icon:$d,alwaysShow:!0},{id:"build",label:"Build Log",icon:Id},{id:"agents",label:"Agents",icon:Fd},{id:"quality",label:"Quality",icon:Jl}];function ax({status:e}){switch(e){case"pass":return r.jsx(Yt,{size:14,className:"text-success"});case"fail":return r.jsx(gt,{size:14,className:"text-danger"});default:return r.jsx(ut,{size:14,className:"text-muted"})}}function lx({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(wd,{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 cx({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(Jl,{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(ax,{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 hx({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var _;const[c,f]=d.useState("terminal"),p=s&&s.length>0,u=i&&i.items&&i.items.length>0,g=e&&e.length>0,m=Ml.filter(x=>!!(x.alwaysShow||x.id==="build"&&(g||o)||x.id==="agents"&&(p||o)||x.id==="quality"&&(u||o)));return m.find(x=>x.id===c)||f("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:m.map(x=>{const y=x.icon,b=c===x.id;return r.jsxs("button",{role:"tab","aria-selected":b,onClick:()=>f(x.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${b?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),x.label,x.id==="agents"&&p&&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}),x.id==="quality"&&u&&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]})]},x.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=Ml.find(x=>x.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(rx,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Ad,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(lx,{agents:s}),c==="activity"&&r.jsx(ox,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(cx,{checklist:i})]})]})}const Ll={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Working..."],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 dx({context:e="general",className:t=""}){const s=Ll[e]||Ll.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{if(s.length<2)return;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(gi,{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 Jr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:ru},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Hd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ai},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:as},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:ps}];function ux({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(null),[h,c]=d.useState(e),[f,p]=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){p(!0);const x=setTimeout(()=>{c(e),p(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const u=Jr.findIndex(x=>x.id===e),g=t!==null&&s?Math.min(t/s*100,100):0,m=a!==null&&t&&s?Math.ceil(a/t*Math.max(0,s-t)):null,_=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 ${f?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Jr.map((x,y)=>{const b=y<u,k=y===u,S=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${k?"phase-indicator-active":""} ${b?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${k?"phase-icon-active":""} ${b?"phase-icon-complete":""}`,children:b?r.jsx(ps,{size:14,className:"text-success phase-check-enter"}):k?r.jsx(S,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(S,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${k?"text-ink":b?"text-success":"text-muted/50"}`,children:x.label}),y<Jr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${b?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(dx,{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(Ls,{size:12}),"Iter ",t??"--",s?`/${s}`:""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ut,{size:12}),a===null?"--":_(a),o&&m!==null&&m>0&&r.jsxs("span",{className:"text-muted/60",children:["(est. ",_(m)," to iteration cap)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(sc,{size:12}),i!==null?`$${i.toFixed(2)}`:"not recorded"]})]})]})]})}const Zr=[{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 Nh(e,t){return e?"Connected":t?"Status unknown":"Not connected"}function fx({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(f){l(f instanceof Error?f.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
|
|
220
|
+
*/var px=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=gx.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 _x(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 gx=class Ji{static computeLink(t,s,i,n){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,c]=Ji._getWindowedLineStrings(t-1,i),h=a.join(""),l,f=[];for(;l=o.exec(h);){let m=l[0];if(!_x(m))continue;let[u,g]=Ji._mapStrIdx(i,c,0,l.index),[p,_]=Ji._mapStrIdx(i,u,g,m.length);if(u===-1||g===-1||p===-1||_===-1)continue;let x={start:{x:g+1,y:u+1},end:{x:_,y:p+1}};f.push({range:x,text:m,activate:n})}return f}static _getWindowedLineStrings(t,s){let i,n=t,o=t,a=0,c="",h=[];if(i=s.buffer.active.getLine(t)){let l=i.translateToString(!0);if(i.isWrapped&&l[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--n))&&a<2048&&(c=i.translateToString(!0),a+=c.length,h.push(c),!(!i.isWrapped||c.indexOf(" ")!==-1)););h.reverse()}for(h.push(l),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(c=i.translateToString(!0),a+=c.length,h.push(c),c.indexOf(" ")===-1););}return[h,n]}static _mapStrIdx(t,s,i,n){let o=t.buffer.active,a=o.getNullCell(),c=i;for(;n;){let h=o.getLine(s);if(!h)return[-1,-1];for(let l=c;l<h.length;++l){h.getCell(l,a);let f=a.getChars();if(a.getWidth()&&(n-=f.length||1,l===h.length-1&&f==="")){let m=o.getLine(s+1);m&&m.isWrapped&&(m.getCell(0,a),a.getWidth()===2&&(n+=1))}if(n<0)return[s,l]}s++,c=0}return[s,c]}},xx=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function vx(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 bx=class{constructor(e=vx,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||xx;this._linkProvider=this._terminal.registerLinkProvider(new px(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const Ll=10,yx=1e3,Sx=3e4;function wx({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),c=d.useRef(!0),h=d.useRef(0),l=d.useCallback(()=>{const m=o.current,u=i.current;m&&m.readyState===WebSocket.OPEN&&u&&m.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},[]),f=d.useCallback(()=>{if(!c.current)return;o.current&&(o.current.onclose=null,o.current.onerror=null,o.current.close(),o.current=null);const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${rn}/ws/terminal/${e}`,g=new WebSocket(u);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{}l()}},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(!c.current)return;const _=i.current;if(p.code===4e3){_&&_.writeln(`\r
|
|
221
|
+
\x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const x=h.current;if(x>=Ll){_&&_.writeln(`\r
|
|
222
|
+
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(yx*Math.pow(2,x),Sx);h.current=x+1,_&&_.writeln(`\r
|
|
223
|
+
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${x+1}/${Ll})... --\x1B[0m`),a.current=setTimeout(()=>{c.current&&f()},y)},g.onerror=()=>{}},[e,l]);return d.useEffect(()=>{c.current=!0,h.current=0;const m=s.current;if(!m)return;const u=new dx({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 mx,p=new bx;u.loadAddon(g),u.loadAddon(p),u.open(m),i.current=u,n.current=g;try{g.fit()}catch{}u.onData(y=>{const v=o.current;v&&v.readyState===WebSocket.OPEN&&v.send(JSON.stringify({type:"input",data:y}))}),f();let _=null;const x=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),l()}catch{}},50)});return x.observe(m),()=>{c.current=!1,x.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),u.dispose(),i.current=null,n.current=null}},[f,l]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var u;try{(u=n.current)==null||u.fit(),l()}catch{}},50);return()=>clearTimeout(m)}},[t,l]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const Pl={file_created:{icon:_r,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:ee,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:rc,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:vs,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Ql,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:fs,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Xt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Xt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Tt,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Ed,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Ml(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function Cx({event:e,isLast:t,onFileClick:s}){const i=Pl[e.type]||Pl.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(ft,{size:10}),Ml(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(ft,{size:10}),Ml(e.timestamp)]})]})})]})}const Jr=20,Bl=10;function kx({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>Jr},[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(Zl,{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>Jr&&n,c=a?e.slice(-Bl):e,h=a?e.length-Bl: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(mr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Jr&&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(xs,{size:12}),"Collapse older events"]}),c.map((l,f)=>r.jsx(Cx,{event:l,isLast:f===c.length-1,onFileClick:t},l.id))]})}const Tl=[{id:"terminal",label:"Terminal",icon:fs,alwaysShow:!0},{id:"activity",label:"Activity",icon:Kd,alwaysShow:!0},{id:"build",label:"Build Log",icon:qd},{id:"agents",label:"Agents",icon:Vd},{id:"quality",label:"Quality",icon:ec}];function Nx({status:e}){switch(e){case"pass":return r.jsx(es,{size:14,className:"text-success"});case"fail":return r.jsx(vt,{size:14,className:"text-danger"});default:return r.jsx(ft,{size:14,className:"text-muted"})}}function jx({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(Dd,{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 Ex({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(ec,{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 Dx({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:c,onFileClick:h}){var _;const[l,f]=d.useState("terminal"),m=s&&s.length>0,u=i&&i.items&&i.items.length>0,g=e&&e.length>0,p=Tl.filter(x=>!!(x.alwaysShow||x.id==="build"&&(g||o)||x.id==="agents"&&(m||o)||x.id==="quality"&&(u||o)));return p.find(x=>x.id===l)||f("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(x=>{const y=x.icon,v=l===x.id;return r.jsxs("button",{role:"tab","aria-selected":v,onClick:()=>f(x.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${v?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),x.label,x.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}),x.id==="quality"&&u&&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]})]},x.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=Tl.find(x=>x.id===l))==null?void 0:_.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:l==="terminal"?"visible":"hidden",zIndex:l==="terminal"?1:0},children:r.jsx(wx,{sessionId:n,isActive:l==="terminal"})}),l==="build"&&r.jsx(Wd,{logs:e,loading:t,subscribe:a}),l==="agents"&&r.jsx(jx,{agents:s}),l==="activity"&&r.jsx(kx,{events:c||[],onFileClick:h}),l==="quality"&&r.jsx(Ex,{checklist:i})]})]})}const zl={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Working..."],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 Rx({context:e="general",className:t=""}){const s=zl[e]||zl.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{if(s.length<2)return;const c=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(c)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(xi,{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 Zr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:hu},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Gd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ai},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:ms},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:vs}];function Lx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,c]=d.useState(null),[h,l]=d.useState(e),[f,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{c(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{l(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const u=Zr.findIndex(x=>x.id===e),g=t!==null&&s?Math.min(t/s*100,100):0,p=a!==null&&t&&s?Math.ceil(a/t*Math.max(0,s-t)):null,_=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 ${f?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Zr.map((x,y)=>{const v=y<u,k=y===u,w=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${k?"phase-indicator-active":""} ${v?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${k?"phase-icon-active":""} ${v?"phase-icon-complete":""}`,children:v?r.jsx(vs,{size:14,className:"text-success phase-check-enter"}):k?r.jsx(w,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(w,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${k?"text-ink":v?"text-success":"text-muted/50"}`,children:x.label}),y<Zr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${v?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(Rx,{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(zs,{size:12}),"Iter ",t??"--",s?`/${s}`:""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ft,{size:12}),a===null?"--":_(a),o&&p!==null&&p>0&&r.jsxs("span",{className:"text-muted/60",children:["(est. ",_(p)," to iteration cap)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(nc,{size:12}),i!==null?`$${i.toFixed(2)}`:"not recorded"]})]})]})]})}const Qr=[{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 Ph(e,t){return e?"Connected":t?"Status unknown":"Not connected"}function Px({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,c]=d.useState(null),h=d.useCallback(async l=>{if(l.preventDefault(),!!s.trim()){o(!0),c(null);try{await t(s.trim()),i("")}catch(f){c(f instanceof Error?f.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:l=>i(l.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
|
|
224
224
|
focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
|
|
225
|
-
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(ls,{size:10})]}),r.jsx(le,{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(_s,{size:12}),a]})]})}function mx(){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(os,{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(ls,{size:10})]})]})}function px({platform:e,status:t,loadFailed:s,onConnect:i,onDisconnect:n}){const[o,a]=d.useState(!1),[l,h]=d.useState(!1),c=d.useCallback(async()=>{h(!0);try{n()}finally{h(!1)}},[n]),f=d.useCallback(async p=>{await i(p),a(!1)},[i]);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:Nh(t.connected,s)})})]}),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(ps,{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(le,{variant:"danger",size:"sm",icon:Uu,onClick:c,loading:l,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!o&&r.jsx("div",{className:"mt-3",children:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>a(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),o&&r.jsx(fx,{platform:e,onConnect:f})]}):r.jsx(mx,{})]})]})}function _x({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 m=await V.getDeployStatus();i(m),t==null||t(m),l(null)}catch(m){l(m instanceof Error?m.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const m=setInterval(h,3e4);return()=>clearInterval(m)},[h]);const c=d.useCallback(async m=>{const _=await V.connectVercel(m);_.success&&(i(x=>({...x,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),f=d.useCallback(async m=>{const _=await V.connectNetlify(m);_.success&&(i(x=>({...x,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),p=d.useCallback(async m=>{await V.disconnectPlatform(m),i(x=>({...x,[m]:{connected:!1}}));const _={...s,[m]:{connected:!1}};t==null||t(_)},[s,t]),u={vercel:c,netlify:f,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(gi,{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(m=>m.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 ",Zr.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(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Zr.map(m=>{const _=s[m.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${m.name}: ${_.connected?`Connected as ${_.user}`:Nh(!1,a!==null)}`,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:m.name})]},m.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{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(_s,{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:Zr.map(m=>r.jsx(px,{platform:m,status:s[m.id],loadFailed:a!==null,onConnect:u[m.id],onDisconnect:()=>p(m.id)},m.id))})]})}const Bl={connected:"Connected",disconnected:"Not connected",checking:"Checking...",unknown:"Status unknown"},gx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:nn,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:nn,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:Te,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function xx({platform:e,deployState:t,onDeploy:s,disabled:i,connection: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=n==="connected",f=i||!c;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==="disconnected"?"opacity-60":"hover:border-primary/30 hover:bg-hover"}`,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})]}),n==="checking"||n==="unknown"?r.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:Bl[n]}):r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${c?"bg-green-500":"bg-gray-300"}`,title:Bl[n]})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:["Deploy to ",e.name]}),n==="disconnected"&&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(gi,{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(ps,{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(nn,{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(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{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(ls,{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(_s,{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(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:"Retry"})]})]})}function vx({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 V.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(Te,{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(le,{variant:"secondary",size:"sm",icon:Te,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(gi,{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(ps,{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(Te,{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(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{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(_s,{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(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function bx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState(null),[o,a]=d.useState(!1);d.useEffect(()=>{V.getDeployStatus().then(n).catch(()=>a(!0))},[]);const[l,h]=d.useState(!1),c=Object.values(t).some(u=>u.status==="deploying"),f=d.useCallback(async u=>{s(g=>({...g,[u]:{status:"deploying"}}));try{const g=await V.deployProject(e,u);g.url?s(m=>({...m,[u]:{status:"success",url:g.url}})):s(m=>({...m,[u]:{status:"error",error:g.error||"Deploy failed"}}))}catch(g){s(m=>({...m,[u]:{status:"error",error:g instanceof Error?g.message:"Deploy failed"}}))}},[e]),p=u=>{var g;return i?(g=i[u.connectionKey])!=null&&g.connected?"connected":"disconnected":o?"unknown":"checking"};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(Kt,{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:()=>h(!l),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(hc,{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:i?["vercel","netlify","github"].map(u=>{var g,m;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(g=i[u])!=null&&g.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(m=i[u])!=null&&m.connected?"Connected":"Not connected"}`},u)}):r.jsx("span",{className:"text-[11px] text-muted",children:o?"Status unknown":"Checking..."})})]}),r.jsx("span",{className:"text-xs text-muted",children:l?"Hide":"Manage"})]}),l&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(_x,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:gx.map(u=>r.jsx(xx,{platform:u,deployState:t[u.id],onDeploy:()=>f(u.id),disabled:c,connection:p(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(vx,{sessionId:e,disabled:c})]})})}const jh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Et=jh?"Cmd":"Ctrl",Tl=[{keys:[`${Et}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Et}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Et}+,`],label:"Open settings",category:"navigation"},{keys:[`${Et}+S`],label:"Save file",category:"editor"},{keys:[`${Et}+Z`],label:"Undo",category:"editor"},{keys:[`${Et}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Et}+B`],label:"Start / stop build",category:"build"},{keys:[`${Et}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Et}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],yx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},Sx=["navigation","editor","build","general"];function wx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,f;const a=jh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((f=o.target)==null?void 0:f.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(p=>!p);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(p=>!p);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 Cx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Tl;const a=s.toLowerCase();return Tl.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(Cd,{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(gt,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(as,{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:[Sx.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:yx[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 kx({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 Eh="pl_recent_commands",Nx=5;function Dh(){try{const e=localStorage.getItem(Eh);return e?JSON.parse(e):[]}catch{return[]}}function Qr(e){try{const t=Dh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(Eh,JSON.stringify(t.slice(0,Nx)))}catch{}}function jx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:ee,ts:ee,tsx:ee,jsx:ee,py:ee,go:ee,rs:ee,rb:ee,sh:ee,html:cc,css:no,json:ro,md:_i}[t]||oo}function Ex(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 zl({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 Dx(e,t,s){return t?null:s?"File search failed":e===0?"No results found":null}function Rx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,f]=d.useState([]),[p,u]=d.useState(!1),[g,m]=d.useState(!1),_=d.useRef(null),x=d.useRef(null),y=kd(e);Nd(e,t),d.useEffect(()=>{e&&(a(""),h(0),f([]),u(!1),m(!1),setTimeout(()=>{var C;return(C=_.current)==null?void 0:C.focus()},50))},[e]);const b=d.useMemo(()=>Dh().map(H=>s.find(F=>F.id===H)).filter(Boolean),[s]),k=d.useMemo(()=>{if(!o.trim())return s.map(H=>({cmd:H,indices:[]}));const C=[];for(const H of s){const F=Ex(o,H.label);if(F){const K=F[0]*10+(F[F.length-1]-F[0]);C.push({cmd:H,indices:F,score:K})}}return C.sort((H,F)=>H.score-F.score),C.map(H=>({cmd:H.cmd,indices:H.indices}))},[s,o]),S=d.useMemo(()=>o.trim()?k.filter(C=>C.cmd.category==="setting"):[],[k,o]),w=d.useMemo(()=>k.filter(C=>C.cmd.category!=="setting"),[k]);d.useEffect(()=>{if(!i||!o.trim()){f([]),u(!1),m(!1);return}return u(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{try{const C=await V.searchFiles(i,o);f(C.filter(H=>H.type==="file")),m(!1)}catch{f([]),m(!0)}u(!1)},200),()=>{x.current&&clearTimeout(x.current)}},[o,i]);const j=!o.trim()&&b.length>0,B=d.useMemo(()=>{const C=[];return j&&b.forEach((H,F)=>C.push({type:"recent",index:F})),w.forEach((H,F)=>C.push({type:"command",index:F})),S.length>0&&S.forEach((H,F)=>C.push({type:"setting",index:F})),c.forEach((H,F)=>C.push({type:"file",index:F})),C},[j,b,w,S,c]),M=B.length;d.useEffect(()=>{h(0)},[o]);const Y=d.useCallback(C=>{const H=B[C];if(H){if(H.type==="recent"){const F=b[H.index];F&&(Qr(F.id),F.action(),t())}else if(H.type==="command"){const F=w[H.index];F&&(Qr(F.cmd.id),F.cmd.action(),t())}else if(H.type==="setting"){const F=S[H.index];F&&(Qr(F.cmd.id),F.cmd.action(),t())}else if(H.type==="file"){const F=c[H.index];F&&n&&(n(F.path,F.name),t())}}},[B,b,w,S,c,n,t]),X=d.useCallback(C=>{C.key==="ArrowDown"?(C.preventDefault(),h(H=>Math.min(H+1,M-1))):C.key==="ArrowUp"?(C.preventDefault(),h(H=>Math.max(H-1,0))):C.key==="Enter"&&M>0?Y(l):C.key==="Escape"&&t()},[M,l,Y,t]);if(!e)return null;let $=0;const D=()=>$++,N=w.length>0,L=S.length>0,E=c.length>0,P=p&&o.trim().length>0,U=Dx(M,P,g);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:y,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:C=>C.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(as,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:C=>a(C.target.value),onKeyDown:X,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:[j&&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(ut,{size:10})," Recent"]}),b.map((C,H)=>{const F=D(),K=C.icon;return r.jsxs("button",{onClick:()=>Y(F),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${F===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:C.label}),C.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:C.shortcut})]},`recent-${C.id}`)})]}),N&&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"}),w.map((C,H)=>{const F=D(),K=C.cmd.icon;return r.jsxs("button",{onClick:()=>Y(F),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${F===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(zl,{text:C.cmd.label,indices:C.indices}):C.cmd.label}),C.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:C.cmd.shortcut})]},C.cmd.id)})]}),L&&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"}),S.map((C,H)=>{const F=D(),K=C.cmd.icon;return r.jsxs("button",{onClick:()=>Y(F),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${F===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(zl,{text:C.cmd.label,indices:C.indices})}),C.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:C.cmd.shortcut})]},`setting-${C.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((C,H)=>{const F=D(),K=C.type==="directory"?ao:jx(C.name);return r.jsxs("button",{onClick:()=>Y(F),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${F===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:C.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:C.path})]},`file-${C.path}`)})]}),P&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),U&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",role:g?"alert":void 0,children:U})]})]})]})}const Px=d.lazy(()=>eo(()=>import("./GitHubIssuesPanel-L-JdQNH7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),Mx=d.lazy(()=>eo(()=>import("./GitHubPRsPanel-BmASy439.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,8,24,25,26,27,28,29,9,30,31,32,33,34])).then(e=>({default:e.GitHubPRsPanel}))),Lx=d.lazy(()=>eo(()=>Promise.resolve().then(()=>Jx),void 0).then(e=>({default:e.CICDPanel}))),Bx=3e4,Tx={modified:r.jsx(ee,{size:13,className:"text-yellow-500"}),added:r.jsx(_r,{size:13,className:"text-green-500"}),deleted:r.jsx(io,{size:13,className:"text-red-400"}),renamed:r.jsx(ee,{size:13,className:"text-blue-400"}),untracked:r.jsx(rc,{size:13,className:"text-muted"})},zx={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Ax({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(ic,{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(Te,{size:9}),t]},s))})]})]})})}function Al({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:[Tx[e.status]||r.jsx(rc,{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:zx[e.status]||"?"})]})}function Ox({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,f]=d.useState(!0),[p,u]=d.useState(null),[g,m]=d.useState(""),[_,x]=d.useState(!1),[y,b]=d.useState(null),[k,S]=d.useState(!1),[w,j]=d.useState(""),[B,M]=d.useState(!1),[Y,X]=d.useState(!1),[$,D]=d.useState(""),[N,L]=d.useState(""),[E,P]=d.useState(!1),[U,C]=d.useState(null),[H,F]=d.useState(!1),K=d.useCallback(async()=>{f(!0),u(null);try{const[z,xe,T]=await Promise.all([V.git.status(e),V.git.log(e),V.git.branches(e)]);n(z),a(xe),h(T)}catch(z){u(z instanceof Error?z.message:"Failed to load git data")}f(!1)},[e]);d.useEffect(()=>{K()},[K]);const Q=async()=>{if(!(!g.trim()||_)){x(!0),b(null);try{const z=await V.git.commit(e,g.trim());b(`Committed: ${z.hash}`),m(""),await K()}catch(z){b(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}x(!1)}},ie=async()=>{if(!(!w.trim()||B)){M(!0);try{await V.git.createBranch(e,w.trim()),j(""),S(!1),await K()}catch(z){u(z instanceof Error?z.message:"Branch creation failed")}M(!1)}},de=async z=>{try{await V.git.checkoutBranch(e,z),await K()}catch(xe){u(xe instanceof Error?xe.message:"Checkout failed")}},ue=async()=>{F(!0);try{await V.git.push(e),await K()}catch(z){u(z instanceof Error?z.message:"Push failed")}F(!1)},ce=async()=>{if(!(!$.trim()||E)){P(!0),C(null);try{const z=await V.git.pr(e,$.trim(),N.trim());C(z.url),D(""),L(""),X(!1)}catch(z){C(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}P(!1)}},ge=(i==null?void 0:i.files.filter(z=>z.staged))||[],Fe=(i==null?void 0:i.files.filter(z=>!z.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(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):p&&!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(_s,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:p}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(le,{size:"sm",variant:"secondary",icon:bt,onClick:K,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(Te,{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(Yt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:K,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{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:ee,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ut},{id:"branches",label:"Branches",icon:Te,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.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:z.count})]},z.id))}),p&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:p}),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(Yt,{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:[ge.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 (",ge.length,")"]}),ge.map((z,xe)=>r.jsx(Al,{file:z},`s-${xe}`))]}),Fe.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 (",Fe.length,")"]}),Fe.map((z,xe)=>r.jsx(Al,{file:z},`u-${xe}`))]}),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:z=>m(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",icon:ic,onClick:Q,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(le,{size:"sm",variant:"secondary",icon:oc,onClick:ue,loading:H,disabled:H,children:"Push"}),r.jsx(le,{size:"sm",variant:"ghost",icon:an,onClick:()=>X(!Y),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),U&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:U.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:U}):r.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:U})})]}),Y&&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:$,onChange:z=>D(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:N,onChange:z=>L(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(le,{size:"sm",icon:an,onClick:ce,disabled:!$.trim()||E,loading:E,children:"Create PR"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>X(!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(ut,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Ax,{commit:z},xe))}),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:()=>S(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(gr,{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:z=>j(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&ie()}}),r.jsx(le,{size:"sm",onClick:ie,disabled:!w.trim()||B,loading:B,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Te,{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(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&de(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(Te,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.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-${xe}`)),l.filter(z=>z.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(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(Te,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function en(){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(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function tn({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await V.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(fu,{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(le,{size:"sm",icon:oc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function $x({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({actions:0,fetchedAt:0}),c=d.useRef(!1),f=d.useCallback(async()=>{n(!0);try{const _=await V.git.branches(e);a({has_remote:_.some(x=>x.remote)})}catch{a(null)}n(!1)},[e]);d.useEffect(()=>{f()},[f]);const p=d.useCallback(async()=>{if(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Bx||c.current)return;c.current=!0;const x=await V.getWorkflowRuns(e,5).catch(()=>null);h({actions:x?x.filter(y=>y.status==="in_progress").length:0,fetchedAt:Date.now()}),c.current=!1},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&p()},[o==null?void 0:o.has_remote,p]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&p()},[t,o==null?void 0:o.has_remote,p]),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(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const u=(o==null?void 0:o.has_remote)??!0,g=[{id:"changes",label:"Changes",icon:ee,requiresRemote:!1},{id:"issues",label:"Issues",icon:Wd,requiresRemote:!0},{id:"prs",label:"PRs",icon:an,requiresRemote:!0},{id:"actions",label:"Actions",icon:rs,count:l.actions,requiresRemote:!0}],m=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:[m.map(_=>{const x=_.requiresRemote&&!u;return r.jsxs("button",{onClick:()=>s(_.id),disabled:x,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":x?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:x?"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)}),u&&(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(hc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Ox,{sessionId:e}),t==="issues"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(Px,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="prs"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(Mx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="actions"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Lx,{sessionId:e})})}):r.jsx(tn,{sessionId:e,onPushed:f}))]})]})}function Ix({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(null),u=d.useCallback(async()=>{try{const _=await V.getCheckpoints(e);i(_),p(null)}catch{p("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{u();const _=setInterval(u,15e3);return()=>clearInterval(_)},[u]);const g=d.useCallback(async _=>{if(a)return;const x=s.find(b=>b.id===_);if(!(!x||!window.confirm(`Restore to checkpoint "${x.description}"?
|
|
225
|
+
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(ps,{size:10})]}),r.jsx(he,{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(bs,{size:12}),a]})]})}function Mx(){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(fs,{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(ps,{size:10})]})]})}function Bx({platform:e,status:t,loadFailed:s,onConnect:i,onDisconnect:n}){const[o,a]=d.useState(!1),[c,h]=d.useState(!1),l=d.useCallback(async()=>{h(!0);try{n()}finally{h(!1)}},[n]),f=d.useCallback(async m=>{await i(m),a(!1)},[i]);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:Ph(t.connected,s)})})]}),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(vs,{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(he,{variant:"danger",size:"sm",icon:Xu,onClick:l,loading:c,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(bs,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!o&&r.jsx("div",{className:"mt-3",children:r.jsx(he,{variant:"secondary",size:"sm",onClick:()=>a(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),o&&r.jsx(Px,{platform:e,onConnect:f})]}):r.jsx(Mx,{})]})]})}function Tx({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,c]=d.useState(null),h=d.useCallback(async()=>{try{const p=await V.getDeployStatus();i(p),t==null||t(p),c(null)}catch(p){c(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 l=d.useCallback(async p=>{const _=await V.connectVercel(p);_.success&&(i(x=>({...x,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),f=d.useCallback(async p=>{const _=await V.connectNetlify(p);_.success&&(i(x=>({...x,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),m=d.useCallback(async p=>{await V.disconnectPlatform(p),i(x=>({...x,[p]:{connected:!1}}));const _={...s,[p]:{connected:!1}};t==null||t(_)},[s,t]),u={vercel:l,netlify:f,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(xi,{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 ",Qr.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(St,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Qr.map(p=>{const _=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${_.connected?`Connected as ${_.user}`:Ph(!1,a!==null)}`,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(St,{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(bs,{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:Qr.map(p=>r.jsx(Bx,{platform:p,status:s[p.id],loadFailed:a!==null,onConnect:u[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const Al={connected:"Connected",disconnected:"Not connected",checking:"Checking...",unknown:"Status unknown"},zx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:on,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:on,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:Ie,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function Ax({platform:e,deployState:t,onDeploy:s,disabled:i,connection:n}){const[o,a]=d.useState(!1),c=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]),l=n==="connected",f=i||!l;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==="disconnected"?"opacity-60":"hover:border-primary/30 hover:bg-hover"}`,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(c,{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})]}),n==="checking"||n==="unknown"?r.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:Al[n]}):r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${l?"bg-green-500":"bg-gray-300"}`,title:Al[n]})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(he,{variant:"secondary",size:"sm",icon:Xt,onClick:s,disabled:f,className:"w-full",children:["Deploy to ",e.name]}),n==="disconnected"&&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(xi,{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(vs,{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(on,{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(es,{size:12,className:"text-green-500"}):r.jsx(ro,{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(ps,{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(bs,{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(he,{variant:"secondary",size:"sm",icon:Xt,onClick:s,disabled:f,className:"w-full",children:"Retry"})]})]})}function Ix({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 V.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]),c=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(Ie,{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(he,{variant:"secondary",size:"sm",icon:Ie,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(xi,{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(vs,{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(Ie,{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:c,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(es,{size:12,className:"text-green-500"}):r.jsx(ro,{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(bs,{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(he,{variant:"secondary",size:"sm",icon:Ie,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function Ox({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState(null),[o,a]=d.useState(!1);d.useEffect(()=>{V.getDeployStatus().then(n).catch(()=>a(!0))},[]);const[c,h]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),f=d.useCallback(async u=>{s(g=>({...g,[u]:{status:"deploying"}}));try{const g=await V.deployProject(e,u);g.url?s(p=>({...p,[u]:{status:"success",url:g.url}})):s(p=>({...p,[u]:{status:"error",error:g.error||"Deploy failed"}}))}catch(g){s(p=>({...p,[u]:{status:"error",error:g instanceof Error?g.message:"Deploy failed"}}))}},[e]),m=u=>{var g;return i?(g=i[u.connectionKey])!=null&&g.connected?"connected":"disconnected":o?"unknown":"checking"};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(Xt,{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:()=>h(!c),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(fc,{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:i?["vercel","netlify","github"].map(u=>{var g,p;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(g=i[u])!=null&&g.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(p=i[u])!=null&&p.connected?"Connected":"Not connected"}`},u)}):r.jsx("span",{className:"text-[11px] text-muted",children:o?"Status unknown":"Checking..."})})]}),r.jsx("span",{className:"text-xs text-muted",children:c?"Hide":"Manage"})]}),c&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(Tx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:zx.map(u=>r.jsx(Ax,{platform:u,deployState:t[u.id],onDeploy:()=>f(u.id),disabled:l,connection:m(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(Ix,{sessionId:e,disabled:l})]})})}const Mh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Mt=Mh?"Cmd":"Ctrl",Il=[{keys:[`${Mt}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Mt}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Mt}+,`],label:"Open settings",category:"navigation"},{keys:[`${Mt}+S`],label:"Save file",category:"editor"},{keys:[`${Mt}+Z`],label:"Undo",category:"editor"},{keys:[`${Mt}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Mt}+B`],label:"Start / stop build",category:"build"},{keys:[`${Mt}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Mt}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],$x={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},Fx=["navigation","editor","build","general"];function Hx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var l,f;const a=Mh?o.metaKey:o.ctrlKey,c=(l=o.target)==null?void 0:l.tagName,h=c==="INPUT"||c==="TEXTAREA"||((f=o.target)==null?void 0:f.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 Il;const a=s.toLowerCase();return Il.filter(c=>c.label.toLowerCase().includes(a)||c.keys.some(h=>h.toLowerCase().includes(a))||c.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const c of n)a[c.category]||(a[c.category]=[]),a[c.category].push(c);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(Rd,{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(vt,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(ms,{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:[Fx.map(a=>{const c=o[a];return!c||c.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:$x[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:c.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(l=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:l},l))})]},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 Ux({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 Bh="pl_recent_commands",Kx=5;function Th(){try{const e=localStorage.getItem(Bh);return e?JSON.parse(e):[]}catch{return[]}}function en(e){try{const t=Th().filter(s=>s!==e);t.unshift(e),localStorage.setItem(Bh,JSON.stringify(t.slice(0,Kx)))}catch{}}function qx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:ee,ts:ee,tsx:ee,jsx:ee,py:ee,go:ee,rs:ee,rb:ee,sh:ee,html:uc,css:ao,json:oo,md:gi}[t]||lo}function Vx(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 Ol({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 Gx(e,t,s){return t?null:s?"File search failed":e===0?"No results found":null}function Yx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[c,h]=d.useState(0),[l,f]=d.useState([]),[m,u]=d.useState(!1),[g,p]=d.useState(!1),_=d.useRef(null),x=d.useRef(null),y=Ld(e);Pd(e,t),d.useEffect(()=>{e&&(a(""),h(0),f([]),u(!1),p(!1),setTimeout(()=>{var C;return(C=_.current)==null?void 0:C.focus()},50))},[e]);const v=d.useMemo(()=>Th().map(I=>s.find(O=>O.id===I)).filter(Boolean),[s]),k=d.useMemo(()=>{if(!o.trim())return s.map(I=>({cmd:I,indices:[]}));const C=[];for(const I of s){const O=Vx(o,I.label);if(O){const K=O[0]*10+(O[O.length-1]-O[0]);C.push({cmd:I,indices:O,score:K})}}return C.sort((I,O)=>I.score-O.score),C.map(I=>({cmd:I.cmd,indices:I.indices}))},[s,o]),w=d.useMemo(()=>o.trim()?k.filter(C=>C.cmd.category==="setting"):[],[k,o]),D=d.useMemo(()=>k.filter(C=>C.cmd.category!=="setting"),[k]);d.useEffect(()=>{if(!i||!o.trim()){f([]),u(!1),p(!1);return}return u(!0),x.current&&clearTimeout(x.current),x.current=setTimeout(async()=>{try{const C=await V.searchFiles(i,o);f(C.filter(I=>I.type==="file")),p(!1)}catch{f([]),p(!0)}u(!1)},200),()=>{x.current&&clearTimeout(x.current)}},[o,i]);const N=!o.trim()&&v.length>0,T=d.useMemo(()=>{const C=[];return N&&v.forEach((I,O)=>C.push({type:"recent",index:O})),D.forEach((I,O)=>C.push({type:"command",index:O})),w.length>0&&w.forEach((I,O)=>C.push({type:"setting",index:O})),l.forEach((I,O)=>C.push({type:"file",index:O})),C},[N,v,D,w,l]),L=T.length;d.useEffect(()=>{h(0)},[o]);const U=d.useCallback(C=>{const I=T[C];if(I){if(I.type==="recent"){const O=v[I.index];O&&(en(O.id),O.action(),t())}else if(I.type==="command"){const O=D[I.index];O&&(en(O.cmd.id),O.cmd.action(),t())}else if(I.type==="setting"){const O=w[I.index];O&&(en(O.cmd.id),O.cmd.action(),t())}else if(I.type==="file"){const O=l[I.index];O&&n&&(n(O.path,O.name),t())}}},[T,v,D,w,l,n,t]),Y=d.useCallback(C=>{C.key==="ArrowDown"?(C.preventDefault(),h(I=>Math.min(I+1,L-1))):C.key==="ArrowUp"?(C.preventDefault(),h(I=>Math.max(I-1,0))):C.key==="Enter"&&L>0?U(c):C.key==="Escape"&&t()},[L,c,U,t]);if(!e)return null;let X=0;const M=()=>X++,E=D.length>0,P=w.length>0,S=l.length>0,j=m&&o.trim().length>0,z=Gx(L,j,g);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:y,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:C=>C.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(ms,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:C=>a(C.target.value),onKeyDown:Y,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(ft,{size:10})," Recent"]}),v.map((C,I)=>{const O=M(),K=C.icon;return r.jsxs("button",{onClick:()=>U(O),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${O===c?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:C.label}),C.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:C.shortcut})]},`recent-${C.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",children:"Commands"}),D.map((C,I)=>{const O=M(),K=C.cmd.icon;return r.jsxs("button",{onClick:()=>U(O),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${O===c?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Ol,{text:C.cmd.label,indices:C.indices}):C.cmd.label}),C.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:C.cmd.shortcut})]},C.cmd.id)})]}),P&&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"}),w.map((C,I)=>{const O=M(),K=C.cmd.icon;return r.jsxs("button",{onClick:()=>U(O),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${O===c?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Ol,{text:C.cmd.label,indices:C.indices})}),C.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:C.cmd.shortcut})]},`setting-${C.cmd.id}`)})]}),S&&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"}),l.map((C,I)=>{const O=M(),K=C.type==="directory"?co:qx(C.name);return r.jsxs("button",{onClick:()=>U(O),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${O===c?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(K,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:C.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:C.path})]},`file-${C.path}`)})]}),j&&!S&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),z&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",role:g?"alert":void 0,children:z})]})]})]})}const Xx=d.lazy(()=>so(()=>import("./GitHubIssuesPanel-DpSh68Vr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),Jx=d.lazy(()=>so(()=>import("./GitHubPRsPanel-PsM0TRCK.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,8,24,25,26,27,28,29,9,30,31,32,33,34])).then(e=>({default:e.GitHubPRsPanel}))),Zx=d.lazy(()=>so(()=>Promise.resolve().then(()=>_v),void 0).then(e=>({default:e.CICDPanel}))),Qx=3e4,ev={modified:r.jsx(ee,{size:13,className:"text-yellow-500"}),added:r.jsx(_r,{size:13,className:"text-green-500"}),deleted:r.jsx(no,{size:13,className:"text-red-400"}),renamed:r.jsx(ee,{size:13,className:"text-blue-400"}),untracked:r.jsx(ac,{size:13,className:"text-muted"})},tv={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function sv({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(oc,{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(Ie,{size:9}),t]},s))})]})]})})}function $l({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:[ev[e.status]||r.jsx(ac,{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:tv[e.status]||"?"})]})}function iv({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[c,h]=d.useState([]),[l,f]=d.useState(!0),[m,u]=d.useState(null),[g,p]=d.useState(""),[_,x]=d.useState(!1),[y,v]=d.useState(null),[k,w]=d.useState(!1),[D,N]=d.useState(""),[T,L]=d.useState(!1),[U,Y]=d.useState(!1),[X,M]=d.useState(""),[E,P]=d.useState(""),[S,j]=d.useState(!1),[z,C]=d.useState(null),[I,O]=d.useState(!1),K=d.useCallback(async()=>{f(!0),u(null);try{const[A,pe,B]=await Promise.all([V.git.status(e),V.git.log(e),V.git.branches(e)]);n(A),a(pe),h(B)}catch(A){u(A instanceof Error?A.message:"Failed to load git data")}f(!1)},[e]);d.useEffect(()=>{K()},[K]);const Z=async()=>{if(!(!g.trim()||_)){x(!0),v(null);try{const A=await V.git.commit(e,g.trim());v(`Committed: ${A.hash}`),p(""),await K()}catch(A){v(`Error: ${A instanceof Error?A.message:"Commit failed"}`)}x(!1)}},ne=async()=>{if(!(!D.trim()||T)){L(!0);try{await V.git.createBranch(e,D.trim()),N(""),w(!1),await K()}catch(A){u(A instanceof Error?A.message:"Branch creation failed")}L(!1)}},ce=async A=>{try{await V.git.checkoutBranch(e,A),await K()}catch(pe){u(pe instanceof Error?pe.message:"Checkout failed")}},oe=async()=>{O(!0);try{await V.git.push(e),await K()}catch(A){u(A instanceof Error?A.message:"Push failed")}O(!1)},_e=async()=>{if(!(!X.trim()||S)){j(!0),C(null);try{const A=await V.git.pr(e,X.trim(),E.trim());C(A.url),M(""),P(""),Y(!1)}catch(A){C(`Error: ${A instanceof Error?A.message:"PR creation failed"}`)}j(!1)}},ue=(i==null?void 0:i.files.filter(A=>A.staged))||[],De=(i==null?void 0:i.files.filter(A=>!A.staged))||[];return l&&!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(St,{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(bs,{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(he,{size:"sm",variant:"secondary",icon:St,onClick:K,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(Ie,{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(es,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:K,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(St,{size:13,className:l?"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:ee,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ft},{id:"branches",label:"Branches",icon:Ie,count:c.length}].map(A=>r.jsxs("button",{onClick:()=>s(A.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===A.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(A.icon,{size:12}),A.label,A.count!==void 0&&A.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:A.count})]},A.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(es,{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:[ue.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 (",ue.length,")"]}),ue.map((A,pe)=>r.jsx($l,{file:A},`s-${pe}`))]}),De.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 (",De.length,")"]}),De.map((A,pe)=>r.jsx($l,{file:A},`u-${pe}`))]}),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:A=>p(A.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(he,{size:"sm",icon:oc,onClick:Z,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(he,{size:"sm",variant:"secondary",icon:cc,onClick:oe,loading:I,disabled:I,children:"Push"}),r.jsx(he,{size:"sm",variant:"ghost",icon:ln,onClick:()=>Y(!U),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),z&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:z.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:z}):r.jsx("a",{href:z,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:z})})]}),U&&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:X,onChange:A=>M(A.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:A=>P(A.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(he,{size:"sm",icon:ln,onClick:_e,disabled:!X.trim()||S,loading:S,children:"Create PR"}),r.jsx(he,{size:"sm",variant:"ghost",onClick:()=>Y(!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(ft,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((A,pe)=>r.jsx(sv,{commit:A},pe))}),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:()=>w(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(gr,{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:D,onChange:A=>N(A.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:A=>{A.key==="Enter"&&ne()}}),r.jsx(he,{size:"sm",onClick:ne,disabled:!D.trim()||T,loading:T,children:"Create"})]}),c.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ie,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[c.filter(A=>!A.remote).map((A,pe)=>r.jsxs("button",{onClick:()=>!A.current&&ce(A.name),disabled:A.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${A.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(Ie,{size:13,className:A.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${A.current?"text-primary font-semibold":"text-ink"}`,children:A.name}),A.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-${pe}`)),c.filter(A=>A.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"}),c.filter(A=>A.remote).map((A,pe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(Ie,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:A.name})]},`r-${pe}`))]})]})]})]})]})}function tn(){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(St,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function sn({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await V.githubPush(e),t()}catch(c){o(c instanceof Error?c.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(vu,{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(he,{size:"sm",icon:cc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function rv({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[c,h]=d.useState({actions:0,fetchedAt:0}),l=d.useRef(!1),f=d.useCallback(async()=>{n(!0);try{const _=await V.git.branches(e);a({has_remote:_.some(x=>x.remote)})}catch{a(null)}n(!1)},[e]);d.useEffect(()=>{f()},[f]);const m=d.useCallback(async()=>{if(!(o!=null&&o.has_remote)||Date.now()-c.fetchedAt<Qx||l.current)return;l.current=!0;const x=await V.getWorkflowRuns(e,5).catch(()=>null);h({actions:x?x.filter(y=>y.status==="in_progress").length:0,fetchedAt:Date.now()}),l.current=!1},[e,o==null?void 0:o.has_remote,c.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(St,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const u=(o==null?void 0:o.has_remote)??!0,g=[{id:"changes",label:"Changes",icon:ee,requiresRemote:!1},{id:"issues",label:"Issues",icon:Yd,requiresRemote:!0},{id:"prs",label:"PRs",icon:ln,requiresRemote:!0},{id:"actions",label:"Actions",icon:ds,count:c.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 x=_.requiresRemote&&!u;return r.jsxs("button",{onClick:()=>s(_.id),disabled:x,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":x?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:x?"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)}),u&&(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(fc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(iv,{sessionId:e}),t==="issues"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(tn,{}),children:r.jsx(Xx,{sessionId:e})}):r.jsx(sn,{sessionId:e,onPushed:f})),t==="prs"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(tn,{}),children:r.jsx(Jx,{sessionId:e})}):r.jsx(sn,{sessionId:e,onPushed:f})),t==="actions"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(tn,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Zx,{sessionId:e})})}):r.jsx(sn,{sessionId:e,onPushed:f}))]})]})}function nv({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,c]=d.useState(null),[h,l]=d.useState(null),[f,m]=d.useState(null),u=d.useCallback(async()=>{try{const _=await V.getCheckpoints(e);i(_),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{u();const _=setInterval(u,15e3);return()=>clearInterval(_)},[u]);const g=d.useCallback(async _=>{if(a)return;const x=s.find(v=>v.id===_);if(!(!x||!window.confirm(`Restore to checkpoint "${x.description}"?
|
|
226
226
|
|
|
227
|
-
This will revert files to this checkpoint state.`))){l(_);try{await V.restoreCheckpoint(e,_),await u(),t==null||t()}catch{p("Failed to restore checkpoint")}l(null)}},[e,s,a,u,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(rr,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(f&&s.length===0||s.length===0)return null;const m=_=>{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(rr,{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((_,x)=>r.jsxs("div",{className:"flex items-center gap-1",children:[x>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(ut,{size:10}),m(_.timestamp)]}),(_.files_changed??0)>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ee,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),(_.iteration??0)>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(ac,{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))}),f&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:f})]})}function Fx({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 Hx({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(_r,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(cu,{size:14,className:"text-danger"}):r.jsx(ee,{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(pr,{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(gr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(nc,{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,f)=>r.jsx(Fx,{line:c},`${h}-${f}`))]},h))})]})}function Wx({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(u=>u.path))),[l,h]=d.useState(0),c=d.useCallback(u=>{a(g=>{const m=new Set(g);return m.has(u)?m.delete(u):m.add(u),m})},[]),f=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(u=>u.path)))},[o.size,e.files]),p=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:u=>u.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:u=>u.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(ee,{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(gr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(nc,{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(gt,{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:f,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((u,g)=>{const m=u.action==="add"?"text-success":u.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(u.path),onChange:()=>c(u.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:u.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${m}`,children:u.action==="add"?"+":u.action==="delete"?"-":"M"})]},u.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Hx,{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(lc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:p,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(Yt,{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(su,{size:14}),"Accept All"]})]})]})]})}function jo(e){switch(e.status){case"completed":switch(e.conclusion){case"success":return"success";case"failure":case"timed_out":case"startup_failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"unknown"}case"in_progress":return"running";case"queued":case"waiting":case"requested":case"pending":return"pending";default:return"unknown"}}function Zi(e){return jo(e)}function Ux(e){return jo(e)}function Kx(e){return jo(e)}const Eo={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ut,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:xr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Zl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:sr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:lc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:jd,label:"Skipped"},unknown:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Rt,label:"Unknown"}};function Rh(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 Ph(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 Do({status:e}){const t=Eo[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 qx({step:e}){const t=Kx(e),s=Eo[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:Ph(e.startedAt,e.completedAt)}),r.jsx(Do,{status:t})]})}function Vx({job:e}){const[t,s]=d.useState(!1),i=Ux(e),n=Eo[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(ms,{size:14,className:"text-[#939084]"}):r.jsx(pr,{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:Ph(e.startedAt,e.completedAt)}),r.jsx(Do,{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(qx,{step:o},o.number))})]})}function Gx({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 V.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(xr,{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 Yx({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),[f,p]=d.useState(!1),u=Zi(e),g=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const _=await V.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){c(_ instanceof Error?_.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),m=()=>{const _=!s;i(_),_&&g()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:m,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(ms,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(pr,{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(Do,{status:u})]}),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(Te,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:Rh(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(ls,{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(xr,{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(Rt,{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(Vx,{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:()=>p(!f),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(os,{size:12}),f?"Hide full logs":"View full logs"]}),f&&r.jsx("div",{className:"mt-2",children:r.jsx(Gx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Xx({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),[f,p]=d.useState(null),u=async()=>{if(n){c(!0),p(null);try{await V.dispatchWorkflow(e,n,a),i(),s()}catch(m){p(m instanceof Error?m.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:m=>o(m.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(m=>r.jsxs("option",{value:m.name,children:[m.name," (",m.name,")"]},m.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:m=>l(m.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"})]}),f&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Rt,{size:12}),r.jsx("span",{className:"text-xs",children:f})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(le,{size:"sm",icon:rs,onClick:u,loading:h,children:"Dispatch"})]})]})}function Mh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,f]=d.useState(null),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useRef(null),x=t.some(j=>j.status==="in_progress"||j.status==="queued"||j.status==="waiting"||j.status==="requested"||j.status==="pending"),y=d.useCallback(async(j=!1)=>{if(e){j&&h(!0),f(null);try{const B=await V.getWorkflowRuns(e);s(B),a(""),m(new Date)}catch(B){const M=B instanceof Error?B.message:String(B);M.includes("gh CLI not found")?f({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):M.includes("not authenticated")||M.includes("401")?f({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):M.includes("Could not detect")?f({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):f({type:"generic",message:M})}finally{h(!1)}}},[e]),b=d.useCallback(async()=>{if(e)try{const j=await V.getWorkflows(e);n(j.filter(B=>B.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),b()},[y,b]),d.useEffect(()=>(x&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[x,e,y]);const k=t.filter(j=>Zi(j)==="success").length,S=t.filter(j=>Zi(j)==="failed").length,w=t.filter(j=>{const B=Zi(j);return B==="running"||B==="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(Te,{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(fc,{size:10}),Rh(g.toISOString())]}),r.jsx(le,{size:"sm",variant:"ghost",icon:bt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(le,{size:"sm",icon:rs,onClick:()=>u(!p),children:"Run Workflow"})]})]}),p&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Xx,{sessionId:e,workflows:i,onClose:()=>u(!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(Rt,{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(ls,{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(Rt,{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(Te,{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(Rt,{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(Zl,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(sr,{size:12}),S," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(xr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),x&&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(j=>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"})]})},j))}),!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(j=>r.jsx(Yx,{run:j,sessionId:e},j.databaseId))})]})}const Jx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Mh},Symbol.toStringTag,{value:"Module"}));function Zx({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 f=Math.floor(c/60),p=c%60;return`${f}m ${p}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(ps,{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 Qx({tokenHistory:e,className:t=""}){const s=e.slice(-10);if(s.length<2)return null;const i=64,n=20,o=2,a=Math.max(...s,1),l=Math.min(...s,0),h=a-l||1,c=s.map((u,g)=>({x:o+g/(s.length-1)*(i-o*2),y:o+(1-(u-l)/h)*(n-o*2)})),f=c.map((u,g)=>`${g===0?"M":"L"} ${u.x.toFixed(1)} ${u.y.toFixed(1)}`).join(" "),p=`${f} L ${c[c.length-1].x.toFixed(1)} ${n-o} L ${c[0].x.toFixed(1)} ${n-o} Z`;return r.jsxs("svg",{width:i,height:n,viewBox:`0 0 ${i} ${n}`,className:`inline-block align-middle text-muted ${t}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:p,fill:"currentColor",fillOpacity:.15}),r.jsx("path",{d:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:c[c.length-1].x,cy:c[c.length-1].y,r:"2",fill:"currentColor"})]})}function ev(){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 tv(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:ee,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:ee,color:"text-yellow-500",label:"JSX"},ts:{icon:ee,color:"text-blue-500",label:"TypeScript"},tsx:{icon:ee,color:"text-blue-400",label:"TSX"},py:{icon:ee,color:"text-green-600",label:"Python"},html:{icon:ee,color:"text-orange-500",label:"HTML"},css:{icon:no,color:"text-purple-500",label:"CSS"},json:{icon:ro,color:"text-green-500",label:"JSON"},md:{icon:_i,color:"text-muted",label:"Markdown"},go:{icon:ee,color:"text-cyan-600",label:"Go"},rs:{icon:ee,color:"text-orange-600",label:"Rust"}}[t]||{icon:oo,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function sv(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 Ol(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function iv({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:f}){const[p,u]=d.useState(""),[g,m]=d.useState(!1);d.useEffect(()=>{if(!n)return;const b=()=>u(sv(n));b();const k=setInterval(b,5e3);return()=>clearInterval(k)},[n]);const _=d.useCallback(async()=>{const b=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Ol(h)}`:"",f?`
|
|
227
|
+
This will revert files to this checkpoint state.`))){c(_);try{await V.restoreCheckpoint(e,_),await u(),t==null||t()}catch{m("Failed to restore checkpoint")}c(null)}},[e,s,a,u,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(rr,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(f&&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(rr,{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((_,x)=>r.jsxs("div",{className:"flex items-center gap-1",children:[x>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:()=>l(_.id),onMouseLeave:()=>l(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(ft,{size:10}),p(_.timestamp)]}),(_.files_changed??0)>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ee,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),(_.iteration??0)>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(hc,{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))}),f&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:f})]})}function ov({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 av({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(_r,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(pu,{size:14,className:"text-danger"}):r.jsx(ee,{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(c=>!c),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(pr,{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(gr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(lc,{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((c,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:["@@ -",c.old_start,",",c.old_count," +",c.new_start,",",c.new_count," @@"]}),c.lines.map((l,f)=>r.jsx(ov,{line:l},`${h}-${f}`))]},h))})]})}function lv({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(u=>u.path))),[c,h]=d.useState(0),l=d.useCallback(u=>{a(g=>{const p=new Set(g);return p.has(u)?p.delete(u):p.add(u),p})},[]),f=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(u=>u.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:u=>u.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:u=>u.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(ee,{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(gr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(lc,{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(vt,{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:f,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((u,g)=>{const p=u.action==="add"?"text-success":u.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===c?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(u.path),onChange:()=>l(u.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:u.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:u.action==="add"?"+":u.action==="delete"?"-":"M"})]},u.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[c]&&r.jsx(av,{file:e.files[c],isSelected:o.has(e.files[c].path),onToggle:()=>l(e.files[c].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(dc,{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(es,{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(lu,{size:14}),"Accept All"]})]})]})]})}function Do(e){switch(e.status){case"completed":switch(e.conclusion){case"success":return"success";case"failure":case"timed_out":case"startup_failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"unknown"}case"in_progress":return"running";case"queued":case"waiting":case"requested":case"pending":return"pending";default:return"unknown"}}function Zi(e){return Do(e)}function cv(e){return Do(e)}function hv(e){return Do(e)}const Ro={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ft,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:xr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:tc,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:sr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:dc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Md,label:"Skipped"},unknown:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Tt,label:"Unknown"}};function zh(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 Ah(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),c=n%60;return`${a}h ${c}m`}function Lo({status:e}){const t=Ro[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 dv({step:e}){const t=hv(e),s=Ro[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:Ah(e.startedAt,e.completedAt)}),r.jsx(Lo,{status:t})]})}function uv({job:e}){const[t,s]=d.useState(!1),i=cv(e),n=Ro[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(xs,{size:14,className:"text-[#939084]"}):r.jsx(pr,{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:Ah(e.startedAt,e.completedAt)}),r.jsx(Lo,{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(dv,{step:o},o.number))})]})}function fv({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,c]=d.useState(null),h=d.useCallback(async()=>{o(!0),c(null);try{const l=await V.getWorkflowRunLogs(e,t);i(l)}catch(l){c(l instanceof Error?l.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(xr,{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 mv({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,c]=d.useState(!1),[h,l]=d.useState(null),[f,m]=d.useState(!1),u=Zi(e),g=d.useCallback(async()=>{if(!(n||a)){c(!0),l(null);try{const _=await V.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){l(_ instanceof Error?_.message:"Failed to load run details")}finally{c(!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(xs,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(pr,{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(Lo,{status:u})]}),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(Ie,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:zh(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(ps,{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(xr,{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(Tt,{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(uv,{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(!f),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(fs,{size:12}),f?"Hide full logs":"View full logs"]}),f&&r.jsx("div",{className:"mt-2",children:r.jsx(fv,{sessionId:t,runId:e.databaseId})})]})]})]})}function pv({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var g;const[n,o]=d.useState(((g=t[0])==null?void 0:g.name)||""),[a,c]=d.useState(""),[h,l]=d.useState(!1),[f,m]=d.useState(null),u=async()=>{if(n){l(!0),m(null);try{await V.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{l(!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=>c(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"})]}),f&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Tt,{size:12}),r.jsx("span",{className:"text-xs",children:f})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(he,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(he,{size:"sm",icon:ds,onClick:u,loading:h,children:"Dispatch"})]})]})}function Ih({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[c,h]=d.useState(!0),[l,f]=d.useState(null),[m,u]=d.useState(!1),[g,p]=d.useState(null),_=d.useRef(null),x=t.some(N=>N.status==="in_progress"||N.status==="queued"||N.status==="waiting"||N.status==="requested"||N.status==="pending"),y=d.useCallback(async(N=!1)=>{if(e){N&&h(!0),f(null);try{const T=await V.getWorkflowRuns(e);s(T),a(""),p(new Date)}catch(T){const L=T instanceof Error?T.message:String(T);L.includes("gh CLI not found")?f({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):L.includes("not authenticated")||L.includes("401")?f({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):L.includes("Could not detect")?f({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):f({type:"generic",message:L})}finally{h(!1)}}},[e]),v=d.useCallback(async()=>{if(e)try{const N=await V.getWorkflows(e);n(N.filter(T=>T.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),v()},[y,v]),d.useEffect(()=>(x&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[x,e,y]);const k=t.filter(N=>Zi(N)==="success").length,w=t.filter(N=>Zi(N)==="failed").length,D=t.filter(N=>{const T=Zi(N);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(Ie,{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(_c,{size:10}),zh(g.toISOString())]}),r.jsx(he,{size:"sm",variant:"ghost",icon:St,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(he,{size:"sm",icon:ds,onClick:()=>u(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(pv,{sessionId:e,workflows:i,onClose:()=>u(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),l&&r.jsxs("div",{className:"mb-4",children:[l.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(Tt,{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:l.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(ps,{size:10})]})]})]}),l.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(Tt,{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:l.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"})]})]}),l.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(Ie,{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:l.message})]})]}),l.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(Tt,{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:l.message})]})]})]}),!c&&!l&&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(tc,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(sr,{size:12}),w," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(xr,{size:12,className:D>0?"animate-spin":""}),D," active"]}),x&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),c&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(N=>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"})]})},N))}),!c&&!l&&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"})]}),!c&&!l&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(N=>r.jsx(mv,{run:N,sessionId:e},N.databaseId))})]})}const _v=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Ih},Symbol.toStringTag,{value:"Module"}));function gv({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),c=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&c.current!=="complete"){n(!0),a(!1);const l=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(l)}e!=="complete"&&a(!1),c.current=e},[e,s]),!i||o)return null;const h=l=>{if(l<60)return`${l}s`;const f=Math.floor(l/60),m=l%60;return`${f}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:l=>l.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(vs,{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 xv({tokenHistory:e,className:t=""}){const s=e.slice(-10);if(s.length<2)return null;const i=64,n=20,o=2,a=Math.max(...s,1),c=Math.min(...s,0),h=a-c||1,l=s.map((u,g)=>({x:o+g/(s.length-1)*(i-o*2),y:o+(1-(u-c)/h)*(n-o*2)})),f=l.map((u,g)=>`${g===0?"M":"L"} ${u.x.toFixed(1)} ${u.y.toFixed(1)}`).join(" "),m=`${f} L ${l[l.length-1].x.toFixed(1)} ${n-o} L ${l[0].x.toFixed(1)} ${n-o} Z`;return r.jsxs("svg",{width:i,height:n,viewBox:`0 0 ${i} ${n}`,className:`inline-block align-middle text-muted ${t}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:m,fill:"currentColor",fillOpacity:.15}),r.jsx("path",{d:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:l[l.length-1].x,cy:l[l.length-1].y,r:"2",fill:"currentColor"})]})}function vv(){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 bv(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:ee,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:ee,color:"text-yellow-500",label:"JSX"},ts:{icon:ee,color:"text-blue-500",label:"TypeScript"},tsx:{icon:ee,color:"text-blue-400",label:"TSX"},py:{icon:ee,color:"text-green-600",label:"Python"},html:{icon:ee,color:"text-orange-500",label:"HTML"},css:{icon:ao,color:"text-purple-500",label:"CSS"},json:{icon:oo,color:"text-green-500",label:"JSON"},md:{icon:gi,color:"text-muted",label:"Markdown"},go:{icon:ee,color:"text-cyan-600",label:"Go"},rs:{icon:ee,color:"text-orange-600",label:"Rust"}}[t]||{icon:lo,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function yv(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 Fl(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Sv({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:c,buildTime:h,sessionId:l,prd:f}){const[m,u]=d.useState(""),[g,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const v=()=>u(yv(n));v();const k=setInterval(v,5e3);return()=>clearInterval(k)},[n]);const _=d.useCallback(async()=>{const v=["Built with Loki Mode",l?`Session: ${l}`:"",h?`Build time: ${Fl(h)}`:"",f?`
|
|
228
228
|
Project: ${f.substring(0,100)}${f.length>100?"...":""}`:"",`
|
|
229
229
|
https://autonomi.dev`].filter(Boolean).join(`
|
|
230
|
-
`);try{await navigator.clipboard.writeText(b),m(!0),setTimeout(()=>m(!1),2e3)}catch{}},[c,h,f]);if(!e)return null;const x=tv(t),y=x.icon;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:x.color}),r.jsx("span",{children:x.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(Pu,{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 ",p]}):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(fc,{size:11}),r.jsxs("span",{children:["Built in ",Ol(h)]})]}),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(Yt,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(uc,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Jn=[{id:"desktop",label:"Desktop",icon:Ed,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Ou,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:zu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function rv({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Jn.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 nv(){const[e,t]=d.useState("desktop"),s=Jn.find(i=>i.id===e)||Jn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const ov=[75,100,125];function av({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:ov.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 lv(){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(eu,{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 cv({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(Yt,{size:14,className:"text-success"}):r.jsx(so,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function hv({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(dc,{size:14}):r.jsx(cn,{size:14})})}function $l({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(_s,{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(ms,{size:12}):r.jsx(mr,{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 dv({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(zd,{size:14,className:s||t?"animate-spin-once":""})})}function Il(){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..."})]})}const Fl={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(p=>p.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(p=>p.path.includes(".test.")||p.path.includes(".spec.")||p.path.includes("__tests__")),c=i==null?void 0:i.some(p=>p.path.endsWith(".css")||p.path.endsWith(".scss")),f=i==null?void 0:i.some(p=>p.path.includes("Dockerfile")||p.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"}),f||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 fv(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 p=setInterval(()=>{a(!0),setTimeout(()=>{c(u=>(u+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(p)},[l.length]),l.length===0||!i)return null;const f=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(Dd,{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:f.map((p,u)=>r.jsxs("button",{onClick:()=>t(p.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
230
|
+
`);try{await navigator.clipboard.writeText(v),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[l,h,f]);if(!e)return null;const x=bv(t),y=x.icon;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:x.color}),r.jsx("span",{children:x.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 ",c]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Au,{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(_c,{size:11}),r.jsxs("span",{children:["Built in ",Fl(h)]})]}),l&&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(es,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(pc,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Qn=[{id:"desktop",label:"Desktop",icon:Bd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Uu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Hu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function wv({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Qn.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 Cv(){const[e,t]=d.useState("desktop"),s=Qn.find(i=>i.id===e)||Qn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const kv=[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:kv.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 jv(){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(ou,{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 Ev({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(es,{size:14,className:"text-success"}):r.jsx(ro,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function Dv({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(mc,{size:14}):r.jsx(hn,{size:14})})}function Hl({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(bs,{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(xs,{size:12}):r.jsx(mr,{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 Rv({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(Hd,{size:14,className:s||t?"animate-spin-once":""})})}function Wl(){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..."})]})}const Ul={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 Lv(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 c=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${c}`,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=[],c=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__")),l=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),f=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return c||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"}),f||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),c&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),l||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 Pv(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),c=d.useMemo(()=>Lv(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,l]=d.useState(0);if(d.useEffect(()=>{if(c.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{l(u=>(u+1)%c.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[c.length]),c.length===0||!i)return null;const f=c.slice(h,h+4).concat(h+4>c.length?c.slice(0,h+4-c.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(Td,{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:f.map((m,u)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
231
231
|
border rounded-pill transition-all duration-200 cursor-pointer
|
|
232
|
-
${
|
|
233
|
-
`,children:[
|
|
234
|
-
`))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
|
|
232
|
+
${Ul[m.category]||Ul.create}
|
|
233
|
+
`,children:[m.label,r.jsx(io,{size:10,className:"opacity-50"})]},`${m.label}-${u}`))})]})}function as(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 Kl(e,t){return e||(typeof t!="number"?"No output, exit status unknown":t===0?"Finished with no output":`Failed (exit ${t}), no output`)}function Mv(e){const t=[],s=[],i=[];for(const n of e.split(`
|
|
234
|
+
`))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 Bv({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(Xd,{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(Vu,{size:12})})]})}const eo=[{id:"@file",label:"@file",description:"Reference a file in your project",icon:ee},{id:"@template",label:"@template",description:"Reference a template",icon:zd},{id:"@docs",label:"@docs",description:"Reference documentation",icon:Zs}];function Tv({visible:e,filter:t,onSelect:s,onClose:i,selectedIndex:n}){if(!e)return null;const o=eo.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(iu,{size:10}),"Mentions"]})}),o.map((a,c)=>{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 ${c===n?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(h,{size:14,className:c===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 zv(){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 Av({msg:e,msgIndex:t}){var c;const[s,i]=d.useState(!1),n=d.useMemo(()=>e.role==="system"?Mv(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(`
|
|
235
235
|
`).trim():e.content,a=o.split(`
|
|
236
|
-
`).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,
|
|
236
|
+
`).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,l)=>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(fs,{size:10,className:"text-muted/60 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:h})]},l))}),r.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[a&&!s?o.split(`
|
|
237
237
|
`).slice(0,30).join(`
|
|
238
238
|
`)+`
|
|
239
239
|
...`:o,e.isStreaming&&r.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5 align-text-bottom"})]}),a&&!e.isStreaming&&r.jsx("button",{onClick:()=>i(h=>!h),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:s?"Show less":`Show all (${o.split(`
|
|
240
|
-
`).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,
|
|
241
|
-
[cancelled]`}:{})),(
|
|
242
|
-
`);o(
|
|
243
|
-
`),
|
|
240
|
+
`).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,l)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},l))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(ee,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,l)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},l))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((c=e.filesChanged)==null?void 0:c.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(Bv,{msgIndex:t})]})]})}const Iv={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"},Ov=10*1024*1024,$v=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Fv(e){return $v.has(e.type.toLowerCase())?e.size>Ov?"This attachment was not added because it exceeds the 10 MiB limit.":null:"This attachment was not added. Use a PNG, JPEG, GIF, or WebP image."}function Hv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function Wv(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(String(i.result)),i.onerror=()=>s(i.error),i.readAsDataURL(e)})}function Uv({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var pe;const[n,o]=d.useState([]),[a,c]=d.useState(""),[h,l]=d.useState(t||"quick"),[f,m]=d.useState(!1),[u,g]=d.useState(!1),[p,_]=d.useState(null),[x,y]=d.useState(!1),[v,k]=d.useState(null),w=d.useRef(null),D=d.useRef(null),N=d.useRef(null),T=d.useRef(null),L=d.useRef(null),U=d.useRef(null),Y=d.useRef(null),X=d.useRef(new Set);d.useEffect(()=>{const B=sessionStorage.getItem(`chat_${e}`);if(B)try{o(JSON.parse(B))}catch{}},[e]),d.useEffect(()=>{if(n.length>0){const B=n.slice(-50).map(J=>({...J,imageUrl:void 0}));sessionStorage.setItem(`chat_${e}`,JSON.stringify(B))}},[n,e]),d.useEffect(()=>{w.current&&(w.current.scrollTop=w.current.scrollHeight)},[n]),d.useEffect(()=>{const B=X.current;return()=>{L.current&&L.current.abort();for(const J of B)URL.revokeObjectURL(J);B.clear()}},[]);const M=d.useCallback(B=>{X.current.delete(B)&&URL.revokeObjectURL(B)},[]),E=d.useCallback(B=>{if(f)return;const J=Fv(B);if(J){k(J);return}k(null),p!=null&&p.previewUrl&&M(p.previewUrl);const G=URL.createObjectURL(B);X.current.add(G),_({file:B,previewUrl:G})},[p==null?void 0:p.previewUrl,M,f]),P=d.useCallback(()=>{var B;p!=null&&p.previewUrl&&M(p.previewUrl),_(null),k(null),N.current&&(N.current.value=""),(B=T.current)==null||B.focus()},[p==null?void 0:p.previewUrl,M]);d.useEffect(()=>{const B=J=>{var ae;const G=(ae=J.clipboardData)==null?void 0:ae.items;if(G){for(const Ke of G)if(Ke.type.startsWith("image/")){J.preventDefault();const be=Ke.getAsFile();be&&E(be);return}}};return document.addEventListener("paste",B),()=>document.removeEventListener("paste",B)},[E]);const[S,j]=d.useState(!1),[z,C]=d.useState(!1),[I,O]=d.useState(""),[K,Z]=d.useState(0),ne=d.useCallback(B=>{B.preventDefault(),B.stopPropagation(),B.dataTransfer.types.includes("Files")&&j(!0)},[]),ce=d.useCallback(B=>{B.preventDefault(),B.stopPropagation(),j(!1)},[]),oe=d.useCallback(B=>{B.preventDefault(),B.stopPropagation(),j(!1);const J=B.dataTransfer.files;if(J.length>0){const G=J[0];G.type.startsWith("image/")&&E(G)}},[E]),_e=d.useCallback(async()=>{var B;if(L.current&&(L.current.abort(),L.current=null),U.current){try{await V.chatCancel(e,U.current)}catch{}U.current=null}g(!1),m(!1),o(J=>as(J,G=>G.isStreaming?{isStreaming:!1,content:G.content+`
|
|
241
|
+
[cancelled]`}:{})),(B=D.current)==null||B.focus()},[e]),ue=d.useCallback(async B=>{var Ke;let G=0,ae;do{if(await new Promise(be=>setTimeout(be,2e3)),ae=await V.chatPoll(e,B),G++,ae.output_lines.length>0){const be=ae.output_lines.join(`
|
|
242
|
+
`);o(de=>as(de,$e=>$e.role==="system"&&$e.isStreaming?{content:be}:{}))}G>=150&&(ae={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(!ae.complete);o(be=>as(be,de=>de.role==="system"?{isStreaming:!1,content:Kl(ae.output_lines.join(`
|
|
243
|
+
`),ae.returncode),filesChanged:ae.files_changed,returncode:ae.returncode}:{})),((Ke=ae.files_changed)==null?void 0:Ke.length)>0&&s&&s(ae.files_changed)},[e,s]),De=d.useCallback(async B=>{var G;const J=new AbortController;L.current=J,U.current=B,g(!0);try{const ae=V.chatStreamUrl(e,B),Ke=await fetch(ae,{signal:J.signal});if(!Ke.ok||!Ke.body)throw new Error(`Stream failed: ${Ke.status}`);const be=Ke.body.getReader(),de=new TextDecoder;let $e="";for(;;){const{done:ge,value:Et}=await be.read();if(ge)break;$e+=de.decode(Et,{stream:!0});const qe=$e.split(`
|
|
244
244
|
|
|
245
|
-
`)
|
|
246
|
-
`);let
|
|
247
|
-
`+Ue:Ue}:{}))}catch{}else if(bs==="complete"&&Ct)try{const{returncode:Ue,files_changed:Ke}=JSON.parse(Ct);o(Je=>es(Je,kt=>kt.role==="system"&&kt.isStreaming?{isStreaming:!1,filesChanged:Ke,returncode:Ue,content:Hl(kt.content,Ue)}:{})),(Ke==null?void 0:Ke.length)>0&&s&&s(Ke)}catch{}else if(bs==="error"&&Ct)try{const{error:Ue}=JSON.parse(Ct);o(Ke=>es(Ke,Je=>Je.role==="system"&&Je.isStreaming?{isStreaming:!1,content:`Error: ${Ue}`}:{}))}catch{}}}}catch(oe){if(oe instanceof DOMException&&oe.name==="AbortError")return;await ge(T)}finally{g(!1),p(!1),M.current=null,Y.current=null,(G=w.current)==null||G.focus()}},[e,s,ge]),z=async()=>{var Ae;const T=a.trim();if(!T&&!m||f)return;p(!0),k(null);let J,G,oe="";if(m){y(!0);try{J=await Cv(m.file);const pe=await V.chatImageUpload(e,m.file);G=pe.filename,oe=`[Attached image: ${pe.filename} (id: ${pe.image_id})] Make it look like this. `}catch{k("The attachment was refused and no message was sent. Use a valid PNG, JPEG, GIF, or WebP image up to 10 MiB."),y(!1),p(!1);return}y(!1)}const He=oe+(T||"Make changes based on this screenshot."),be={role:"user",content:T||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:J,imageName:G},he={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(pe=>[...pe,be,he]),l(""),m&&D(m.previewUrl),_(null);try{const pe=n.filter(We=>We.role==="user"||We.role==="system"&&!We.isStreaming&&We.content).slice(-10).map(We=>({role:We.role==="user"?"user":"assistant",content:We.content})),{task_id:wt}=await V.chatStart(e,He,h,pe.length>0?pe:void 0);await Fe(wt)}catch(pe){o(wt=>es(wt,We=>We.role==="system"&&We.isStreaming?{isStreaming:!1,content:`Error: ${pe instanceof Error?pe.message:"Request failed"}`}:{})),p(!1),(Ae=w.current)==null||Ae.focus()}};return r.jsxs("div",{ref:X,className:`flex flex-col h-full relative ${E?"ring-2 ring-primary ring-inset":""}`,onDragOver:ie,onDragLeave:de,onDrop:ue,children:[E&&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(da,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:S,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((T,J)=>r.jsx(xv,{msg:T,msgIndex:J},J)),u&&r.jsx(gv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[u&&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:ce,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(ir,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!u&&(i==null?void 0:i.some(T=>T.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Yl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(xe=i.find(T=>T.fix_status==="fixing"))==null?void 0:xe.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(T=>r.jsx("button",{onClick:()=>c(T),title:vv[T],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===T?"bg-primary text-white":"text-muted hover:text-ink"}`,children:T},T))}),m&&r.jsxs("div",{role:"group","aria-label":"Selected attachment","aria-live":"polite",className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:m.previewUrl,alt:`Preview of ${m.file.name}`,className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:L,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","aria-label":`Remove ${m.file.name}`,children:r.jsx(gt,{size:10})})]}),r.jsxs("div",{className:"min-w-0 text-[10px] text-muted",children:[r.jsx("p",{className:"truncate max-w-[180px] text-ink",title:m.file.name,children:m.file.name}),r.jsxs("p",{children:[m.file.type," · ",wv(m.file.size)]})]}),x&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),b&&r.jsx("p",{role:"alert",className:"mb-2 px-1 text-[11px] text-red-400",children:b}),!u&&r.jsx(fv,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:T=>l(T),className:"mb-2"}),r.jsx("p",{id:"chat-attachment-guidance",className:"mb-1 px-1 text-[10px] text-muted",children:"Attach one PNG, JPEG, GIF, or WebP image up to 10 MiB."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:T=>{var G;const J=(G=T.target.files)==null?void 0:G[0];J&&N(J),T.target.value=""}}),r.jsx("button",{ref:B,onClick:()=>{var T;return(T=j.current)==null?void 0:T.click()},disabled:f,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)","aria-label":"Attach image","aria-describedby":"chat-attachment-guidance",children:r.jsx(da,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(_v,{visible:U,filter:H,selectedIndex:K,onSelect:T=>{var oe;const J=a.lastIndexOf("@"),G=J>=0?a.slice(0,J):a;l(G+T+" "),C(!1),Q(0),(oe=w.current)==null||oe.focus()},onClose:()=>C(!1)}),r.jsx("textarea",{ref:w,value:a,onChange:T=>{const J=T.target.value;l(J);const G=J.lastIndexOf("@");if(G>=0){const oe=J.slice(G);/^@\w*$/.test(oe)?(C(!0),F(oe),Q(0)):C(!1)}else C(!1)},onKeyDown:T=>{if(U){if(T.key==="ArrowDown"){T.preventDefault(),Q(J=>Math.min(J+1,Zn.length-1));return}if(T.key==="ArrowUp"){T.preventDefault(),Q(J=>Math.max(J-1,0));return}if(T.key==="Tab"||T.key==="Enter"&&!T.shiftKey){T.preventDefault();const J=Zn.filter(G=>G.label.toLowerCase().includes(H.toLowerCase()));if(J[K]){const G=a.lastIndexOf("@"),oe=G>=0?a.slice(0,G):a;l(oe+J[K].label+" "),C(!1),Q(0)}return}if(T.key==="Escape"){C(!1);return}}T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),z())},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:f})]}),u?r.jsx(le,{size:"sm",icon:ir,onClick:ce,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(le,{size:"sm",icon:Lu,onClick:z,disabled:f||!a.trim()&&!m,"aria-label":"Send message",children:"Send"})]})]})]})}function Qi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function er(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 Nv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}const tr="Not recorded";function rt(e,t){return e===null?tr:t(e)}function jv(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 js({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 Ev({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:[er(e.durationSecs)," | ",Qi(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 Dv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:f,provider:p,onShare:u,className:g=""}){const[m,_]=d.useState(!0),x=h===null?null:jv(h),y=Math.max(...a.map(j=>j.durationSecs),1),b=c!==null?`$${c.toFixed(2)}`:tr,k=rt(n,j=>`${Math.round(j*100)}%`),S=h===null||x===null?tr:`${h}/100 (${x.label})`,w=()=>{const j=["Build Insights Summary","=====================",`Provider: ${p}`,`Total Time: ${rt(l,er)}`,`Iterations: ${rt(f,String)}`,`Cost: ${b}`,"","Output:",` Files Created: ${rt(e,String)}`,` Files Modified: ${rt(t,String)}`,` Lines Generated: ${rt(s,String)}`,` Tests Generated: ${rt(i,String)}`,` Test Pass Rate: ${k}`,"","Resources:",` Total Tokens: ${rt(o,Qi)}`,` Quality Score: ${S}`,"","Time Breakdown:",...a.map(B=>` ${B.label}: ${er(B.durationSecs)} (${Math.round(B.percentage)}%)`)].join(`
|
|
248
|
-
`);u==null||u(
|
|
249
|
-
text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(
|
|
245
|
+
`);$e=qe.pop()||"";for(const is of qe){if(!is.trim())continue;const Ze=is.split(`
|
|
246
|
+
`);let Ss="",Dt="";for(const Ve of Ze)Ve.startsWith("event:")?Ss=Ve.slice(6).trim():Ve.startsWith("data:")&&(Dt=Ve.slice(5).trim());if(Ss==="output"&&Dt)try{const{line:Ve}=JSON.parse(Dt);o(Ge=>as(Ge,Qe=>Qe.role==="system"&&Qe.isStreaming?{content:Qe.content?Qe.content+`
|
|
247
|
+
`+Ve:Ve}:{}))}catch{}else if(Ss==="complete"&&Dt)try{const{returncode:Ve,files_changed:Ge}=JSON.parse(Dt);o(Qe=>as(Qe,Rt=>Rt.role==="system"&&Rt.isStreaming?{isStreaming:!1,filesChanged:Ge,returncode:Ve,content:Kl(Rt.content,Ve)}:{})),(Ge==null?void 0:Ge.length)>0&&s&&s(Ge)}catch{}else if(Ss==="error"&&Dt)try{const{error:Ve}=JSON.parse(Dt);o(Ge=>as(Ge,Qe=>Qe.role==="system"&&Qe.isStreaming?{isStreaming:!1,content:`Error: ${Ve}`}:{}))}catch{}}}}catch(ae){if(ae instanceof DOMException&&ae.name==="AbortError")return;await ue(B)}finally{g(!1),m(!1),L.current=null,U.current=null,(G=D.current)==null||G.focus()}},[e,s,ue]),A=async()=>{var $e;const B=a.trim();if(!B&&!p||f)return;m(!0),k(null);let J,G,ae="";if(p){y(!0);try{J=await Wv(p.file);const ge=await V.chatImageUpload(e,p.file);G=ge.filename,ae=`[Attached image: ${ge.filename} (id: ${ge.image_id})] Make it look like this. `}catch{k("The attachment was refused and no message was sent. Use a valid PNG, JPEG, GIF, or WebP image up to 10 MiB."),y(!1),m(!1);return}y(!1)}const Ke=ae+(B||"Make changes based on this screenshot."),be={role:"user",content:B||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:J,imageName:G},de={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(ge=>[...ge,be,de]),c(""),p&&M(p.previewUrl),_(null);try{const ge=n.filter(qe=>qe.role==="user"||qe.role==="system"&&!qe.isStreaming&&qe.content).slice(-10).map(qe=>({role:qe.role==="user"?"user":"assistant",content:qe.content})),{task_id:Et}=await V.chatStart(e,Ke,h,ge.length>0?ge:void 0);await De(Et)}catch(ge){o(Et=>as(Et,qe=>qe.role==="system"&&qe.isStreaming?{isStreaming:!1,content:`Error: ${ge instanceof Error?ge.message:"Request failed"}`}:{})),m(!1),($e=D.current)==null||$e.focus()}};return r.jsxs("div",{ref:Y,className:`flex flex-col h-full relative ${S?"ring-2 ring-primary ring-inset":""}`,onDragOver:ne,onDragLeave:ce,onDrop:oe,children:[S&&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(fa,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:w,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((B,J)=>r.jsx(Av,{msg:B,msgIndex:J},J)),u&&r.jsx(zv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[u&&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:_e,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(ir,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!u&&(i==null?void 0:i.some(B=>B.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Zl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(pe=i.find(B=>B.fix_status==="fixing"))==null?void 0:pe.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(B=>r.jsx("button",{onClick:()=>l(B),title:Iv[B],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===B?"bg-primary text-white":"text-muted hover:text-ink"}`,children:B},B))}),p&&r.jsxs("div",{role:"group","aria-label":"Selected attachment","aria-live":"polite",className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:`Preview of ${p.file.name}`,className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:P,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","aria-label":`Remove ${p.file.name}`,children:r.jsx(vt,{size:10})})]}),r.jsxs("div",{className:"min-w-0 text-[10px] text-muted",children:[r.jsx("p",{className:"truncate max-w-[180px] text-ink",title:p.file.name,children:p.file.name}),r.jsxs("p",{children:[p.file.type," · ",Hv(p.file.size)]})]}),x&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),v&&r.jsx("p",{role:"alert",className:"mb-2 px-1 text-[11px] text-red-400",children:v}),!u&&r.jsx(Pv,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:B=>c(B),className:"mb-2"}),r.jsx("p",{id:"chat-attachment-guidance",className:"mb-1 px-1 text-[10px] text-muted",children:"Attach one PNG, JPEG, GIF, or WebP image up to 10 MiB."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:N,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:B=>{var G;const J=(G=B.target.files)==null?void 0:G[0];J&&E(J),B.target.value=""}}),r.jsx("button",{ref:T,onClick:()=>{var B;return(B=N.current)==null?void 0:B.click()},disabled:f,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)","aria-label":"Attach image","aria-describedby":"chat-attachment-guidance",children:r.jsx(fa,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(Tv,{visible:z,filter:I,selectedIndex:K,onSelect:B=>{var ae;const J=a.lastIndexOf("@"),G=J>=0?a.slice(0,J):a;c(G+B+" "),C(!1),Z(0),(ae=D.current)==null||ae.focus()},onClose:()=>C(!1)}),r.jsx("textarea",{ref:D,value:a,onChange:B=>{const J=B.target.value;c(J);const G=J.lastIndexOf("@");if(G>=0){const ae=J.slice(G);/^@\w*$/.test(ae)?(C(!0),O(ae),Z(0)):C(!1)}else C(!1)},onKeyDown:B=>{if(z){if(B.key==="ArrowDown"){B.preventDefault(),Z(J=>Math.min(J+1,eo.length-1));return}if(B.key==="ArrowUp"){B.preventDefault(),Z(J=>Math.max(J-1,0));return}if(B.key==="Tab"||B.key==="Enter"&&!B.shiftKey){B.preventDefault();const J=eo.filter(G=>G.label.toLowerCase().includes(I.toLowerCase()));if(J[K]){const G=a.lastIndexOf("@"),ae=G>=0?a.slice(0,G):a;c(ae+J[K].label+" "),C(!1),Z(0)}return}if(B.key==="Escape"){C(!1);return}}B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),A())},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:f})]}),u?r.jsx(he,{size:"sm",icon:ir,onClick:_e,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(he,{size:"sm",icon:Ou,onClick:A,disabled:f||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function Qi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function er(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 Kv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}const tr="Not recorded";function nt(e,t){return e===null?tr:t(e)}function qv(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 Ds({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 Vv({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:[er(e.durationSecs)," | ",Qi(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 Gv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:c,qualityScore:h,totalCost:l,iterations:f,provider:m,onShare:u,className:g=""}){const[p,_]=d.useState(!0),x=h===null?null:qv(h),y=Math.max(...a.map(N=>N.durationSecs),1),v=l!==null?`$${l.toFixed(2)}`:tr,k=nt(n,N=>`${Math.round(N*100)}%`),w=h===null||x===null?tr:`${h}/100 (${x.label})`,D=()=>{const N=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${nt(c,er)}`,`Iterations: ${nt(f,String)}`,`Cost: ${v}`,"","Output:",` Files Created: ${nt(e,String)}`,` Files Modified: ${nt(t,String)}`,` Lines Generated: ${nt(s,String)}`,` Tests Generated: ${nt(i,String)}`,` Test Pass Rate: ${k}`,"","Resources:",` Total Tokens: ${nt(o,Qi)}`,` Quality Score: ${w}`,"","Time Breakdown:",...a.map(T=>` ${T.label}: ${er(T.durationSecs)} (${Math.round(T.percentage)}%)`)].join(`
|
|
248
|
+
`);u==null||u(N)};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(nn,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),h!==null&&x!==null&&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:x.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(mr,{size:16}):r.jsx(xs,{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(Ds,{icon:ee,label:"Files",value:e===null?tr:String(t===null?e:e+t),subtext:e===null?void 0:t===null?`${e} new, modified not recorded`:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(Ds,{icon:cn,label:"Lines of Code",value:nt(s,Kv),iconColor:"text-info"}),r.jsx(Ds,{icon:ai,label:"Tests",value:nt(i,String),subtext:n===null?"pass rate not recorded":`${k} passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(Ds,{icon:zs,label:"Tokens Used",value:nt(o,Qi),iconColor:"text-warning"}),r.jsx(Ds,{icon:ft,label:"Build Time",value:nt(c,er),subtext:f===null?"iterations not recorded":`${f} iterations`,iconColor:"text-muted"}),r.jsx(Ds,{icon:Ad,label:"Quality",value:nt(h,String),subtext:x==null?void 0:x.label,iconColor:(x==null?void 0:x.color)??"text-muted"})]}),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(Zd,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsx("span",{className:"text-sm font-bold font-mono text-ink",children:v})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Qd,{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(N=>r.jsx(Vv,{phase:N,maxDuration:y},N.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(zs,{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(N=>{const T={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${T[N.phase]||"bg-primary"}`,style:{width:`${N.percentage}%`},title:`${N.label}: ${Qi(N.tokenCount)} tokens (${Math.round(N.percentage)}%)`},N.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(N=>{const T={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 ${T[N.phase]||"bg-primary"}`}),N.label]},N.phase)})})]}),u&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:D,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
249
|
+
text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(pc,{size:12}),"Share Insights"]})})]})]})}const Yv=800,ql=[1,2,5];function Xv(e){const t=new Date(e);return e&&!Number.isNaN(t.getTime())?t.toLocaleTimeString():"--"}function Jv({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState(null),[o,a]=d.useState(0),[c,h]=d.useState(!1),[l,f]=d.useState(0),m=ql[l],u=(t==null?void 0:t.length)??0;if(d.useEffect(()=>{let p=!1;return V.getCheckpoints(e).then(_=>{p||s(_)}).catch(()=>{p||n("Failed to load checkpoints")}),()=>{p=!0}},[e]),d.useEffect(()=>{if(!c)return;if(o>=u){h(!1);return}const p=setTimeout(()=>a(_=>_+1),Yv/m);return()=>clearTimeout(p)},[c,o,u,m]),i)return r.jsx("div",{className:"text-xs text-danger py-6 text-center",children:i});if(t===null)return r.jsx("div",{className:"text-xs text-muted py-6 text-center",children:"Loading checkpoints..."});if(u===0)return r.jsx("div",{className:"text-xs text-muted py-6 text-center",children:"No checkpoints recorded for this build."});const g=t.slice(0,o);return r.jsxs("div",{className:"card overflow-hidden",children:[r.jsx("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px] space-y-1",children:g.length===0?r.jsxs("div",{className:"text-xs text-muted py-4 text-center",children:["Press play to step through ",u," recorded checkpoint",u!==1?"s":"","."]}):g.map(p=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[r.jsx(rr,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"font-mono text-muted flex-shrink-0",children:Xv(p.timestamp)}),r.jsx("span",{className:"truncate text-secondary",children:p.description}),(p.iteration??0)>0&&r.jsxs("span",{className:"font-mono text-muted flex-shrink-0",children:["Iter ",p.iteration]}),(p.files_changed??0)>0&&r.jsxs("span",{className:"text-muted flex-shrink-0",children:[p.files_changed," file",p.files_changed!==1?"s":""]})]},p.id))}),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:()=>{o>=u&&a(0),h(!c)},className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:c?"Pause":"Play",children:c?r.jsx(ic,{size:16}):r.jsx(ds,{size:16})}),r.jsx("button",{onClick:()=>{h(!1),a(0)},className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(hc,{size:14})}),r.jsxs("button",{onClick:()=>f((l+1)%ql.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[m,"x"]})]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:["Checkpoint ",o,"/",u]})]})]})}function Zv(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(c=>!["the","a","an","my"].includes(c)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(c=>!["the","a","an","my","all"].includes(c)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(c=>!["the","a","an","my"].includes(c))),(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(c=>c.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(c))),{terms:s,filePattern:i}}function Qv(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}function eb(e){return!e.searched||e.loading?{kind:"hidden"}:e.error!==null?{kind:"error",message:`Search failed: ${e.error}`}:e.count===0?{kind:"empty",message:"No results found. Try a different query."}:{kind:"results"}}const tb=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function sb({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[c,h]=d.useState(!1),[l,f]=d.useState(!1),[m,u]=d.useState(!1),[g,p]=d.useState(null),_=d.useRef(null),x=d.useRef(null),y=d.useCallback(async L=>{if(!L.trim()||!e){a([]),u(!1),p(null);return}h(!0),u(!0),p(null);try{const{terms:U}=Zv(L),Y=U.join(" "),M=(await V.searchFiles(e,Y)).map(E=>({path:E.path,name:E.name,relevanceScore:Qv(E,U)}));M.sort((E,P)=>P.relevanceScore-E.relevanceScore),a(M.slice(0,15))}catch(U){a([]),p(U instanceof Error?U.message:String(U))}finally{h(!1)}},[e]),v=L=>{n(L),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>y(L),400)},k=L=>{L.preventDefault(),x.current&&clearTimeout(x.current),y(i)},w=()=>{var L;n(""),a([]),u(!1),p(null),(L=_.current)==null||L.focus()},D=L=>{n(L),y(L)};d.useEffect(()=>()=>{x.current&&clearTimeout(x.current)},[]);const N=eb({searched:m,loading:c,error:g,count:o.length}),T=L=>L.includes(".test.")||L.includes(".spec.")?"text-teal":L.endsWith(".css")||L.endsWith(".scss")?"text-pink":L.endsWith(".json")||L.endsWith(".yaml")?"text-warning":L.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(ms,{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:k,className:"relative",children:[r.jsx(ms,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:_,type:"text",value:i,onChange:L=>v(L.target.value),onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!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
|
|
250
250
|
focus:border-primary focus:ring-1 focus:ring-primary/20 outline-none
|
|
251
|
-
text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:
|
|
252
|
-
px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:
|
|
251
|
+
text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:w,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(vt,{size:14})})]})]}),!m&&l&&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:tb.map(L=>r.jsx("button",{onClick:()=>D(L),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
|
|
252
|
+
px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:L},L))})]}),c&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(xi,{size:14,className:"animate-spin"}),"Searching..."]}),N.kind!=="hidden"&&r.jsx("div",{className:"border-t border-border",children:N.kind==="error"?r.jsx("div",{role:"alert",className:"text-center py-6 text-xs text-danger",children:N.message}):N.kind==="empty"?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:N.message}):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((L,U)=>r.jsxs("button",{onClick:()=>t(L.path,L.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
|
|
253
253
|
hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
|
|
254
|
-
group cursor-pointer`,children:[r.jsx(ee,{size:14,className:B(M.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:M.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:M.path}),M.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:M.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[M.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(pu,{size:10}),M.lineNumber]}),r.jsx(to,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${M.path}-${Y}`))]})})]})}const ur={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"}},fr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Ov(e,t,s){const i=ur[t]||ur.claude,n=fr[e]||fr.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(m=>{const _=Math.round(h*m.pct),x=_*.4,y=_*.6,b=(x*i.input+y*i.output)/1e3;return{phase:m.phase,label:m.label,estimatedCost:b,estimatedTokens:_}}),f=c.reduce((m,_)=>m+_.estimatedCost,0),u=o*(e==="complex"?40:e==="simple"?15:25),g=u<60?`${u}s`:u<3600?`${Math.round(u/60)}min`:`${(u/3600).toFixed(1)}hr`;return{total:{low:f*.7,high:f*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Ul(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function $v({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Ov(e,t,i),f=ur[t]||ur.claude,p=fr[e]||fr.standard,u=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(sc,{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(Ls,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Ul(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(ut,{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(Ls,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||p.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:f.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:p.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(Gd,{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(mr,{size:12}):r.jsx(ms,{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:[Ul(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),u&&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(Rt,{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(le,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,icon:Ls,children:"Start Build"})]})]})}function Iv({sessionId:e}){return r.jsx(Mh,{sessionId:e})}function Qn(e,t,s){var o;if(t==="directory")return s?r.jsx(on,{size:14}):r.jsx(ao,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(ee,{size:14,className:"text-yellow-600"}),ts:r.jsx(ee,{size:14,className:"text-blue-500"}),tsx:r.jsx(ee,{size:14,className:"text-blue-400"}),jsx:r.jsx(ee,{size:14,className:"text-yellow-500"}),py:r.jsx(ee,{size:14,className:"text-green-600"}),html:r.jsx(cc,{size:14,className:"text-orange-500"}),css:r.jsx(no,{size:14,className:"text-purple-500"}),json:r.jsx(ro,{size:14,className:"text-green-500"}),md:r.jsx(_i,{size:14,className:"text-muted"}),go:r.jsx(ee,{size:14,className:"text-cyan-600"}),rs:r.jsx(ee,{size:14,className:"text-orange-600"}),rb:r.jsx(ee,{size:14,className:"text-red-500"}),sh:r.jsx(ee,{size:14,className:"text-green-600"})}[i]||r.jsx(oo,{size:14})}function Fv(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 Lh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Lh(s.children,t);if(i!==void 0)return i}}}function Bh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Th({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",f=a.has(h.path),p=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":p,...c?{"aria-expanded":f}:{},onContextMenu:u=>{u.preventDefault(),n==null||n(u,h.path,h.name,h.type)},onClick:()=>{c?l(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${p?"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:f?r.jsx(ms,{size:14}):r.jsx(pr,{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:Qn(h.name,h.type,f)}),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:Bh(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(gt,{size:12})})]}),c&&f&&h.children&&r.jsx(Th,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function zh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...zh(i.children,i.path+"/"));return s}function Ah(e,t){return e==="secrets"?t?"Could not load secrets. Check that the server is running and try again.":"No secrets configured yet. Add your first secret below.":t?"Could not load documentation. Check that the server is running and try again.":'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}function Hv(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[f,p]=d.useState(!1),[u,g]=d.useState(new Set),m=d.useCallback(async()=>{try{const k=await V.getSecrets();t(k),p(!1)}catch{p(!0)}l(!1)},[]);d.useEffect(()=>{m()},[m]);const _=async()=>{const k=s.trim();if(k){if(!/^[A-Z_][A-Z0-9_]*$/.test(k)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await V.setSecret(k,n),i(""),o(""),await m()}catch(S){c(S instanceof Error?S.message:"Failed to set secret")}}},x=async k=>{if(window.confirm(`Delete secret "${k}"?`))try{await V.deleteSecret(k),await m()}catch(S){c(S instanceof Error?S.message:"Failed to delete secret")}},y=k=>{g(S=>{const w=new Set(S);return w.has(k)?w.delete(k):w.add(k),w})},b=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"}),r.jsx(oi,{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(Rt,{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."})]}),b.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:b.map(k=>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:k}),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(k)?e[k]:"***"}),r.jsx("button",{onClick:()=>y(k),className:"text-muted hover:text-ink transition-colors",title:u.has(k)?"Hide value":"Show value",children:u.has(k)?r.jsx(Kd,{size:14}):r.jsx(Es,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>x(k),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(io,{size:14})})})]},k))})]})}),b.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:`text-sm text-center py-4 ${f?"text-danger":"text-muted-accessible"}`,children:Ah("secrets",f)})}),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:k=>i(k.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:k=>o(k.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:_,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(gr,{size:14}),"Add"]})]})]})]})})}function Wv({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,f]=d.useState(!0),[p,u]=d.useState(!1),[g,m]=d.useState(null),[_,x]=d.useState(!1),y=d.useCallback(async()=>{try{const S=await V.getDocsStatus(e);if(s(S),S.has_docs){const w=await V.getDocFiles(e);n(w.files)}x(!1)}catch{x(!0)}f(!1)},[e]);d.useEffect(()=>{y()},[y]);const b=async()=>{u(!0),m(null);try{await V.generateDocs(e);const S=setInterval(async()=>{try{const w=await V.getDocsStatus(e);if(w.has_docs){s(w);const j=await V.getDocFiles(e);n(j.files),u(!1),clearInterval(S)}}catch{}},3e3);setTimeout(()=>{clearInterval(S),u(!1)},3e5)}catch(S){m(S instanceof Error?S.message:"Failed to start doc generation"),u(!1)}},k=async S=>{try{const w=await V.getDocFileContent(e,S);a(S),h(w)}catch(w){m(w instanceof Error?w.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Ql,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):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:"Documentation"}),g&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:g})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(le,{onClick:b,disabled:p,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:p?"animate-spin":""}),p?"Updating...":"Update Docs"]}):r.jsx(le,{onClick:b,disabled:p,size:"sm",children:p?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(S=>r.jsxs("button",{onClick:()=>k(S.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(_i,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:S.name}),r.jsx("span",{className:"text-xs text-muted",children:S.size<1024?`${S.size} B`:`${(S.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},S.name))}):_||!(t!=null&&t.has_docs)?r.jsx("p",{className:`text-sm ${_?"text-error":"text-muted"}`,children:Ah("docs",_)}):null,(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function Uv({session:e,onClose:t}){var ia;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(!1),[u,g]=d.useState("code"),[m,_]=d.useState(!1),[x,y]=d.useState(!1),[b,k]=d.useState(e),S=d.useRef(null),[w,j]=d.useState([]),[B,M]=d.useState(!1),[Y,X]=d.useState(""),$=d.useRef(null),D=d.useRef(null),[N,L]=d.useState(0),[E,P]=d.useState(null),[U,C]=d.useState(!0),[H,F]=d.useState(!0),[K,Q]=d.useState(!1),[ie,de]=d.useState("overview"),ue=57374,[ce,ge]=d.useState(null),Fe=d.useCallback(()=>{Q(v=>{const A=!v;return C(!A),F(!A),A})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${b.id}`)||"standard"),[T,J]=d.useState(()=>sessionStorage.getItem(`pl_provider_${b.id}`)||"claude"),[G,oe]=d.useState(null),[He,be]=d.useState(null),[he,Ae]=d.useState(null),[pe,wt]=d.useState(!1),[We,Xt]=d.useState(!1),[Xe,bs]=d.useState({phase:"idle",iteration:null,maxIterations:null,cost:null,startTime:0}),[Ct,Ue]=d.useState(!1),[Ke,Je]=d.useState(null),kt=d.useRef(null),[Oh,Ro]=d.useState(!1),[$h,Po]=d.useState([]),[Mo,Is]=d.useState(null),[Ih,Cr]=d.useState(!1),[Fh,wi]=d.useState(!1),[Hh,Fs]=d.useState(!1),[Ci,Lo]=d.useState("files"),{history:Bo,recordTokens:To}=ev(),[Wh,Uh]=d.useState(null),[zo,Kh]=d.useState({line:1,column:1}),[qh,Ao]=d.useState(0),{device:Vh,setDevice:Gh,frameClass:Oo}=nv(),[kr,Yh]=d.useState(100),[$o,Xh]=d.useState(!1),[ki,Nr]=d.useState(!1),[Io,qv]=d.useState([]),ys=d.useRef(null),[Jh,Fo]=d.useState(0),{subscribe:Ho}=Md(),tt=d.useCallback(async()=>{try{const v=await V.getSessionDetail(b.id);k(v)}catch{}},[b.id]),Wo=d.useCallback(async()=>{try{await V.stopSession(),wt(!1),Xt(!1)}catch{}},[]),Zh=d.useCallback(async()=>{try{await V.pauseSession(),Xt(!0)}catch{}},[]),Qh=d.useCallback(async()=>{try{await V.resumeSession(),Xt(!1)}catch{}},[]),Uo=d.useRef("idle");d.useEffect(()=>{const v=async()=>{try{const W=await V.getStatus();wt(W.running),Xt(W.paused),W.provider&&J(W.provider);const se=W.phase||"idle";if(se!==Uo.current&&se!=="idle"){const ot=new Date().toISOString(),zt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},At={id:`phase-${Date.now()}`,type:"phase_change",message:zt[se]||`Phase: ${se}`,timestamp:ot};Po(Mi=>[...Mi,At]),Uo.current=se}bs({phase:se,iteration:typeof W.iteration=="number"?W.iteration:null,maxIterations:typeof W.max_iterations=="number"&&W.max_iterations>0?W.max_iterations:null,cost:typeof W.cost=="number"?W.cost:null,startTime:W.start_time?W.start_time*1e3:0});const Ze=W.tokens_used;Ze!=null&&To(Ze)}catch{}};v();const A=setInterval(v,pe?3e3:1e4);return()=>clearInterval(A)},[pe,To]),d.useEffect(()=>{if(!(he!=null&&he.loading))return;const v=setInterval(()=>{Ae(A=>A?{...A,elapsed:Math.floor((Date.now()-A.startTime)/1e3)}:null)},1e3);return()=>clearInterval(v)},[he==null?void 0:he.loading]);const[te,ed]=d.useState(null);d.useEffect(()=>{V.getPreviewInfo(b.id).then(ed).catch(()=>{})},[b.id]);const[I,Ni]=d.useState(null),[Hs,Ko]=d.useState(!1),[qo,Vo]=d.useState(!1),[Go,ji]=d.useState(null),[Jt,td]=d.useState("");d.useEffect(()=>{const v=Ho("file_changed",A=>{const W=A;if(!W.paths||W.paths.length===0)return;const se=new Date().toISOString(),Ze=W.paths.map((ot,zt)=>{var ra;const At=(ra=W.event_types)==null?void 0:ra[zt],Mi=At==="created"||At==="IN_CREATE";return{id:`file-${Date.now()}-${zt}`,type:Mi?"file_created":"file_modified",message:Mi?`Created ${ot.split("/").pop()}`:`Modified ${ot.split("/").pop()}`,timestamp:se,filePath:ot}});if(Po(ot=>[...ot,...Ze]),Ue(!0),kt.current&&clearTimeout(kt.current),kt.current=setTimeout(()=>Ue(!1),2e3),tt(),s&&W.paths.some(zt=>zt===s||s.endsWith(zt))&&Je(s),u==="preview"){const ot=["react","vite","next","nuxt","svelte","remix"];(I==null?void 0:I.running)&&(I==null?void 0:I.framework)&&ot.some(At=>I.framework.toLowerCase().includes(At))||L(At=>At+1)}});return()=>{v(),kt.current&&clearTimeout(kt.current)}},[Ho,s,u,I==null?void 0:I.running,tt]);const sd=d.useCallback(async()=>{if(!(!Ke||!b.id)){try{const v=await V.getSessionFileContent(b.id,Ke);l(v.content),c(v.content),_(!1),j(A=>A.map(W=>W.path===Ke?{...W,content:v.content,modified:!1}:W))}catch{}Je(null)}},[Ke,b.id]);d.useEffect(()=>{if(u!=="preview")return;let v=!1;const A=async()=>{try{const se=await V.devserver.status(b.id);v||Ni(se)}catch{}};A();const W=setInterval(A,3e3);return()=>{v=!0,clearInterval(W)}},[u,b.id]),d.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(v=>ge(v.ok)).catch(()=>ge(!1))},[u]);const Ss=d.useCallback(async v=>{Ko(!0),ji(null);try{const A=await V.devserver.start(b.id,v);if(A.status==="error")ji(A.message||"Failed to start dev server");else{const W=await V.devserver.status(b.id);Ni(W)}}catch(A){ji(A instanceof Error?A.message:"Failed to start dev server")}Ko(!1)},[b.id]),Yo=d.useRef(!1);d.useEffect(()=>{Yo.current||te!=null&&te.dev_command&&(I!=null&&I.running||(I==null?void 0:I.status)==="starting"||Hs||(Yo.current=!0,Ss(te.dev_command)))},[te==null?void 0:te.dev_command,I==null?void 0:I.running,I==null?void 0:I.status,Hs,Ss]);const id=d.useCallback(async()=>{try{await V.devserver.stop(b.id);const v=await V.devserver.status(b.id);Ni(v)}catch{}},[b.id]),rd=d.useCallback(async()=>{Vo(!0);try{const v=await V.fixProject(b.id);if(v.task_id){let W=0,se;do await new Promise(ot=>setTimeout(ot,2e3)),se=await V.chatPoll(b.id,v.task_id),W++;while(!se.complete&&W<150);const Ze=await V.devserver.status(b.id);Ni(Ze)}}catch(v){ji(v instanceof Error?v.message:"Fix failed")}Vo(!1)},[b.id]),ws=I!=null&&I.running&&(I!=null&&I.port)?I.framework==="expo"?`${sn}/api/sessions/${encodeURIComponent(b.id)}/expo-qr`:I.portless_url||`http://localhost:${I.port}/`:null,nd=(te==null?void 0:te.preview_url)||`${sn}/api/sessions/${encodeURIComponent(b.id)}/preview/index.html`,od=ws||nd,[Ei,Xo]=d.useState([]),[Nt,Di]=d.useState(0);d.useEffect(()=>{const v=ws||(te==null?void 0:te.preview_url);v&&(Xo([v]),Di(0))},[ws,te==null?void 0:te.preview_url]);const Bt=Ei[Nt]||od,[Jo,jr]=d.useState(Bt),ad=d.useCallback((v,A,W,se)=>{v.preventDefault(),P({x:v.clientX,y:v.clientY,path:A,name:W,type:se})},[]),ld=d.useCallback(()=>{Nt>0&&(Di(v=>v-1),L(v=>v+1))},[Nt]),cd=d.useCallback(()=>{Nt<Ei.length-1&&(Di(v=>v+1),L(v=>v+1))},[Nt,Ei.length]),hd=d.useCallback(v=>{let A=v;if(v.startsWith("/")&&ws)try{A=`${new URL(ws).origin}${v}`}catch{const W=I==null?void 0:I.port;W&&(A=`http://localhost:${W}${v}`)}Xo(W=>[...W.slice(0,Nt+1),A]),Di(W=>W+1),L(W=>W+1)},[Nt,ws,I==null?void 0:I.port]);d.useEffect(()=>{try{const v=new URL(Bt,window.location.origin);jr(v.pathname+v.search+v.hash||"/")}catch{jr(Bt)}},[Bt]);const Ri=d.useCallback(async()=>{Ae({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const v=await V.reviewProject(b.id);be(v.output)}catch(v){be(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Ae(null)}},[b.id]),Pi=d.useCallback(async()=>{Ae({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const v=await V.testProject(b.id);be(v.output)}catch(v){be(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Ae(null)}},[b.id]),Er=d.useCallback(async()=>{Ae({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const v=await V.explainProject(b.id);be(v.output)}catch(v){be(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Ae(null)}},[b.id]),Dr=d.useCallback(async(v,A)=>{if(window.confirm(`Delete "${A}"?`))try{await V.deleteSessionFile(b.id,v),s===v&&(i(null),o(""),l(null),c(null),_(!1)),await tt()}catch(se){const Ze=se instanceof Error?se.message:"Unknown error";window.alert(`Delete failed: ${Ze}`)}},[b.id,s,tt]),dd=d.useCallback(v=>v.type==="file"?[{label:"Review",icon:Es,onClick:()=>{Ri()}},{label:"Generate Tests",icon:ai,onClick:()=>{Pi()}},{label:"Explain",icon:Js,onClick:()=>{Er()}},{label:"Delete",icon:io,onClick:()=>{Dr(v.path,v.name)},variant:"danger"}]:[{label:"Review Project",icon:Es,onClick:()=>{Ri()}},{label:"Run Tests",icon:ai,onClick:()=>{Pi()}}],[Ri,Pi,Er,Dr]),Tt=d.useCallback(async(v,A)=>{Je(null),m&&s&&h!==null&&j(se=>se.map(Ze=>Ze.path===s?{...Ze,content:h,modified:!0}:Ze));const W=w.find(se=>se.path===v);if(W){i(v),o(A),l(W.content),c(W.content),_(W.modified);return}i(v),o(A),p(!0),_(!1);try{const se=b.id?await V.getSessionFileContent(b.id,v):await V.getFileContent(v);l(se.content),c(se.content),j(Ze=>[...Ze,{path:v,name:A,content:se.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{p(!1)}},[b.id,m,s,h,w]),Rr=d.useCallback(async()=>{var v;if(!(!s||h===null||!b.id)){y(!0);try{await V.saveSessionFile(b.id,s,h),l(h),_(!1),Uh(Date.now()),j(W=>W.map(se=>se.path===s?{...se,content:h,modified:!1}:se));const A=((v=s.split(".").pop())==null?void 0:v.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(A)&&L(W=>W+1)}catch(A){const W=A instanceof Error?A.message:"Unknown error";window.alert(`Save failed: ${W}`)}finally{y(!1)}}},[s,h,b.id]),Zo=d.useCallback(v=>{const A=w.find(W=>W.path===v);if(!(A!=null&&A.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(j(W=>W.filter(se=>se.path!==v)),s===v)){const W=w.filter(se=>se.path!==v);if(W.length>0){const se=W[W.length-1];i(se.path),o(se.name),l(se.content),c(se.content),_(se.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const v=A=>{(A.metaKey||A.ctrlKey)&&A.key==="s"&&(A.preventDefault(),m&&s&&Rr()),(A.metaKey||A.ctrlKey)&&A.key==="p"&&(A.preventDefault(),M(W=>!W),X("")),(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),Ro(W=>!W)),A.key==="Escape"&&B&&M(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[m,s,Rr,B]),d.useEffect(()=>{B&&$.current&&$.current.focus()},[B]);const Qo=zh(b.files),Ws=Y?Qo.filter(v=>v.path.toLowerCase().includes(Y.toLowerCase())):Qo;d.useEffect(()=>{const v=b.files.find(A=>A.name==="index.html"&&A.type==="file");v&&Tt(v.path,v.name)},[]);const ud=d.useCallback(v=>{v!==void 0&&(c(v),_(v!==a),Ao(v.split(`
|
|
255
|
-
`).length))},[a]),fd=d.useCallback(v=>{S.current=v;const A=v;if(A!=null&&A.onDidChangeCursorPosition&&A.onDidChangeCursorPosition(W=>{Kh({line:W.position.lineNumber,column:W.position.column})}),A!=null&&A.getModel){const W=A.getModel();W!=null&&W.getLineCount&&Ao(W.getLineCount())}},[]),md=d.useCallback(async()=>{const v=window.prompt("New file name (e.g. src/utils.ts):");if(!(!v||!v.trim()))try{await V.createSessionFile(b.id,v.trim()),await tt()}catch(A){const W=A instanceof Error?A.message:"Unknown error";window.alert(`Create file failed: ${W}`)}},[b.id,tt]),pd=d.useCallback(async()=>{const v=window.prompt("New folder name (e.g. src/components):");if(!(!v||!v.trim()))try{await V.createSessionDirectory(b.id,v.trim()),await tt()}catch(A){const W=A instanceof Error?A.message:"Unknown error";window.alert(`Create folder failed: ${W}`)}},[b.id,tt]),ea=d.useCallback(async()=>{try{const v=await V.previewChanges(b.id,"preview current changes");Is(v)}catch{}},[b.id]),_d=d.useCallback(()=>{Is(null),tt()},[tt]),gd=d.useCallback(v=>{Is(null),tt()},[tt]),xd=d.useCallback(()=>{Is(null)},[]),ta=s?Lh(b.files,s):void 0,vd=((ia=n.split(".").pop())==null?void 0:ia.toUpperCase())||"",{showHelp:bd,setShowHelp:sa}=wx({onToggleBuild:()=>{pe&&Wo()}}),yd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:Es,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:ln,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:os,action:()=>F(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Mr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Kt,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:Te,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:ca,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:ee,action:()=>{M(!0),X("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:cn,action:()=>Fe()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:ha,action:()=>C(v=>!v)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:Te,action:()=>ea()},{id:"insights",label:"Build Insights",category:"command",icon:rn,action:()=>g("insights")},{id:"docs",label:"Documentation",category:"command",icon:Js,action:()=>g("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:as,action:()=>Fs(!0)}],[g,Fe,ea]),Pr=d.useMemo(()=>{if(!pe)return"idle";const v=(Xe.phase||b.status||"").toLowerCase();return v.includes("starting")||v.includes("plan")||v.includes("bootstrap")?"planning":v.includes("review")||v.includes("council")?"reviewing":v.includes("test")||v.includes("verify")?"testing":v.includes("complete")||v.includes("fulfilled")?"complete":"building"},[pe,Xe.phase,b.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:()=>{m&&!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:b.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:b.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${b.status==="completed"||b.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:b.status}),Bo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Qx,{tokenHistory:Bo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>C(v=>!v),title:U?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:U?r.jsx(ha,{size:16}):r.jsx(Du,{size:16})}),r.jsx("button",{onClick:()=>F(v=>!v),title:H?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:H?r.jsx(ku,{size:16}):r.jsx(ju,{size:16})}),r.jsx("button",{onClick:Fe,title:K?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${K?"text-primary":"text-muted hover:text-ink"}`,children:K?r.jsx(dc,{size:16}):r.jsx(cn,{size:16})})]}),!pe&&r.jsx(le,{variant:"primary",size:"sm",icon:rs,onClick:()=>{if(!(b.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}wi(!0)},title:"Start build for this project",children:"Build"}),!pe&&Pr==="complete"&&r.jsx(le,{variant:"ghost",size:"sm",icon:rr,onClick:()=>Cr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Ot,{icon:as,label:"Natural language search",size:"sm",onClick:()=>Fs(!0)}),pe&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[We?r.jsx(le,{variant:"ghost",size:"sm",icon:rs,onClick:Qh,title:"Resume build",children:"Resume"}):r.jsx(le,{variant:"ghost",size:"sm",icon:ec,onClick:Zh,title:"Pause build",children:"Pause"}),r.jsx(le,{variant:"danger",size:"sm",icon:ir,onClick:Wo,title:"Stop build",children:"Stop"})]}),r.jsx(Ot,{icon:Es,label:"Review project",size:"sm",onClick:Ri,disabled:!!(he!=null&&he.loading)}),r.jsx(Ot,{icon:ai,label:"Run tests",size:"sm",onClick:Pi,disabled:!!(he!=null&&he.loading)}),r.jsx(Ot,{icon:Js,label:"Explain project",size:"sm",onClick:Er,disabled:!!(he!=null&&he.loading)}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(kx,{onClick:()=>sa(!0)})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("div",{className:"flex-1",children:r.jsx(ux,{phase:Pr,iteration:Xe.iteration,maxIterations:Xe.maxIterations,cost:Xe.cost,startTime:Xe.startTime,isRunning:pe})})}),r.jsx(Ix,{sessionId:b.id,onRestore:tt}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(un,{orientation:"vertical",children:[r.jsx(ei,{defaultSize:70,minSize:40,children:r.jsxs(un,{orientation:"horizontal",className:"h-full",children:[U&&r.jsx(ei,{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:()=>Lo("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ao,{size:14}),"Files",Ct&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Lo("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Xl,{size:14}),"Chat"]}),Ci==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:md,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(_r,{size:12})," New"]}),r.jsxs("button",{onClick:pd,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(Od,{size:12})," New"]})]})]}),Ci==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:b.files.length>0?r.jsx(Th,{nodes:b.files,selectedPath:s,onSelect:Tt,onDelete:Dr,onContextMenu:ad}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(on,{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(kv,{sessionId:b.id,defaultMode:z})})})]})}),U&&r.jsx(fn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(ei,{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:ln},{id:"preview",label:"Preview",icon:Es},{id:"deploy",label:"Deploy",icon:Kt},{id:"config",label:"Config",icon:ca},{id:"secrets",label:"Secrets",icon:xu},{id:"prd",label:"Spec",icon:_i},{id:"dashboard",label:"Dashboard",icon:Mr},{id:"git",label:"Git",icon:Te},{id:"cicd",label:"CI/CD",icon:Te},{id:"insights",label:"Insights",icon:rn},{id:"docs",label:"Docs",icon:Js}].map(v=>r.jsxs("button",{role:"tab","aria-selected":u===v.id,onClick:()=>g(v.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${u===v.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(v.icon,{size:14}),v.label]},v.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[u==="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(v=>r.jsxs("button",{onClick:()=>Tt(v.path,v.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${v.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Qn(v.name,"file")}),v.name,v.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:A=>{A.stopPropagation(),Zo(v.path)},onKeyDown:A=>{A.key==="Enter"&&(A.stopPropagation(),Zo(v.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(gt,{size:12})})]},v.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}),x&&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:ta!=null?Bh(ta):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:vd}),m&&r.jsx("button",{onClick:Rr,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"})]}),Ke===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(bt,{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:sd,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:()=>Je(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:f?r.jsx(Ld,{}):r.jsx(Wi,{name:"Editor",children:r.jsx(em,{value:h??"",language:Fv(n),theme:"vs",onChange:ud,onMount:fd,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(iv,{selectedFile:s,fileName:n,isModified:m,isSaving:x,lastSavedAt:Wh,lineCount:qh,cursorLine:zo.line,cursorColumn:zo.column,sessionId:b.id,prd:b.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(ee,{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"]})]})]}),u==="preview"&&r.jsx(Wi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${$o?"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:I!=null&&I.running||te!=null&&te.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Ot,{icon:Ql,label:"Back",size:"sm",onClick:ld,disabled:Nt<=0}),r.jsx(Ot,{icon:to,label:"Forward",size:"sm",onClick:cd,disabled:Nt>=Ei.length-1}),r.jsx(dv,{onClick:()=>{Nr(!0),L(v=>v+1)}}),r.jsx("input",{value:Jo,onChange:v=>jr(v.target.value),onKeyDown:v=>{v.key==="Enter"&&hd(Jo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(rv,{selectedDevice:Vh,onDeviceChange:Gh,containerWidth:Jh}),r.jsx(av,{zoom:kr,onZoomChange:Yh}),r.jsx(cv,{url:Bt}),r.jsx(lv,{}),r.jsx(Ot,{icon:ls,label:"Open in new tab",size:"sm",onClick:()=>window.open(Bt,"_blank")}),r.jsx(hv,{isFullscreen:$o,onToggle:()=>Xh(v=>!v)}),(I==null?void 0:I.running)&&r.jsxs("button",{onClick:id,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(ir,{size:12}),"Stop"]})]}):te?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:te.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),I&&I.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${I.running?"bg-green-50 border-green-200 text-green-700":I.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":I.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 ${I.running?"bg-green-500":I.status==="starting"?"bg-yellow-500 animate-pulse":I.status==="error"?"bg-red-500":"bg-gray-400"}`}),I.running&&I.portless_url&&r.jsxs("span",{children:["Running at ",I.portless_url]}),I.running&&I.port&&!I.portless_url&&r.jsxs("span",{children:["Running on port ",I.port]}),I.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),I.status==="error"&&!I.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),I.status==="error"&&I.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",I.auto_fix_status]}),I.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:I.command})]}),I!=null&&I.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx(Il,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Oo} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:D,src:Bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Fo(ys.current.clientWidth)}},N)})}),r.jsx($l,{messages:Io})]}):te!=null&&te.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx(Il,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Oo} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:D,src:Bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Fo(ys.current.clientWidth)}},N)})}),r.jsx($l,{messages:Io})]}):te?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:te.type==="api"||te.type==="python-api"?r.jsx(Yd,{size:28,className:"text-primary"}):te.type==="library"?r.jsx(tc,{size:28,className:"text-primary"}):te.type==="go-app"||te.type==="rust-app"?r.jsx(os,{size:28,className:"text-primary"}):r.jsx(on,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:te.type.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:te.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[te.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:te.dev_command}),r.jsxs("button",{onClick:()=>Ss(te.dev_command||void 0),disabled:Hs,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(rs,{size:12}),Hs?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:te.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:te.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:Jt,onChange:v=>td(v.target.value),onKeyDown:v=>{v.key==="Enter"&&Jt.trim()&&Ss(Jt.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:()=>Jt.trim()&&Ss(Jt.trim()),disabled:Hs||!Jt.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"})]})]})]}),Go&&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:Go})]}),(I==null?void 0:I.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:rd,disabled:qo,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:qo?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>Ss(te.dev_command||Jt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),I.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: ",I.auto_fix_status]}),I.auto_fix_attempts!==void 0&&I.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",I.auto_fix_attempts,"/3"]})]}),I.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:I.output.slice(-10).join(`
|
|
256
|
-
`)})]}),te.port&&!(I!=null&&I.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",te.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),u==="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:["Provider for the next build: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:T})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(v=>r.jsx("button",{disabled:pe,title:pe?"Stop the build to change the provider":void 0,onClick:()=>{V.setProvider(v).then(()=>{J(v),sessionStorage.setItem(`pl_provider_${b.id}`,v),oe(null)}).catch(A=>oe(`Could not set provider: ${A instanceof Error?A.message:"unknown error"}`))},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize disabled:opacity-50 disabled:cursor-not-allowed ${T===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))}),G&&r.jsx("p",{className:"text-xs text-danger mt-2",children:G})]}),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("p",{className:"text-xs text-muted mb-2",children:"Used by chat and the cost estimate in this browser tab. Not sent to the build."}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(v=>r.jsx("button",{onClick:()=>{xe(v),sessionStorage.setItem(`pl_buildmode_${b.id}`,v)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))})]}),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:b.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:b.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),u==="secrets"&&r.jsx(Hv,{}),u==="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"}),b.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:b.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),u==="deploy"&&r.jsx(bx,{sessionId:b.id}),u==="dashboard"&&(ce===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Mr,{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()=>{ge(null);try{const v=await fetch(`http://127.0.0.1:${ue}/health`);ge(v.ok)}catch{ge(!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(v=>r.jsx("button",{onClick:()=>de(v.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===v.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:v.label},v.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${ue}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ls,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${ue}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),u==="git"&&r.jsx($x,{sessionId:b.id}),u==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Iv,{sessionId:e.id})}),u==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Wv,{sessionId:b.id})}),u==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Dv,{filesCreated:null,filesModified:null,linesGenerated:null,testsGenerated:null,testPassRate:null,totalTokens:null,phaseBreakdown:[],totalTimeSecs:pe&&Xe.startTime?Math.floor((Date.now()-Xe.startTime)/1e3):null,qualityScore:null,totalCost:Xe.cost,iterations:Xe.iteration,provider:T})})]})]})})]})}),H&&r.jsx(fn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),H&&r.jsx(ei,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Wi,{name:"ActivityPanel",children:r.jsx(hx,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:b.status==="running"||b.status==="in_progress",buildMode:z,buildEvents:$h,onFileClick:v=>Tt(v,v.split("/").pop()||v)})})})]})}),(he==null?void 0:he.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:[he.type==="review"?"Reviewing project":he.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[he.elapsed,"s"]})]})}),He&&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(Ot,{icon:gt,label:"Close",size:"sm",onClick:()=>be(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:He})]}),E&&r.jsx(Am,{x:E.x,y:E.y,items:dd(E),onClose:()=>P(null)}),B&&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:()=>M(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:v=>v.stopPropagation(),children:[r.jsx("input",{ref:$,type:"text",value:Y,onChange:v=>X(v.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:v=>{v.key==="Enter"&&Ws.length>0&&(Tt(Ws[0].path,Ws[0].name),M(!1)),v.key==="Escape"&&M(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Ws.slice(0,20).map(v=>r.jsxs("button",{onClick:()=>{Tt(v.path,v.name),M(!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:Qn(v.name,"file")}),r.jsx("span",{className:"text-ink",children:v.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:v.path})]},v.path)),Ws.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(Cx,{open:bd,onClose:()=>sa(!1)}),r.jsx(Rx,{isOpen:Oh,onClose:()=>Ro(!1),commands:yd,sessionId:b.id,onFileSelect:Tt}),Mo&&r.jsx(Wx,{data:Mo,onAcceptAll:_d,onAcceptSelected:gd,onReject:xd,onClose:()=>Is(null)}),r.jsx(Zx,{phase:Pr,buildTime:Xe.startTime?Math.floor((Date.now()-Xe.startTime)/1e3):void 0}),Ih&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Cr(!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:v=>v.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:()=>Cr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Mv,{sessionId:b.id})})]})}),Hh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Fs(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:v=>v.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:()=>Fs(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx(Av,{sessionId:b.id,onOpenFile:(v,A)=>{Tt(v,v.split("/").pop()||v),Fs(!1)},className:"p-4"})]})}),Fh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>wi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:v=>v.stopPropagation(),children:r.jsx($v,{complexity:z==="quick"?"simple":z==="max"?"complex":"standard",provider:T,estimatedIterations:0,onConfirm:async()=>{wi(!1);try{const v=b.prd||"";await V.startSession({prd:v,provider:T,projectDir:b.path}),wt(!0)}catch(v){window.alert(`Failed to start: ${v instanceof Error?v.message:"Unknown error"}`)}},onCancel:()=>wi(!1)})})})]})}function Kv(){const{sessionId:e}=Bd(),t=Td(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),V.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(Wi,{name:"ProjectWorkspace",children:r.jsx(Uv,{session:s,onClose:()=>t("/")})})})})}const Nb=Object.freeze(Object.defineProperty({__proto__:null,default:Kv},Symbol.toStringTag,{value:"Module"}));export{xr as L,Nb as P,Lu as S};
|
|
254
|
+
group cursor-pointer`,children:[r.jsx(ee,{size:14,className:T(L.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:L.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:L.path}),L.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:L.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[L.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(yu,{size:10}),L.lineNumber]}),r.jsx(io,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${L.path}-${U}`))]})})]})}const ur={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"}},fr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function ib(e,t,s){const i=ur[t]||ur.claude,n=fr[e]||fr.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}],c=n.tokens*(o/n.iters),h=Math.round(c),l=a.map(p=>{const _=Math.round(h*p.pct),x=_*.4,y=_*.6,v=(x*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:v,estimatedTokens:_}}),f=l.reduce((p,_)=>p+_.estimatedCost,0),u=o*(e==="complex"?40:e==="simple"?15:25),g=u<60?`${u}s`:u<3600?`${Math.round(u/60)}min`:`${(u/3600).toFixed(1)}hr`;return{total:{low:f*.7,high:f*1.4},breakdown:l,totalTokens:h,estimatedTime:g}}function Vl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function rb({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[c,h]=d.useState(!1),l=ib(e,t,i),f=ur[t]||ur.claude,m=fr[e]||fr.standard,u=l.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(nc,{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:["$",l.total.low.toFixed(2)," -- $",l.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(zs,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Vl(l.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(ft,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:l.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(zs,{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:f.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(eu,{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(!c),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[c?r.jsx(mr,{size:12}):r.jsx(xs,{size:12}),"Cost breakdown by phase"]}),c&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:l.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:[Vl(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),u&&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(Tt,{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(he,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(he,{variant:"primary",size:"sm",onClick:n,icon:zs,children:"Start Build"})]})]})}function nb({sessionId:e}){return r.jsx(Ih,{sessionId:e})}function to(e,t,s){var o;if(t==="directory")return s?r.jsx(an,{size:14}):r.jsx(co,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(ee,{size:14,className:"text-yellow-600"}),ts:r.jsx(ee,{size:14,className:"text-blue-500"}),tsx:r.jsx(ee,{size:14,className:"text-blue-400"}),jsx:r.jsx(ee,{size:14,className:"text-yellow-500"}),py:r.jsx(ee,{size:14,className:"text-green-600"}),html:r.jsx(uc,{size:14,className:"text-orange-500"}),css:r.jsx(ao,{size:14,className:"text-purple-500"}),json:r.jsx(oo,{size:14,className:"text-green-500"}),md:r.jsx(gi,{size:14,className:"text-muted"}),go:r.jsx(ee,{size:14,className:"text-cyan-600"}),rs:r.jsx(ee,{size:14,className:"text-orange-600"}),rb:r.jsx(ee,{size:14,className:"text-red-500"}),sh:r.jsx(ee,{size:14,className:"text-green-600"})}[i]||r.jsx(lo,{size:14})}function ob(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 Oh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Oh(s.children,t);if(i!==void 0)return i}}}function $h(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Fh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,c]=d.useState(()=>{const h=new Set;return o<2&&e.filter(l=>l.type==="directory").forEach(l=>h.add(l.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const l=h.type==="directory",f=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,...l?{"aria-expanded":f}:{},onContextMenu:u=>{u.preventDefault(),n==null||n(u,h.path,h.name,h.type)},onClick:()=>{l?c(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[l?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:f?r.jsx(xs,{size:14}):r.jsx(pr,{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 ${l?"text-primary":""}`,children:to(h.name,h.type,f)}),r.jsxs("span",{className:"truncate",children:[h.name,l?"/":""]}),!l&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:$h(h.size)}),!l&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(vt,{size:12})})]}),l&&f&&h.children&&r.jsx(Fh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Hh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Hh(i.children,i.path+"/"));return s}function Wh(e,t){return e==="secrets"?t?"Could not load secrets. Check that the server is running and try again.":"No secrets configured yet. Add your first secret below.":t?"Could not load documentation. Check that the server is running and try again.":'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}function ab(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,c]=d.useState(!0),[h,l]=d.useState(null),[f,m]=d.useState(!1),[u,g]=d.useState(new Set),p=d.useCallback(async()=>{try{const k=await V.getSecrets();t(k),m(!1)}catch{m(!0)}c(!1)},[]);d.useEffect(()=>{p()},[p]);const _=async()=>{const k=s.trim();if(k){if(!/^[A-Z_][A-Z0-9_]*$/.test(k)){l("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}l(null);try{await V.setSecret(k,n),i(""),o(""),await p()}catch(w){l(w instanceof Error?w.message:"Failed to set secret")}}},x=async k=>{if(window.confirm(`Delete secret "${k}"?`))try{await V.deleteSecret(k),await p()}catch(w){l(w instanceof Error?w.message:"Failed to delete secret")}},y=k=>{g(w=>{const D=new Set(w);return D.has(k)?D.delete(k):D.add(k),D})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"}),r.jsx(oi,{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(Tt,{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(k=>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:k}),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(k)?e[k]:"***"}),r.jsx("button",{onClick:()=>y(k),className:"text-muted hover:text-ink transition-colors",title:u.has(k)?"Hide value":"Show value",children:u.has(k)?r.jsx(Jd,{size:14}):r.jsx(Rs,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>x(k),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(no,{size:14})})})]},k))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:`text-sm text-center py-4 ${f?"text-danger":"text-muted-accessible"}`,children:Wh("secrets",f)})}),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:k=>i(k.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:k=>o(k.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:_,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(gr,{size:14}),"Add"]})]})]})]})})}function lb({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[c,h]=d.useState(""),[l,f]=d.useState(!0),[m,u]=d.useState(!1),[g,p]=d.useState(null),[_,x]=d.useState(!1),y=d.useCallback(async()=>{try{const w=await V.getDocsStatus(e);if(s(w),w.has_docs){const D=await V.getDocFiles(e);n(D.files)}x(!1)}catch{x(!0)}f(!1)},[e]);d.useEffect(()=>{y()},[y]);const v=async()=>{u(!0),p(null);try{await V.generateDocs(e);const w=setInterval(async()=>{try{const D=await V.getDocsStatus(e);if(D.has_docs){s(D);const N=await V.getDocFiles(e);n(N.files),u(!1),clearInterval(w)}}catch{}},3e3);setTimeout(()=>{clearInterval(w),u(!1)},3e5)}catch(w){p(w instanceof Error?w.message:"Failed to start doc generation"),u(!1)}},k=async w=>{try{const D=await V.getDocFileContent(e,w);a(w),h(D)}catch(D){p(D instanceof Error?D.message:"Failed to load doc file")}};return l?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(sc,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:c})})]}):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:"Documentation"}),g&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:g})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(he,{onClick:v,disabled:m,size:"sm",variant:"secondary",children:[r.jsx(St,{size:14,className:m?"animate-spin":""}),m?"Updating...":"Update Docs"]}):r.jsx(he,{onClick:v,disabled:m,size:"sm",children:m?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(w=>r.jsxs("button",{onClick:()=>k(w.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(gi,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:w.name}),r.jsx("span",{className:"text-xs text-muted",children:w.size<1024?`${w.size} B`:`${(w.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},w.name))}):_||!(t!=null&&t.has_docs)?r.jsx("p",{className:`text-sm ${_?"text-error":"text-muted"}`,children:Wh("docs",_)}):null,(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function cb({session:e,onClose:t}){var na;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,c]=d.useState(null),[h,l]=d.useState(null),[f,m]=d.useState(!1),[u,g]=d.useState("code"),[p,_]=d.useState(!1),[x,y]=d.useState(!1),[v,k]=d.useState(e),w=d.useRef(null),[D,N]=d.useState([]),[T,L]=d.useState(!1),[U,Y]=d.useState(""),X=d.useRef(null),M=d.useRef(null),[E,P]=d.useState(0),[S,j]=d.useState(null),[z,C]=d.useState(!0),[I,O]=d.useState(!0),[K,Z]=d.useState(!1),[ne,ce]=d.useState("overview"),oe=57374,[_e,ue]=d.useState(null),De=d.useCallback(()=>{Z(b=>{const $=!b;return C(!$),O(!$),$})},[]),[A,pe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${v.id}`)||"standard"),[B,J]=d.useState(()=>sessionStorage.getItem(`pl_provider_${v.id}`)||"claude"),[G,ae]=d.useState(null),[Ke,be]=d.useState(null),[de,$e]=d.useState(null),[ge,Et]=d.useState(!1),[qe,is]=d.useState(!1),[Ze,Ss]=d.useState({phase:"idle",iteration:null,maxIterations:null,cost:null,startTime:0}),[Dt,Ve]=d.useState(!1),[Ge,Qe]=d.useState(null),Rt=d.useRef(null),[Uh,Po]=d.useState(!1),[Kh,Mo]=d.useState([]),[Bo,Fs]=d.useState(null),[qh,kr]=d.useState(!1),[Vh,Ci]=d.useState(!1),[Gh,Hs]=d.useState(!1),[ki,To]=d.useState("files"),{history:zo,recordTokens:Ao}=vv(),[Yh,Xh]=d.useState(null),[Io,Jh]=d.useState({line:1,column:1}),[Zh,Oo]=d.useState(0),{device:Qh,setDevice:ed,frameClass:$o}=Cv(),[Nr,td]=d.useState(100),[Fo,sd]=d.useState(!1),[Ni,jr]=d.useState(!1),[Ho,db]=d.useState([]),ws=d.useRef(null),[id,Wo]=d.useState(0),{subscribe:Uo}=Id(),st=d.useCallback(async()=>{try{const b=await V.getSessionDetail(v.id);k(b)}catch{}},[v.id]),Ko=d.useCallback(async()=>{try{await V.stopSession(),Et(!1),is(!1)}catch{}},[]),rd=d.useCallback(async()=>{try{await V.pauseSession(),is(!0)}catch{}},[]),nd=d.useCallback(async()=>{try{await V.resumeSession(),is(!1)}catch{}},[]),qo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const W=await V.getStatus();Et(W.running),is(W.paused),W.provider&&J(W.provider);const se=W.phase||"idle";if(se!==qo.current&&se!=="idle"){const at=new Date().toISOString(),Ft={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},Ht={id:`phase-${Date.now()}`,type:"phase_change",message:Ft[se]||`Phase: ${se}`,timestamp:at};Mo(Mi=>[...Mi,Ht]),qo.current=se}Ss({phase:se,iteration:typeof W.iteration=="number"?W.iteration:null,maxIterations:typeof W.max_iterations=="number"&&W.max_iterations>0?W.max_iterations:null,cost:typeof W.cost=="number"?W.cost:null,startTime:W.start_time?W.start_time*1e3:0});const et=W.tokens_used;et!=null&&Ao(et)}catch{}};b();const $=setInterval(b,ge?3e3:1e4);return()=>clearInterval($)},[ge,Ao]),d.useEffect(()=>{if(!(de!=null&&de.loading))return;const b=setInterval(()=>{$e($=>$?{...$,elapsed:Math.floor((Date.now()-$.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[de==null?void 0:de.loading]);const[te,od]=d.useState(null);d.useEffect(()=>{V.getPreviewInfo(v.id).then(od).catch(()=>{})},[v.id]);const[H,ji]=d.useState(null),[Ws,Vo]=d.useState(!1),[Go,Yo]=d.useState(!1),[Xo,Ei]=d.useState(null),[rs,ad]=d.useState("");d.useEffect(()=>{const b=Uo("file_changed",$=>{const W=$;if(!W.paths||W.paths.length===0)return;const se=new Date().toISOString(),et=W.paths.map((at,Ft)=>{var oa;const Ht=(oa=W.event_types)==null?void 0:oa[Ft],Mi=Ht==="created"||Ht==="IN_CREATE";return{id:`file-${Date.now()}-${Ft}`,type:Mi?"file_created":"file_modified",message:Mi?`Created ${at.split("/").pop()}`:`Modified ${at.split("/").pop()}`,timestamp:se,filePath:at}});if(Mo(at=>[...at,...et]),Ve(!0),Rt.current&&clearTimeout(Rt.current),Rt.current=setTimeout(()=>Ve(!1),2e3),st(),s&&W.paths.some(Ft=>Ft===s||s.endsWith(Ft))&&Qe(s),u==="preview"){const at=["react","vite","next","nuxt","svelte","remix"];(H==null?void 0:H.running)&&(H==null?void 0:H.framework)&&at.some(Ht=>H.framework.toLowerCase().includes(Ht))||P(Ht=>Ht+1)}});return()=>{b(),Rt.current&&clearTimeout(Rt.current)}},[Uo,s,u,H==null?void 0:H.running,st]);const ld=d.useCallback(async()=>{if(!(!Ge||!v.id)){try{const b=await V.getSessionFileContent(v.id,Ge);c(b.content),l(b.content),_(!1),N($=>$.map(W=>W.path===Ge?{...W,content:b.content,modified:!1}:W))}catch{}Qe(null)}},[Ge,v.id]);d.useEffect(()=>{if(u!=="preview")return;let b=!1;const $=async()=>{try{const se=await V.devserver.status(v.id);b||ji(se)}catch{}};$();const W=setInterval($,3e3);return()=>{b=!0,clearInterval(W)}},[u,v.id]),d.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${oe}/health`).then(b=>ue(b.ok)).catch(()=>ue(!1))},[u]);const Cs=d.useCallback(async b=>{Vo(!0),Ei(null);try{const $=await V.devserver.start(v.id,b);if($.status==="error")Ei($.message||"Failed to start dev server");else{const W=await V.devserver.status(v.id);ji(W)}}catch($){Ei($ instanceof Error?$.message:"Failed to start dev server")}Vo(!1)},[v.id]),Jo=d.useRef(!1);d.useEffect(()=>{Jo.current||te!=null&&te.dev_command&&(H!=null&&H.running||(H==null?void 0:H.status)==="starting"||Ws||(Jo.current=!0,Cs(te.dev_command)))},[te==null?void 0:te.dev_command,H==null?void 0:H.running,H==null?void 0:H.status,Ws,Cs]);const cd=d.useCallback(async()=>{try{await V.devserver.stop(v.id);const b=await V.devserver.status(v.id);ji(b)}catch{}},[v.id]),hd=d.useCallback(async()=>{Yo(!0);try{const b=await V.fixProject(v.id);if(b.task_id){let W=0,se;do await new Promise(at=>setTimeout(at,2e3)),se=await V.chatPoll(v.id,b.task_id),W++;while(!se.complete&&W<150);const et=await V.devserver.status(v.id);ji(et)}}catch(b){Ei(b instanceof Error?b.message:"Fix failed")}Yo(!1)},[v.id]),ks=H!=null&&H.running&&(H!=null&&H.port)?H.framework==="expo"?`${rn}/api/sessions/${encodeURIComponent(v.id)}/expo-qr`:H.portless_url||`http://localhost:${H.port}/`:null,dd=(te==null?void 0:te.preview_url)||`${rn}/api/sessions/${encodeURIComponent(v.id)}/preview/index.html`,ud=ks||dd,[Di,Zo]=d.useState([]),[Lt,Ri]=d.useState(0);d.useEffect(()=>{const b=ks||(te==null?void 0:te.preview_url);b&&(Zo([b]),Ri(0))},[ks,te==null?void 0:te.preview_url]);const Ot=Di[Lt]||ud,[Qo,Er]=d.useState(Ot),fd=d.useCallback((b,$,W,se)=>{b.preventDefault(),j({x:b.clientX,y:b.clientY,path:$,name:W,type:se})},[]),md=d.useCallback(()=>{Lt>0&&(Ri(b=>b-1),P(b=>b+1))},[Lt]),pd=d.useCallback(()=>{Lt<Di.length-1&&(Ri(b=>b+1),P(b=>b+1))},[Lt,Di.length]),_d=d.useCallback(b=>{let $=b;if(b.startsWith("/")&&ks)try{$=`${new URL(ks).origin}${b}`}catch{const W=H==null?void 0:H.port;W&&($=`http://localhost:${W}${b}`)}Zo(W=>[...W.slice(0,Lt+1),$]),Ri(W=>W+1),P(W=>W+1)},[Lt,ks,H==null?void 0:H.port]);d.useEffect(()=>{try{const b=new URL(Ot,window.location.origin);Er(b.pathname+b.search+b.hash||"/")}catch{Er(Ot)}},[Ot]);const Li=d.useCallback(async()=>{$e({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await V.reviewProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{$e(null)}},[v.id]),Pi=d.useCallback(async()=>{$e({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await V.testProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{$e(null)}},[v.id]),Dr=d.useCallback(async()=>{$e({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await V.explainProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{$e(null)}},[v.id]),Rr=d.useCallback(async(b,$)=>{if(window.confirm(`Delete "${$}"?`))try{await V.deleteSessionFile(v.id,b),s===b&&(i(null),o(""),c(null),l(null),_(!1)),await st()}catch(se){const et=se instanceof Error?se.message:"Unknown error";window.alert(`Delete failed: ${et}`)}},[v.id,s,st]),gd=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:Rs,onClick:()=>{Li()}},{label:"Generate Tests",icon:ai,onClick:()=>{Pi()}},{label:"Explain",icon:Zs,onClick:()=>{Dr()}},{label:"Delete",icon:no,onClick:()=>{Rr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:Rs,onClick:()=>{Li()}},{label:"Run Tests",icon:ai,onClick:()=>{Pi()}}],[Li,Pi,Dr,Rr]),$t=d.useCallback(async(b,$)=>{Qe(null),p&&s&&h!==null&&N(se=>se.map(et=>et.path===s?{...et,content:h,modified:!0}:et));const W=D.find(se=>se.path===b);if(W){i(b),o($),c(W.content),l(W.content),_(W.modified);return}i(b),o($),m(!0),_(!1);try{const se=v.id?await V.getSessionFileContent(v.id,b):await V.getFileContent(b);c(se.content),l(se.content),N(et=>[...et,{path:b,name:$,content:se.content,modified:!1}])}catch{c("[Error loading file]"),l("[Error loading file]")}finally{m(!1)}},[v.id,p,s,h,D]),Lr=d.useCallback(async()=>{var b;if(!(!s||h===null||!v.id)){y(!0);try{await V.saveSessionFile(v.id,s,h),c(h),_(!1),Xh(Date.now()),N(W=>W.map(se=>se.path===s?{...se,content:h,modified:!1}:se));const $=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes($)&&P(W=>W+1)}catch($){const W=$ instanceof Error?$.message:"Unknown error";window.alert(`Save failed: ${W}`)}finally{y(!1)}}},[s,h,v.id]),ea=d.useCallback(b=>{const $=D.find(W=>W.path===b);if(!($!=null&&$.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(N(W=>W.filter(se=>se.path!==b)),s===b)){const W=D.filter(se=>se.path!==b);if(W.length>0){const se=W[W.length-1];i(se.path),o(se.name),c(se.content),l(se.content),_(se.modified)}else i(null),o(""),c(null),l(null),_(!1)}},[D,s]);d.useEffect(()=>{const b=$=>{($.metaKey||$.ctrlKey)&&$.key==="s"&&($.preventDefault(),p&&s&&Lr()),($.metaKey||$.ctrlKey)&&$.key==="p"&&($.preventDefault(),L(W=>!W),Y("")),($.metaKey||$.ctrlKey)&&$.key==="k"&&($.preventDefault(),Po(W=>!W)),$.key==="Escape"&&T&&L(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,Lr,T]),d.useEffect(()=>{T&&X.current&&X.current.focus()},[T]);const ta=Hh(v.files),Us=U?ta.filter(b=>b.path.toLowerCase().includes(U.toLowerCase())):ta;d.useEffect(()=>{const b=v.files.find($=>$.name==="index.html"&&$.type==="file");b&&$t(b.path,b.name)},[]);const xd=d.useCallback(b=>{b!==void 0&&(l(b),_(b!==a),Oo(b.split(`
|
|
255
|
+
`).length))},[a]),vd=d.useCallback(b=>{w.current=b;const $=b;if($!=null&&$.onDidChangeCursorPosition&&$.onDidChangeCursorPosition(W=>{Jh({line:W.position.lineNumber,column:W.position.column})}),$!=null&&$.getModel){const W=$.getModel();W!=null&&W.getLineCount&&Oo(W.getLineCount())}},[]),bd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await V.createSessionFile(v.id,b.trim()),await st()}catch($){const W=$ instanceof Error?$.message:"Unknown error";window.alert(`Create file failed: ${W}`)}},[v.id,st]),yd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await V.createSessionDirectory(v.id,b.trim()),await st()}catch($){const W=$ instanceof Error?$.message:"Unknown error";window.alert(`Create folder failed: ${W}`)}},[v.id,st]),sa=d.useCallback(async()=>{try{const b=await V.previewChanges(v.id,"preview current changes");Fs(b)}catch{}},[v.id]),Sd=d.useCallback(()=>{Fs(null),st()},[st]),wd=d.useCallback(b=>{Fs(null),st()},[st]),Cd=d.useCallback(()=>{Fs(null)},[]),ia=s?Oh(v.files,s):void 0,kd=((na=n.split(".").pop())==null?void 0:na.toUpperCase())||"",{showHelp:Nd,setShowHelp:ra}=Hx({onToggleBuild:()=>{ge&&Ko()}}),jd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:Rs,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:cn,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:fs,action:()=>O(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Mr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Xt,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:Ie,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:da,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:ee,action:()=>{L(!0),Y("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:hn,action:()=>De()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:ua,action:()=>C(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:Ie,action:()=>sa()},{id:"insights",label:"Build Insights",category:"command",icon:nn,action:()=>g("insights")},{id:"docs",label:"Documentation",category:"command",icon:Zs,action:()=>g("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:ms,action:()=>Hs(!0)}],[g,De,sa]),Pr=d.useMemo(()=>{if(!ge)return"idle";const b=(Ze.phase||v.status||"").toLowerCase();return b.includes("starting")||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,Ze.phase,v.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:v.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:v.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${v.status==="completed"||v.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:v.status}),zo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(xv,{tokenHistory:zo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>C(b=>!b),title:z?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:z?r.jsx(ua,{size:16}):r.jsx(Tu,{size:16})}),r.jsx("button",{onClick:()=>O(b=>!b),title:I?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:I?r.jsx(Lu,{size:16}):r.jsx(Mu,{size:16})}),r.jsx("button",{onClick:De,title:K?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${K?"text-primary":"text-muted hover:text-ink"}`,children:K?r.jsx(mc,{size:16}):r.jsx(hn,{size:16})})]}),!ge&&r.jsx(he,{variant:"primary",size:"sm",icon:ds,onClick:()=>{if(!(v.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}Ci(!0)},title:"Start build for this project",children:"Build"}),!ge&&Pr==="complete"&&r.jsx(he,{variant:"ghost",size:"sm",icon:rr,onClick:()=>kr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Wt,{icon:ms,label:"Natural language search",size:"sm",onClick:()=>Hs(!0)}),ge&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[qe?r.jsx(he,{variant:"ghost",size:"sm",icon:ds,onClick:nd,title:"Resume build",children:"Resume"}):r.jsx(he,{variant:"ghost",size:"sm",icon:ic,onClick:rd,title:"Pause build",children:"Pause"}),r.jsx(he,{variant:"danger",size:"sm",icon:ir,onClick:Ko,title:"Stop build",children:"Stop"})]}),r.jsx(Wt,{icon:Rs,label:"Review project",size:"sm",onClick:Li,disabled:!!(de!=null&&de.loading)}),r.jsx(Wt,{icon:ai,label:"Run tests",size:"sm",onClick:Pi,disabled:!!(de!=null&&de.loading)}),r.jsx(Wt,{icon:Zs,label:"Explain project",size:"sm",onClick:Dr,disabled:!!(de!=null&&de.loading)}),r.jsx(he,{variant:"secondary",size:"sm",icon:Xt,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(Ux,{onClick:()=>ra(!0)})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("div",{className:"flex-1",children:r.jsx(Lx,{phase:Pr,iteration:Ze.iteration,maxIterations:Ze.maxIterations,cost:Ze.cost,startTime:Ze.startTime,isRunning:ge})})}),r.jsx(nv,{sessionId:v.id,onRestore:st}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(mn,{orientation:"vertical",children:[r.jsx(ei,{defaultSize:70,minSize:40,children:r.jsxs(mn,{orientation:"horizontal",className:"h-full",children:[z&&r.jsx(ei,{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:()=>To("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${ki==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(co,{size:14}),"Files",Dt&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>To("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${ki==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Ql,{size:14}),"Chat"]}),ki==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:bd,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(_r,{size:12})," New"]}),r.jsxs("button",{onClick:yd,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(Ud,{size:12})," New"]})]})]}),ki==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:v.files.length>0?r.jsx(Fh,{nodes:v.files,selectedPath:s,onSelect:$t,onDelete:Rr,onContextMenu:fd}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(an,{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(Uv,{sessionId:v.id,defaultMode:A})})})]})}),z&&r.jsx(pn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(ei,{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:cn},{id:"preview",label:"Preview",icon:Rs},{id:"deploy",label:"Deploy",icon:Xt},{id:"config",label:"Config",icon:da},{id:"secrets",label:"Secrets",icon:Cu},{id:"prd",label:"Spec",icon:gi},{id:"dashboard",label:"Dashboard",icon:Mr},{id:"git",label:"Git",icon:Ie},{id:"cicd",label:"CI/CD",icon:Ie},{id:"insights",label:"Insights",icon:nn},{id:"docs",label:"Docs",icon:Zs}].map(b=>r.jsxs("button",{role:"tab","aria-selected":u===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 ${u===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:[u==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[D.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:D.map(b=>r.jsxs("button",{onClick:()=>$t(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:to(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:$=>{$.stopPropagation(),ea(b.path)},onKeyDown:$=>{$.key==="Enter"&&($.stopPropagation(),ea(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(vt,{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}),x&&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:ia!=null?$h(ia):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:kd}),p&&r.jsx("button",{onClick:Lr,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"})]}),Ge===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(St,{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:ld,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:()=>Qe(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:f?r.jsx(Od,{}):r.jsx(Ui,{name:"Editor",children:r.jsx(om,{value:h??"",language:ob(n),theme:"vs",onChange:xd,onMount:vd,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(Sv,{selectedFile:s,fileName:n,isModified:p,isSaving:x,lastSavedAt:Yh,lineCount:Zh,cursorLine:Io.line,cursorColumn:Io.column,sessionId:v.id,prd:v.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(ee,{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"]})]})]}),u==="preview"&&r.jsx(Ui,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${Fo?"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:H!=null&&H.running||te!=null&&te.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Wt,{icon:sc,label:"Back",size:"sm",onClick:md,disabled:Lt<=0}),r.jsx(Wt,{icon:io,label:"Forward",size:"sm",onClick:pd,disabled:Lt>=Di.length-1}),r.jsx(Rv,{onClick:()=>{jr(!0),P(b=>b+1)}}),r.jsx("input",{value:Qo,onChange:b=>Er(b.target.value),onKeyDown:b=>{b.key==="Enter"&&_d(Qo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(wv,{selectedDevice:Qh,onDeviceChange:ed,containerWidth:id}),r.jsx(Nv,{zoom:Nr,onZoomChange:td}),r.jsx(Ev,{url:Ot}),r.jsx(jv,{}),r.jsx(Wt,{icon:ps,label:"Open in new tab",size:"sm",onClick:()=>window.open(Ot,"_blank")}),r.jsx(Dv,{isFullscreen:Fo,onToggle:()=>sd(b=>!b)}),(H==null?void 0:H.running)&&r.jsxs("button",{onClick:cd,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(ir,{size:12}),"Stop"]})]}):te?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:te.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),H&&H.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${H.running?"bg-green-50 border-green-200 text-green-700":H.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":H.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 ${H.running?"bg-green-500":H.status==="starting"?"bg-yellow-500 animate-pulse":H.status==="error"?"bg-red-500":"bg-gray-400"}`}),H.running&&H.portless_url&&r.jsxs("span",{children:["Running at ",H.portless_url]}),H.running&&H.port&&!H.portless_url&&r.jsxs("span",{children:["Running on port ",H.port]}),H.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),H.status==="error"&&!H.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),H.status==="error"&&H.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",H.auto_fix_status]}),H.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:H.command})]}),H!=null&&H.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ni&&r.jsx(Wl,{}),r.jsx("div",{ref:ws,className:`flex-1 bg-white overflow-auto flex justify-center ${Ni?"hidden":""}`,children:r.jsx("div",{className:`${$o} h-full preview-zoom-${Nr}`,children:r.jsx("iframe",{ref:M,src:Ot,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{jr(!1),ws.current&&Wo(ws.current.clientWidth)}},E)})}),r.jsx(Hl,{messages:Ho})]}):te!=null&&te.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[Ni&&r.jsx(Wl,{}),r.jsx("div",{ref:ws,className:`flex-1 bg-white overflow-auto flex justify-center ${Ni?"hidden":""}`,children:r.jsx("div",{className:`${$o} h-full preview-zoom-${Nr}`,children:r.jsx("iframe",{ref:M,src:Ot,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{jr(!1),ws.current&&Wo(ws.current.clientWidth)}},E)})}),r.jsx(Hl,{messages:Ho})]}):te?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:te.type==="api"||te.type==="python-api"?r.jsx(tu,{size:28,className:"text-primary"}):te.type==="library"?r.jsx(rc,{size:28,className:"text-primary"}):te.type==="go-app"||te.type==="rust-app"?r.jsx(fs,{size:28,className:"text-primary"}):r.jsx(an,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:te.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:te.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[te.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:te.dev_command}),r.jsxs("button",{onClick:()=>Cs(te.dev_command||void 0),disabled:Ws,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(ds,{size:12}),Ws?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:te.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:te.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:rs,onChange:b=>ad(b.target.value),onKeyDown:b=>{b.key==="Enter"&&rs.trim()&&Cs(rs.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:()=>rs.trim()&&Cs(rs.trim()),disabled:Ws||!rs.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"})]})]})]}),Xo&&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:Xo})]}),(H==null?void 0:H.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:hd,disabled:Go,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:Go?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>Cs(te.dev_command||rs||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),H.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: ",H.auto_fix_status]}),H.auto_fix_attempts!==void 0&&H.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",H.auto_fix_attempts,"/3"]})]}),H.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:H.output.slice(-10).join(`
|
|
256
|
+
`)})]}),te.port&&!(H!=null&&H.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",te.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),u==="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:["Provider for the next build: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:B})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{disabled:ge,title:ge?"Stop the build to change the provider":void 0,onClick:()=>{V.setProvider(b).then(()=>{J(b),sessionStorage.setItem(`pl_provider_${v.id}`,b),ae(null)}).catch($=>ae(`Could not set provider: ${$ instanceof Error?$.message:"unknown error"}`))},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize disabled:opacity-50 disabled:cursor-not-allowed ${B===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))}),G&&r.jsx("p",{className:"text-xs text-danger mt-2",children:G})]}),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("p",{className:"text-xs text-muted mb-2",children:"Used by chat and the cost estimate in this browser tab. Not sent to the build."}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{pe(b),sessionStorage.setItem(`pl_buildmode_${v.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${A===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:v.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:v.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),u==="secrets"&&r.jsx(ab,{}),u==="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"}),v.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:v.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),u==="deploy"&&r.jsx(Ox,{sessionId:v.id}),u==="dashboard"&&(_e===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Mr,{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()=>{ue(null);try{const b=await fetch(`http://127.0.0.1:${oe}/health`);ue(b.ok)}catch{ue(!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:()=>ce(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ne===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:${oe}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ps,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${oe}/#${ne}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),u==="git"&&r.jsx(rv,{sessionId:v.id}),u==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(nb,{sessionId:e.id})}),u==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(lb,{sessionId:v.id})}),u==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Gv,{filesCreated:null,filesModified:null,linesGenerated:null,testsGenerated:null,testPassRate:null,totalTokens:null,phaseBreakdown:[],totalTimeSecs:ge&&Ze.startTime?Math.floor((Date.now()-Ze.startTime)/1e3):null,qualityScore:null,totalCost:Ze.cost,iterations:Ze.iteration,provider:B})})]})]})})]})}),I&&r.jsx(pn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),I&&r.jsx(ei,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Ui,{name:"ActivityPanel",children:r.jsx(Dx,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:v.status==="running"||v.status==="in_progress",buildMode:A,buildEvents:Kh,onFileClick:b=>$t(b,b.split("/").pop()||b)})})})]})}),(de==null?void 0:de.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:[de.type==="review"?"Reviewing project":de.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[de.elapsed,"s"]})]})}),Ke&&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(Wt,{icon:vt,label:"Close",size:"sm",onClick:()=>be(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:Ke})]}),S&&r.jsx(sp,{x:S.x,y:S.y,items:gd(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:()=>L(!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:X,type:"text",value:U,onChange:b=>Y(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"&&Us.length>0&&($t(Us[0].path,Us[0].name),L(!1)),b.key==="Escape"&&L(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Us.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{$t(b.path,b.name),L(!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:to(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)),Us.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(Wx,{open:Nd,onClose:()=>ra(!1)}),r.jsx(Yx,{isOpen:Uh,onClose:()=>Po(!1),commands:jd,sessionId:v.id,onFileSelect:$t}),Bo&&r.jsx(lv,{data:Bo,onAcceptAll:Sd,onAcceptSelected:wd,onReject:Cd,onClose:()=>Fs(null)}),r.jsx(gv,{phase:Pr,buildTime:Ze.startTime?Math.floor((Date.now()-Ze.startTime)/1e3):void 0}),qh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>kr(!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:()=>kr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(vt,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Jv,{sessionId:v.id})})]})}),Gh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Hs(!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:()=>Hs(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(vt,{size:16})})]}),r.jsx(sb,{sessionId:v.id,onOpenFile:(b,$)=>{$t(b,b.split("/").pop()||b),Hs(!1)},className:"p-4"})]})}),Vh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Ci(!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(rb,{complexity:A==="quick"?"simple":A==="max"?"complex":"standard",provider:B,estimatedIterations:0,onConfirm:async()=>{Ci(!1);try{const b=v.prd||"";await V.startSession({prd:b,provider:B,projectDir:v.path}),Et(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>Ci(!1)})})})]})}function hb(){const{sessionId:e}=$d(),t=Fd(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,c]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),c(null),V.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{c(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(Ui,{name:"ProjectWorkspace",children:r.jsx(cb,{session:s,onClose:()=>t("/")})})})})}const Kb=Object.freeze(Object.defineProperty({__proto__:null,default:hb},Symbol.toStringTag,{value:"Module"}));export{xr as L,Kb as P,Ou as S};
|