@tom2012/cc-web 2026.4.28-c → 2026.5.6-b
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/frontend/dist/assets/{ChatOverlay-hsnODQGR.js → ChatOverlay-Dewml63P.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-Cmjm1I3F.js → GraphPreview-DKqon8iY.js} +1 -1
- package/frontend/dist/assets/{MobilePage-BiDPFXK5.js → MobilePage-0yihNWS5.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-w7JOIEJv.js → OfficePreview-CLoz-Kzs.js} +2 -2
- package/frontend/dist/assets/PdfPreview-Bu5q60D-.css +1 -0
- package/frontend/dist/assets/PdfPreview-ceFK86bz.js +1 -0
- package/frontend/dist/assets/{ProjectPage-B5YJ83Rv.js → ProjectPage-Dx8ti9Xg.js} +5 -5
- package/frontend/dist/assets/{SettingsPage-DWXI6hew.js → SettingsPage-DqXMFZN7.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-CSHbaiiv.js → SkillHubPage-0i_Vbges.js} +1 -1
- package/frontend/dist/assets/{chevron-down-_pCloBRe.js → chevron-down-CabXIthZ.js} +1 -1
- package/frontend/dist/assets/{index-Bt-82S8q.js → index-DFmoROkt.js} +1 -1
- package/frontend/dist/assets/{index-DilBM9k1.js → index-DKiLzICV.js} +1 -1
- package/frontend/dist/assets/{index-GVFhpTLY.js → index-PkEuCOb6.js} +2 -2
- package/frontend/dist/assets/{index-BbPigByG.js → index-QPAdq047.js} +1 -1
- package/frontend/dist/assets/{jszip.min-6N_hzJd2.js → jszip.min-C5eqdtGO.js} +1 -1
- package/frontend/dist/assets/pdf.worker.min-qwK7q_zL.mjs +28 -0
- package/frontend/dist/assets/{search-BbGeCtC1.js → search-CO9hGSbE.js} +1 -1
- package/frontend/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-
|
|
2
|
-
var e,t,i,s,r,n;import{c as o,u as a,r as l,a as h,g as c,b as d,w as u,t as _,j as f,d as p,E as m,P as g,M as v,e as S,X as b,f as w,h as x,S as y,R as C,_ as k,s as E,i as M,k as N,D,T as R,l as L,F as P,m as B,n as T,C as j,o as O,A,p as I,q as z,v as W,B as H,x as F,y as $,I as K,z as U,G as q,H as V,J as Y,K as G,L as X,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as _e,a8 as fe,a9 as pe,aa as me,ab as ge,ac as ve,ad as Se,ae as be,af as we,ag as xe,ah as ye,ai as Ce,aj as ke,ak as Ee,al as Me,am as Ne,an as De,ao as Re,ap as Le,aq as Pe,ar as Be,as as Te,at as je,au as Oe,av as Ae,aw as Ie,ax as ze,ay as We,az as He,aA as Fe,aB as $e,aC as Ke,aD as Ue,aE as qe,aF as Ve,aG as Ye,aH as Ge,aI as Xe,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt,aO as it,aP as st,aQ as rt,aR as nt,aS as ot,aT as at,aU as lt,aV as ht,aW as ct}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-DKqon8iY.js","assets/index-PkEuCOb6.js","assets/index-BJDTvhqr.css","assets/purify.es-CgRAQgUo.js","assets/ChatOverlay-Dewml63P.js","assets/chevron-down-CabXIthZ.js","assets/index-QPAdq047.js","assets/ChatOverlay-wklAmtGL.css","assets/index-DFmoROkt.js","assets/search-CO9hGSbE.js","assets/OfficePreview-CLoz-Kzs.js","assets/PdfPreview-ceFK86bz.js","assets/PdfPreview-Bu5q60D-.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e,t,i,s,r,n;import{c as o,u as a,r as l,a as h,g as c,b as d,w as u,t as _,j as f,d as p,E as m,P as g,M as v,e as S,X as b,f as w,h as x,S as y,R as C,_ as k,s as E,i as M,k as N,D,T as R,l as L,F as P,m as B,n as T,C as j,o as O,A,p as I,q as z,v as W,B as H,x as F,y as $,I as K,z as U,G as q,H as V,J as Y,K as G,L as X,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as _e,a8 as fe,a9 as pe,aa as me,ab as ge,ac as ve,ad as Se,ae as be,af as we,ag as xe,ah as ye,ai as Ce,aj as ke,ak as Ee,al as Me,am as Ne,an as De,ao as Re,ap as Le,aq as Pe,ar as Be,as as Te,at as je,au as Oe,av as Ae,aw as Ie,ax as ze,ay as We,az as He,aA as Fe,aB as $e,aC as Ke,aD as Ue,aE as qe,aF as Ve,aG as Ye,aH as Ge,aI as Xe,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt,aO as it,aP as st,aQ as rt,aR as nt,aS as ot,aT as at,aU as lt,aV as ht,aW as ct}from"./index-PkEuCOb6.js";import{p as dt}from"./purify.es-CgRAQgUo.js";import{F as ut,M as _t,r as ft,a as pt,b as mt,c as gt,h as vt,o as St,d as bt,e as wt,I as xt,C as yt,f as Ct}from"./ChatOverlay-Dewml63P.js";import{S as kt,U as Et,T as Mt,a as Nt,b as Dt,c as Rt,R as Lt,A as Pt,d as Bt,e as Tt,f as jt,I as Ot,g as At,C as It,h as zt}from"./index-DFmoROkt.js";import{C as Wt}from"./chevron-down-CabXIthZ.js";import{u as Ht,C as Ft}from"./index-QPAdq047.js";import{S as $t}from"./search-CO9hGSbE.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.309.0 - ISC
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the ISC license.
|
|
7
7
|
* See the LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/const Kt=o("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Ut=o("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),qt=o("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Vt=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Yt=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Gt=o("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Xt=o("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Jt=o("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),Zt=o("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]),Qt=o("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),ei=o("MoreVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),ti=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ii=o("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),si=o("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),ri=o("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),ni=o("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),oi=o("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),ai=o("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),li=C.lazy(()=>k(()=>import("./GraphPreview-
|
|
8
|
+
*/const Kt=o("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Ut=o("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),qt=o("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Vt=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Yt=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Gt=o("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Xt=o("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Jt=o("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),Zt=o("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]),Qt=o("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),ei=o("MoreVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),ti=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ii=o("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),si=o("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),ri=o("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),ni=o("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),oi=o("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),ai=o("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),li=C.lazy(()=>k(()=>import("./GraphPreview-DKqon8iY.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GraphPreview}))),hi=C.lazy(()=>k(()=>import("./OfficePreview-CLoz-Kzs.js"),__vite__mapDeps([10,1,2,3])).then(e=>({default:e.OfficePreview}))),ci=C.lazy(()=>k(()=>import("./PdfPreview-ceFK86bz.js"),__vite__mapDeps([11,1,2,12])).then(e=>({default:e.PdfPreview}))),di=new Set(["docx","xlsx","xls","pptx"]),ui=new Set(["pdf"]),_i={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};
|
|
9
9
|
/**
|
|
10
10
|
* @license lucide-react v0.309.0 - ISC
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/const ui=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function _i(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const fi=[50,75,100,125,150,200,250,300],pi=100;function mi({filePath:e,onClose:t}){const i=a(),s=e.endsWith("/.notebook/graph.yaml"),r=s?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[n,o]=l.useState(null),[C,k]=l.useState(null),[M,N]=l.useState(()=>s?"graph":"rendered"),[D,R]=l.useState(!1),[L,P]=l.useState(pi),[B,T]=l.useState(""),[j,O]=l.useState(!1),[A,I]=l.useState(!1),z=l.useRef(null),[W,H]=l.useState(!0),{resolved:F}=h(),$=e.split("/").pop()??e,K=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),U=ui.has(K),q=ci.has(K),V=function(e){return"md"===e||"html"===e||"htm"===e||e in di}(K),Y=di[K]||K,G=l.useMemo(()=>{if(!U)return"";const t=w(e),i=c(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,U]);l.useEffect(()=>{if(H(!0),o(null),k(null),P(function(e){const t=x(y.fileZoom,{},!0)[e];return fi.includes(t)?t:pi}(e)),I(!1),U||q)return o({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void N("rendered");N(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),d(e).then(e=>{o(e),T(e.content??"")}).catch(e=>k(e instanceof Error?e.message:"Failed to load file"))},[e,U,q]);const X=l.useCallback(async()=>{O(!0);try{await u(e,B),o(e=>e?{...e,content:B,size:new Blob([B]).size}:e),I(!1)}catch(t){_.error(t instanceof Error?t.message:"保存失败")}finally{O(!1)}},[e,B]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===M&&(e.preventDefault(),X())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[M,X]),l.useEffect(()=>{const e=async e=>{if("Escape"===e.key&&W){if(A){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,t,A,i]);const J=async()=>{if(A){if(!(await i({description:"有未保存的修改,确定退出编辑?",confirmLabel:"放弃修改",destructive:!0})))return}N(s?"graph":V?"rendered":"plain"),I(!1)},Z=t=>{P(t),function(e,t){const i=x(y.fileZoom,{},!0);t===pi?delete i[e]:i[e]=t,E(y.fileZoom,i,!0)}(e,t)},Q=(null==n?void 0:n.content)??"",ee="dark"===F?St:bt,te=L/100*12,ie=n&&!n.binary&&!n.tooLarge,se=l.useDeferredValue(B),re=l.useMemo(()=>{var e,t;if(!n||n.binary||n.tooLarge)return null;if(U||q)return null;const i="edit"===M?se:Q;if(null==i)return null;return{bytes:new Blob([i]).size,words:((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0),lines:""===i?0:i.split("\n").length}},[n,U,q,M,se,Q]);return f.jsx("div",{className:p("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",W?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&H(!1)},children:f.jsxs("div",{className:p("relative flex flex-col bg-background border border-border shadow-sm transition-all duration-200 pointer-events-auto",D?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-xl",!W&&!D&&"opacity-50"),onClick:()=>H(!0),onFocus:e=>{e.stopPropagation(),H(!0)},children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[f.jsx(ut,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[$,A&&f.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),re&&f.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs tabular-nums",children:[(ne=re.bytes,ne<1024?`${ne} B`:ne<1048576?`${(ne/1024).toFixed(1)} KB`:`${(ne/1024/1024).toFixed(2)} MB`)," · ",re.words.toLocaleString()," 词 · ",re.lines.toLocaleString()," 行"]})]}),ie&&!U&&!q&&f.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[V&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{onClick:()=>"edit"===M?J():N("plain"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","plain"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[f.jsx(qt,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),f.jsxs("button",{onClick:()=>"edit"===M?J():N("rendered"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","rendered"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:_i(K),children:[f.jsx(m,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:_i(K)})]})]}),s&&f.jsxs("button",{onClick:()=>"edit"===M?J():N("graph"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","graph"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[f.jsx(ti,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),f.jsxs("button",{onClick:()=>"edit"===M?J():(T((null==n?void 0:n.content)??""),I(!1),N("edit"),void setTimeout(()=>{var e;return null==(e=z.current)?void 0:e.focus()},0)),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","edit"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[f.jsx(g,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===M&&f.jsxs("button",{onClick:()=>{X()},disabled:j||!A,className:p("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",A?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[f.jsx(kt,{className:"h-3 w-3"}),j?"保存中...":"保存"]}),(ie||U)&&"edit"!==M&&"graph"!==M&&f.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[f.jsx("button",{onClick:()=>{const e=[...fi].reverse().find(e=>e<L);e&&Z(e)},disabled:L<=fi[0],className:"p-1 rounded-md text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:f.jsx(ai,{className:"h-3 w-3"})}),f.jsxs("button",{onClick:()=>Z(pi),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[L,"%"]}),f.jsx("button",{onClick:()=>{const e=fi.find(e=>e>L);e&&Z(e)},disabled:L>=fi[fi.length-1],className:"p-1 rounded-md text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:f.jsx(oi,{className:"h-3 w-3"})})]}),f.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>R(e=>!e),title:D?"退出全屏":"全屏",children:D?f.jsx(v,{className:"h-3.5 w-3.5"}):f.jsx(S,{className:"h-3.5 w-3.5"})}),f.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:async()=>{if(A){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()},children:f.jsx(b,{className:"h-4 w-4"})})]}),f.jsxs("div",{className:p("flex-1 min-h-0","graph"===M?"overflow-hidden":"overflow-auto"),children:["graph"===M&&f.jsx(l.Suspense,{fallback:f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:f.jsx(li,{folderPath:r})}),"graph"!==M&&!n&&!C&&f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==M&&C&&f.jsx("p",{className:"text-sm text-red-400 p-4",children:C}),"graph"!==M&&U&&n&&f.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:f.jsx("img",{src:G,alt:$,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${L/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==M&&q&&n&&f.jsx(l.Suspense,{fallback:f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:f.jsx(hi,{filePath:e,ext:K,zoom:L})}),"graph"!==M&&!U&&!q&&n&&n.binary&&f.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[f.jsx(ut,{className:"h-8 w-8"}),f.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024).toFixed(1)," KB"]})]}),"graph"!==M&&!q&&n&&n.tooLarge&&f.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[f.jsx(ut,{className:"h-8 w-8"}),f.jsx("p",{className:"text-sm",children:"File too large to preview"}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==M&&ie&&null!==Q&&f.jsxs(f.Fragment,{children:["edit"===M&&f.jsx("textarea",{ref:z,value:B,onChange:e=>{T(e.target.value),I(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${te}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==M&&f.jsxs("div",{className:"p-4",style:{fontSize:`${te}px`},children:["plain"===M&&f.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q}),"rendered"===M&&"md"===K&&f.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:f.jsx(_t,{remarkPlugins:[pt,mt],rehypePlugins:[ft],urlTransform:(e,t,i)=>"src"===t&&"img"===i.tagName?e:wt(e),components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?f.jsx("code",{className:e,...i,children:t}):f.jsx(vt,{style:ee,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})},img:({src:t,alt:i,...s})=>f.jsx("img",{...s,src:gt(e,t,c()),alt:i??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:Q})}),"rendered"===M&&("html"===K||"htm"===K)&&f.jsx("iframe",{srcDoc:dt.sanitize(Q,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:$,style:{minHeight:"60vh",transform:`scale(${L/100})`,transformOrigin:"top left",width:1e4/L+"%",height:1e4/L+"%"}}),"rendered"===M&&"md"!==K&&"html"!==K&&"htm"!==K&&Y&&f.jsx(vt,{style:ee,language:Y,showLineNumbers:!0,lineNumberStyle:{color:"dark"===F?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:Q}),"rendered"===M&&!V&&f.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q})]})]})]})]})});var ne}async function gi(e){var t;if("undefined"!=typeof navigator&&(null==(t=navigator.clipboard)?void 0:t.writeText))try{return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.setAttribute("readonly",""),document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length);const i=document.execCommand("copy");return document.body.removeChild(t),i}catch{return!1}}const vi=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function Si(e){const t=e.lastIndexOf(".");return t>=0&&vi.has(e.slice(t+1).toLowerCase())}function bi({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,h]=l.useState(new Set),d=M(e=>e.get(t).filePreviewPath),u=M(e=>e.setFilePreviewPath),m=e=>u(t,e),[g,v]=l.useState(null),[S,b]=l.useState(!1),[x,y]=l.useState(null),[C,k]=l.useState(!1),E=a(),z=l.useRef(null),W=l.useRef(null),H=function(e={}){const t=e.duration??500,i=e.moveTolerance??10,s=l.useRef(null),r=l.useRef(null),n=l.useRef(!1),o=l.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),r.current=null},[]);return{bind:l.useCallback(e=>({onTouchStart:i=>{if(1!==i.touches.length)return;const o=i.touches[0];r.current={x:o.clientX,y:o.clientY},n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(n.current=!0,"undefined"!=typeof navigator&&"vibrate"in navigator)try{navigator.vibrate(15)}catch{}e(o.clientX,o.clientY)},t)},onTouchMove:e=>{if(!r.current||!s.current)return;const t=e.touches[0],n=t.clientX-r.current.x,a=t.clientY-r.current.y;Math.hypot(n,a)>i&&o()},onTouchEnd:o,onTouchCancel:o}),[t,i,o]),wasTriggered:n}}();l.useEffect(()=>{if(!g)return;const e=()=>v(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[g]);const F=async t=>{var i;if(0===t.length)return;const s=t.reduce((e,t)=>e+t.size,0);b(!0),y({loaded:0,total:s});try{const s=await T(e,t,(e,t)=>{y({loaded:e,total:t})});K(e);const r=s.uploaded.length,n=(null==(i=s.skipped)?void 0:i.length)??0,o=s.errors.length;o>0?_.error(`上传完成:${r} 成功,${o} 失败${n?`,${n} 跳过`:""}`):n>0?_.info(`已上传 ${r} 个文件,${n} 个同名文件被跳过`):_.success(`已上传 ${r} 个文件`)}catch(r){console.error("[FileTree] Upload failed:",r),_.error(`上传失败: ${r.message}`)}finally{b(!1),y(null)}},$=e=>e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(1)+" MB":e>=1024?(e/1024).toFixed(0)+" KB":e+" B",K=l.useCallback(async e=>{h(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await N(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{h(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),h(new Set),K(e)},[e,K]);const U=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||K(e)),s})},[i,K]),q=l.useCallback(()=>{s(new Map),n(new Set([e])),h(new Set),K(e)},[e,K]),V=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return f.jsxs("div",{children:[f.jsxs("div",{className:p("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted-foreground/10",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px",WebkitTouchCallout:"none"},onClick:t=>{if(H.wasTriggered.current)return H.wasTriggered.current=!1,void t.stopPropagation();"dir"===e.type?U(e.path):m(e.path)},onContextMenu:t=>{t.preventDefault(),v({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},...H.bind((t,i)=>{v({x:t,y:i,filePath:e.path,fileName:e.name,type:e.type})}),children:[f.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?f.jsx(L,{className:"h-2.5 w-2.5 animate-spin"}):s?f.jsx(Wt,{className:"h-2.5 w-2.5"}):f.jsx(j,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?f.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):f.jsx(O,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):Si(e.name)?f.jsx(xt,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):f.jsx(ut,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsx("span",{className:p("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),f.jsx(A,{initial:!1,children:"dir"===e.type&&s&&f.jsxs(I.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&f.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&f.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&V(a,t+1)]})})]},e.path)}),Y=i.get(e),G=o.has(e),X=e.split("/").filter(Boolean).pop()??e;return f.jsxs(f.Fragment,{children:[d&&f.jsx(mi,{filePath:d,onClose:()=>m(null)}),g&&f.jsxs("div",{ref:z,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:g.x,top:g.y},onClick:e=>e.stopPropagation(),children:[f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{gi(g.filePath.startsWith(e+"/")?g.filePath.slice(e.length+1):g.filePath).then(e=>{e?_.success("已复制相对路径"):_.error("复制失败")}),v(null)},children:[f.jsx(Vt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{gi(g.filePath).then(e=>{e?_.success("已复制绝对路径"):_.error("复制失败")}),v(null)},children:[f.jsx(Ut,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===g.type&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"my-1 border-t border-border"}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=w(e);const s=c();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`);const r=`${i}${i.includes("?")?"&":"?"}dl=1`;try{const e=await fetch(r,{method:"HEAD"});if(!e.ok)return void _.error(`下载失败 (${e.status})`)}catch{return void _.error("下载失败:网络错误")}const n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)})(g.filePath,g.fileName),v(null)},children:[f.jsx(D,{className:"h-3.5 w-3.5"}),"下载"]})]}),f.jsx("div",{className:"my-1 border-t border-border"}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(await E({title:"确认删除",description:`确认删除${n}?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await B(t),_.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?K(r):K(e)}catch(o){_.error(`删除失败: ${o.message}`)}})(g.filePath,g.fileName,g.type),v(null)},children:[f.jsx(R,{className:"h-3.5 w-3.5"}),"删除"]})]}),f.jsxs("div",{className:"h-full flex flex-col text-foreground select-none",children:[f.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("input",{ref:W,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&F(t),e.target.value=""}}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=W.current)?void 0:e.click()},disabled:S,title:"上传文件",children:f.jsx(Et,{className:p("h-3 w-3",S&&"animate-pulse")})}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:q,title:"Refresh file tree",children:f.jsx(L,{className:p("h-3 w-3",G&&"animate-spin")})})]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[f.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),f.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:X})]}),f.jsxs("div",{className:p("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",C&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),k(!0)},onDragEnter:e=>{e.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:e=>{e.preventDefault(),k(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&F(t)},children:[S&&x&&f.jsxs("div",{className:"px-3 py-2 border-b border-border space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[f.jsxs("span",{children:["上传中 ",Math.floor(x.loaded/Math.max(x.total,1)*100),"%"]}),f.jsxs("span",{className:"font-mono",children:[$(x.loaded)," / ",$(x.total)]})]}),f.jsx("div",{className:"h-1 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-primary transition-[width] duration-150",style:{width:x.loaded/Math.max(x.total,1)*100+"%"}})})]}),C&&!S&&f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),G&&!Y?f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):Y&&0!==Y.length?V(Y,0):f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function wi(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function xi({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,m]=l.useState(!1),[g,v]=l.useState([]),[S,b]=l.useState(0),[w,x]=l.useState(!0),[y,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await z(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?g.length:0,s=await W(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),b(s.total)}catch{}finally{C(!1)}},[e,g.length]);l.useEffect(()=>{k(),E()},[e]);const M=async t=>{try{const{diff:i}=await U(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{_.error("获取 diff 失败")}},N=async t=>{try{await q(e,[t]),_.success(`已暂存 ${t}`),await k()}catch{_.error("git add 失败")}},D=async()=>{if(c.trim()){m(!0);try{await V(e,c),_.success("提交成功"),d(""),await k()}catch(t){_.error(t instanceof Error?t.message:"提交失败")}finally{m(!1)}}};if(!t&&s)return f.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[f.jsx(Gt,{className:"h-5 w-5"}),f.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return f.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[f.jsx(Gt,{className:"h-5 w-5"}),f.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const R=[...t.modified??[],...t.deleted??[]],P=t.staged??[],B=t.untracked??[];return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[f.jsx(Gt,{className:"h-3 w-3"}),f.jsx("span",{children:t.branch}),(t.ahead??0)>0&&f.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&f.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:f.jsx(L,{className:p("h-3 w-3",s&&"animate-spin")})})]}),P.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",P.length,")"]}),P.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx(F,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),f.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{M(e)},children:e})]},e))]}),R.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",R.length,")"]}),R.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{N(e)},children:f.jsx($,{className:"h-2.5 w-2.5"})}),f.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{M(e)},children:e})]},e))]}),B.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",B.length,")"]}),B.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{N(e)},children:f.jsx($,{className:"h-2.5 w-2.5"})}),f.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===R.length&&0===P.length&&0===B.length&&f.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),P.length>0&&f.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[f.jsx(K,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||D()},className:"h-7 text-xs"}),f.jsx(H,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{D()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${P.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&f.jsxs("div",{className:"border-t border-border pt-2",children:[f.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>x(e=>!e),children:[f.jsx(Wt,{className:p("h-3 w-3 transition-transform",!w&&"-rotate-90")}),f.jsx(Xt,{className:"h-3 w-3"}),f.jsxs("span",{children:["提交历史 (",S,")"]})]}),w&&f.jsxs("div",{className:"space-y-0.5",children:[g.map((e,t)=>{const i=e.parents.length>1;return f.jsxs("div",{className:"flex gap-1.5 items-start group",children:[f.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[f.jsx("div",{className:p("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<g.length-1&&f.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),f.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[f.jsxs("div",{className:"flex items-baseline gap-1",children:[f.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),f.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[f.jsx("span",{children:e.author}),f.jsx("span",{children:wi(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>f.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),g.length<S&&f.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:y,children:y?"加载中...":`加载更多 (${g.length}/${S})`})]})]}),null!==n&&f.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[f.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),f.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-xl shadow-sm",onClick:e=>e.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[f.jsx("span",{className:"truncate text-muted-foreground",children:a}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),f.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>f.jsx("span",{className:p("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}function yi(e){if(!e)return"-";const t=e-Date.now(),i=Math.abs(t),s=t<0,r=Math.round(i/1e3);if(r<60)return s?`${r} 秒前`:`${r} 秒后`;const n=Math.round(r/60);if(n<60)return s?`${n} 分钟前`:`${n} 分钟后`;const o=Math.round(n/60);if(o<24)return s?`${o} 小时前`:`${o} 小时后`;const a=Math.round(o/24);return s?`${a} 天前`:`${a} 天后`}function Ci(e){if(!e)return"";return new Date(e).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function ki({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[,a]=l.useState(0),h=l.useRef(!0),c=l.useRef(0),d=l.useCallback(async()=>{const t=++c.current;r(!0),o(null);try{const{tasks:s}=await Y(e);if(!h.current||t!==c.current)return;i(s)}catch(pa){if(!h.current||t!==c.current)return;o(pa.message),i([])}finally{h.current&&t===c.current&&r(!1)}},[e]);return l.useEffect(()=>{h.current=!0,d();const e=setInterval(()=>{d()},3e4),t=setInterval(()=>a(e=>e+1),1e3);return()=>{h.current=!1,clearInterval(e),clearInterval(t)}},[d]),f.jsxs("div",{className:"h-full flex flex-col bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-shrink-0 px-3 py-2 flex items-center justify-between border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[f.jsx(yt,{className:"size-4"}),f.jsx("span",{children:"已排程任务"})]}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{d()},title:"刷新","aria-label":"刷新",children:f.jsx(L,{className:p("size-3.5",s&&"animate-spin")})})]}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-1.5",children:[f.jsxs("div",{className:"rounded-md bg-muted-foreground/5 px-2 py-1.5 text-[11px] text-muted-foreground flex items-start gap-1.5",children:[f.jsx(Jt,{className:"size-3 mt-0.5 shrink-0"}),f.jsxs("span",{className:"leading-snug",children:["best-effort 重建:从 session JSONL 反推「Claude 创建过的 schedule」,",f.jsx("strong",{className:"text-foreground/80",children:"不是"}),"权威活动列表。已触发 / 已删除 无法直接观测。"]})]}),n&&f.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 text-destructive p-2 text-xs",children:n}),!n&&t&&0===t.length&&!s&&f.jsxs("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:[f.jsx("p",{children:"本项目最近 7 天没有创建过 schedule。"}),f.jsx("p",{className:"mt-2 leading-relaxed",children:"一次性 ScheduleWakeup 触发时间过了的会被隐藏(认为已触发); CronCreate 仅显示 7 天内创建的(与 Claude 自动过期窗口对齐)。"})]}),t&&t.map(e=>{const t=e.nextFireAt?Date.parse(e.nextFireAt):null,i="CronCreate"===e.type&&(e.recurring||/[,*\/-]/.test(e.cron??"")),s="ScheduleWakeup"===e.type&&null!==e.delaySeconds?function(e){if(e<60)return`${e} 秒后`;const t=Math.round(e/60);return t<60?`${t} 分钟后`:Math.round(t/60*10)/10+" 小时后"}(e.delaySeconds):e.cron??"?";return f.jsx("div",{className:"rounded-md border border-border bg-background px-2.5 py-2 text-xs",children:f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("div",{className:"shrink-0 mt-0.5 text-muted-foreground",children:i?f.jsx(ni,{className:"size-3.5"}):f.jsx(G,{className:"size-3.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-1",children:[f.jsx("span",{className:"text-[10px] font-mono px-1.5 rounded bg-muted-foreground/10 text-muted-foreground",children:"ScheduleWakeup"===e.type?"SW":"CC"}),e.durable&&f.jsx("span",{className:"text-[10px] px-1.5 rounded bg-primary/10 text-primary",children:"durable"}),f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded font-mono",children:s})]}),f.jsx("div",{className:"font-medium text-foreground line-clamp-2 leading-snug",children:e.prompt.trim()||"(无 prompt)"}),e.reason&&f.jsxs("div",{className:"mt-0.5 text-muted-foreground line-clamp-1 italic text-[11px]",children:["reason: ",e.reason]}),f.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-muted-foreground",children:[null!==t&&f.jsxs("span",{title:Ci(t),children:["下次: ",f.jsx("span",{className:"text-foreground/90",children:yi(t)})]}),f.jsxs("span",{title:Ci(e.createdAt),children:["创建: ",yi(e.createdAt)]}),f.jsx("span",{className:"font-mono text-muted-foreground/70",children:e.sessionId.slice(0,8)})]})]})]})},`${e.sessionId}:${e.id}`)}),s&&!t&&f.jsx("div",{className:"space-y-1.5",children:[0,1].map(e=>f.jsx("div",{className:"rounded-md border border-border bg-background px-2.5 py-2 h-16 animate-pulse"},e))})]})]})}function Ei(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function Mi(e){if(!e)return"-";const t=e-Date.now(),i=Math.abs(t),s=t<0,r=Math.round(i/1e3);if(r<60)return s?`${r} 秒前`:`${r} 秒后`;const n=Math.round(r/60);if(n<60)return s?`${n} 分钟前`:`${n} 分钟后`;const o=Math.round(n/60);if(o<24)return s?`${o} 小时前`:`${o} 小时后`;const a=Math.round(o/24);return s?`${a} 天前`:`${a} 天后`}function Ni(e){return new Date(e).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Di({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(!1),[a,h]=l.useState(null),[,c]=l.useState(0),d=l.useRef(!0),u=l.useCallback(async()=>{h(null);try{const t=await X(e);if(!d.current)return;i(t)}catch(pa){if(!d.current)return;h(pa.message)}finally{d.current&&r(!1)}},[e]),m=l.useCallback(async()=>{o(!0);try{const t=await J(e);if(!d.current)return;const i=[];t.copied>0&&i.push(`新增/更新 ${t.copied}`),t.deleted>0&&i.push(`删除 ${t.deleted}`),t.skipped>0&&i.push(`跳过 ${t.skipped}`),_.success(`同步完成:${i.join("·")||"无变化"}`),await u()}catch(pa){_.error(`同步失败:${pa.message}`)}finally{d.current&&o(!1)}},[e,u]);l.useEffect(()=>{d.current=!0,u();const e=setInterval(()=>{u()},3e4),t=setInterval(()=>c(e=>e+1),5e3);return()=>{d.current=!1,clearInterval(e),clearInterval(t)}},[u]);const g=(null==t?void 0:t.files.reduce((e,t)=>e+t.bytes,0))??0;return f.jsxs("div",{className:"h-full flex flex-col bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-shrink-0 px-3 py-2 flex items-center justify-between border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[f.jsx(Z,{className:"size-4"}),f.jsx("span",{children:"聊天记录备份"})]}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{u()},title:"刷新","aria-label":"刷新",disabled:s,children:f.jsx(L,{className:p("size-3.5",s&&"animate-spin")})})]}),f.jsx("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border bg-background/40",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"text-[11px] text-muted-foreground min-w-0",children:[f.jsxs("div",{children:["最后同步:"," ",f.jsx("span",{className:"text-foreground/90",title:(null==t?void 0:t.meta)?Ni(t.meta.lastBackupAt):void 0,children:(null==t?void 0:t.meta)?Mi(t.meta.lastBackupAt):"从未同步"})]}),t&&f.jsxs("div",{className:"mt-0.5 text-muted-foreground/80",children:[t.files.length," 个文件 · ",Ei(g)]})]}),f.jsx(H,{size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{m()},disabled:n||!(null==t?void 0:t.supported),children:n?"同步中…":"立即同步"})]})}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-1",children:[a&&f.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 text-destructive p-2 text-xs flex items-start gap-2",children:[f.jsx(Kt,{className:"size-3.5 shrink-0 mt-0.5"}),f.jsx("span",{children:a})]}),t&&!t.supported&&f.jsx("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:f.jsxs("p",{children:["此项目使用 ",f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded",children:"terminal"})," 模式,无聊天记录需备份。"]})}),(null==t?void 0:t.supported)&&0===t.files.length&&!s&&!a&&f.jsxs("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:[f.jsx("p",{children:"暂无已备份的聊天记录"}),f.jsx("p",{className:"mt-2 leading-relaxed text-muted-foreground/80",children:'定时每 5 分钟同步一次,也可点击右上方"立即同步"手动触发。'}),f.jsxs("p",{className:"mt-1 text-muted-foreground/70",children:["备份路径: ",f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded break-all",children:t.backupDir})]})]}),null==t?void 0:t.files.map(e=>f.jsxs("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[f.jsx(ut,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"font-mono text-[11px] text-foreground truncate",title:e.name,children:e.name}),f.jsxs("div",{className:"text-muted-foreground/80 text-[10px] flex items-center gap-2",children:[f.jsx("span",{title:Ni(e.mtime),children:Mi(e.mtime)}),f.jsx("span",{className:"text-muted-foreground/40",children:"·"}),f.jsx("span",{children:Ei(e.bytes)})]})]})]},e.name)),s&&!t&&f.jsx("div",{className:"space-y-1",children:[0,1].map(e=>f.jsx("div",{className:"rounded-md border border-border bg-background h-10 animate-pulse"},e))})]})]})}function Ri({projectPath:e,projectId:t,cliTool:i}){const[s,r]=Q(y.leftPanelTab,"files"),n="claude"===i,o="terminal"!==i;let a;return a="git"===s?"git":"scheduled"===s&&n?"scheduled":"backup"===s&&o?"backup":"files",f.jsxs(Mt,{value:a,onValueChange:e=>r(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[f.jsxs(Nt,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-r border-border rounded-none p-1 gap-1"),children:[f.jsx(Dt,{value:"files",title:"Files","aria-label":"Files",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(P,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"git",title:"Git","aria-label":"Git",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Gt,{className:"h-3.5 w-3.5"})}),n&&f.jsx(Dt,{value:"scheduled",title:"已排程任务","aria-label":"Scheduled tasks",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(yt,{className:"h-3.5 w-3.5"})}),o&&f.jsx(Dt,{value:"backup",title:"聊天记录备份","aria-label":"Sessions backup",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Z,{className:"h-3.5 w-3.5"})})]}),f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-l border-border",children:[f.jsx(Rt,{value:"files",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(bi,{projectPath:e,projectId:t})}),f.jsx(Rt,{value:"git",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(xi,{projectId:t})}),n&&f.jsx(Rt,{value:"scheduled",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(ki,{projectId:t})}),o&&f.jsx(Rt,{value:"backup",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Di,{projectId:t})})]})]})}function Li(e){const t=Pi(e),i=l.forwardRef((e,i)=>{const{children:s,...r}=e,n=l.Children.toArray(s),o=n.find(Ti);if(o){const e=o.props.children,s=n.map(t=>t===o?l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null:t);return f.jsx(t,{...r,ref:i,children:l.isValidElement(e)?l.cloneElement(e,void 0,s):null})}return f.jsx(t,{...r,ref:i,children:s})});return i.displayName=`${e}.Slot`,i}function Pi(e){const t=l.forwardRef((e,t)=>{const{children:i,...s}=e;if(l.isValidElement(i)){const e=function(e){var t,i;let s=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=s&&"isReactWarning"in s&&s.isReactWarning;if(r)return e.ref;if(s=null==(i=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:i.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),r=function(e,t){const i={...t};for(const s in t){const r=e[s],n=t[s];/^on[A-Z]/.test(s)?r&&n?i[s]=(...e)=>{const t=n(...e);return r(...e),t}:r&&(i[s]=r):"style"===s?i[s]={...r,...n}:"className"===s&&(i[s]=[r,n].filter(Boolean).join(" "))}return{...e,...i}}(s,i.props);return i.type!==l.Fragment&&(r.ref=t?ee(t,e):e),l.cloneElement(i,r)}return l.Children.count(i)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Bi=Symbol("radix.slottable");function Ti(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Bi}var ji=["Enter"," "],Oi=["ArrowUp","PageDown","End"],Ai=["ArrowDown","PageUp","Home",...Oi],Ii={ltr:[...ji,"ArrowRight"],rtl:[...ji,"ArrowLeft"]},zi={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Wi="Menu",[Hi,Fi,$i]=jt(Wi),[Ki,Ui]=ie(Wi,[$i,Bt,Tt]),qi=Bt(),Vi=Tt(),[Yi,Gi]=Ki(Wi),[Xi,Ji]=Ki(Wi),Zi=e=>{const{__scopeMenu:t,open:i=!1,children:s,dir:r,onOpenChange:n,modal:o=!0}=e,a=qi(t),[h,c]=l.useState(null),d=l.useRef(!1),u=te(n),_=Ht(r);return l.useEffect(()=>{const e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),f.jsx(Lt,{...a,children:f.jsx(Yi,{scope:t,open:i,onOpenChange:u,content:h,onContentChange:c,children:f.jsx(Xi,{scope:t,onClose:l.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:_,modal:o,children:s})})})};Zi.displayName=Wi;var Qi=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=qi(i);return f.jsx(Pt,{...r,...s,ref:t})});Qi.displayName="MenuAnchor";var es="MenuPortal",[ts,is]=Ki(es,{forceMount:void 0}),ss=e=>{const{__scopeMenu:t,forceMount:i,children:s,container:r}=e,n=Gi(es,t);return f.jsx(ts,{scope:t,forceMount:i,children:f.jsx(se,{present:i||n.open,children:f.jsx(re,{asChild:!0,container:r,children:s})})})};ss.displayName=es;var rs="MenuContent",[ns,os]=Ki(rs),as=l.forwardRef((e,t)=>{const i=is(rs,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Gi(rs,e.__scopeMenu),o=Ji(rs,e.__scopeMenu);return f.jsx(Hi.Provider,{scope:e.__scopeMenu,children:f.jsx(se,{present:s||n.open,children:f.jsx(Hi.Slot,{scope:e.__scopeMenu,children:o.modal?f.jsx(ls,{...r,ref:t}):f.jsx(hs,{...r,ref:t})})})})}),ls=l.forwardRef((e,t)=>{const i=Gi(rs,e.__scopeMenu),s=l.useRef(null),r=ne(t,s);return l.useEffect(()=>{const e=s.current;if(e)return le(e)},[]),f.jsx(ds,{...e,ref:r,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})}),hs=l.forwardRef((e,t)=>{const i=Gi(rs,e.__scopeMenu);return f.jsx(ds,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})}),cs=Li("MenuContent.ScrollLock"),ds=l.forwardRef((e,t)=>{const{__scopeMenu:i,loop:s=!1,trapFocus:r,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:_,onDismiss:p,disableOutsideScroll:m,...g}=e,v=Gi(rs,i),S=Ji(rs,i),b=qi(i),w=Vi(i),x=Fi(i),[y,C]=l.useState(null),k=l.useRef(null),E=ne(t,k,v.onContentChange),M=l.useRef(0),N=l.useRef(""),D=l.useRef(0),R=l.useRef(null),L=l.useRef("right"),P=l.useRef(0),B=m?de:l.Fragment,T=m?{as:cs,allowPinchZoom:!0}:void 0,j=e=>{var t,i;const s=N.current+e,r=x().filter(e=>!e.disabled),n=document.activeElement,o=null==(t=r.find(e=>e.ref.current===n))?void 0:t.textValue,a=function(e,t,i){const s=t.length>1&&Array.from(t).every(e=>e===t[0]),r=s?t[0]:t,n=i?e.indexOf(i):-1;let o=(a=e,l=Math.max(n,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===r.length&&(o=o.filter(e=>e!==i));const h=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return h!==i?h:void 0}(r.map(e=>e.textValue),s,o),l=null==(i=r.find(e=>e.textValue===a))?void 0:i.ref.current;!function e(t){N.current=t,window.clearTimeout(M.current),""!==t&&(M.current=window.setTimeout(()=>e(""),1e3))}(s),l&&setTimeout(()=>l.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),ce();const O=l.useCallback(e=>{var t,i;return L.current===(null==(t=R.current)?void 0:t.side)&&function(e,t){if(!t)return!1;const i={x:e.clientX,y:e.clientY};return function(e,t){const{x:i,y:s}=e;let r=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const e=t[n],a=t[o],l=e.x,h=e.y,c=a.x,d=a.y;h>s!=d>s&&i<(c-l)*(s-h)/(d-h)+l&&(r=!r)}return r}(i,t)}(e,null==(i=R.current)?void 0:i.area)},[]);return f.jsx(ns,{scope:i,searchRef:N,onItemEnter:l.useCallback(e=>{O(e)&&e.preventDefault()},[O]),onItemLeave:l.useCallback(e=>{var t;O(e)||(null==(t=k.current)||t.focus(),C(null))},[O]),onTriggerLeave:l.useCallback(e=>{O(e)&&e.preventDefault()},[O]),pointerGraceTimerRef:D,onPointerGraceIntentChange:l.useCallback(e=>{R.current=e},[]),children:f.jsx(B,{...T,children:f.jsx(ue,{asChild:!0,trapped:r,onMountAutoFocus:oe(n,e=>{var t;e.preventDefault(),null==(t=k.current)||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:f.jsx(_e,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:_,onDismiss:p,children:f.jsx(At,{asChild:!0,...w,dir:S.dir,orientation:"vertical",loop:s,currentTabStopId:y,onCurrentTabStopIdChange:C,onEntryFocus:oe(h,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(It,{role:"menu","aria-orientation":"vertical","data-state":As(v.open),"data-radix-menu-content":"",dir:S.dir,...b,...g,ref:E,style:{outline:"none",...g.style},onKeyDown:oe(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,i=e.ctrlKey||e.altKey||e.metaKey,s=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!i&&s&&j(e.key));const r=k.current;if(e.target!==r)return;if(!Ai.includes(e.key))return;e.preventDefault();const n=x().filter(e=>!e.disabled).map(e=>e.ref.current);Oi.includes(e.key)&&n.reverse(),function(e){const t=document.activeElement;for(const i of e){if(i===t)return;if(i.focus(),document.activeElement!==t)return}}(n)}),onBlur:oe(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current="")}),onPointerMove:oe(e.onPointerMove,Ws(e=>{const t=e.target,i=P.current!==e.clientX;if(e.currentTarget.contains(t)&&i){const t=e.clientX>P.current?"right":"left";L.current=t,P.current=e.clientX}}))})})})})})})});as.displayName=rs;var us=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{role:"group",...s,ref:t})});us.displayName="MenuGroup";var _s=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{...s,ref:t})});_s.displayName="MenuLabel";var fs="MenuItem",ps="menu.itemSelect",ms=l.forwardRef((e,t)=>{const{disabled:i=!1,onSelect:s,...r}=e,n=l.useRef(null),o=Ji(fs,e.__scopeMenu),a=os(fs,e.__scopeMenu),h=ne(t,n),c=l.useRef(!1);return f.jsx(gs,{...r,ref:h,disabled:i,onClick:oe(e.onClick,()=>{const e=n.current;if(!i&&e){const t=new CustomEvent(ps,{bubbles:!0,cancelable:!0});e.addEventListener(ps,e=>null==s?void 0:s(e),{once:!0}),he(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{var i;null==(i=e.onPointerDown)||i.call(e,t),c.current=!0},onPointerUp:oe(e.onPointerUp,e=>{var t;c.current||null==(t=e.currentTarget)||t.click()}),onKeyDown:oe(e.onKeyDown,e=>{const t=""!==a.searchRef.current;i||t&&" "===e.key||ji.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ms.displayName=fs;var gs=l.forwardRef((e,t)=>{const{__scopeMenu:i,disabled:s=!1,textValue:r,...n}=e,o=os(fs,i),a=Vi(i),h=l.useRef(null),c=ne(t,h),[d,u]=l.useState(!1),[_,p]=l.useState("");return l.useEffect(()=>{const e=h.current;e&&p((e.textContent??"").trim())},[n.children]),f.jsx(Hi.ItemSlot,{scope:i,disabled:s,textValue:r??_,children:f.jsx(Ot,{asChild:!0,...a,focusable:!s,children:f.jsx(ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...n,ref:c,onPointerMove:oe(e.onPointerMove,Ws(e=>{if(s)o.onItemLeave(e);else if(o.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:oe(e.onPointerLeave,Ws(e=>o.onItemLeave(e))),onFocus:oe(e.onFocus,()=>u(!0)),onBlur:oe(e.onBlur,()=>u(!1))})})})}),vs=l.forwardRef((e,t)=>{const{checked:i=!1,onCheckedChange:s,...r}=e;return f.jsx(Es,{scope:e.__scopeMenu,checked:i,children:f.jsx(ms,{role:"menuitemcheckbox","aria-checked":Is(i)?"mixed":i,...r,ref:t,"data-state":zs(i),onSelect:oe(r.onSelect,()=>null==s?void 0:s(!!Is(i)||!i),{checkForDefaultPrevented:!1})})})});vs.displayName="MenuCheckboxItem";var Ss="MenuRadioGroup",[bs,ws]=Ki(Ss,{value:void 0,onValueChange:()=>{}}),xs=l.forwardRef((e,t)=>{const{value:i,onValueChange:s,...r}=e,n=te(s);return f.jsx(bs,{scope:e.__scopeMenu,value:i,onValueChange:n,children:f.jsx(us,{...r,ref:t})})});xs.displayName=Ss;var ys="MenuRadioItem",Cs=l.forwardRef((e,t)=>{const{value:i,...s}=e,r=ws(ys,e.__scopeMenu),n=i===r.value;return f.jsx(Es,{scope:e.__scopeMenu,checked:n,children:f.jsx(ms,{role:"menuitemradio","aria-checked":n,...s,ref:t,"data-state":zs(n),onSelect:oe(s.onSelect,()=>{var e;return null==(e=r.onValueChange)?void 0:e.call(r,i)},{checkForDefaultPrevented:!1})})})});Cs.displayName=ys;var ks="MenuItemIndicator",[Es,Ms]=Ki(ks,{checked:!1}),Ns=l.forwardRef((e,t)=>{const{__scopeMenu:i,forceMount:s,...r}=e,n=Ms(ks,i);return f.jsx(se,{present:s||Is(n.checked)||!0===n.checked,children:f.jsx(ae.span,{...r,ref:t,"data-state":zs(n.checked)})})});Ns.displayName=ks;var Ds=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Ds.displayName="MenuSeparator";var Rs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=qi(i);return f.jsx(zt,{...r,...s,ref:t})});Rs.displayName="MenuArrow";var[Ls,Ps]=Ki("MenuSub"),Bs="MenuSubTrigger",Ts=l.forwardRef((e,t)=>{const i=Gi(Bs,e.__scopeMenu),s=Ji(Bs,e.__scopeMenu),r=Ps(Bs,e.__scopeMenu),n=os(Bs,e.__scopeMenu),o=l.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:h}=n,c={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const e=a.current;return()=>{window.clearTimeout(e),h(null)}},[a,h]),f.jsx(Qi,{asChild:!0,...c,children:f.jsx(gs,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":r.contentId,"data-state":As(i.open),...e,ref:ee(t,r.onTriggerChange),onClick:t=>{var s;null==(s=e.onClick)||s.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),i.open||i.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,Ws(t=>{n.onItemEnter(t),t.defaultPrevented||e.disabled||i.open||o.current||(n.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{i.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,Ws(e=>{var t,s;d();const r=null==(t=i.content)?void 0:t.getBoundingClientRect();if(r){const t=null==(s=i.content)?void 0:s.dataset.side,o="right"===t,l=o?-5:5,h=r[o?"left":"right"],c=r[o?"right":"left"];n.onPointerGraceIntentChange({area:[{x:e.clientX+l,y:e.clientY},{x:h,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:h,y:r.bottom}],side:t}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>n.onPointerGraceIntentChange(null),300)}else{if(n.onTriggerLeave(e),e.defaultPrevented)return;n.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,t=>{var r;const o=""!==n.searchRef.current;e.disabled||o&&" "===t.key||Ii[s.dir].includes(t.key)&&(i.onOpenChange(!0),null==(r=i.content)||r.focus(),t.preventDefault())})})})});Ts.displayName=Bs;var js="MenuSubContent",Os=l.forwardRef((e,t)=>{const i=is(rs,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Gi(rs,e.__scopeMenu),o=Ji(rs,e.__scopeMenu),a=Ps(js,e.__scopeMenu),h=l.useRef(null),c=ne(t,h);return f.jsx(Hi.Provider,{scope:e.__scopeMenu,children:f.jsx(se,{present:s||n.open,children:f.jsx(Hi.Slot,{scope:e.__scopeMenu,children:f.jsx(ds,{id:a.contentId,"aria-labelledby":a.triggerId,...r,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;o.isUsingKeyboardRef.current&&(null==(t=h.current)||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:oe(e.onFocusOutside,e=>{e.target!==a.trigger&&n.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:oe(e.onKeyDown,e=>{var t;const i=e.currentTarget.contains(e.target),s=zi[o.dir].includes(e.key);i&&s&&(n.onOpenChange(!1),null==(t=a.trigger)||t.focus(),e.preventDefault())})})})})})});function As(e){return e?"open":"closed"}function Is(e){return"indeterminate"===e}function zs(e){return Is(e)?"indeterminate":e?"checked":"unchecked"}function Ws(e){return t=>"mouse"===t.pointerType?e(t):void 0}Os.displayName=js;var Hs=Zi,Fs=Qi,$s=ss,Ks=as,Us=us,qs=_s,Vs=ms,Ys=vs,Gs=xs,Xs=Cs,Js=Ns,Zs=Ds,Qs=Rs,er=Ts,tr=Os,ir="ContextMenu",[sr]=ie(ir,[Ui]),rr=Ui(),[nr,or]=sr(ir),ar=e=>{const{__scopeContextMenu:t,children:i,onOpenChange:s,dir:r,modal:n=!0}=e,[o,a]=l.useState(!1),h=rr(t),c=te(s),d=l.useCallback(e=>{a(e),c(e)},[c]);return f.jsx(nr,{scope:t,open:o,onOpenChange:d,modal:n,children:f.jsx(Hs,{...h,dir:r,open:o,onOpenChange:d,modal:n,children:i})})};ar.displayName=ir;var lr="ContextMenuTrigger",hr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,disabled:s=!1,...r}=e,n=or(lr,i),o=rr(i),a=l.useRef({x:0,y:0}),h=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(c.current),[]),u=e=>{a.current={x:e.clientX,y:e.clientY},n.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.useEffect(()=>{s&&d()},[s,d]),f.jsxs(f.Fragment,{children:[f.jsx(Fs,{...o,virtualRef:h}),f.jsx(ae.span,{"data-state":n.open?"open":"closed","data-disabled":s?"":void 0,...r,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:oe(e.onContextMenu,e=>{d(),u(e),e.preventDefault()}),onPointerDown:s?e.onPointerDown:oe(e.onPointerDown,pr(e=>{d(),c.current=window.setTimeout(()=>u(e),700)})),onPointerMove:s?e.onPointerMove:oe(e.onPointerMove,pr(d)),onPointerCancel:s?e.onPointerCancel:oe(e.onPointerCancel,pr(d)),onPointerUp:s?e.onPointerUp:oe(e.onPointerUp,pr(d))})]})});hr.displayName=lr;var cr=e=>{const{__scopeContextMenu:t,...i}=e,s=rr(t);return f.jsx($s,{...s,...i})};cr.displayName="ContextMenuPortal";var dr="ContextMenuContent",ur=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(dr,i),n=rr(i),o=l.useRef(!1);return f.jsx(Ks,{...n,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var i;null==(i=e.onCloseAutoFocus)||i.call(e,t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{var i;null==(i=e.onInteractOutside)||i.call(e,t),t.defaultPrevented||r.modal||(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ur.displayName=dr;l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Us,{...r,...s,ref:t})}).displayName="ContextMenuGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(qs,{...r,...s,ref:t})}).displayName="ContextMenuLabel";var _r=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Vs,{...r,...s,ref:t})});_r.displayName="ContextMenuItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Ys,{...r,...s,ref:t})}).displayName="ContextMenuCheckboxItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Gs,{...r,...s,ref:t})}).displayName="ContextMenuRadioGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Xs,{...r,...s,ref:t})}).displayName="ContextMenuRadioItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Js,{...r,...s,ref:t})}).displayName="ContextMenuItemIndicator";var fr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Zs,{...r,...s,ref:t})});fr.displayName="ContextMenuSeparator";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(Qs,{...r,...s,ref:t})}).displayName="ContextMenuArrow";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(er,{...r,...s,ref:t})}).displayName="ContextMenuSubTrigger";function pr(e){return t=>"mouse"!==t.pointerType?e(t):void 0}l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=rr(i);return f.jsx(tr,{...r,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="ContextMenuSubContent";var mr=cr,gr=ur,vr=_r,Sr=fr;const br=ar,wr=hr,xr=l.forwardRef(({className:e,...t},i)=>f.jsx(mr,{children:f.jsx(gr,{ref:i,className:p("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",e),...t})}));xr.displayName=gr.displayName;const yr=l.forwardRef(({className:e,destructive:t,...i},s)=>f.jsx(vr,{ref:s,className:p("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"text-red-500 focus:text-red-500 focus:bg-red-500/10",e),...i}));yr.displayName=vr.displayName;const Cr=l.forwardRef(({className:e,...t},i)=>f.jsx(Sr,{ref:i,className:p("-mx-1 my-1 h-px bg-border",e),...t}));function kr({kind:e,label:t,preview:i,inserted:s,unclicked:r,onLeftClick:n,onEdit:o,onDelete:a,onShare:h,onRefresh:c,footer:d,readOnly:u,noContextMenu:_,cornerHint:m,instructionsFile:v="CLAUDE.md"}){const S=l.useRef(null),b=p("agent-prompt"===e?s?"border-green-500/50 bg-green-500/10 hover:bg-green-500/15":"border-dashed border-border hover:border-border/80 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20":r?"border-blue-500/30 bg-blue-500/15 hover:bg-blue-500/20 dark:bg-blue-500/15 dark:hover:bg-blue-500/25":"border-transparent bg-background dark:bg-muted-foreground/10 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20 hover:border-muted-foreground/30"),w="agent-prompt"===e,x=!_||c?" · 右键更多":"",y="quick-prompt"===e?`点击发送${x}`:(s?`点击从 ${v} 移除`:`点击插入 ${v}`)+x,C=f.jsxs("div",{ref:S,className:p("group relative rounded-md border text-xs transition-colors cursor-pointer select-none",b),onClick:n,title:y,children:[w&&f.jsx("span",{"aria-hidden":!0,className:p("absolute top-1.5 left-1.5 h-2 w-2 rounded-full transition-colors",s?"bg-green-500 ring-1 ring-green-500/40":"border border-muted-foreground/40 bg-transparent")}),f.jsxs("div",{className:p("py-1.5",_&&m?"pr-10":_?"pr-2":"pr-7",w?"pl-5":"pl-3"),children:[f.jsx("div",{className:"font-medium truncate",children:t}),i&&i!==t&&f.jsx("div",{className:"mt-0.5 text-muted-foreground/80 truncate font-mono",children:i}),d]}),_&&m&&f.jsx("span",{"aria-hidden":!0,className:"absolute top-1.5 right-2 text-[10px] leading-none font-mono tabular-nums text-muted-foreground/60 pointer-events-none",children:m}),!_&&f.jsx("button",{onClick:e=>{e.stopPropagation(),e.preventDefault();const t=S.current;if(!t)return;const i=t.getBoundingClientRect(),s=new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:i.right-8,clientY:i.top+i.height/2,button:2});t.dispatchEvent(s)},className:p("absolute top-1 right-1 p-0.5 rounded transition-opacity","md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100","hover:bg-muted-foreground/10 focus-visible:bg-muted-foreground/10","text-muted-foreground hover:text-foreground"),title:"更多","aria-label":"更多操作",children:f.jsx(ei,{className:"h-3.5 w-3.5"})})]});return!(!c&&(_||!o&&!a&&!h))?f.jsxs(br,{children:[f.jsx(wr,{asChild:!0,children:C}),f.jsxs(xr,{children:[c&&f.jsxs(yr,{onSelect:c,children:[f.jsx(L,{className:"h-3.5 w-3.5"}),"更新"]}),!_&&!u&&o&&a&&f.jsxs(f.Fragment,{children:[c&&f.jsx(Cr,{}),f.jsxs(yr,{onSelect:o,children:[f.jsx(g,{className:"h-3.5 w-3.5"}),"编辑"]}),f.jsxs(yr,{destructive:!0,onSelect:a,children:[f.jsx(R,{className:"h-3.5 w-3.5"}),"删除"]}),h&&f.jsx(Cr,{})]}),!_&&h&&f.jsxs(yr,{onSelect:h,children:[f.jsx(fe,{className:"h-3.5 w-3.5"}),"共享到 ccweb-hub"]})]})]}):f.jsx("div",{onContextMenu:e=>e.preventDefault(),children:C})}function Er({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const _=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return f.jsx(xe,{open:e,onOpenChange:t,modal:!1,children:f.jsxs(ye,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:r}),f.jsx(Ee,{children:"左键点击卡片会把此命令发送到 CLI。"})]}),f.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Me,{htmlFor:"qp-label",children:"标签"}),f.jsx(K,{id:"qp-label",placeholder:"显示名(可选,默认用命令文本)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),f.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[f.jsx(Me,{htmlFor:"qp-command",children:"命令"}),f.jsx("textarea",{id:"qp-command",placeholder:"输入要发送的命令...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())}})]})]}),f.jsxs(Ne,{className:"flex items-center justify-between sm:justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"取消"}),f.jsx(H,{onClick:_,disabled:!h.trim(),children:"保存"})]})]})]})})}function Mr({title:e,count:t,onAdd:i,children:s}){return f.jsxs("div",{className:"px-2 py-2",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[f.jsx("span",{children:e}),f.jsxs("span",{className:"text-muted-foreground/60",children:["(",t,")"]})]}),f.jsx("button",{onClick:i,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:f.jsx($,{className:"h-3 w-3"})})]}),s]})}function Nr({projectId:e,onSend:t}){const i=a(),[s,r]=l.useState([]),[n,o]=l.useState([]),h=M(),c=h.get(e),[d,u]=l.useState({open:!1}),[_,p]=l.useState(c.shareHubOpen),[m,g]=l.useState(c.shareHubLabel),[v,S]=l.useState(c.shareHubCommand),b=l.useCallback(t=>{r(e=>{const i=e.findIndex(e=>e.id===t);if(i<0||e[i].used)return e;const s=[...e];return s[i]={...s[i],used:!0},s}),pe(e,t,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})},[e]);l.useEffect(()=>{me(e).then(r).catch(()=>r([]))},[e]),l.useEffect(()=>{ge().then(o).catch(()=>o([]))},[]);const w=l.useCallback(e=>{const t=[],i=new Set;let s=e;const r=[];for(;s&&!i.has(s.id);)i.add(s.id),r.unshift(s),s=s.parentId?n.find(e=>e.id===s.parentId):void 0;for(const n of r)t.push(n.command);return t},[n]),x=l.useCallback(async e=>{const i=w(e);for(const s of i)try{await Promise.resolve(t(s+"\r"))}catch{return}},[w,t]),y=e=>u({open:!0,mode:"create",scope:e}),C=(t,i)=>{g(t),S(i),p(!0),h.setShareHub(e,!0,t,i)};return f.jsxs("div",{className:"h-full flex flex-col text-foreground overflow-hidden",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Quick Prompts"}),f.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片发送命令到 CLI;新建的命令在首次点击前以浅蓝色标识"})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[f.jsx(Mr,{title:"项目",count:s.length,onAdd:()=>y("project"),children:0===s.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无项目命令"}):f.jsx("div",{className:"space-y-1.5",children:s.map(s=>f.jsx(kr,{kind:"quick-prompt",label:s.label,preview:s.label!==s.command?s.command:"",unclicked:!s.used,onLeftClick:()=>(e=>{t(e.command+"\r"),b(e.id)})(s),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}))(s),onDelete:()=>{(async t=>{if(await i({title:"删除项目快捷 Prompt",description:`确认删除「${t.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await be(e,t.id),r(e=>e.filter(e=>e.id!==t.id))}catch(s){console.error("Failed to delete shortcut:",s)}})(s)},onShare:()=>C(s.label,s.command)},s.id))})}),f.jsx("div",{className:"h-px bg-border mx-2"}),f.jsx(Mr,{title:"全局",count:n.length,onAdd:()=>y("global"),children:0===n.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无全局命令"}):f.jsx("div",{className:"space-y-1.5",children:n.map(e=>{var t;const s=e.parentId?null==(t=n.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return f.jsx(kr,{kind:"quick-prompt",label:e.label,preview:s?"":e.label!==e.command?e.command:"",onLeftClick:()=>x(e),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}))(e),onDelete:()=>{(async e=>{const t=n.filter(t=>t.parentId===e.id);if(await i({title:"删除全局快捷 Prompt",description:t.length>0?`「${e.label}」被 ${t.length} 个其他全局命令继承。删除后这些命令的继承会断链。确认删除?`:`确认删除「${e.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await we(e.id),o(t=>t.filter(t=>t.id!==e.id))}catch(s){console.error("Failed to delete global shortcut:",s)}})(e)},onShare:()=>C(e.label,e.command),footer:s?f.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[f.jsx(ve,{className:"h-2.5 w-2.5 text-muted-foreground"}),f.jsxs("span",{className:"text-muted-foreground truncate",children:["继承: ",s,"(继承链仅可在 Dashboard 编辑)"]})]}):null},e.id)})})})]}),f.jsx(Er,{open:d.open,onOpenChange:e=>{e||u({open:!1})},initialLabel:d.open&&"edit"===d.mode?d.label:"",initialCommand:d.open&&"edit"===d.mode?d.command:"",title:d.open?"create"===d.mode?`新建${"global"===d.scope?"全局":"项目"}命令`:"编辑命令":"",onSave:(t,i)=>{(async(t,i)=>{if(d.open)try{if("create"===d.mode)if("global"===d.scope){const e=await De({label:t,command:i});o(t=>[...t,e])}else{const s=await Re(e,{label:t,command:i});r(e=>[...e,s])}else if("global"===d.scope){const e=n.find(e=>e.id===d.id),s=await Le(d.id,{label:t,command:i,parentId:(null==e?void 0:e.parentId)??null});o(e=>e.map(e=>e.id===s.id?s:e))}else{const s=await Pe(e,d.id,{label:t,command:i});r(e=>e.map(e=>e.id===s.id?s:e))}}catch(s){console.error("Failed to save shortcut:",s)}})(t,i)}}),f.jsx(Se,{open:_,onOpenChange:t=>{p(t),t||h.setShareHub(e,!1)},kind:"quick-prompt",label:m,content:v})]})}Cr.displayName=Sr.displayName;function Dr({open:e,onOpenChange:t,title:i,initialLabel:s,initialCommand:r,onSave:n,instructionsFile:o="CLAUDE.md"}){const[a,h]=l.useState(s),[c,d]=l.useState(r),[u,_]=l.useState(!0);l.useEffect(()=>{e&&(h(s),d(r),_(!0))},[e,s,r]);const m=a.trim(),g=c.trim(),v=m.length>100,S=g.length>8e3,b=g.length>0&&m.length>0&&!v&&!S,w=()=>{b&&(n(m,c),t(!1))};return f.jsx(xe,{open:e,onOpenChange:t,modal:!1,children:f.jsxs(ye,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!u&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),_(!1)},onClick:()=>_(!0),children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:i}),f.jsxs(Ee,{children:["This prompt can be clicked once in the sidebar to insert into ",o,", and clicked again to remove (by exact text match)."]})]}),f.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Me,{htmlFor:"prompt-label",children:"Label"}),f.jsxs("span",{className:p("text-xs text-muted-foreground",v&&"text-red-500"),children:[m.length," / ",100]})]}),f.jsx(K,{id:"prompt-label",placeholder:"A short name for this prompt",value:a,onChange:e=>h(e.target.value),className:"text-base",autoFocus:!0})]}),f.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Me,{htmlFor:"prompt-command",children:"Prompt"}),f.jsxs("span",{className:p("text-xs text-muted-foreground",S&&"text-red-500"),children:[g.length," / ",8e3]})]}),f.jsx("textarea",{id:"prompt-command",placeholder:`The exact text that will be appended to ${o}...`,value:c,onChange:e=>d(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-sm leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),w())}})]})]}),f.jsxs(Ne,{className:"flex items-center justify-between sm:justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),f.jsx(H,{onClick:w,disabled:!b,children:"Save"})]})]})]})})}function Rr({projectId:e}){const t=a(),[i,s]=l.useState([]),[r,n]=l.useState([]),[o,h]=l.useState("CLAUDE.md"),[c,d]=l.useState(!0),[u,p]=l.useState({open:!1}),[m,g]=l.useState({open:!1,label:"",content:""}),v=l.useCallback(async()=>{try{const t=await Be(e);s(t.global),n(t.project),t.instructionsFilename&&h(t.instructionsFilename)}catch(t){_.error(`加载提示词失败: ${t.message}`)}finally{d(!1)}},[e]);l.useEffect(()=>{d(!0),v()},[v]);const S=l.useRef(new Set),b=l.useCallback(async(t,i)=>{if(S.current.has(i.id))return;S.current.add(i.id);const r=i.inserted?"remove":"insert",a=e=>e.map(e=>e.id===i.id?{...e,inserted:!e.inserted}:e);"global"===t?s(a):n(a);try{const t=await Te(e,i.command,r);if("remove"===r&&!1===t.changed)return"not-found"===t.reason?_.error(`${o} 中找不到该提示词的精确文本,请自行编辑 ${o} 移除。`):_.warning(`该提示词当前不在 ${o} 中(可能被手动编辑过),已重新同步状态。`),void v();v()}catch(l){_.error(`操作失败: ${l.message}`),"global"===t?s(a):n(a)}finally{S.current.delete(i.id)}},[e,v,o]),w=l.useCallback(async(t,i,s,r,n)=>{try{if("create"===t)"global"===i?await je({label:r,command:n}):await Oe(e,{label:r,command:n}),_.success("已添加");else{if(!s)return;"global"===i?await Ae(s,{label:r,command:n}):await Ie(e,s,{label:r,command:n}),_.success("已更新")}v()}catch(o){_.error(`保存失败: ${o.message}`)}},[e,v]),x=l.useCallback(async(i,s)=>{const r=s.inserted?`此提示词目前已插入当前项目的 ${o}。\n\n删除后它会在 ${o} 中成为"孤儿文本"——仅删除提示词记录,不会自动从 ${o} 移除。\n\n确认删除?`:"确认删除此提示词?此操作不可撤销。";if(await t({title:"删除提示词",description:r,destructive:!0,confirmLabel:"删除"}))try{"global"===i?await ze(s.id):await We(e,s.id),_.success("已删除"),v()}catch(n){_.error(`删除失败: ${n.message}`)}},[e,v,t,o]),y=l.useCallback(e=>{g({open:!0,label:e.label,content:e.command})},[]);return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent Prompts"}),f.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["点击卡片插入 / 移出当前项目的 ",o,";左上角绿点表示已插入"]})]}),f.jsx(Lr,{title:"项目",count:r.length,loading:c,prompts:r,emptyText:"暂无项目提示词",instructionsFile:o,onAdd:()=>p({open:!0,mode:"create",scope:"project"}),onToggle:e=>{b("project",e)},onEdit:e=>p({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}),onDelete:e=>{x("project",e)},onShare:y}),f.jsx("div",{className:"h-px bg-border mx-2"}),f.jsx(Lr,{title:"全局",count:i.length,loading:c,prompts:i,emptyText:"暂无全局提示词",instructionsFile:o,onAdd:()=>p({open:!0,mode:"create",scope:"global"}),onToggle:e=>{b("global",e)},onEdit:e=>p({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}),onDelete:e=>{x("global",e)},onShare:y}),f.jsx(Dr,{open:u.open,onOpenChange:e=>{e||p({open:!1})},title:!1===u.open?"":"create"===u.mode?`新建${"global"===u.scope?"全局":"项目"}提示词`:`编辑${"global"===u.scope?"全局":"项目"}提示词`,initialLabel:u.open&&"edit"===u.mode?u.label:"",initialCommand:u.open&&"edit"===u.mode?u.command:"",instructionsFile:o,onSave:(e,t)=>{if(!u.open)return;const i="edit"===u.mode?u.id:null;w(u.mode,u.scope,i,e,t)}}),f.jsx(Se,{open:m.open,onOpenChange:e=>g(t=>({...t,open:e})),kind:"agent-prompt",label:m.label,content:m.content})]})}function Lr({title:e,count:t,loading:i,prompts:s,emptyText:r,onAdd:n,onToggle:o,onEdit:a,onDelete:l,onShare:h,instructionsFile:c}){return f.jsxs("div",{className:"px-2 py-2",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[f.jsx("span",{children:e}),f.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),f.jsx("button",{onClick:n,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:f.jsx($,{className:"h-3 w-3"})})]}),i?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"加载中…"}):0===s.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:r}):f.jsx("div",{className:"space-y-1.5",children:s.map(e=>{const t=e.command.split("\n").find(e=>e.trim())??e.command.trim();return f.jsx(kr,{kind:"agent-prompt",label:e.label,preview:t,inserted:e.inserted,instructionsFile:c,onLeftClick:()=>o(e),onEdit:()=>a(e),onDelete:()=>l(e),onShare:()=>h(e)},e.id)})})]})}function Pr({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(null),[n,o]=l.useState("CLAUDE.md"),[a,h]=l.useState(!0),[c,d]=l.useState(!1),u=l.useRef(new Set),m=l.useCallback(async()=>{h(!0);try{const t=await He(e);i(t.items),r(t.claudeMdLineCount),t.instructionsFilename&&o(t.instructionsFilename)}catch(t){_.error(`加载失败: ${t.message}`)}finally{h(!1)}},[e]);l.useEffect(()=>{m()},[m]);const g=l.useCallback(async t=>{if(u.current.has(t.filename))return;u.current.add(t.filename),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:!e.inserted}:e));const s=t.inserted?"remove":"insert";try{const n=await Fe(e,t.filename,s);if(!n.ok)return _.error("操作失败"+(n.reason?`(${n.reason})`:"")),void m();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:n.inserted}:e)),"number"==typeof n.claudeMdLineCount&&r(n.claudeMdLineCount),"insert"===s&&"refreshed"===n.reason&&_.info(`${t.name} 已更新(文件内容有变化)`)}catch(n){_.error(`操作失败: ${n.message}`),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:t.inserted}:e))}finally{u.current.delete(t.filename)}},[e,m]),v=l.useCallback(async()=>{if(c)return;const s=t.filter(e=>e.inserted);if(0===s.length)return void _.info("没有已插入的 memory 卡片");d(!0);let n=0,o=0;for(const t of s)if(u.current.has(t.filename))o++;else{u.current.add(t.filename);try{const s=await Fe(e,t.filename,"insert");s.ok?(i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:s.inserted}:e)),"number"==typeof s.claudeMdLineCount&&r(s.claudeMdLineCount),n++):o++}catch{o++}finally{u.current.delete(t.filename)}}d(!1),0===o?_.success(`已从磁盘更新 ${n} 个 memory 卡片`):_.error(`${n} 个更新成功,${o} 个失败`)},[e,t,c]),S=l.useCallback(async t=>{if(!u.current.has(t.filename))if(t.inserted){u.current.add(t.filename);try{const s=await Fe(e,t.filename,"insert");if(!s.ok)return _.error("更新失败"+(s.reason?`(${s.reason})`:"")),void m();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:s.inserted}:e)),"number"==typeof s.claudeMdLineCount&&r(s.claudeMdLineCount),_.success(`${t.name} 已从磁盘重新加载`)}catch(s){_.error(`更新失败: ${s.message}`)}finally{u.current.delete(t.filename)}}else _.info("卡片未插入,无需更新")},[e,m]);return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Memory Prompts"}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:()=>{v()},disabled:c||!t.some(e=>e.inserted),className:p("p-0.5 rounded text-muted-foreground transition-colors","hover:text-foreground hover:bg-muted-foreground/10","disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-muted-foreground"),title:`把所有已插入卡片的内容从磁盘重新加载到 ${n}`,children:f.jsx(Zt,{className:p("h-3.5 w-3.5",c&&"animate-spin")})}),f.jsx("button",{onClick:()=>{m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"刷新(重新扫描 .ccweb/memory/)",children:f.jsx(L,{className:p("h-3.5 w-3.5",a&&"animate-spin")})})]})]}),f.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["来自 ",f.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 的文件,点击插入 / 移除 ",n,"(以",f.jsx("code",{className:"text-[11px]",children:" START 名 / END 名 "}),"包裹)"]}),null!==s&&f.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground/60 font-mono tabular-nums",children:[n,": ",s," 行"]})]}),f.jsx("div",{className:"px-2 py-2 flex-1 min-h-0",children:a&&0===t.length?f.jsx("div",{className:"px-1 py-6 text-xs text-muted-foreground/60 text-center",children:"加载中…"}):0===t.length?f.jsxs("div",{className:"px-1 py-8 text-xs text-muted-foreground/60 flex flex-col items-center gap-2",children:[f.jsx(Yt,{className:"h-5 w-5"}),f.jsxs("div",{className:"text-center leading-relaxed",children:["暂无 memory 文件",f.jsx("br",{}),"新建 ",f.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 文件后点刷新"]})]}):f.jsx("div",{className:"space-y-1.5",children:t.map(e=>f.jsx(kr,{kind:"agent-prompt",noContextMenu:!0,label:e.name,preview:e.preview,inserted:e.inserted,instructionsFile:n,cornerHint:`${e.lineCount} 行`,onLeftClick:()=>{g(e)},onRefresh:e.inserted?()=>{S(e)}:void 0},e.filename))})})]})}function Br({projectId:e,onSend:t}){const[i,s]=Q(y.rightPanelTab,"shortcuts"),r="prompts"===i?"prompts":"memory"===i?"memory":"shortcuts";return f.jsxs(Mt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-border",children:[f.jsx(Rt,{value:"shortcuts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Nr,{projectId:e,onSend:t})}),f.jsx(Rt,{value:"prompts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Rr,{projectId:e})}),f.jsx(Rt,{value:"memory",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Pr,{projectId:e})})]}),f.jsxs(Nt,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-l border-border rounded-none p-1 gap-1"),children:[f.jsx(Dt,{value:"shortcuts",title:"Quick Prompts (快捷 Prompts)","aria-label":"Quick Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx($e,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"prompts",title:"Agent Prompts","aria-label":"Agent Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Ke,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"memory",title:"Memory Prompts (.ccweb/memory/*.md)","aria-label":"Memory Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Yt,{className:"h-3.5 w-3.5"})})]})]})}var Tr=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const i=Ue(`Primitive.${t}`),s=l.forwardRef((e,s)=>{const{asChild:r,...n}=e,o=r?i:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f.jsx(o,{...n,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),jr="horizontal",Or=["horizontal","vertical"],Ar=l.forwardRef((e,t)=>{const{decorative:i,orientation:s=jr,...r}=e,n=function(e){return Or.includes(e)}(s)?s:jr,o=i?{role:"none"}:{"aria-orientation":"vertical"===n?n:void 0,role:"separator"};return f.jsx(Tr.div,{"data-orientation":n,...o,...r,ref:t})});Ar.displayName="Separator";var Ir=Ar;const zr=l.forwardRef(({className:e,orientation:t="horizontal",decorative:i=!0,...s},r)=>f.jsx(Ir,{ref:r,decorative:i,orientation:t,className:p("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...s}));zr.displayName=Ir.displayName;const Wr=[{tool:"claude",label:"Claude Code",supportsContinue:!0},{tool:"codex",label:"Codex",supportsContinue:!0},{tool:"gemini",label:"Gemini CLI",supportsContinue:!0},{tool:"opencode",label:"OpenCode",supportsContinue:!1},{tool:"qwen",label:"Qwen Code",supportsContinue:!1},{tool:"terminal",label:"Bare Shell",supportsContinue:!1}];function Hr(e){var t;return(null==(t=Wr.find(t=>t.tool===e))?void 0:t.label)??String(e??"")}function Fr(e){var t;return(null==(t=Wr.find(t=>t.tool===e))?void 0:t.supportsContinue)??!1}function $r({open:e,onOpenChange:t,currentCliTool:i,loading:s,onConfirm:r}){const{t:n}=qe(),[o,a]=l.useState(null),[h,c]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{e&&(a(null),c(!1),u(null))},[e]),l.useEffect(()=>{o&&!Fr(o)&&c(!1)},[o]);const _=!!o&&Fr(o);return f.jsx(xe,{open:e,onOpenChange:t,children:f.jsxs(ye,{className:"max-w-lg",children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:n("switch_cli.title")}),f.jsx(Ee,{children:n("switch_cli.description",{current:Hr(i)})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-sm font-medium",children:n("switch_cli.target_label")}),f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Wr.map(e=>{const t=e.tool===i,r=e.tool===o;return f.jsxs("button",{type:"button",disabled:t||s,onClick:()=>a(e.tool),className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",r?"border-primary bg-accent":"border-border hover:bg-accent/50",t&&"opacity-50 cursor-not-allowed"),children:[f.jsx("div",{className:"font-medium",children:e.label}),f.jsx("div",{className:"text-xs text-muted-foreground",children:t?n("switch_cli.tag_current"):e.supportsContinue?n("switch_cli.tag_supports_continue"):n("switch_cli.tag_no_continue")})]},e.tool)})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-sm font-medium",children:n("switch_cli.mode_label")}),f.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[f.jsxs("button",{type:"button",disabled:s,onClick:()=>c(!1),className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",h?"border-border hover:bg-accent/50":"border-primary bg-accent"),children:[f.jsx("div",{className:"font-medium",children:n("switch_cli.mode_fresh")}),f.jsx("div",{className:"text-xs text-muted-foreground",children:n("switch_cli.mode_fresh_hint")})]}),f.jsxs("button",{type:"button",disabled:s||!o||!_,onClick:()=>c(!0),title:o&&!_?n("switch_cli.mode_continue_unsupported",{tool:Hr(o)}):void 0,className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",h?"border-primary bg-accent":"border-border hover:bg-accent/50",(!o||!_)&&"opacity-50 cursor-not-allowed"),children:[f.jsx("div",{className:"font-medium",children:n("switch_cli.mode_continue")}),f.jsx("div",{className:"text-xs text-muted-foreground",children:o&&!_?n("switch_cli.mode_continue_unsupported",{tool:Hr(o)}):n("switch_cli.mode_continue_hint")})]})]})]}),d&&f.jsx("div",{className:"text-xs text-red-500 break-words",children:d})]}),f.jsxs(Ne,{children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),disabled:s,children:n("switch_cli.cancel")}),f.jsx(H,{onClick:()=>{(async()=>{if(o){u(null);try{await r(o,h)}catch(e){u(e instanceof Error?e.message:String(e))}}})()},disabled:!o||s,children:n(s?"switch_cli.confirming":"switch_cli.confirm")})]})]})})}function Kr({status:e}){return f.jsxs("span",{className:p("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[f.jsx("span",{className:p("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Ur({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const{t:c}=qe(),d=Ve(),[u,m]=l.useState(!1),[g,w]=l.useState(!1),[x,y]=l.useState(0),[C,k]=l.useState(!1),[E,M]=l.useState(!1),[N,D]=l.useState(!1),[R,P]=l.useState(!1);Ye({onStart:e=>{e.projectId===t&&y(0)},onProgress:e=>{e.projectId===t&&y(e.filesTransferred)},onDone:e=>{e.projectId===t&&y(0)}}),l.useEffect(()=>{const e=()=>M(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const B=Ge(e=>e.updateProject);return f.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:f.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[f.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d("/"),children:f.jsx(Xe,{className:"h-4 w-4"})}),f.jsx(zr,{orientation:"vertical",className:"h-5 mx-0.5"}),f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",i&&"bg-accent"),onClick:n,title:c("project_header.toggle_file_tree"),children:f.jsx(ii,{className:"h-4 w-4"})}),f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",s&&"bg-accent"),onClick:o,title:c("project_header.toggle_right_panel"),children:f.jsx(si,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",r&&"bg-accent"),onClick:a,title:c("project_header.toggle_chat_overlay"),children:f.jsx(Qt,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-2",children:[f.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),f.jsx(Kr,{status:e.status}),f.jsx(Je,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),f.jsxs("button",{type:"button",onClick:()=>D(!0),disabled:R,title:`${c("project_header.switch_cli_title")} (${Hr(e.cliTool)})`,className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border border-border bg-background hover:bg-accent transition-colors disabled:opacity-50 flex-shrink-0",children:[f.jsx(L,{className:"h-3 w-3"}),f.jsx("span",{className:"font-medium hidden sm:inline",children:Hr(e.cliTool)})]}),f.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),f.jsx(Ze,{}),f.jsx(Qe,{}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:c(E?"project_header.fullscreen_exit":"project_header.fullscreen_enter"),children:E?f.jsx(v,{className:"h-3.5 w-3.5"}):f.jsx(S,{className:"h-3.5 w-3.5"})}),f.jsx(zr,{orientation:"vertical",className:"h-5 mx-0.5"}),g?f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(g&&!C){k(!0);try{(await it(t)).cancelled?_.info(c("project_header.sync_cancelled")):_.error(c("project_header.sync_cancel_failed"))}catch(e){_.error(e instanceof Error?e.message:c("project_header.sync_cancel_failed")),k(!1)}}})()},disabled:C,title:c("project_header.sync_cancel_title"),children:[C?f.jsx(et,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):f.jsx(b,{className:"h-3.5 w-3.5 mr-1.5"}),f.jsx("span",{className:"tabular-nums",children:x>0?c("project_header.sync_progress_label",{files:x}):c("project_header.sync_progress_label_empty")})]}):f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(!g){w(!0),y(0);try{const e=await st(t);e.skipped?_.info(c("project_header.sync_skipped")):e.ok?_.success(c("project_header.sync_success",{files:e.filesTransferred,seconds:Math.round(e.durationMs/1e3)})):"cancelled"===e.reason||_.error(e.reason?c("project_header.sync_failed_with_reason",{reason:e.reason}):c("project_header.sync_failed"))}catch(e){_.error(e instanceof Error?e.message:c("project_header.sync_failed"))}finally{w(!1),y(0),k(!1)}}})()},title:c("project_header.sync_button_title"),children:[f.jsx(tt,{className:"h-3.5 w-3.5 mr-1.5"}),c("project_header.sync")]}),f.jsx($r,{open:N,onOpenChange:e=>{R||D(e)},currentCliTool:e.cliTool,loading:R,onConfirm:async(t,i)=>{P(!0);try{const s=await rt(e.id,t,i);h(s),B(s),D(!1),_.success(c("switch_cli.switched_toast",{tool:Hr(t)}))}catch(s){const e=s instanceof Error?s.message:String(s);throw _.error(c("switch_cli.switch_failed",{reason:e})),s}finally{P(!1)}}}),"stopped"===e.status&&f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{m(!0);try{h(await nt(e.id))}catch(t){console.error(t)}finally{m(!1)}})()},disabled:u,children:[f.jsx(ri,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
|
|
14
|
+
*/const fi=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function pi(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const mi=[50,75,100,125,150,200,250,300],gi=100;function vi({filePath:e,onClose:t}){const i=a(),s=e.endsWith("/.notebook/graph.yaml"),r=s?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[n,o]=l.useState(null),[C,k]=l.useState(null),[M,N]=l.useState(()=>s?"graph":"rendered"),[D,R]=l.useState(!1),[L,P]=l.useState(gi),[B,T]=l.useState(""),[j,O]=l.useState(!1),[A,I]=l.useState(!1),z=l.useRef(null),[W,H]=l.useState(!0),{resolved:F}=h(),$=e.split("/").pop()??e,K=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),U=fi.has(K),q=di.has(K),V=ui.has(K),Y=function(e){return"md"===e||"html"===e||"htm"===e||e in _i}(K),G=_i[K]||K,X=l.useMemo(()=>{if(!U)return"";const t=w(e),i=c(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,U]);l.useEffect(()=>{if(H(!0),o(null),k(null),P(function(e){const t=x(y.fileZoom,{},!0)[e];return mi.includes(t)?t:gi}(e)),I(!1),U||q||V)return o({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void N("rendered");N(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),d(e).then(e=>{o(e),T(e.content??"")}).catch(e=>k(e instanceof Error?e.message:"Failed to load file"))},[e,U,q,V]);const J=l.useCallback(async()=>{O(!0);try{await u(e,B),o(e=>e?{...e,content:B,size:new Blob([B]).size}:e),I(!1)}catch(t){_.error(t instanceof Error?t.message:"保存失败")}finally{O(!1)}},[e,B]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===M&&(e.preventDefault(),J())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[M,J]),l.useEffect(()=>{const e=async e=>{if("Escape"===e.key&&W){if(A){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,t,A,i]);const Z=async()=>{if(A){if(!(await i({description:"有未保存的修改,确定退出编辑?",confirmLabel:"放弃修改",destructive:!0})))return}N(s?"graph":Y?"rendered":"plain"),I(!1)},Q=t=>{P(t),function(e,t){const i=x(y.fileZoom,{},!0);t===gi?delete i[e]:i[e]=t,E(y.fileZoom,i,!0)}(e,t)},ee=(null==n?void 0:n.content)??"",te="dark"===F?St:bt,ie=L/100*12,se=n&&!n.binary&&!n.tooLarge&&!V,re=l.useDeferredValue(B),ne=l.useMemo(()=>{var e,t;if(!n||n.binary||n.tooLarge)return null;if(U||q||V)return null;const i="edit"===M?re:ee;if(null==i)return null;return{bytes:new Blob([i]).size,words:((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0),lines:""===i?0:i.split("\n").length}},[n,U,q,M,re,ee]);return f.jsx("div",{className:p("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",W?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&H(!1)},children:f.jsxs("div",{className:p("relative flex flex-col bg-background border border-border shadow-sm transition-all duration-200 pointer-events-auto",D?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-xl",!W&&!D&&"opacity-50"),onClick:()=>H(!0),onFocus:e=>{e.stopPropagation(),H(!0)},children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[f.jsx(ut,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[$,A&&f.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),ne&&f.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs tabular-nums",children:[(oe=ne.bytes,oe<1024?`${oe} B`:oe<1048576?`${(oe/1024).toFixed(1)} KB`:`${(oe/1024/1024).toFixed(2)} MB`)," · ",ne.words.toLocaleString()," 词 · ",ne.lines.toLocaleString()," 行"]})]}),se&&!U&&!q&&f.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[Y&&f.jsxs(f.Fragment,{children:[f.jsxs("button",{onClick:()=>"edit"===M?Z():N("plain"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","plain"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[f.jsx(qt,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),f.jsxs("button",{onClick:()=>"edit"===M?Z():N("rendered"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","rendered"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:pi(K),children:[f.jsx(m,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:pi(K)})]})]}),s&&f.jsxs("button",{onClick:()=>"edit"===M?Z():N("graph"),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","graph"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[f.jsx(ti,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),f.jsxs("button",{onClick:()=>"edit"===M?Z():(T((null==n?void 0:n.content)??""),I(!1),N("edit"),void setTimeout(()=>{var e;return null==(e=z.current)?void 0:e.focus()},0)),className:p("p-1 rounded-md transition-colors flex items-center gap-1 text-xs","edit"===M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[f.jsx(g,{className:"h-3 w-3"}),f.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===M&&f.jsxs("button",{onClick:()=>{J()},disabled:j||!A,className:p("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",A?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[f.jsx(kt,{className:"h-3 w-3"}),j?"保存中...":"保存"]}),(se||U||V)&&"edit"!==M&&"graph"!==M&&f.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[f.jsx("button",{onClick:()=>{const e=[...mi].reverse().find(e=>e<L);e&&Q(e)},disabled:L<=mi[0],className:"p-1 rounded-md text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:f.jsx(ai,{className:"h-3 w-3"})}),f.jsxs("button",{onClick:()=>Q(gi),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[L,"%"]}),f.jsx("button",{onClick:()=>{const e=mi.find(e=>e>L);e&&Q(e)},disabled:L>=mi[mi.length-1],className:"p-1 rounded-md text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:f.jsx(oi,{className:"h-3 w-3"})})]}),f.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>R(e=>!e),title:D?"退出全屏":"全屏",children:D?f.jsx(v,{className:"h-3.5 w-3.5"}):f.jsx(S,{className:"h-3.5 w-3.5"})}),f.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:async()=>{if(A){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()},children:f.jsx(b,{className:"h-4 w-4"})})]}),f.jsxs("div",{className:p("flex-1 min-h-0","graph"===M?"overflow-hidden":"overflow-auto"),children:["graph"===M&&f.jsx(l.Suspense,{fallback:f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:f.jsx(li,{folderPath:r})}),"graph"!==M&&!n&&!C&&f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==M&&C&&f.jsx("p",{className:"text-sm text-red-400 p-4",children:C}),"graph"!==M&&U&&n&&f.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:f.jsx("img",{src:X,alt:$,className:"max-w-full max-h-full object-contain rounded-md",style:{transform:`scale(${L/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==M&&q&&n&&f.jsx(l.Suspense,{fallback:f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:f.jsx(hi,{filePath:e,ext:K,zoom:L})}),"graph"!==M&&V&&n&&f.jsx(l.Suspense,{fallback:f.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:f.jsx(ci,{filePath:e,zoom:L})}),"graph"!==M&&!U&&!q&&!V&&n&&n.binary&&f.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[f.jsx(ut,{className:"h-8 w-8"}),f.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024).toFixed(1)," KB"]})]}),"graph"!==M&&!q&&n&&n.tooLarge&&f.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[f.jsx(ut,{className:"h-8 w-8"}),f.jsx("p",{className:"text-sm",children:"File too large to preview"}),f.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==M&&se&&null!==ee&&f.jsxs(f.Fragment,{children:["edit"===M&&f.jsx("textarea",{ref:z,value:B,onChange:e=>{T(e.target.value),I(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${ie}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==M&&f.jsxs("div",{className:"p-4",style:{fontSize:`${ie}px`},children:["plain"===M&&f.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:ee}),"rendered"===M&&"md"===K&&f.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:f.jsx(_t,{remarkPlugins:[pt,mt],rehypePlugins:[ft],urlTransform:(e,t,i)=>"src"===t&&"img"===i.tagName?e:wt(e),components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?f.jsx("code",{className:e,...i,children:t}):f.jsx(vt,{style:te,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})},img:({src:t,alt:i,...s})=>f.jsx("img",{...s,src:gt(e,t,c()),alt:i??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:ee})}),"rendered"===M&&("html"===K||"htm"===K)&&f.jsx("iframe",{srcDoc:dt.sanitize(ee,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:$,style:{minHeight:"60vh",transform:`scale(${L/100})`,transformOrigin:"top left",width:1e4/L+"%",height:1e4/L+"%"}}),"rendered"===M&&"md"!==K&&"html"!==K&&"htm"!==K&&G&&f.jsx(vt,{style:te,language:G,showLineNumbers:!0,lineNumberStyle:{color:"dark"===F?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:ee}),"rendered"===M&&!Y&&f.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:ee})]})]})]})]})});var oe}async function Si(e){var t;if("undefined"!=typeof navigator&&(null==(t=navigator.clipboard)?void 0:t.writeText))try{return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="0",t.setAttribute("readonly",""),document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length);const i=document.execCommand("copy");return document.body.removeChild(t),i}catch{return!1}}const bi=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function wi(e){const t=e.lastIndexOf(".");return t>=0&&bi.has(e.slice(t+1).toLowerCase())}function xi({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,h]=l.useState(new Set),d=M(e=>e.get(t).filePreviewPath),u=M(e=>e.setFilePreviewPath),m=e=>u(t,e),[g,v]=l.useState(null),[S,b]=l.useState(!1),[x,y]=l.useState(null),[C,k]=l.useState(!1),E=a(),z=l.useRef(null),W=l.useRef(null),H=function(e={}){const t=e.duration??500,i=e.moveTolerance??10,s=l.useRef(null),r=l.useRef(null),n=l.useRef(!1),o=l.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null),r.current=null},[]);return{bind:l.useCallback(e=>({onTouchStart:i=>{if(1!==i.touches.length)return;const o=i.touches[0];r.current={x:o.clientX,y:o.clientY},n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{if(n.current=!0,"undefined"!=typeof navigator&&"vibrate"in navigator)try{navigator.vibrate(15)}catch{}e(o.clientX,o.clientY)},t)},onTouchMove:e=>{if(!r.current||!s.current)return;const t=e.touches[0],n=t.clientX-r.current.x,a=t.clientY-r.current.y;Math.hypot(n,a)>i&&o()},onTouchEnd:o,onTouchCancel:o}),[t,i,o]),wasTriggered:n}}();l.useEffect(()=>{if(!g)return;const e=()=>v(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[g]);const F=async t=>{var i;if(0===t.length)return;const s=t.reduce((e,t)=>e+t.size,0);b(!0),y({loaded:0,total:s});try{const s=await T(e,t,(e,t)=>{y({loaded:e,total:t})});K(e);const r=s.uploaded.length,n=(null==(i=s.skipped)?void 0:i.length)??0,o=s.errors.length;o>0?_.error(`上传完成:${r} 成功,${o} 失败${n?`,${n} 跳过`:""}`):n>0?_.info(`已上传 ${r} 个文件,${n} 个同名文件被跳过`):_.success(`已上传 ${r} 个文件`)}catch(r){console.error("[FileTree] Upload failed:",r),_.error(`上传失败: ${r.message}`)}finally{b(!1),y(null)}},$=e=>e>=1073741824?(e/1073741824).toFixed(2)+" GB":e>=1048576?(e/1048576).toFixed(1)+" MB":e>=1024?(e/1024).toFixed(0)+" KB":e+" B",K=l.useCallback(async e=>{h(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await N(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{h(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),h(new Set),K(e)},[e,K]);const U=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||K(e)),s})},[i,K]),q=l.useCallback(()=>{s(new Map),n(new Set([e])),h(new Set),K(e)},[e,K]),V=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return f.jsxs("div",{children:[f.jsxs("div",{className:p("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted-foreground/10",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px",WebkitTouchCallout:"none"},onClick:t=>{if(H.wasTriggered.current)return H.wasTriggered.current=!1,void t.stopPropagation();"dir"===e.type?U(e.path):m(e.path)},onContextMenu:t=>{t.preventDefault(),v({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},...H.bind((t,i)=>{v({x:t,y:i,filePath:e.path,fileName:e.name,type:e.type})}),children:[f.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?f.jsx(L,{className:"h-2.5 w-2.5 animate-spin"}):s?f.jsx(Wt,{className:"h-2.5 w-2.5"}):f.jsx(j,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?f.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):f.jsx(O,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):wi(e.name)?f.jsx(xt,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):f.jsx(ut,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsx("span",{className:p("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),f.jsx(A,{initial:!1,children:"dir"===e.type&&s&&f.jsxs(I.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&f.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&f.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&V(a,t+1)]})})]},e.path)}),Y=i.get(e),G=o.has(e),X=e.split("/").filter(Boolean).pop()??e;return f.jsxs(f.Fragment,{children:[d&&f.jsx(vi,{filePath:d,onClose:()=>m(null)}),g&&f.jsxs("div",{ref:z,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:g.x,top:g.y},onClick:e=>e.stopPropagation(),children:[f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{Si(g.filePath.startsWith(e+"/")?g.filePath.slice(e.length+1):g.filePath).then(e=>{e?_.success("已复制相对路径"):_.error("复制失败")}),v(null)},children:[f.jsx(Vt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{Si(g.filePath).then(e=>{e?_.success("已复制绝对路径"):_.error("复制失败")}),v(null)},children:[f.jsx(Ut,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===g.type&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"my-1 border-t border-border"}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=w(e);const s=c();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`);const r=`${i}${i.includes("?")?"&":"?"}dl=1`;try{const e=await fetch(r,{method:"HEAD"});if(!e.ok)return void _.error(`下载失败 (${e.status})`)}catch{return void _.error("下载失败:网络错误")}const n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)})(g.filePath,g.fileName),v(null)},children:[f.jsx(D,{className:"h-3.5 w-3.5"}),"下载"]})]}),f.jsx("div",{className:"my-1 border-t border-border"}),f.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(await E({title:"确认删除",description:`确认删除${n}?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await B(t),_.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?K(r):K(e)}catch(o){_.error(`删除失败: ${o.message}`)}})(g.filePath,g.fileName,g.type),v(null)},children:[f.jsx(R,{className:"h-3.5 w-3.5"}),"删除"]})]}),f.jsxs("div",{className:"h-full flex flex-col text-foreground select-none",children:[f.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("input",{ref:W,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&F(t),e.target.value=""}}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=W.current)?void 0:e.click()},disabled:S,title:"上传文件",children:f.jsx(Et,{className:p("h-3 w-3",S&&"animate-pulse")})}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:q,title:"Refresh file tree",children:f.jsx(L,{className:p("h-3 w-3",G&&"animate-spin")})})]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[f.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),f.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:X})]}),f.jsxs("div",{className:p("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",C&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),k(!0)},onDragEnter:e=>{e.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:e=>{e.preventDefault(),k(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&F(t)},children:[S&&x&&f.jsxs("div",{className:"px-3 py-2 border-b border-border space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[f.jsxs("span",{children:["上传中 ",Math.floor(x.loaded/Math.max(x.total,1)*100),"%"]}),f.jsxs("span",{className:"font-mono",children:[$(x.loaded)," / ",$(x.total)]})]}),f.jsx("div",{className:"h-1 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full bg-primary transition-[width] duration-150",style:{width:x.loaded/Math.max(x.total,1)*100+"%"}})})]}),C&&!S&&f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),G&&!Y?f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):Y&&0!==Y.length?V(Y,0):f.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function yi(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function Ci({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,m]=l.useState(!1),[g,v]=l.useState([]),[S,b]=l.useState(0),[w,x]=l.useState(!0),[y,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await z(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?g.length:0,s=await W(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),b(s.total)}catch{}finally{C(!1)}},[e,g.length]);l.useEffect(()=>{k(),E()},[e]);const M=async t=>{try{const{diff:i}=await U(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{_.error("获取 diff 失败")}},N=async t=>{try{await q(e,[t]),_.success(`已暂存 ${t}`),await k()}catch{_.error("git add 失败")}},D=async()=>{if(c.trim()){m(!0);try{await V(e,c),_.success("提交成功"),d(""),await k()}catch(t){_.error(t instanceof Error?t.message:"提交失败")}finally{m(!1)}}};if(!t&&s)return f.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[f.jsx(Gt,{className:"h-5 w-5"}),f.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return f.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[f.jsx(Gt,{className:"h-5 w-5"}),f.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const R=[...t.modified??[],...t.deleted??[]],P=t.staged??[],B=t.untracked??[];return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[f.jsx(Gt,{className:"h-3 w-3"}),f.jsx("span",{children:t.branch}),(t.ahead??0)>0&&f.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&f.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:f.jsx(L,{className:p("h-3 w-3",s&&"animate-spin")})})]}),P.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",P.length,")"]}),P.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx(F,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),f.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{M(e)},children:e})]},e))]}),R.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",R.length,")"]}),R.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{N(e)},children:f.jsx($,{className:"h-2.5 w-2.5"})}),f.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{M(e)},children:e})]},e))]}),B.length>0&&f.jsxs("div",{children:[f.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",B.length,")"]}),B.map(e=>f.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[f.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{N(e)},children:f.jsx($,{className:"h-2.5 w-2.5"})}),f.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===R.length&&0===P.length&&0===B.length&&f.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),P.length>0&&f.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[f.jsx(K,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||D()},className:"h-7 text-xs"}),f.jsx(H,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{D()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${P.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&f.jsxs("div",{className:"border-t border-border pt-2",children:[f.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>x(e=>!e),children:[f.jsx(Wt,{className:p("h-3 w-3 transition-transform",!w&&"-rotate-90")}),f.jsx(Xt,{className:"h-3 w-3"}),f.jsxs("span",{children:["提交历史 (",S,")"]})]}),w&&f.jsxs("div",{className:"space-y-0.5",children:[g.map((e,t)=>{const i=e.parents.length>1;return f.jsxs("div",{className:"flex gap-1.5 items-start group",children:[f.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[f.jsx("div",{className:p("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<g.length-1&&f.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),f.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[f.jsxs("div",{className:"flex items-baseline gap-1",children:[f.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),f.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[f.jsx("span",{children:e.author}),f.jsx("span",{children:yi(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>f.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),g.length<S&&f.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:y,children:y?"加载中...":`加载更多 (${g.length}/${S})`})]})]}),null!==n&&f.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[f.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),f.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-xl shadow-sm",onClick:e=>e.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[f.jsx("span",{className:"truncate text-muted-foreground",children:a}),f.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),f.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>f.jsx("span",{className:p("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}function ki(e){if(!e)return"-";const t=e-Date.now(),i=Math.abs(t),s=t<0,r=Math.round(i/1e3);if(r<60)return s?`${r} 秒前`:`${r} 秒后`;const n=Math.round(r/60);if(n<60)return s?`${n} 分钟前`:`${n} 分钟后`;const o=Math.round(n/60);if(o<24)return s?`${o} 小时前`:`${o} 小时后`;const a=Math.round(o/24);return s?`${a} 天前`:`${a} 天后`}function Ei(e){if(!e)return"";return new Date(e).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Mi({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[,a]=l.useState(0),h=l.useRef(!0),c=l.useRef(0),d=l.useCallback(async()=>{const t=++c.current;r(!0),o(null);try{const{tasks:s}=await Y(e);if(!h.current||t!==c.current)return;i(s)}catch(ga){if(!h.current||t!==c.current)return;o(ga.message),i([])}finally{h.current&&t===c.current&&r(!1)}},[e]);return l.useEffect(()=>{h.current=!0,d();const e=setInterval(()=>{d()},3e4),t=setInterval(()=>a(e=>e+1),1e3);return()=>{h.current=!1,clearInterval(e),clearInterval(t)}},[d]),f.jsxs("div",{className:"h-full flex flex-col bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-shrink-0 px-3 py-2 flex items-center justify-between border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[f.jsx(yt,{className:"size-4"}),f.jsx("span",{children:"已排程任务"})]}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{d()},title:"刷新","aria-label":"刷新",children:f.jsx(L,{className:p("size-3.5",s&&"animate-spin")})})]}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-1.5",children:[f.jsxs("div",{className:"rounded-md bg-muted-foreground/5 px-2 py-1.5 text-[11px] text-muted-foreground flex items-start gap-1.5",children:[f.jsx(Jt,{className:"size-3 mt-0.5 shrink-0"}),f.jsxs("span",{className:"leading-snug",children:["best-effort 重建:从 session JSONL 反推「Claude 创建过的 schedule」,",f.jsx("strong",{className:"text-foreground/80",children:"不是"}),"权威活动列表。已触发 / 已删除 无法直接观测。"]})]}),n&&f.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 text-destructive p-2 text-xs",children:n}),!n&&t&&0===t.length&&!s&&f.jsxs("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:[f.jsx("p",{children:"本项目最近 7 天没有创建过 schedule。"}),f.jsx("p",{className:"mt-2 leading-relaxed",children:"一次性 ScheduleWakeup 触发时间过了的会被隐藏(认为已触发); CronCreate 仅显示 7 天内创建的(与 Claude 自动过期窗口对齐)。"})]}),t&&t.map(e=>{const t=e.nextFireAt?Date.parse(e.nextFireAt):null,i="CronCreate"===e.type&&(e.recurring||/[,*\/-]/.test(e.cron??"")),s="ScheduleWakeup"===e.type&&null!==e.delaySeconds?function(e){if(e<60)return`${e} 秒后`;const t=Math.round(e/60);return t<60?`${t} 分钟后`:Math.round(t/60*10)/10+" 小时后"}(e.delaySeconds):e.cron??"?";return f.jsx("div",{className:"rounded-md border border-border bg-background px-2.5 py-2 text-xs",children:f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx("div",{className:"shrink-0 mt-0.5 text-muted-foreground",children:i?f.jsx(ni,{className:"size-3.5"}):f.jsx(G,{className:"size-3.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-1",children:[f.jsx("span",{className:"text-[10px] font-mono px-1.5 rounded bg-muted-foreground/10 text-muted-foreground",children:"ScheduleWakeup"===e.type?"SW":"CC"}),e.durable&&f.jsx("span",{className:"text-[10px] px-1.5 rounded bg-primary/10 text-primary",children:"durable"}),f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded font-mono",children:s})]}),f.jsx("div",{className:"font-medium text-foreground line-clamp-2 leading-snug",children:e.prompt.trim()||"(无 prompt)"}),e.reason&&f.jsxs("div",{className:"mt-0.5 text-muted-foreground line-clamp-1 italic text-[11px]",children:["reason: ",e.reason]}),f.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-muted-foreground",children:[null!==t&&f.jsxs("span",{title:Ei(t),children:["下次: ",f.jsx("span",{className:"text-foreground/90",children:ki(t)})]}),f.jsxs("span",{title:Ei(e.createdAt),children:["创建: ",ki(e.createdAt)]}),f.jsx("span",{className:"font-mono text-muted-foreground/70",children:e.sessionId.slice(0,8)})]})]})]})},`${e.sessionId}:${e.id}`)}),s&&!t&&f.jsx("div",{className:"space-y-1.5",children:[0,1].map(e=>f.jsx("div",{className:"rounded-md border border-border bg-background px-2.5 py-2 h-16 animate-pulse"},e))})]})]})}function Ni(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function Di(e){if(!e)return"-";const t=e-Date.now(),i=Math.abs(t),s=t<0,r=Math.round(i/1e3);if(r<60)return s?`${r} 秒前`:`${r} 秒后`;const n=Math.round(r/60);if(n<60)return s?`${n} 分钟前`:`${n} 分钟后`;const o=Math.round(n/60);if(o<24)return s?`${o} 小时前`:`${o} 小时后`;const a=Math.round(o/24);return s?`${a} 天前`:`${a} 天后`}function Ri(e){return new Date(e).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Li({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(!1),[a,h]=l.useState(null),[,c]=l.useState(0),d=l.useRef(!0),u=l.useCallback(async()=>{h(null);try{const t=await X(e);if(!d.current)return;i(t)}catch(ga){if(!d.current)return;h(ga.message)}finally{d.current&&r(!1)}},[e]),m=l.useCallback(async()=>{o(!0);try{const t=await J(e);if(!d.current)return;const i=[];t.copied>0&&i.push(`新增/更新 ${t.copied}`),t.deleted>0&&i.push(`删除 ${t.deleted}`),t.skipped>0&&i.push(`跳过 ${t.skipped}`),_.success(`同步完成:${i.join("·")||"无变化"}`),await u()}catch(ga){_.error(`同步失败:${ga.message}`)}finally{d.current&&o(!1)}},[e,u]);l.useEffect(()=>{d.current=!0,u();const e=setInterval(()=>{u()},3e4),t=setInterval(()=>c(e=>e+1),5e3);return()=>{d.current=!1,clearInterval(e),clearInterval(t)}},[u]);const g=(null==t?void 0:t.files.reduce((e,t)=>e+t.bytes,0))??0;return f.jsxs("div",{className:"h-full flex flex-col bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-shrink-0 px-3 py-2 flex items-center justify-between border-b border-border",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[f.jsx(Z,{className:"size-4"}),f.jsx("span",{children:"聊天记录备份"})]}),f.jsx(H,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{u()},title:"刷新","aria-label":"刷新",disabled:s,children:f.jsx(L,{className:p("size-3.5",s&&"animate-spin")})})]}),f.jsx("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border bg-background/40",children:f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"text-[11px] text-muted-foreground min-w-0",children:[f.jsxs("div",{children:["最后同步:"," ",f.jsx("span",{className:"text-foreground/90",title:(null==t?void 0:t.meta)?Ri(t.meta.lastBackupAt):void 0,children:(null==t?void 0:t.meta)?Di(t.meta.lastBackupAt):"从未同步"})]}),t&&f.jsxs("div",{className:"mt-0.5 text-muted-foreground/80",children:[t.files.length," 个文件 · ",Ni(g)]})]}),f.jsx(H,{size:"sm",className:"h-7 px-2.5 text-xs",onClick:()=>{m()},disabled:n||!(null==t?void 0:t.supported),children:n?"同步中…":"立即同步"})]})}),f.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-1",children:[a&&f.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 text-destructive p-2 text-xs flex items-start gap-2",children:[f.jsx(Kt,{className:"size-3.5 shrink-0 mt-0.5"}),f.jsx("span",{children:a})]}),t&&!t.supported&&f.jsx("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:f.jsxs("p",{children:["此项目使用 ",f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded",children:"terminal"})," 模式,无聊天记录需备份。"]})}),(null==t?void 0:t.supported)&&0===t.files.length&&!s&&!a&&f.jsxs("div",{className:"px-2 py-6 text-center text-xs text-muted-foreground",children:[f.jsx("p",{children:"暂无已备份的聊天记录"}),f.jsx("p",{className:"mt-2 leading-relaxed text-muted-foreground/80",children:'定时每 5 分钟同步一次,也可点击右上方"立即同步"手动触发。'}),f.jsxs("p",{className:"mt-1 text-muted-foreground/70",children:["备份路径: ",f.jsx("code",{className:"text-[10px] bg-muted-foreground/10 px-1 rounded break-all",children:t.backupDir})]})]}),null==t?void 0:t.files.map(e=>f.jsxs("div",{className:"rounded-md border border-border bg-background px-2.5 py-1.5 text-xs flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[f.jsx(ut,{className:"size-3.5 shrink-0 text-muted-foreground"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"font-mono text-[11px] text-foreground truncate",title:e.name,children:e.name}),f.jsxs("div",{className:"text-muted-foreground/80 text-[10px] flex items-center gap-2",children:[f.jsx("span",{title:Ri(e.mtime),children:Di(e.mtime)}),f.jsx("span",{className:"text-muted-foreground/40",children:"·"}),f.jsx("span",{children:Ni(e.bytes)})]})]})]},e.name)),s&&!t&&f.jsx("div",{className:"space-y-1",children:[0,1].map(e=>f.jsx("div",{className:"rounded-md border border-border bg-background h-10 animate-pulse"},e))})]})]})}function Pi({projectPath:e,projectId:t,cliTool:i}){const[s,r]=Q(y.leftPanelTab,"files"),n="claude"===i,o="terminal"!==i;let a;return a="git"===s?"git":"scheduled"===s&&n?"scheduled":"backup"===s&&o?"backup":"files",f.jsxs(Mt,{value:a,onValueChange:e=>r(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[f.jsxs(Nt,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-r border-border rounded-none p-1 gap-1"),children:[f.jsx(Dt,{value:"files",title:"Files","aria-label":"Files",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(P,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"git",title:"Git","aria-label":"Git",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Gt,{className:"h-3.5 w-3.5"})}),n&&f.jsx(Dt,{value:"scheduled",title:"已排程任务","aria-label":"Scheduled tasks",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(yt,{className:"h-3.5 w-3.5"})}),o&&f.jsx(Dt,{value:"backup",title:"聊天记录备份","aria-label":"Sessions backup",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Z,{className:"h-3.5 w-3.5"})})]}),f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-l border-border",children:[f.jsx(Rt,{value:"files",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(xi,{projectPath:e,projectId:t})}),f.jsx(Rt,{value:"git",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Ci,{projectId:t})}),n&&f.jsx(Rt,{value:"scheduled",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Mi,{projectId:t})}),o&&f.jsx(Rt,{value:"backup",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Li,{projectId:t})})]})]})}function Bi(e){const t=Ti(e),i=l.forwardRef((e,i)=>{const{children:s,...r}=e,n=l.Children.toArray(s),o=n.find(Oi);if(o){const e=o.props.children,s=n.map(t=>t===o?l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null:t);return f.jsx(t,{...r,ref:i,children:l.isValidElement(e)?l.cloneElement(e,void 0,s):null})}return f.jsx(t,{...r,ref:i,children:s})});return i.displayName=`${e}.Slot`,i}function Ti(e){const t=l.forwardRef((e,t)=>{const{children:i,...s}=e;if(l.isValidElement(i)){const e=function(e){var t,i;let s=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=s&&"isReactWarning"in s&&s.isReactWarning;if(r)return e.ref;if(s=null==(i=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:i.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),r=function(e,t){const i={...t};for(const s in t){const r=e[s],n=t[s];/^on[A-Z]/.test(s)?r&&n?i[s]=(...e)=>{const t=n(...e);return r(...e),t}:r&&(i[s]=r):"style"===s?i[s]={...r,...n}:"className"===s&&(i[s]=[r,n].filter(Boolean).join(" "))}return{...e,...i}}(s,i.props);return i.type!==l.Fragment&&(r.ref=t?ee(t,e):e),l.cloneElement(i,r)}return l.Children.count(i)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ji=Symbol("radix.slottable");function Oi(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===ji}var Ai=["Enter"," "],Ii=["ArrowUp","PageDown","End"],zi=["ArrowDown","PageUp","Home",...Ii],Wi={ltr:[...Ai,"ArrowRight"],rtl:[...Ai,"ArrowLeft"]},Hi={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Fi="Menu",[$i,Ki,Ui]=jt(Fi),[qi,Vi]=ie(Fi,[Ui,Bt,Tt]),Yi=Bt(),Gi=Tt(),[Xi,Ji]=qi(Fi),[Zi,Qi]=qi(Fi),es=e=>{const{__scopeMenu:t,open:i=!1,children:s,dir:r,onOpenChange:n,modal:o=!0}=e,a=Yi(t),[h,c]=l.useState(null),d=l.useRef(!1),u=te(n),_=Ht(r);return l.useEffect(()=>{const e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),f.jsx(Lt,{...a,children:f.jsx(Xi,{scope:t,open:i,onOpenChange:u,content:h,onContentChange:c,children:f.jsx(Zi,{scope:t,onClose:l.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:_,modal:o,children:s})})})};es.displayName=Fi;var ts=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Yi(i);return f.jsx(Pt,{...r,...s,ref:t})});ts.displayName="MenuAnchor";var is="MenuPortal",[ss,rs]=qi(is,{forceMount:void 0}),ns=e=>{const{__scopeMenu:t,forceMount:i,children:s,container:r}=e,n=Ji(is,t);return f.jsx(ss,{scope:t,forceMount:i,children:f.jsx(se,{present:i||n.open,children:f.jsx(re,{asChild:!0,container:r,children:s})})})};ns.displayName=is;var os="MenuContent",[as,ls]=qi(os),hs=l.forwardRef((e,t)=>{const i=rs(os,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Ji(os,e.__scopeMenu),o=Qi(os,e.__scopeMenu);return f.jsx($i.Provider,{scope:e.__scopeMenu,children:f.jsx(se,{present:s||n.open,children:f.jsx($i.Slot,{scope:e.__scopeMenu,children:o.modal?f.jsx(cs,{...r,ref:t}):f.jsx(ds,{...r,ref:t})})})})}),cs=l.forwardRef((e,t)=>{const i=Ji(os,e.__scopeMenu),s=l.useRef(null),r=ne(t,s);return l.useEffect(()=>{const e=s.current;if(e)return le(e)},[]),f.jsx(_s,{...e,ref:r,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})}),ds=l.forwardRef((e,t)=>{const i=Ji(os,e.__scopeMenu);return f.jsx(_s,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})}),us=Bi("MenuContent.ScrollLock"),_s=l.forwardRef((e,t)=>{const{__scopeMenu:i,loop:s=!1,trapFocus:r,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:_,onDismiss:p,disableOutsideScroll:m,...g}=e,v=Ji(os,i),S=Qi(os,i),b=Yi(i),w=Gi(i),x=Ki(i),[y,C]=l.useState(null),k=l.useRef(null),E=ne(t,k,v.onContentChange),M=l.useRef(0),N=l.useRef(""),D=l.useRef(0),R=l.useRef(null),L=l.useRef("right"),P=l.useRef(0),B=m?de:l.Fragment,T=m?{as:us,allowPinchZoom:!0}:void 0,j=e=>{var t,i;const s=N.current+e,r=x().filter(e=>!e.disabled),n=document.activeElement,o=null==(t=r.find(e=>e.ref.current===n))?void 0:t.textValue,a=function(e,t,i){const s=t.length>1&&Array.from(t).every(e=>e===t[0]),r=s?t[0]:t,n=i?e.indexOf(i):-1;let o=(a=e,l=Math.max(n,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===r.length&&(o=o.filter(e=>e!==i));const h=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return h!==i?h:void 0}(r.map(e=>e.textValue),s,o),l=null==(i=r.find(e=>e.textValue===a))?void 0:i.ref.current;!function e(t){N.current=t,window.clearTimeout(M.current),""!==t&&(M.current=window.setTimeout(()=>e(""),1e3))}(s),l&&setTimeout(()=>l.focus())};l.useEffect(()=>()=>window.clearTimeout(M.current),[]),ce();const O=l.useCallback(e=>{var t,i;return L.current===(null==(t=R.current)?void 0:t.side)&&function(e,t){if(!t)return!1;const i={x:e.clientX,y:e.clientY};return function(e,t){const{x:i,y:s}=e;let r=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const e=t[n],a=t[o],l=e.x,h=e.y,c=a.x,d=a.y;h>s!=d>s&&i<(c-l)*(s-h)/(d-h)+l&&(r=!r)}return r}(i,t)}(e,null==(i=R.current)?void 0:i.area)},[]);return f.jsx(as,{scope:i,searchRef:N,onItemEnter:l.useCallback(e=>{O(e)&&e.preventDefault()},[O]),onItemLeave:l.useCallback(e=>{var t;O(e)||(null==(t=k.current)||t.focus(),C(null))},[O]),onTriggerLeave:l.useCallback(e=>{O(e)&&e.preventDefault()},[O]),pointerGraceTimerRef:D,onPointerGraceIntentChange:l.useCallback(e=>{R.current=e},[]),children:f.jsx(B,{...T,children:f.jsx(ue,{asChild:!0,trapped:r,onMountAutoFocus:oe(n,e=>{var t;e.preventDefault(),null==(t=k.current)||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:f.jsx(_e,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:_,onDismiss:p,children:f.jsx(At,{asChild:!0,...w,dir:S.dir,orientation:"vertical",loop:s,currentTabStopId:y,onCurrentTabStopIdChange:C,onEntryFocus:oe(h,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(It,{role:"menu","aria-orientation":"vertical","data-state":zs(v.open),"data-radix-menu-content":"",dir:S.dir,...b,...g,ref:E,style:{outline:"none",...g.style},onKeyDown:oe(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,i=e.ctrlKey||e.altKey||e.metaKey,s=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!i&&s&&j(e.key));const r=k.current;if(e.target!==r)return;if(!zi.includes(e.key))return;e.preventDefault();const n=x().filter(e=>!e.disabled).map(e=>e.ref.current);Ii.includes(e.key)&&n.reverse(),function(e){const t=document.activeElement;for(const i of e){if(i===t)return;if(i.focus(),document.activeElement!==t)return}}(n)}),onBlur:oe(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(M.current),N.current="")}),onPointerMove:oe(e.onPointerMove,Fs(e=>{const t=e.target,i=P.current!==e.clientX;if(e.currentTarget.contains(t)&&i){const t=e.clientX>P.current?"right":"left";L.current=t,P.current=e.clientX}}))})})})})})})});hs.displayName=os;var fs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{role:"group",...s,ref:t})});fs.displayName="MenuGroup";var ps=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{...s,ref:t})});ps.displayName="MenuLabel";var ms="MenuItem",gs="menu.itemSelect",vs=l.forwardRef((e,t)=>{const{disabled:i=!1,onSelect:s,...r}=e,n=l.useRef(null),o=Qi(ms,e.__scopeMenu),a=ls(ms,e.__scopeMenu),h=ne(t,n),c=l.useRef(!1);return f.jsx(Ss,{...r,ref:h,disabled:i,onClick:oe(e.onClick,()=>{const e=n.current;if(!i&&e){const t=new CustomEvent(gs,{bubbles:!0,cancelable:!0});e.addEventListener(gs,e=>null==s?void 0:s(e),{once:!0}),he(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{var i;null==(i=e.onPointerDown)||i.call(e,t),c.current=!0},onPointerUp:oe(e.onPointerUp,e=>{var t;c.current||null==(t=e.currentTarget)||t.click()}),onKeyDown:oe(e.onKeyDown,e=>{const t=""!==a.searchRef.current;i||t&&" "===e.key||Ai.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});vs.displayName=ms;var Ss=l.forwardRef((e,t)=>{const{__scopeMenu:i,disabled:s=!1,textValue:r,...n}=e,o=ls(ms,i),a=Gi(i),h=l.useRef(null),c=ne(t,h),[d,u]=l.useState(!1),[_,p]=l.useState("");return l.useEffect(()=>{const e=h.current;e&&p((e.textContent??"").trim())},[n.children]),f.jsx($i.ItemSlot,{scope:i,disabled:s,textValue:r??_,children:f.jsx(Ot,{asChild:!0,...a,focusable:!s,children:f.jsx(ae.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...n,ref:c,onPointerMove:oe(e.onPointerMove,Fs(e=>{if(s)o.onItemLeave(e);else if(o.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:oe(e.onPointerLeave,Fs(e=>o.onItemLeave(e))),onFocus:oe(e.onFocus,()=>u(!0)),onBlur:oe(e.onBlur,()=>u(!1))})})})}),bs=l.forwardRef((e,t)=>{const{checked:i=!1,onCheckedChange:s,...r}=e;return f.jsx(Ns,{scope:e.__scopeMenu,checked:i,children:f.jsx(vs,{role:"menuitemcheckbox","aria-checked":Ws(i)?"mixed":i,...r,ref:t,"data-state":Hs(i),onSelect:oe(r.onSelect,()=>null==s?void 0:s(!!Ws(i)||!i),{checkForDefaultPrevented:!1})})})});bs.displayName="MenuCheckboxItem";var ws="MenuRadioGroup",[xs,ys]=qi(ws,{value:void 0,onValueChange:()=>{}}),Cs=l.forwardRef((e,t)=>{const{value:i,onValueChange:s,...r}=e,n=te(s);return f.jsx(xs,{scope:e.__scopeMenu,value:i,onValueChange:n,children:f.jsx(fs,{...r,ref:t})})});Cs.displayName=ws;var ks="MenuRadioItem",Es=l.forwardRef((e,t)=>{const{value:i,...s}=e,r=ys(ks,e.__scopeMenu),n=i===r.value;return f.jsx(Ns,{scope:e.__scopeMenu,checked:n,children:f.jsx(vs,{role:"menuitemradio","aria-checked":n,...s,ref:t,"data-state":Hs(n),onSelect:oe(s.onSelect,()=>{var e;return null==(e=r.onValueChange)?void 0:e.call(r,i)},{checkForDefaultPrevented:!1})})})});Es.displayName=ks;var Ms="MenuItemIndicator",[Ns,Ds]=qi(Ms,{checked:!1}),Rs=l.forwardRef((e,t)=>{const{__scopeMenu:i,forceMount:s,...r}=e,n=Ds(Ms,i);return f.jsx(se,{present:s||Ws(n.checked)||!0===n.checked,children:f.jsx(ae.span,{...r,ref:t,"data-state":Hs(n.checked)})})});Rs.displayName=Ms;var Ls=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return f.jsx(ae.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Ls.displayName="MenuSeparator";var Ps=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Yi(i);return f.jsx(zt,{...r,...s,ref:t})});Ps.displayName="MenuArrow";var[Bs,Ts]=qi("MenuSub"),js="MenuSubTrigger",Os=l.forwardRef((e,t)=>{const i=Ji(js,e.__scopeMenu),s=Qi(js,e.__scopeMenu),r=Ts(js,e.__scopeMenu),n=ls(js,e.__scopeMenu),o=l.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:h}=n,c={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const e=a.current;return()=>{window.clearTimeout(e),h(null)}},[a,h]),f.jsx(ts,{asChild:!0,...c,children:f.jsx(Ss,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":r.contentId,"data-state":zs(i.open),...e,ref:ee(t,r.onTriggerChange),onClick:t=>{var s;null==(s=e.onClick)||s.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),i.open||i.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,Fs(t=>{n.onItemEnter(t),t.defaultPrevented||e.disabled||i.open||o.current||(n.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{i.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,Fs(e=>{var t,s;d();const r=null==(t=i.content)?void 0:t.getBoundingClientRect();if(r){const t=null==(s=i.content)?void 0:s.dataset.side,o="right"===t,l=o?-5:5,h=r[o?"left":"right"],c=r[o?"right":"left"];n.onPointerGraceIntentChange({area:[{x:e.clientX+l,y:e.clientY},{x:h,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:h,y:r.bottom}],side:t}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>n.onPointerGraceIntentChange(null),300)}else{if(n.onTriggerLeave(e),e.defaultPrevented)return;n.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,t=>{var r;const o=""!==n.searchRef.current;e.disabled||o&&" "===t.key||Wi[s.dir].includes(t.key)&&(i.onOpenChange(!0),null==(r=i.content)||r.focus(),t.preventDefault())})})})});Os.displayName=js;var As="MenuSubContent",Is=l.forwardRef((e,t)=>{const i=rs(os,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Ji(os,e.__scopeMenu),o=Qi(os,e.__scopeMenu),a=Ts(As,e.__scopeMenu),h=l.useRef(null),c=ne(t,h);return f.jsx($i.Provider,{scope:e.__scopeMenu,children:f.jsx(se,{present:s||n.open,children:f.jsx($i.Slot,{scope:e.__scopeMenu,children:f.jsx(_s,{id:a.contentId,"aria-labelledby":a.triggerId,...r,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;o.isUsingKeyboardRef.current&&(null==(t=h.current)||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:oe(e.onFocusOutside,e=>{e.target!==a.trigger&&n.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:oe(e.onKeyDown,e=>{var t;const i=e.currentTarget.contains(e.target),s=Hi[o.dir].includes(e.key);i&&s&&(n.onOpenChange(!1),null==(t=a.trigger)||t.focus(),e.preventDefault())})})})})})});function zs(e){return e?"open":"closed"}function Ws(e){return"indeterminate"===e}function Hs(e){return Ws(e)?"indeterminate":e?"checked":"unchecked"}function Fs(e){return t=>"mouse"===t.pointerType?e(t):void 0}Is.displayName=As;var $s=es,Ks=ts,Us=ns,qs=hs,Vs=fs,Ys=ps,Gs=vs,Xs=bs,Js=Cs,Zs=Es,Qs=Rs,er=Ls,tr=Ps,ir=Os,sr=Is,rr="ContextMenu",[nr]=ie(rr,[Vi]),or=Vi(),[ar,lr]=nr(rr),hr=e=>{const{__scopeContextMenu:t,children:i,onOpenChange:s,dir:r,modal:n=!0}=e,[o,a]=l.useState(!1),h=or(t),c=te(s),d=l.useCallback(e=>{a(e),c(e)},[c]);return f.jsx(ar,{scope:t,open:o,onOpenChange:d,modal:n,children:f.jsx($s,{...h,dir:r,open:o,onOpenChange:d,modal:n,children:i})})};hr.displayName=rr;var cr="ContextMenuTrigger",dr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,disabled:s=!1,...r}=e,n=lr(cr,i),o=or(i),a=l.useRef({x:0,y:0}),h=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(c.current),[]),u=e=>{a.current={x:e.clientX,y:e.clientY},n.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.useEffect(()=>{s&&d()},[s,d]),f.jsxs(f.Fragment,{children:[f.jsx(Ks,{...o,virtualRef:h}),f.jsx(ae.span,{"data-state":n.open?"open":"closed","data-disabled":s?"":void 0,...r,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:oe(e.onContextMenu,e=>{d(),u(e),e.preventDefault()}),onPointerDown:s?e.onPointerDown:oe(e.onPointerDown,gr(e=>{d(),c.current=window.setTimeout(()=>u(e),700)})),onPointerMove:s?e.onPointerMove:oe(e.onPointerMove,gr(d)),onPointerCancel:s?e.onPointerCancel:oe(e.onPointerCancel,gr(d)),onPointerUp:s?e.onPointerUp:oe(e.onPointerUp,gr(d))})]})});dr.displayName=cr;var ur=e=>{const{__scopeContextMenu:t,...i}=e,s=or(t);return f.jsx(Us,{...s,...i})};ur.displayName="ContextMenuPortal";var _r="ContextMenuContent",fr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=lr(_r,i),n=or(i),o=l.useRef(!1);return f.jsx(qs,{...n,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var i;null==(i=e.onCloseAutoFocus)||i.call(e,t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{var i;null==(i=e.onInteractOutside)||i.call(e,t),t.defaultPrevented||r.modal||(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fr.displayName=_r;l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Vs,{...r,...s,ref:t})}).displayName="ContextMenuGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Ys,{...r,...s,ref:t})}).displayName="ContextMenuLabel";var pr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Gs,{...r,...s,ref:t})});pr.displayName="ContextMenuItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Xs,{...r,...s,ref:t})}).displayName="ContextMenuCheckboxItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Js,{...r,...s,ref:t})}).displayName="ContextMenuRadioGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Zs,{...r,...s,ref:t})}).displayName="ContextMenuRadioItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(Qs,{...r,...s,ref:t})}).displayName="ContextMenuItemIndicator";var mr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(er,{...r,...s,ref:t})});mr.displayName="ContextMenuSeparator";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(tr,{...r,...s,ref:t})}).displayName="ContextMenuArrow";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(ir,{...r,...s,ref:t})}).displayName="ContextMenuSubTrigger";function gr(e){return t=>"mouse"!==t.pointerType?e(t):void 0}l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=or(i);return f.jsx(sr,{...r,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="ContextMenuSubContent";var vr=ur,Sr=fr,br=pr,wr=mr;const xr=hr,yr=dr,Cr=l.forwardRef(({className:e,...t},i)=>f.jsx(vr,{children:f.jsx(Sr,{ref:i,className:p("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",e),...t})}));Cr.displayName=Sr.displayName;const kr=l.forwardRef(({className:e,destructive:t,...i},s)=>f.jsx(br,{ref:s,className:p("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"text-red-500 focus:text-red-500 focus:bg-red-500/10",e),...i}));kr.displayName=br.displayName;const Er=l.forwardRef(({className:e,...t},i)=>f.jsx(wr,{ref:i,className:p("-mx-1 my-1 h-px bg-border",e),...t}));function Mr({kind:e,label:t,preview:i,inserted:s,unclicked:r,onLeftClick:n,onEdit:o,onDelete:a,onShare:h,onRefresh:c,footer:d,readOnly:u,noContextMenu:_,cornerHint:m,instructionsFile:v="CLAUDE.md"}){const S=l.useRef(null),b=p("agent-prompt"===e?s?"border-green-500/50 bg-green-500/10 hover:bg-green-500/15":"border-dashed border-border hover:border-border/80 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20":r?"border-blue-500/30 bg-blue-500/15 hover:bg-blue-500/20 dark:bg-blue-500/15 dark:hover:bg-blue-500/25":"border-transparent bg-background dark:bg-muted-foreground/10 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20 hover:border-muted-foreground/30"),w="agent-prompt"===e,x=!_||c?" · 右键更多":"",y="quick-prompt"===e?`点击发送${x}`:(s?`点击从 ${v} 移除`:`点击插入 ${v}`)+x,C=f.jsxs("div",{ref:S,className:p("group relative rounded-md border text-xs transition-colors cursor-pointer select-none",b),onClick:n,title:y,children:[w&&f.jsx("span",{"aria-hidden":!0,className:p("absolute top-1.5 left-1.5 h-2 w-2 rounded-full transition-colors",s?"bg-green-500 ring-1 ring-green-500/40":"border border-muted-foreground/40 bg-transparent")}),f.jsxs("div",{className:p("py-1.5",_&&m?"pr-10":_?"pr-2":"pr-7",w?"pl-5":"pl-3"),children:[f.jsx("div",{className:"font-medium truncate",children:t}),i&&i!==t&&f.jsx("div",{className:"mt-0.5 text-muted-foreground/80 truncate font-mono",children:i}),d]}),_&&m&&f.jsx("span",{"aria-hidden":!0,className:"absolute top-1.5 right-2 text-[10px] leading-none font-mono tabular-nums text-muted-foreground/60 pointer-events-none",children:m}),!_&&f.jsx("button",{onClick:e=>{e.stopPropagation(),e.preventDefault();const t=S.current;if(!t)return;const i=t.getBoundingClientRect(),s=new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:i.right-8,clientY:i.top+i.height/2,button:2});t.dispatchEvent(s)},className:p("absolute top-1 right-1 p-0.5 rounded transition-opacity","md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100","hover:bg-muted-foreground/10 focus-visible:bg-muted-foreground/10","text-muted-foreground hover:text-foreground"),title:"更多","aria-label":"更多操作",children:f.jsx(ei,{className:"h-3.5 w-3.5"})})]});return!(!c&&(_||!o&&!a&&!h))?f.jsxs(xr,{children:[f.jsx(yr,{asChild:!0,children:C}),f.jsxs(Cr,{children:[c&&f.jsxs(kr,{onSelect:c,children:[f.jsx(L,{className:"h-3.5 w-3.5"}),"更新"]}),!_&&!u&&o&&a&&f.jsxs(f.Fragment,{children:[c&&f.jsx(Er,{}),f.jsxs(kr,{onSelect:o,children:[f.jsx(g,{className:"h-3.5 w-3.5"}),"编辑"]}),f.jsxs(kr,{destructive:!0,onSelect:a,children:[f.jsx(R,{className:"h-3.5 w-3.5"}),"删除"]}),h&&f.jsx(Er,{})]}),!_&&h&&f.jsxs(kr,{onSelect:h,children:[f.jsx(fe,{className:"h-3.5 w-3.5"}),"共享到 ccweb-hub"]})]})]}):f.jsx("div",{onContextMenu:e=>e.preventDefault(),children:C})}function Nr({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const _=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return f.jsx(xe,{open:e,onOpenChange:t,modal:!1,children:f.jsxs(ye,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:r}),f.jsx(Ee,{children:"左键点击卡片会把此命令发送到 CLI。"})]}),f.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Me,{htmlFor:"qp-label",children:"标签"}),f.jsx(K,{id:"qp-label",placeholder:"显示名(可选,默认用命令文本)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),f.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[f.jsx(Me,{htmlFor:"qp-command",children:"命令"}),f.jsx("textarea",{id:"qp-command",placeholder:"输入要发送的命令...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),_())}})]})]}),f.jsxs(Ne,{className:"flex items-center justify-between sm:justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"取消"}),f.jsx(H,{onClick:_,disabled:!h.trim(),children:"保存"})]})]})]})})}function Dr({title:e,count:t,onAdd:i,children:s}){return f.jsxs("div",{className:"px-2 py-2",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[f.jsx("span",{children:e}),f.jsxs("span",{className:"text-muted-foreground/60",children:["(",t,")"]})]}),f.jsx("button",{onClick:i,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:f.jsx($,{className:"h-3 w-3"})})]}),s]})}function Rr({projectId:e,onSend:t}){const i=a(),[s,r]=l.useState([]),[n,o]=l.useState([]),h=M(),c=h.get(e),[d,u]=l.useState({open:!1}),[_,p]=l.useState(c.shareHubOpen),[m,g]=l.useState(c.shareHubLabel),[v,S]=l.useState(c.shareHubCommand),b=l.useCallback(t=>{r(e=>{const i=e.findIndex(e=>e.id===t);if(i<0||e[i].used)return e;const s=[...e];return s[i]={...s[i],used:!0},s}),pe(e,t,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})},[e]);l.useEffect(()=>{me(e).then(r).catch(()=>r([]))},[e]),l.useEffect(()=>{ge().then(o).catch(()=>o([]))},[]);const w=l.useCallback(e=>{const t=[],i=new Set;let s=e;const r=[];for(;s&&!i.has(s.id);)i.add(s.id),r.unshift(s),s=s.parentId?n.find(e=>e.id===s.parentId):void 0;for(const n of r)t.push(n.command);return t},[n]),x=l.useCallback(async e=>{const i=w(e);for(const s of i)try{await Promise.resolve(t(s+"\r"))}catch{return}},[w,t]),y=e=>u({open:!0,mode:"create",scope:e}),C=(t,i)=>{g(t),S(i),p(!0),h.setShareHub(e,!0,t,i)};return f.jsxs("div",{className:"h-full flex flex-col text-foreground overflow-hidden",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Quick Prompts"}),f.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片发送命令到 CLI;新建的命令在首次点击前以浅蓝色标识"})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[f.jsx(Dr,{title:"项目",count:s.length,onAdd:()=>y("project"),children:0===s.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无项目命令"}):f.jsx("div",{className:"space-y-1.5",children:s.map(s=>f.jsx(Mr,{kind:"quick-prompt",label:s.label,preview:s.label!==s.command?s.command:"",unclicked:!s.used,onLeftClick:()=>(e=>{t(e.command+"\r"),b(e.id)})(s),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}))(s),onDelete:()=>{(async t=>{if(await i({title:"删除项目快捷 Prompt",description:`确认删除「${t.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await be(e,t.id),r(e=>e.filter(e=>e.id!==t.id))}catch(s){console.error("Failed to delete shortcut:",s)}})(s)},onShare:()=>C(s.label,s.command)},s.id))})}),f.jsx("div",{className:"h-px bg-border mx-2"}),f.jsx(Dr,{title:"全局",count:n.length,onAdd:()=>y("global"),children:0===n.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无全局命令"}):f.jsx("div",{className:"space-y-1.5",children:n.map(e=>{var t;const s=e.parentId?null==(t=n.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return f.jsx(Mr,{kind:"quick-prompt",label:e.label,preview:s?"":e.label!==e.command?e.command:"",onLeftClick:()=>x(e),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}))(e),onDelete:()=>{(async e=>{const t=n.filter(t=>t.parentId===e.id);if(await i({title:"删除全局快捷 Prompt",description:t.length>0?`「${e.label}」被 ${t.length} 个其他全局命令继承。删除后这些命令的继承会断链。确认删除?`:`确认删除「${e.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await we(e.id),o(t=>t.filter(t=>t.id!==e.id))}catch(s){console.error("Failed to delete global shortcut:",s)}})(e)},onShare:()=>C(e.label,e.command),footer:s?f.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[f.jsx(ve,{className:"h-2.5 w-2.5 text-muted-foreground"}),f.jsxs("span",{className:"text-muted-foreground truncate",children:["继承: ",s,"(继承链仅可在 Dashboard 编辑)"]})]}):null},e.id)})})})]}),f.jsx(Nr,{open:d.open,onOpenChange:e=>{e||u({open:!1})},initialLabel:d.open&&"edit"===d.mode?d.label:"",initialCommand:d.open&&"edit"===d.mode?d.command:"",title:d.open?"create"===d.mode?`新建${"global"===d.scope?"全局":"项目"}命令`:"编辑命令":"",onSave:(t,i)=>{(async(t,i)=>{if(d.open)try{if("create"===d.mode)if("global"===d.scope){const e=await De({label:t,command:i});o(t=>[...t,e])}else{const s=await Re(e,{label:t,command:i});r(e=>[...e,s])}else if("global"===d.scope){const e=n.find(e=>e.id===d.id),s=await Le(d.id,{label:t,command:i,parentId:(null==e?void 0:e.parentId)??null});o(e=>e.map(e=>e.id===s.id?s:e))}else{const s=await Pe(e,d.id,{label:t,command:i});r(e=>e.map(e=>e.id===s.id?s:e))}}catch(s){console.error("Failed to save shortcut:",s)}})(t,i)}}),f.jsx(Se,{open:_,onOpenChange:t=>{p(t),t||h.setShareHub(e,!1)},kind:"quick-prompt",label:m,content:v})]})}Er.displayName=wr.displayName;function Lr({open:e,onOpenChange:t,title:i,initialLabel:s,initialCommand:r,onSave:n,instructionsFile:o="CLAUDE.md"}){const[a,h]=l.useState(s),[c,d]=l.useState(r),[u,_]=l.useState(!0);l.useEffect(()=>{e&&(h(s),d(r),_(!0))},[e,s,r]);const m=a.trim(),g=c.trim(),v=m.length>100,S=g.length>8e3,b=g.length>0&&m.length>0&&!v&&!S,w=()=>{b&&(n(m,c),t(!1))};return f.jsx(xe,{open:e,onOpenChange:t,modal:!1,children:f.jsxs(ye,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!u&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),_(!1)},onClick:()=>_(!0),children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:i}),f.jsxs(Ee,{children:["This prompt can be clicked once in the sidebar to insert into ",o,", and clicked again to remove (by exact text match)."]})]}),f.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Me,{htmlFor:"prompt-label",children:"Label"}),f.jsxs("span",{className:p("text-xs text-muted-foreground",v&&"text-red-500"),children:[m.length," / ",100]})]}),f.jsx(K,{id:"prompt-label",placeholder:"A short name for this prompt",value:a,onChange:e=>h(e.target.value),className:"text-base",autoFocus:!0})]}),f.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx(Me,{htmlFor:"prompt-command",children:"Prompt"}),f.jsxs("span",{className:p("text-xs text-muted-foreground",S&&"text-red-500"),children:[g.length," / ",8e3]})]}),f.jsx("textarea",{id:"prompt-command",placeholder:`The exact text that will be appended to ${o}...`,value:c,onChange:e=>d(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-sm leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),w())}})]})]}),f.jsxs(Ne,{className:"flex items-center justify-between sm:justify-between",children:[f.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),f.jsx(H,{onClick:w,disabled:!b,children:"Save"})]})]})]})})}function Pr({projectId:e}){const t=a(),[i,s]=l.useState([]),[r,n]=l.useState([]),[o,h]=l.useState("CLAUDE.md"),[c,d]=l.useState(!0),[u,p]=l.useState({open:!1}),[m,g]=l.useState({open:!1,label:"",content:""}),v=l.useCallback(async()=>{try{const t=await Be(e);s(t.global),n(t.project),t.instructionsFilename&&h(t.instructionsFilename)}catch(t){_.error(`加载提示词失败: ${t.message}`)}finally{d(!1)}},[e]);l.useEffect(()=>{d(!0),v()},[v]);const S=l.useRef(new Set),b=l.useCallback(async(t,i)=>{if(S.current.has(i.id))return;S.current.add(i.id);const r=i.inserted?"remove":"insert",a=e=>e.map(e=>e.id===i.id?{...e,inserted:!e.inserted}:e);"global"===t?s(a):n(a);try{const t=await Te(e,i.command,r);if("remove"===r&&!1===t.changed)return"not-found"===t.reason?_.error(`${o} 中找不到该提示词的精确文本,请自行编辑 ${o} 移除。`):_.warning(`该提示词当前不在 ${o} 中(可能被手动编辑过),已重新同步状态。`),void v();v()}catch(l){_.error(`操作失败: ${l.message}`),"global"===t?s(a):n(a)}finally{S.current.delete(i.id)}},[e,v,o]),w=l.useCallback(async(t,i,s,r,n)=>{try{if("create"===t)"global"===i?await je({label:r,command:n}):await Oe(e,{label:r,command:n}),_.success("已添加");else{if(!s)return;"global"===i?await Ae(s,{label:r,command:n}):await Ie(e,s,{label:r,command:n}),_.success("已更新")}v()}catch(o){_.error(`保存失败: ${o.message}`)}},[e,v]),x=l.useCallback(async(i,s)=>{const r=s.inserted?`此提示词目前已插入当前项目的 ${o}。\n\n删除后它会在 ${o} 中成为"孤儿文本"——仅删除提示词记录,不会自动从 ${o} 移除。\n\n确认删除?`:"确认删除此提示词?此操作不可撤销。";if(await t({title:"删除提示词",description:r,destructive:!0,confirmLabel:"删除"}))try{"global"===i?await ze(s.id):await We(e,s.id),_.success("已删除"),v()}catch(n){_.error(`删除失败: ${n.message}`)}},[e,v,t,o]),y=l.useCallback(e=>{g({open:!0,label:e.label,content:e.command})},[]);return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent Prompts"}),f.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["点击卡片插入 / 移出当前项目的 ",o,";左上角绿点表示已插入"]})]}),f.jsx(Br,{title:"项目",count:r.length,loading:c,prompts:r,emptyText:"暂无项目提示词",instructionsFile:o,onAdd:()=>p({open:!0,mode:"create",scope:"project"}),onToggle:e=>{b("project",e)},onEdit:e=>p({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}),onDelete:e=>{x("project",e)},onShare:y}),f.jsx("div",{className:"h-px bg-border mx-2"}),f.jsx(Br,{title:"全局",count:i.length,loading:c,prompts:i,emptyText:"暂无全局提示词",instructionsFile:o,onAdd:()=>p({open:!0,mode:"create",scope:"global"}),onToggle:e=>{b("global",e)},onEdit:e=>p({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}),onDelete:e=>{x("global",e)},onShare:y}),f.jsx(Lr,{open:u.open,onOpenChange:e=>{e||p({open:!1})},title:!1===u.open?"":"create"===u.mode?`新建${"global"===u.scope?"全局":"项目"}提示词`:`编辑${"global"===u.scope?"全局":"项目"}提示词`,initialLabel:u.open&&"edit"===u.mode?u.label:"",initialCommand:u.open&&"edit"===u.mode?u.command:"",instructionsFile:o,onSave:(e,t)=>{if(!u.open)return;const i="edit"===u.mode?u.id:null;w(u.mode,u.scope,i,e,t)}}),f.jsx(Se,{open:m.open,onOpenChange:e=>g(t=>({...t,open:e})),kind:"agent-prompt",label:m.label,content:m.content})]})}function Br({title:e,count:t,loading:i,prompts:s,emptyText:r,onAdd:n,onToggle:o,onEdit:a,onDelete:l,onShare:h,instructionsFile:c}){return f.jsxs("div",{className:"px-2 py-2",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[f.jsx("span",{children:e}),f.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),f.jsx("button",{onClick:n,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:f.jsx($,{className:"h-3 w-3"})})]}),i?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"加载中…"}):0===s.length?f.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:r}):f.jsx("div",{className:"space-y-1.5",children:s.map(e=>{const t=e.command.split("\n").find(e=>e.trim())??e.command.trim();return f.jsx(Mr,{kind:"agent-prompt",label:e.label,preview:t,inserted:e.inserted,instructionsFile:c,onLeftClick:()=>o(e),onEdit:()=>a(e),onDelete:()=>l(e),onShare:()=>h(e)},e.id)})})]})}function Tr({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(null),[n,o]=l.useState("CLAUDE.md"),[a,h]=l.useState(!0),[c,d]=l.useState(!1),u=l.useRef(new Set),m=l.useCallback(async()=>{h(!0);try{const t=await He(e);i(t.items),r(t.claudeMdLineCount),t.instructionsFilename&&o(t.instructionsFilename)}catch(t){_.error(`加载失败: ${t.message}`)}finally{h(!1)}},[e]);l.useEffect(()=>{m()},[m]);const g=l.useCallback(async t=>{if(u.current.has(t.filename))return;u.current.add(t.filename),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:!e.inserted}:e));const s=t.inserted?"remove":"insert";try{const n=await Fe(e,t.filename,s);if(!n.ok)return _.error("操作失败"+(n.reason?`(${n.reason})`:"")),void m();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:n.inserted}:e)),"number"==typeof n.claudeMdLineCount&&r(n.claudeMdLineCount),"insert"===s&&"refreshed"===n.reason&&_.info(`${t.name} 已更新(文件内容有变化)`)}catch(n){_.error(`操作失败: ${n.message}`),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:t.inserted}:e))}finally{u.current.delete(t.filename)}},[e,m]),v=l.useCallback(async()=>{if(c)return;const s=t.filter(e=>e.inserted);if(0===s.length)return void _.info("没有已插入的 memory 卡片");d(!0);let n=0,o=0;for(const t of s)if(u.current.has(t.filename))o++;else{u.current.add(t.filename);try{const s=await Fe(e,t.filename,"insert");s.ok?(i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:s.inserted}:e)),"number"==typeof s.claudeMdLineCount&&r(s.claudeMdLineCount),n++):o++}catch{o++}finally{u.current.delete(t.filename)}}d(!1),0===o?_.success(`已从磁盘更新 ${n} 个 memory 卡片`):_.error(`${n} 个更新成功,${o} 个失败`)},[e,t,c]),S=l.useCallback(async t=>{if(!u.current.has(t.filename))if(t.inserted){u.current.add(t.filename);try{const s=await Fe(e,t.filename,"insert");if(!s.ok)return _.error("更新失败"+(s.reason?`(${s.reason})`:"")),void m();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:s.inserted}:e)),"number"==typeof s.claudeMdLineCount&&r(s.claudeMdLineCount),_.success(`${t.name} 已从磁盘重新加载`)}catch(s){_.error(`更新失败: ${s.message}`)}finally{u.current.delete(t.filename)}}else _.info("卡片未插入,无需更新")},[e,m]);return f.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[f.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Memory Prompts"}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:()=>{v()},disabled:c||!t.some(e=>e.inserted),className:p("p-0.5 rounded text-muted-foreground transition-colors","hover:text-foreground hover:bg-muted-foreground/10","disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-muted-foreground"),title:`把所有已插入卡片的内容从磁盘重新加载到 ${n}`,children:f.jsx(Zt,{className:p("h-3.5 w-3.5",c&&"animate-spin")})}),f.jsx("button",{onClick:()=>{m()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"刷新(重新扫描 .ccweb/memory/)",children:f.jsx(L,{className:p("h-3.5 w-3.5",a&&"animate-spin")})})]})]}),f.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["来自 ",f.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 的文件,点击插入 / 移除 ",n,"(以",f.jsx("code",{className:"text-[11px]",children:" START 名 / END 名 "}),"包裹)"]}),null!==s&&f.jsxs("p",{className:"mt-0.5 text-[11px] text-muted-foreground/60 font-mono tabular-nums",children:[n,": ",s," 行"]})]}),f.jsx("div",{className:"px-2 py-2 flex-1 min-h-0",children:a&&0===t.length?f.jsx("div",{className:"px-1 py-6 text-xs text-muted-foreground/60 text-center",children:"加载中…"}):0===t.length?f.jsxs("div",{className:"px-1 py-8 text-xs text-muted-foreground/60 flex flex-col items-center gap-2",children:[f.jsx(Yt,{className:"h-5 w-5"}),f.jsxs("div",{className:"text-center leading-relaxed",children:["暂无 memory 文件",f.jsx("br",{}),"新建 ",f.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 文件后点刷新"]})]}):f.jsx("div",{className:"space-y-1.5",children:t.map(e=>f.jsx(Mr,{kind:"agent-prompt",noContextMenu:!0,label:e.name,preview:e.preview,inserted:e.inserted,instructionsFile:n,cornerHint:`${e.lineCount} 行`,onLeftClick:()=>{g(e)},onRefresh:e.inserted?()=>{S(e)}:void 0},e.filename))})})]})}function jr({projectId:e,onSend:t}){const[i,s]=Q(y.rightPanelTab,"shortcuts"),r="prompts"===i?"prompts":"memory"===i?"memory":"shortcuts";return f.jsxs(Mt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-border",children:[f.jsx(Rt,{value:"shortcuts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Rr,{projectId:e,onSend:t})}),f.jsx(Rt,{value:"prompts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Pr,{projectId:e})}),f.jsx(Rt,{value:"memory",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:f.jsx(Tr,{projectId:e})})]}),f.jsxs(Nt,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-l border-border rounded-none p-1 gap-1"),children:[f.jsx(Dt,{value:"shortcuts",title:"Quick Prompts (快捷 Prompts)","aria-label":"Quick Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx($e,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"prompts",title:"Agent Prompts","aria-label":"Agent Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Ke,{className:"h-3.5 w-3.5"})}),f.jsx(Dt,{value:"memory",title:"Memory Prompts (.ccweb/memory/*.md)","aria-label":"Memory Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:f.jsx(Yt,{className:"h-3.5 w-3.5"})})]})]})}var Or=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const i=Ue(`Primitive.${t}`),s=l.forwardRef((e,s)=>{const{asChild:r,...n}=e,o=r?i:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),f.jsx(o,{...n,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),Ar="horizontal",Ir=["horizontal","vertical"],zr=l.forwardRef((e,t)=>{const{decorative:i,orientation:s=Ar,...r}=e,n=function(e){return Ir.includes(e)}(s)?s:Ar,o=i?{role:"none"}:{"aria-orientation":"vertical"===n?n:void 0,role:"separator"};return f.jsx(Or.div,{"data-orientation":n,...o,...r,ref:t})});zr.displayName="Separator";var Wr=zr;const Hr=l.forwardRef(({className:e,orientation:t="horizontal",decorative:i=!0,...s},r)=>f.jsx(Wr,{ref:r,decorative:i,orientation:t,className:p("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...s}));Hr.displayName=Wr.displayName;const Fr=[{tool:"claude",label:"Claude Code",supportsContinue:!0},{tool:"codex",label:"Codex",supportsContinue:!0},{tool:"gemini",label:"Gemini CLI",supportsContinue:!0},{tool:"opencode",label:"OpenCode",supportsContinue:!1},{tool:"qwen",label:"Qwen Code",supportsContinue:!1},{tool:"terminal",label:"Bare Shell",supportsContinue:!1}];function $r(e){var t;return(null==(t=Fr.find(t=>t.tool===e))?void 0:t.label)??String(e??"")}function Kr(e){var t;return(null==(t=Fr.find(t=>t.tool===e))?void 0:t.supportsContinue)??!1}function Ur({open:e,onOpenChange:t,currentCliTool:i,loading:s,onConfirm:r}){const{t:n}=qe(),[o,a]=l.useState(null),[h,c]=l.useState(!1),[d,u]=l.useState(null);l.useEffect(()=>{e&&(a(null),c(!1),u(null))},[e]),l.useEffect(()=>{o&&!Kr(o)&&c(!1)},[o]);const _=!!o&&Kr(o);return f.jsx(xe,{open:e,onOpenChange:t,children:f.jsxs(ye,{className:"max-w-lg",children:[f.jsxs(Ce,{children:[f.jsx(ke,{children:n("switch_cli.title")}),f.jsx(Ee,{children:n("switch_cli.description",{current:$r(i)})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-sm font-medium",children:n("switch_cli.target_label")}),f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Fr.map(e=>{const t=e.tool===i,r=e.tool===o;return f.jsxs("button",{type:"button",disabled:t||s,onClick:()=>a(e.tool),className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",r?"border-primary bg-accent":"border-border hover:bg-accent/50",t&&"opacity-50 cursor-not-allowed"),children:[f.jsx("div",{className:"font-medium",children:e.label}),f.jsx("div",{className:"text-xs text-muted-foreground",children:t?n("switch_cli.tag_current"):e.supportsContinue?n("switch_cli.tag_supports_continue"):n("switch_cli.tag_no_continue")})]},e.tool)})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-sm font-medium",children:n("switch_cli.mode_label")}),f.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[f.jsxs("button",{type:"button",disabled:s,onClick:()=>c(!1),className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",h?"border-border hover:bg-accent/50":"border-primary bg-accent"),children:[f.jsx("div",{className:"font-medium",children:n("switch_cli.mode_fresh")}),f.jsx("div",{className:"text-xs text-muted-foreground",children:n("switch_cli.mode_fresh_hint")})]}),f.jsxs("button",{type:"button",disabled:s||!o||!_,onClick:()=>c(!0),title:o&&!_?n("switch_cli.mode_continue_unsupported",{tool:$r(o)}):void 0,className:p("text-left px-3 py-2 rounded-md border text-sm transition-colors",h?"border-primary bg-accent":"border-border hover:bg-accent/50",(!o||!_)&&"opacity-50 cursor-not-allowed"),children:[f.jsx("div",{className:"font-medium",children:n("switch_cli.mode_continue")}),f.jsx("div",{className:"text-xs text-muted-foreground",children:o&&!_?n("switch_cli.mode_continue_unsupported",{tool:$r(o)}):n("switch_cli.mode_continue_hint")})]})]})]}),d&&f.jsx("div",{className:"text-xs text-red-500 break-words",children:d})]}),f.jsxs(Ne,{children:[f.jsx(H,{variant:"outline",onClick:()=>t(!1),disabled:s,children:n("switch_cli.cancel")}),f.jsx(H,{onClick:()=>{(async()=>{if(o){u(null);try{await r(o,h)}catch(e){u(e instanceof Error?e.message:String(e))}}})()},disabled:!o||s,children:n(s?"switch_cli.confirming":"switch_cli.confirm")})]})]})})}function qr({status:e}){return f.jsxs("span",{className:p("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[f.jsx("span",{className:p("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Vr({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const{t:c}=qe(),d=Ve(),[u,m]=l.useState(!1),[g,w]=l.useState(!1),[x,y]=l.useState(0),[C,k]=l.useState(!1),[E,M]=l.useState(!1),[N,D]=l.useState(!1),[R,P]=l.useState(!1);Ye({onStart:e=>{e.projectId===t&&y(0)},onProgress:e=>{e.projectId===t&&y(e.filesTransferred)},onDone:e=>{e.projectId===t&&y(0)}}),l.useEffect(()=>{const e=()=>M(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const B=Ge(e=>e.updateProject);return f.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:f.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[f.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>d("/"),children:f.jsx(Xe,{className:"h-4 w-4"})}),f.jsx(Hr,{orientation:"vertical",className:"h-5 mx-0.5"}),f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",i&&"bg-accent"),onClick:n,title:c("project_header.toggle_file_tree"),children:f.jsx(ii,{className:"h-4 w-4"})}),f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",s&&"bg-accent"),onClick:o,title:c("project_header.toggle_right_panel"),children:f.jsx(si,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&f.jsx(H,{variant:"ghost",size:"icon",className:p("h-7 w-7",r&&"bg-accent"),onClick:a,title:c("project_header.toggle_chat_overlay"),children:f.jsx(Qt,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-2",children:[f.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),f.jsx(qr,{status:e.status}),f.jsx(Je,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),f.jsxs("button",{type:"button",onClick:()=>D(!0),disabled:R,title:`${c("project_header.switch_cli_title")} (${$r(e.cliTool)})`,className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full border border-border bg-background hover:bg-accent transition-colors disabled:opacity-50 flex-shrink-0",children:[f.jsx(L,{className:"h-3 w-3"}),f.jsx("span",{className:"font-medium hidden sm:inline",children:$r(e.cliTool)})]}),f.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),f.jsx(Ze,{}),f.jsx(Qe,{}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:c(E?"project_header.fullscreen_exit":"project_header.fullscreen_enter"),children:E?f.jsx(v,{className:"h-3.5 w-3.5"}):f.jsx(S,{className:"h-3.5 w-3.5"})}),f.jsx(Hr,{orientation:"vertical",className:"h-5 mx-0.5"}),g?f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(g&&!C){k(!0);try{(await it(t)).cancelled?_.info(c("project_header.sync_cancelled")):_.error(c("project_header.sync_cancel_failed"))}catch(e){_.error(e instanceof Error?e.message:c("project_header.sync_cancel_failed")),k(!1)}}})()},disabled:C,title:c("project_header.sync_cancel_title"),children:[C?f.jsx(et,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):f.jsx(b,{className:"h-3.5 w-3.5 mr-1.5"}),f.jsx("span",{className:"tabular-nums",children:x>0?c("project_header.sync_progress_label",{files:x}):c("project_header.sync_progress_label_empty")})]}):f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(!g){w(!0),y(0);try{const e=await st(t);e.skipped?_.info(c("project_header.sync_skipped")):e.ok?_.success(c("project_header.sync_success",{files:e.filesTransferred,seconds:Math.round(e.durationMs/1e3)})):"cancelled"===e.reason||_.error(e.reason?c("project_header.sync_failed_with_reason",{reason:e.reason}):c("project_header.sync_failed"))}catch(e){_.error(e instanceof Error?e.message:c("project_header.sync_failed"))}finally{w(!1),y(0),k(!1)}}})()},title:c("project_header.sync_button_title"),children:[f.jsx(tt,{className:"h-3.5 w-3.5 mr-1.5"}),c("project_header.sync")]}),f.jsx(Ur,{open:N,onOpenChange:e=>{R||D(e)},currentCliTool:e.cliTool,loading:R,onConfirm:async(t,i)=>{P(!0);try{const s=await rt(e.id,t,i);h(s),B(s),D(!1),_.success(c("switch_cli.switched_toast",{tool:$r(t)}))}catch(s){const e=s instanceof Error?s.message:String(s);throw _.error(c("switch_cli.switch_failed",{reason:e})),s}finally{P(!1)}}}),"stopped"===e.status&&f.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{m(!0);try{h(await nt(e.id))}catch(t){console.error(t)}finally{m(!1)}})()},disabled:u,children:[f.jsx(ri,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
|
|
15
15
|
/**
|
|
16
16
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
17
17
|
* @license MIT
|
|
@@ -23,4 +23,4 @@ var e,t,i,s,r,n;import{c as o,u as a,r as l,a as h,g as c,b as d,w as u,t as _,j
|
|
|
23
23
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
24
24
|
* http://bellard.org/jslinux/
|
|
25
25
|
* Copyright (c) 2011 Fabrice Bellard
|
|
26
|
-
*/var qr=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,Yr=(e,t,i,s)=>{for(var r,n=s>1?void 0:s?Vr(t,i):t,o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s?r(t,i,n):r(n))||n);return s&&n&&qr(t,i,n),n},Gr=(e,t)=>(i,s)=>t(i,s,e),Xr="Terminal input",Jr=()=>Xr,Zr=e=>Xr=e,Qr="Too much output to announce, navigate to rows manually to read",en=()=>Qr,tn=e=>Qr=e;function sn(e,t,i,s){e=function(e,t){return t?"[200~"+e+"[201~":e}(e=function(e){return e.replace(/\r?\n/g,"\r")}(e),i.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=""}function rn(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function nn(e,t,i,s,r){rn(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function on(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function an(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let t=e[r];t>65535?(t-=65536,s+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):s+=String.fromCharCode(t)}return s}var ln=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let i=e.charCodeAt(r++);56320<=i&&i<=57343?t[s++]=1024*(this._interim-55296)+i-56320+65536:(t[s++]=this._interim,t[s++]=i),this._interim=0}for(let n=r;n<i;++n){let r=e.charCodeAt(n);if(55296<=r&&r<=56319){if(++n>=i)return this._interim=r,s;let o=e.charCodeAt(n);56320<=o&&o<=57343?t[s++]=1024*(r-55296)+o-56320+65536:(t[s++]=r,t[s++]=o);continue}65279!==r&&(t[s++]=r)}return s}},hn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s,r,n,o,a=0,l=0,h=0;if(this.interim[0]){let s=!1,r=this.interim[0];r&=192==(224&r)?31:224==(240&r)?15:7;let n,o=0;for(;(n=63&this.interim[++o])&&o<4;)r<<=6,r|=n;let l=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,c=l-o;for(;h<c;){if(h>=i)return 0;if(n=e[h++],128!=(192&n)){h--,s=!0;break}this.interim[o++]=n,r<<=6,r|=63&n}s||(2===l?r<128?h--:t[a++]=r:3===l?r<2048||r>=55296&&r<=57343||65279===r||(t[a++]=r):r<65536||r>1114111||(t[a++]=r)),this.interim.fill(0)}let c=i-4,d=h;for(;d<i;){for(;!(!(d<c)||128&(s=e[d])||128&(r=e[d+1])||128&(n=e[d+2])||128&(o=e[d+3]));)t[a++]=s,t[a++]=r,t[a++]=n,t[a++]=o,d+=4;if(s=e[d++],s<128)t[a++]=s;else if(192==(224&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(l=(31&s)<<6|63&r,l<128){d--;continue}t[a++]=l}else if(224==(240&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[d++],128!=(192&n)){d--;continue}if(l=(15&s)<<12|(63&r)<<6|63&n,l<2048||l>=55296&&l<=57343||65279===l)continue;t[a++]=l}else if(240==(248&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[d++],128!=(192&n)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,this.interim[2]=n,a;if(o=e[d++],128!=(192&o)){d--;continue}if(l=(7&s)<<18|(63&r)<<12|(63&n)<<6|63&o,l<65536||l>1114111)continue;t[a++]=l}}return a}},cn=" ",dn=class e{constructor(){this.fg=0,this.bg=0,this.extended=new un}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},un=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},_n=class e extends dn{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new un,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?on(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=1024*(i-55296)+s-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fn="di$target",pn="di$dependencies",mn=new Map;function gn(e){if(mn.has(e))return mn.get(e);let t=function(e,i,s){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[fn]===t?t[pn].push({id:e,index:i}):(t[pn]=[{id:e,index:i}],t[fn]=t)}(t,e,s)};return t._id=e,mn.set(e,t),t}var vn=gn("BufferService"),Sn=gn("CoreMouseService"),bn=gn("CoreService"),wn=gn("CharsetService"),xn=gn("InstantiationService"),yn=gn("LogService"),Cn=gn("OptionsService"),kn=gn("OscLinkService"),En=gn("UnicodeService"),Mn=gn("DecorationService"),Nn=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var i;let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void t(void 0);let r=[],n=this._optionsService.rawOptions.linkHandler,o=new _n,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(-1!==h||s.hasContent(d)){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId){if(-1===h){h=d,l=o.extended.urlId;continue}c=o.extended.urlId!==l}else-1!==h&&(c=!0);if(c||-1!==h&&d===a-1){let t=null==(i=this._oscLinkService.getLinkData(l))?void 0:i.uri;if(t){let i={start:{x:h+1,y:e},end:{x:d+(c||d!==a-1?0:1),y:e}},s=!1;if(!(null==n?void 0:n.allowNonHttpProtocols))try{let e=new URL(t);["http:","https:"].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:t,range:i,activate:(e,t)=>n?n.activate(e,t,i):Dn(e,t),hover:(e,t)=>{var s;return null==(s=null==n?void 0:n.hover)?void 0:s.call(n,e,t,i)},leave:(e,t)=>{var s;return null==(s=null==n?void 0:n.leave)?void 0:s.call(n,e,t,i)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};function Dn(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}Nn=Yr([Gr(0,vn),Gr(1,Cn),Gr(2,kn)],Nn);var Rn=gn("CharSizeService"),Ln=gn("CoreBrowserService"),Pn=gn("MouseService"),Bn=gn("RenderService"),Tn=gn("SelectionService"),jn=gn("CharacterJoinerService"),On=gn("ThemeService"),An=gn("LinkProviderService"),In=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Un.isErrorNoTelemetry(e)?new Un(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function zn(e){(function(e){return e instanceof Hn||e instanceof Error&&e.name===Wn&&e.message===Wn})(e)||In.onUnexpectedError(e)}var Wn="Canceled";var Hn=class extends Error{constructor(){super(Wn),this.name=this.message}};var Fn,$n,Kn,Un=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},qn=class e extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function Vn(e,t=0){return e[e.length-(1+t)]}function Yn(e,t){let i,s=this,r=!1;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}function Gn(e){if(Kn.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(zo){t.push(zo)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Xn(e){return{dispose:Yn(()=>{e()})}}($n=Fn||(Fn={})).isLessThan=function(e){return e<0},$n.isLessThanOrEqual=function(e){return e<=0},$n.isGreaterThan=function(e){return e>0},$n.isNeitherLessOrGreaterThan=function(e){return 0===e},$n.greaterThan=1,$n.lessThan=-1,$n.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*s(e){yield e}e.empty=function(){return i},e.single=s,e.wrap=function(e){return t(e)?e:s(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let s of e)if(t(s,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let s of e)yield t(s,i++)},e.flatMap=function*(e,t){let i=0;for(let s of e)yield*t(s,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let s=i;for(let r of e)s=t(s,r);return s},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let s=[];if(0===i)return[s,t];let r=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=r.next();if(t.done)return[s,e.empty()];s.push(t.value)}return[s,{[Symbol.iterator]:()=>r}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(Kn||(Kn={}));var Jn=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Gn(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?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};Jn.DISABLE_DISPOSED_WARNING=!1;var Zn=Jn,Qn=class{constructor(){this._store=new Zn,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)}};Qn.None=Object.freeze({dispose(){}});var eo=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},to="object"==typeof window?window:globalThis,io=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};io.Undefined=new io(void 0);var so,ro=io,no=class{constructor(){this._first=ro.Undefined,this._last=ro.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ro.Undefined}clear(){let e=this._first;for(;e!==ro.Undefined;){let t=e.next;e.prev=ro.Undefined,e.next=ro.Undefined,e=t}this._first=ro.Undefined,this._last=ro.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new ro(e);if(this._first===ro.Undefined)this._first=i,this._last=i;else if(t){let e=this._last;this._last=i,i.prev=e,e.next=i}else{let e=this._first;this._first=i,i.next=e,e.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==ro.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ro.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ro.Undefined&&e.next!==ro.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ro.Undefined&&e.next===ro.Undefined?(this._first=ro.Undefined,this._last=ro.Undefined):e.next===ro.Undefined?(this._last=this._last.prev,this._last.next=ro.Undefined):e.prev===ro.Undefined&&(this._first=this._first.next,this._first.prev=ro.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ro.Undefined;)yield e.element,e=e.next}},oo=globalThis.performance&&"function"==typeof globalThis.performance.now,ao=class e{static create(t){return new e(t)}constructor(e){this._now=oo&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,s)=>{let r,n=!1;return r=e(e=>{if(!n)return r?r.dispose():n=!0,t.call(i,e)},null,s),n&&r.dispose(),r}}function i(e,t,i){return r((i,s=null,r)=>e(e=>i.call(s,t(e)),null,r),i)}function s(e,t,i){return r((i,s=null,r)=>e(e=>t(e)&&i.call(s,e),null,r),i)}function r(e,t){let i,s=new vo({onWillAddFirstListener(){i=e(s.fire,s)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(s),s.event}function n(e,t,i=100,s=!1,r=!1,n,o){let a,l,h,c,d=0,u=new vo({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{d++,l=t(l,e),s&&!h&&(u.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!s||d>1)&&u.fire(e),d=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){r&&d>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(u),u.event}e.None=()=>Qn.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return r((i,s=null,r)=>e(e=>{t(e),i.call(s,e)},null,r),i)},e.filter=s,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,s)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(function(...e){return Xn(()=>Gn(e))}(...e.map(e=>e(e=>t.call(i,e)))),s)},e.reduce=function(e,t,s,r){let n=s;return i(e,e=>(n=t(n,e),n),r)},e.debounce=n,e.accumulate=function(t,i=0,s){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,s)},e.latch=function(e,t=(e,t)=>e===t,i){let r,n=!0;return s(e,e=>{let i=n||!t(e,r);return n=!1,r=e,i},i)},e.split=function(t,i,s){return[e.filter(t,i,s),e.filter(t,e=>!i(e),s)]},e.buffer=function(e,t=!1,i=[],s){let r=i.slice(),n=e(e=>{r?r.push(e):a.fire(e)});s&&s.add(n);let o=()=>{null==r||r.forEach(e=>a.fire(e)),r=null},a=new vo({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),s&&s.add(n))},onDidAddFirstListener(){r&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return s&&s.add(a),a.event},e.chain=function(e,t){return(i,s,r)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(s,t)},void 0,r)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(s=>{let r=i||!e(s,t);return i=!1,t=s,r?s:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new vo({onWillAddFirstListener:()=>e.on(t,s),onDidRemoveLastListener:()=>e.removeListener(t,s)});return r.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new vo({onWillAddFirstListener:()=>e.addEventListener(t,s),onDidRemoveLastListener:()=>e.removeEventListener(t,s)});return r.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new vo;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new vo(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,s)=>{let r=0,n=!1,o={beginUpdate(){r++},endUpdate(){r--,0===r&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return s instanceof Zn?s.add(a):Array.isArray(s)&&s.push(a),a}}})(so||(so={}));var lo=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new ao,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};lo.all=new Set,lo._idPool=0;var ho=lo,co=class e{constructor(t,i,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,s]=this.getMostFrequentStack(),r=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${s}):`;console.warn(r),console.warn(e);let n=new fo(r,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,s]of this._stacks)(!e||t<s)&&(e=[i,s],t=s);return e}};co._idPool=1;var uo=co,_o=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},fo=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},po=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},mo=0,go=class{constructor(e){this.value=e,this.id=mo++}},vo=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new uo((null==e?void 0:e.onListenerError)??zn,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(s=this._options)?void 0:s._profName)?new ho(this._options._profName):void 0,this._deliveryQueue=null==(r=this._options)?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(s=this._leakageMon)||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var s,r,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new po(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(s=this._options)?void 0:s.onListenerError)||zn)(i),Qn.None}if(this._disposed)return Qn.None;t&&(e=e.bind(t));let l,h=new go(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=_o.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof go?(this._deliveryQueue??(this._deliveryQueue=new So),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(r=this._options)?void 0:r.onWillAddFirstListener)||n.call(r,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=Xn(()=>{null==l||l(),this._removeListener(h)});return i instanceof Zn?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,s,r;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(r=null==(s=this._options)?void 0:s.onDidRemoveLastListener)||r.call(s,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let s=(null==(i=this._options)?void 0:i.onListenerError)||zn;if(s)try{e.value(t)}catch(r){s(r)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(s=this._perfMon)||s.start(this._size),this._listeners)if(this._listeners instanceof go)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(r=this._perfMon)||r.stop()}hasListeners(){return this._size>0}},So=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},bo=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new vo,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new vo,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};bo.INSTANCE=new bo;var wo=bo;wo.INSTANCE.onDidChangeZoomLevel,wo.INSTANCE.onDidChangeFullscreen;var xo="object"==typeof navigator?navigator.userAgent:"",yo=xo.indexOf("Firefox")>=0,Co=xo.indexOf("AppleWebKit")>=0,ko=xo.indexOf("Chrome")>=0,Eo=!ko&&xo.indexOf("Safari")>=0;xo.indexOf("Electron/"),xo.indexOf("Android");var Mo=!1;if("function"==typeof to.matchMedia){let e=to.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=to.matchMedia("(display-mode: fullscreen)");Mo=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(to,e,({matches:e})=>{Mo&&t.matches||(Mo=e)})}var No,Do,Ro="en",Lo=!1,Po=!1,Bo=!1,To=!1,jo=Ro,Oo=globalThis;typeof Oo.vscode<"u"&&typeof Oo.vscode.process<"u"?Do=Oo.vscode.process:typeof process<"u"&&"string"==typeof(null==(e=null==process?void 0:process.versions)?void 0:e.node)&&(Do=process);var Ao="string"==typeof(null==(t=null==Do?void 0:Do.versions)?void 0:t.electron)&&"renderer"===(null==Do?void 0:Do.type);if("object"==typeof Do){Lo="win32"===Do.platform,Po="darwin"===Do.platform,(Bo="linux"===Do.platform)&&!!Do.env.SNAP&&Do.env.SNAP_REVISION,!!Do.env.CI||Do.env.BUILD_ARTIFACTSTAGINGDIRECTORY,jo=Ro;let e=Do.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,jo=t.resolvedLanguage||Ro,null==(i=t.languagePack)?void 0:i.translationsConfigFile}catch{}To=!0}else"object"!=typeof navigator||Ao?console.error("Unable to resolve platform."):(Lo=(No=navigator.userAgent).indexOf("Windows")>=0,Po=No.indexOf("Macintosh")>=0,(No.indexOf("Macintosh")>=0||No.indexOf("iPad")>=0||No.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Bo=No.indexOf("Linux")>=0,null==No||No.indexOf("Mobi"),jo=globalThis._VSCODE_NLS_LANGUAGE||Ro,navigator.language.toLowerCase());var Io,zo,Wo=Lo,Ho=Po,Fo=Bo,$o=To,Ko=No,Uo=jo;(zo=Io||(Io={})).value=function(){return Uo},zo.isDefaultVariant=function(){return 2===Uo.length?"en"===Uo:Uo.length>=3&&"e"===Uo[0]&&"n"===Uo[1]&&"-"===Uo[2]},zo.isDefault=function(){return"en"===Uo};var qo="function"==typeof Oo.postMessage&&!Oo.importScripts;(()=>{if(qo){let e=[];Oo.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let s=e[i];if(s.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void s.callback()}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Oo.postMessage({vscodeScheduleAsyncWork:s},"*")}}})();var Vo=!!(Ko&&Ko.indexOf("Chrome")>=0);Ko&&Ko.indexOf("Firefox"),!Vo&&Ko&&Ko.indexOf("Safari"),Ko&&Ko.indexOf("Edg/"),Ko&&Ko.indexOf("Android");var Yo="object"==typeof navigator?navigator:{};$o||document.queryCommandSupported&&document.queryCommandSupported("copy")||Yo&&Yo.clipboard&&Yo.clipboard.writeText,$o||Yo&&Yo.clipboard&&Yo.clipboard.readText;var Go,Xo,Jo=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}},Zo=new Jo,Qo=new Jo,ea=new Jo,ta=new Array(230);(Xo=Go||(Go={})).toString=function(e){return Zo.keyCodeToStr(e)},Xo.fromString=function(e){return Zo.strToKeyCode(e)},Xo.toUserSettingsUS=function(e){return Qo.keyCodeToStr(e)},Xo.toUserSettingsGeneral=function(e){return ea.keyCodeToStr(e)},Xo.fromUserSettings=function(e){return Qo.strToKeyCode(e)||ea.strToKeyCode(e)},Xo.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Zo.keyCodeToStr(e)};var ia=class e{constructor(e,t,i,s,r){this.ctrlKey=e,this.shiftKey=t,this.altKey=i,this.metaKey=s,this.keyCode=r}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?"1":"0"}${this.shiftKey?"1":"0"}${this.altKey?"1":"0"}${this.metaKey?"1":"0"}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new sa([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},sa=class{constructor(e){if(0===e.length)throw new Error(`Illegal argument: ${"chords"}`);this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)0!==t&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(null===e||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}};var ra=Ho?256:2048,na=Ho?2048:256,oa=class{constructor(e){var t;this._standardKeyboardEventBrand=!0;let i=e;this.browserEvent=i,this.target=i.target,this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.altGraphKey=null==(t=i.getModifierState)?void 0:t.call(i,"AltGraph"),this.keyCode=function(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Go.fromString(t)}let t=e.keyCode;if(3===t)return 7;if(yo)switch(t){case 59:return 85;case 60:if(Fo)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ho)return 57}else if(Co){if(Ho&&93===t)return 57;if(!Ho&&92===t)return 57}return ta[t]||0}(i),this.code=i.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,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;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=ra),this.altKey&&(t|=512),this.shiftKey&&(t|=1024),this.metaKey&&(t|=na),t|=e,t}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new ia(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},aa=new WeakMap;function la(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if("null"!==t.origin&&"null"!==i.origin&&t.origin!==i.origin)return null}catch{return null}return e.parent}var ha,ca=class{static getSameOriginWindowChain(e){let t=aa.get(e);if(!t){t=[],aa.set(e,t);let i,s=e;do{i=la(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 i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let e=n.window.deref();if(i+=(null==e?void 0:e.scrollY)??0,s+=(null==e?void 0:e.scrollX)??0,e===t||!n.iframeElement)break;let r=n.iframeElement.getBoundingClientRect();i+=r.top,s+=r.left}return{top:i,left:s}}},da=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=0===t.button,this.middleButton=1===t.button,this.rightButton=2===t.button,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,"dblclick"===t.type&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,"number"==typeof t.pageX?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=ca.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ua=class{constructor(e,t=0,i=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let r=!1;if(ko){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,i=e,n=(null==(s=e.view)?void 0:s.devicePixelRatio)||1;if(typeof t.wheelDeltaY<"u")this.deltaY=r?t.wheelDeltaY/(120*n):t.wheelDeltaY/120;else if(typeof i.VERTICAL_AXIS<"u"&&i.axis===i.VERTICAL_AXIS)this.deltaY=-i.detail/3;else if("wheel"===e.type){let t=e;t.deltaMode===t.DOM_DELTA_LINE?this.deltaY=yo&&!Ho?-e.deltaY/3:-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<"u")this.deltaX=Eo&&Wo?-t.wheelDeltaX/120:r?t.wheelDeltaX/(120*n):t.wheelDeltaX/120;else if(typeof i.HORIZONTAL_AXIS<"u"&&i.axis===i.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if("wheel"===e.type){let t=e;t.deltaMode===t.DOM_DELTA_LINE?this.deltaX=yo&&!Ho?-e.deltaX/3:-e.deltaX:this.deltaX=-e.deltaX/40}0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*n):e.wheelDelta/120)}}preventDefault(){var e;null==(e=this.browserEvent)||e.preventDefault()}stopPropagation(){var e;null==(e=this.browserEvent)||e.stopPropagation()}},_a=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof ma||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:so.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:_a})})(ha||(ha={}));var fa,pa,ma=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?_a:(this._emitter||(this._emitter=new vo),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},ga=class{constructor(e,t){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof t&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new qn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new qn("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},va=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;null==(e=this.disposable)||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new qn("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=Xn(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(pa=fa||(fa={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},pa.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(Xo){i(Xo)}})};var Sa=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new vo,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await so.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let s of t)e.emitOne(i(s))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let s of t)i(s)&&e.emitOne(s)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Sa.EMPTY=Sa.fromArray([]);var{getWindow:ba,getWindowId:wa,onDidRegisterWindow:xa}=function(){let e=new Map,t={window:to,disposables:new Zn};e.set(to.vscodeWindowId,t);let i=new vo,s=new vo,r=new vo;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Qn.None;let n=new Zn,o={window:t,disposables:n.add(new Zn)};return e.set(t.vscodeWindowId,o),n.add(Xn(()=>{e.delete(t.vscodeWindowId),s.fire(t)})),n.add(Ca(t,Da.BEFORE_UNLOAD,()=>{r.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,s){return("number"==typeof i?e.get(i):void 0)??(s?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let s=e;return(null==s?void 0:s.view)?s.view.window:to},getDocument:e=>ba(e).document}}(),ya=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ca(e,t,i,s){return new ya(e,t,i,s)}var ka,Ea=function(e,t,i,s){return Ca(e,t,i,s)},Ma=class extends va{constructor(e){super(),this.defaultTarget=e&&ba(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Na=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(ou){zn(ou)}}static sort(e,t){return t.priority-e.priority}};!function(){let e=new Map,t=new Map,i=new Map,s=new Map;ka=(r,n,o=0)=>{let a=wa(r),l=new Na(n,o),h=e.get(a);return h||(h=[],e.set(a,h)),h.push(l),i.get(a)||(i.set(a,!0),r.requestAnimationFrame(()=>(r=>{i.set(r,!1);let n=e.get(r)??[];for(t.set(r,n),e.set(r,[]),s.set(r,!0);n.length>0;)n.sort(Na.sort),n.shift().execute();s.set(r,!1)})(a))),l}}();var Da={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"},Ra=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=La(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=La(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=La(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=La(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=La(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=La(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=La(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=La(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=La(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=La(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=La(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=La(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=La(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=La(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 La(e){return"number"==typeof e?`${e}px`:e}function Pa(e){return new Ra(e)}var Ba,Ta,ja=class{constructor(){this._hooks=new Zn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(Xn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ba(e)}this._hooks.add(Ca(n,Da.POINTER_MOVE,e=>{e.buttons===i?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(Ca(n,Da.POINTER_UP,e=>this.stopMonitoring(!0)))}};(Ta=Ba||(Ba={})).Tap="-xterm-gesturetap",Ta.Change="-xterm-gesturechange",Ta.Start="-xterm-gesturestart",Ta.End="-xterm-gesturesend",Ta.Contextmenu="-xterm-gesturecontextmenu";var Oa=class e extends Qn{constructor(){super(),this.dispatched=!1,this.targets=new no,this.ignoreTargets=new no,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(so.runAndSubscribe(xa,({window:e,disposables:t})=>{t.add(Ca(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),t.add(Ca(e.document,"touchend",t=>this.onTouchEnd(e,t))),t.add(Ca(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:to,disposables:this._store}))}static addTarget(t){if(!e.isTouchDevice())return Qn.None;return e.INSTANCE||(e.INSTANCE=new e),Xn(e.INSTANCE.targets.push(t))}static ignoreTarget(t){if(!e.isTouchDevice())return Qn.None;return e.INSTANCE||(e.INSTANCE=new e),Xn(e.INSTANCE.ignoreTargets.push(t))}static isTouchDevice(){return"ontouchstart"in to||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,s=e.targetTouches.length;i<s;i++){let s=e.targetTouches.item(i);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:t,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[t],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let r=this.newGestureEvent(Ba.Start,s.target);r.pageX=s.pageX,r.pageY=s.pageY,this.dispatchEvent(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let o=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("move of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=Date.now()-a.initialTimeStamp;if(l<e.HOLD_DELAY&&Math.abs(a.initialPageX-Vn(a.rollingPageX))<30&&Math.abs(a.initialPageY-Vn(a.rollingPageY))<30){let e=this.newGestureEvent(Ba.Tap,a.initialTarget);e.pageX=Vn(a.rollingPageX),e.pageY=Vn(a.rollingPageY),this.dispatchEvent(e)}else if(l>=e.HOLD_DELAY&&Math.abs(a.initialPageX-Vn(a.rollingPageX))<30&&Math.abs(a.initialPageY-Vn(a.rollingPageY))<30){let e=this.newGestureEvent(Ba.Contextmenu,a.initialTarget);e.pageX=Vn(a.rollingPageX),e.pageY=Vn(a.rollingPageY),this.dispatchEvent(e)}else if(1===r){let e=Vn(a.rollingPageX),i=Vn(a.rollingPageY),r=Vn(a.rollingTimestamps)-a.rollingTimestamps[0],n=e-a.rollingPageX[0],o=i-a.rollingPageY[0],l=[...this.targets].filter(e=>a.initialTarget instanceof Node&&e.contains(a.initialTarget));this.inertia(t,l,s,Math.abs(n)/r,n>0?1:-1,e,Math.abs(o)/r,o>0?1:-1,i)}this.dispatchEvent(this.newGestureEvent(Ba.End,a.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,t){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=t,i.tapCount=0,i}dispatchEvent(t){if(t.type===Ba.Tap){let i=(new Date).getTime(),s=0;s=i-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Ba.Change||t.type===Ba.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let e=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let s=0,r=t.initialTarget;for(;r&&r!==i;)s++,r=r.parentElement;e.push([s,i])}e.sort((e,t)=>e[0]-t[0]);for(let[i,s]of e)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,l,h){this.handle=ka(t,()=>{let c=Date.now(),d=c-s,u=0,_=0,f=!0;r+=e.SCROLL_FRICTION*d,a+=e.SCROLL_FRICTION*d,r>0&&(f=!1,u=n*r*d),a>0&&(f=!1,_=l*a*d);let p=this.newGestureEvent(Ba.Change);p.translationX=u,p.translationY=_,i.forEach(e=>e.dispatchEvent(p)),f||this.inertia(t,i,c,r,n,o+u,a,l,h+_)})}onTouchMove(e){let t=Date.now();for(let i=0,s=e.changedTouches.length;i<s;i++){let s=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let r=this.activeTouches[s.identifier],n=this.newGestureEvent(Ba.Change,r.initialTarget);n.translationX=s.pageX-Vn(r.rollingPageX),n.translationY=s.pageY-Vn(r.rollingPageY),n.pageX=s.pageX,n.pageY=s.pageY,this.dispatchEvent(n),r.rollingPageX.length>3&&(r.rollingPageX.shift(),r.rollingPageY.shift(),r.rollingTimestamps.shift()),r.rollingPageX.push(s.pageX),r.rollingPageY.push(s.pageY),r.rollingTimestamps.push(t)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Oa.SCROLL_FRICTION=-.005,Oa.HOLD_DELAY=700,Oa.CLEAR_TAP_COUNT_TIME=400,Yr([function(e,t,i){let s=null,r=null;if("function"==typeof i.value?(s="value",r=i.value,0!==r.length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof i.get&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...e){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,e)}),this[n]}}],Oa,"isTouchDevice",1);var Aa=Oa,Ia=class extends Qn{onclick(e,t){this._register(Ca(e,Da.CLICK,i=>t(new da(ba(e),i))))}onmousedown(e,t){this._register(Ca(e,Da.MOUSE_DOWN,i=>t(new da(ba(e),i))))}onmouseover(e,t){this._register(Ca(e,Da.MOUSE_OVER,i=>t(new da(ba(e),i))))}onmouseleave(e,t){this._register(Ca(e,Da.MOUSE_LEAVE,i=>t(new da(ba(e),i))))}onkeydown(e,t){this._register(Ca(e,Da.KEY_DOWN,e=>t(new oa(e))))}onkeyup(e,t){this._register(Ca(e,Da.KEY_UP,e=>t(new oa(e))))}oninput(e,t){this._register(Ca(e,Da.INPUT,t))}onblur(e,t){this._register(Ca(e,Da.BLUR,t))}onfocus(e,t){this._register(Ca(e,Da.FOCUS,t))}onchange(e,t){this._register(Ca(e,Da.CHANGE,t))}ignoreGesture(e){return Aa.ignoreTarget(e)}},za=class extends Ia{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="11px",this.domNode.style.height="11px",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 ja),this._register(Ea(this.bgDomNode,Da.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Ea(this.domNode,Da.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Ma),this._pointerdownScheduleRepeatTimer=this._register(new ga)}_arrowPointerDown(e){if(!(e.target&&e.target instanceof Element))return;this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ba(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Wa=class e{constructor(e,t,i,s,r,n,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,i|=0,s|=0,r|=0,n|=0,o|=0),this.rawScrollLeft=s,this.rawScrollTop=o,t<0&&(t=0),s+t>i&&(s=i-t),s<0&&(s=0),r<0&&(r=0),o+r>n&&(o=n-r),o<0&&(o=0),this.width=t,this.scrollWidth=i,this.scrollLeft=s,this.height=r,this.scrollHeight=n,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,i){return new e(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(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(e,t){let i=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,r=this.scrollLeft!==e.scrollLeft,n=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,a=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:s,scrollLeftChanged:r,heightChanged:n,scrollHeightChanged:o,scrollTopChanged:a}}},Ha=class extends Qn{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new vo),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Wa(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),null==(i=this._smoothScrolling)||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(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i,s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;i=t?new Ka(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Ka.start(this._state,t,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)return this._smoothScrolling.dispose(),void(this._smoothScrolling=null);this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Fa=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function $a(e,t){let i=t-e;return function(t){return e+i*function(e){return 1-function(e){return Math.pow(e,3)}(1-e)}(t)}}var Ka=class e{constructor(e,t,i,s){this.from=e,this.to=t,this.duration=s,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(e,t,i){if(Math.abs(e-t)>2.5*i){let s,r;return e<t?(s=e+.75*i,r=t-.75*i):(s=e-.75*i,r=t+.75*i),function(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}($a(e,s),$a(r,t),.33)}return $a(e,t)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;if(t<1){let e=this.scrollLeft(t),i=this.scrollTop(t);return new Fa(e,i,!1)}return new Fa(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return e.start(t,i,s)}static start(t,i,s){s+=10;let r=Date.now()-10;return new e(t,i,r,s)}};var Ua=class extends Qn{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new ga)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||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(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;null==(e=this._domNode)||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,null==(t=this._domNode)||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},qa=class extends Ia{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 Ua(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ja),this._shouldRender=!0,this.domNode=Pa(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(Ca(this.domNode.domNode,Da.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new za(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Pa(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),"number"==typeof i&&this.slider.setWidth(i),"number"==typeof s&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ca(this.slider.domNode,Da.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)t=e.offsetX,i=e.offsetY;else{let s=function(e){let t=e.getBoundingClientRect(),i=ba(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}(this.domNode.domNode);t=e.pageX-s.left,i=e.pageY-s.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!(e.target&&e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let r=this._sliderOrthogonalPointerPosition(e),n=Math.abs(r-i);if(Wo&&n>140)return void this._setDesiredScrollPositionNow(s.getScrollPosition());let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(o))},()=>{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()}},Va=class e{constructor(e,t,i,s,r,n){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=r,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,i,s,r){let n=Math.max(0,i-e),o=Math.max(0,n-2*t),a=s>0&&s>i;if(!a)return{computedAvailableSize:Math.round(n),computedIsNeeded:a,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*o/s))),h=(o-l)/(s-i),c=r*h;return{computedAvailableSize:Math.round(n),computedIsNeeded:a,computedSliderSize:Math.round(l),computedSliderRatio:h,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let t=e._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(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,i=this._scrollPosition;return t<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},Ya=class extends qa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Va(t.horizontalHasArrows?t.arrowSize:0,2===t.horizontal?0:t.horizontalScrollbarSize,2===t.vertical?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Ga=class extends qa{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Va(t.verticalHasArrows?t.arrowSize:0,2===t.vertical?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Xa=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Ja=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,t=0,i=1,s=this._rear;for(;;){let r=s===this._front?e:Math.pow(2,-i);if(e-=r,t+=this._memory[s].score*r,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}return t<=.5}acceptStandardWheelEvent(e){if(ko){let i=ba(e.browserEvent),s=(t=i,wo.INSTANCE.getZoomFactor(t));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY);var t}accept(e,t,i){let s=null,r=new Xa(e,t,i);-1===this._front&&-1===this._rear?(this._memory[0]=r,this._front=0,this._rear=0):(s=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]=r),r.score=this._computeScore(r,s)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),t){let s=Math.abs(e.deltaX),r=Math.abs(e.deltaY),n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.max(Math.min(s,n),1),l=Math.max(Math.min(r,o),1),h=Math.max(s,n),c=Math.max(r,o);h%a===0&&c%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Ja.INSTANCE=new Ja;var Za=Ja,Qa=class extends Ia{constructor(e,t,i){super(),this._onScroll=this._register(new vo),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new vo),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let t={lazyRender:typeof e.lazyRender<"u"&&e.lazyRender,className:typeof e.className<"u"?e.className:"",useShadows:!(typeof e.useShadows<"u")||e.useShadows,handleMouseWheel:!(typeof e.handleMouseWheel<"u")||e.handleMouseWheel,flipAxes:typeof e.flipAxes<"u"&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<"u"&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:!(typeof e.scrollPredominantAxis<"u")||e.scrollPredominantAxis,mouseWheelSmoothScroll:!(typeof e.mouseWheelSmoothScroll<"u")||e.mouseWheelSmoothScroll,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,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Ho&&(t.className+=" mac"),t}(t),this._scrollable=i,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let s={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Ga(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Ya(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Pa(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Pa(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Pa(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new ga),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Gn(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,Ho&&(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 ua(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Gn(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new ua(e))};this._mouseWheelToDispose.push(Ca(this._listenOnDomNode,Da.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){var t;if(null==(t=e.browserEvent)?void 0:t.defaultPrevented)return;let i=Za.INSTANCE;i.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let t=e.deltaY*this._options.mouseWheelScrollSensitivity,r=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&r+t===0?r=t=0:Math.abs(t)>=Math.abs(r)?r=0:t=0),this._options.flipAxes&&([t,r]=[r,t]);let n=!Ho&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!r&&(r=t,t=0),e.browserEvent&&e.browserEvent.altKey&&(r*=this._options.fastScrollSensitivity,t*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),a={};if(t){let e=50*t,i=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(a,i)}if(r){let e=50*r,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(a,t)}a=this._scrollable.validateScrollPosition(a),(o.scrollLeft!==a.scrollLeft||o.scrollTop!==a.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(a):this._scrollable.setScrollPositionNow(a),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},el=class extends Qa{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};var tl=class extends Qn{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new vo),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new Ha({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>ka(s.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new el(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(so.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Xn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Xn(()=>this._styleElement.remove())),this._register(so.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join("\n")})),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(e=>this._handleScroll(e)))}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:(null==(e=this._optionsService.rawOptions.overviewRuler)?void 0:e.width)||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;0!==i&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};tl=Yr([Gr(2,vn),Gr(3,Ln),Gr(4,Sn),Gr(5,On),Gr(6,Cn),Gr(7,Bn)],tl);var il=class extends Qn{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(Xn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(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 t;let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer","top"===(null==(t=null==e?void 0:e.options)?void 0:t.layer)),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=t*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;"right"===(e.options.anchor||"left")?t.style.right=i?i*this._renderService.dimensions.css.cell.width+"px":"":t.style.left=i?i*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(e){var t;null==(t=this._decorationElements.get(e))||t.remove(),this._decorationElements.delete(e),e.dispose()}};il=Yr([Gr(1,vn),Gr(2,Ln),Gr(3,Mn),Gr(4,Bn)],il);var sl,rl,nl,ol,al,ll=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))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return 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,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},hl={full:0,left:0,center:0,right:0},cl={full:0,left:0,center:0,right:0},dl={full:0,left:0,center:0,right:0},ul=class extends Qn{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new ll,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(),null==(l=this._viewportElement.parentElement)||l.insertBefore(this._canvas,this._viewportElement),this._register(Xn(()=>{var e;return null==(e=this._canvas)?void 0:e.remove()}));let h=this._canvas.getContext("2d");if(!h)throw new Error("Ctx cannot be null");this._ctx=h,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(null==(e=this._optionsService.options.overviewRuler)?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);cl.full=this._canvas.width,cl.left=e,cl.center=t,cl.right=e,this._refreshDrawHeightConstants(),dl.full=1,dl.left=1,dl.center=1+cl.left,dl.right=1+cl.left+cl.center}_refreshDrawHeightConstants(){hl.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);hl.left=t,hl.center=t,hl.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hl.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hl.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hl.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*hl.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)"full"!==t.position&&this._renderColorZone(t);for(let t of e)"full"===t.position&&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(dl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-hl[e.position||"full"]/2),cl[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+hl[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ul=Yr([Gr(2,vn),Gr(3,Mn),Gr(4,Bn),Gr(5,Cn),Gr(6,On),Gr(7,Ln)],ul),(rl=sl||(sl={})).NUL="\0",rl.SOH="",rl.STX="",rl.ETX="",rl.EOT="",rl.ENQ="",rl.ACK="",rl.BEL="",rl.BS="\b",rl.HT="\t",rl.LF="\n",rl.VT="\v",rl.FF="\f",rl.CR="\r",rl.SO="",rl.SI="",rl.DLE="",rl.DC1="",rl.DC2="",rl.DC3="",rl.DC4="",rl.NAK="",rl.SYN="",rl.ETB="",rl.CAN="",rl.EM="",rl.SUB="",rl.ESC="",rl.FS="",rl.GS="",rl.RS="",rl.US="",rl.SP=" ",rl.DEL="",(ol=nl||(nl={})).PAD="",ol.HOP="",ol.BPH="",ol.NBH="",ol.IND="",ol.NEL="
",ol.SSA="",ol.ESA="",ol.HTS="",ol.HTJ="",ol.VTS="",ol.PLD="",ol.PLU="",ol.RI="",ol.SS2="",ol.SS3="",ol.DCS="",ol.PU1="",ol.PU2="",ol.STS="",ol.CCH="",ol.MW="",ol.SPA="",ol.EPA="",ol.SOS="",ol.SGCI="",ol.SCI="",ol.CSI="",ol.ST="",ol.OSC="",ol.PM="",ol.APC="",(al||(al={})).ST=`${sl.ESC}\\`;var _l=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${sl.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 e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let r=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(r.width,1)+"px",this._textarea.style.height=Math.max(r.height,1)+"px",this._textarea.style.lineHeight=r.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};_l=Yr([Gr(2,vn),Gr(3,Cn),Gr(4,bn),Gr(5,Bn)],_l);var fl,pl,ml,gl,vl,Sl=0,bl=0,wl=0,xl=0,yl={css:"#00000000",rgba:0};function Cl(e){let t=e.toString(16);return t.length<2?"0"+t:t}function kl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}(e=>{e.toCss=function(e,t,i,s){return void 0!==s?`#${Cl(e)}${Cl(t)}${Cl(i)}${Cl(s)}`:`#${Cl(e)}${Cl(t)}${Cl(i)}`},e.toRgba=function(e,t,i,s=255){return(e<<24|t<<16|i<<8|s)>>>0},e.toColor=function(t,i,s,r){return{css:e.toCss(t,i,s,r),rgba:e.toRgba(t,i,s,r)}}})(fl||(fl={})),(e=>{function t(e,t){return xl=Math.round(255*t),[Sl,bl,wl]=vl.toChannels(e.rgba),{css:fl.toCss(Sl,bl,wl,xl),rgba:fl.toRgba(Sl,bl,wl,xl)}}e.blend=function(e,t){if(1===(xl=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,s=t.rgba>>16&255,r=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return Sl=n+Math.round((i-n)*xl),bl=o+Math.round((s-o)*xl),wl=a+Math.round((r-a)*xl),{css:fl.toCss(Sl,bl,wl),rgba:fl.toRgba(Sl,bl,wl)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let s=vl.ensureContrastRatio(e.rgba,t.rgba,i);if(s)return fl.toColor(s>>24&255,s>>16&255,s>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[Sl,bl,wl]=vl.toChannels(t),{css:fl.toCss(Sl,bl,wl),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(xl=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(pl||(pl={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let s=e.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Sl=parseInt(e.slice(1,2).repeat(2),16),bl=parseInt(e.slice(2,3).repeat(2),16),wl=parseInt(e.slice(3,4).repeat(2),16),fl.toColor(Sl,bl,wl);case 5:return Sl=parseInt(e.slice(1,2).repeat(2),16),bl=parseInt(e.slice(2,3).repeat(2),16),wl=parseInt(e.slice(3,4).repeat(2),16),xl=parseInt(e.slice(4,5).repeat(2),16),fl.toColor(Sl,bl,wl,xl);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let s=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return Sl=parseInt(s[1]),bl=parseInt(s[2]),wl=parseInt(s[3]),xl=Math.round(255*(void 0===s[5]?1:parseFloat(s[5]))),fl.toColor(Sl,bl,wl,xl);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Sl,bl,wl,xl]=t.getImageData(0,0,1,1).data,255!==xl)throw new Error("css.toColor: Unsupported css format");return{rgba:fl.toRgba(Sl,bl,wl,xl),css:e}}})(ml||(ml={})),(e=>{function t(e,t,i){let s=e/255,r=t/255,n=i/255;return.2126*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(gl||(gl={})),(e=>{function t(e,t,i){let s=e>>24&255,r=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=kl(gl.relativeLuminance2(o,a,l),gl.relativeLuminance2(s,r,n));for(;h<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h=kl(gl.relativeLuminance2(o,a,l),gl.relativeLuminance2(s,r,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let s=e>>24&255,r=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=kl(gl.relativeLuminance2(o,a,l),gl.relativeLuminance2(s,r,n));for(;h<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=kl(gl.relativeLuminance2(o,a,l),gl.relativeLuminance2(s,r,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(xl=(255&t)/255))return t;let i=t>>24&255,s=t>>16&255,r=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return Sl=n+Math.round((i-n)*xl),bl=o+Math.round((s-o)*xl),wl=a+Math.round((r-a)*xl),fl.toRgba(Sl,bl,wl)},e.ensureContrastRatio=function(e,s,r){let n=gl.relativeLuminance(e>>8),o=gl.relativeLuminance(s>>8);if(kl(n,o)<r){if(o<n){let o=t(e,s,r),a=kl(n,gl.relativeLuminance(o>>8));if(a<r){let t=i(e,s,r);return a>kl(n,gl.relativeLuminance(t>>8))?o:t}return o}let a=i(e,s,r),l=kl(n,gl.relativeLuminance(a>>8));if(l<r){let i=t(e,s,r);return l>kl(n,gl.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(vl||(vl={}));var El=class extends dn{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ml=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _n}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(0===this._characterJoiners.length)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];let i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let e=this._getJoinedRanges(s,o,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||1}if(this._bufferService.cols-r>1){let e=this._getJoinedRanges(s,o,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let h=1;h<this._characterJoiners.length;h++)try{let e=this._characterJoiners[h].handler(n);for(let t=0;t<e.length;t++)Ml._mergeRanges(o,e[t])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let i=t.getWidth(a),l=t.getString(a).length||1;if(0!==i){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0)}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Ml=Yr([Gr(0,vn)],Ml);var Nl=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new _n,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,l,h,c){let d=[],u=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let p,m=0,g="",v=0,S=0,b=0,w=0,x=!1,y=0,C=!1,k=0,E=0,M=[],N=-1!==h&&-1!==c;for(let D=0;D<f;D++){e.loadCell(D,this._workCell);let f=this._workCell.getWidth();if(0===f)continue;let R=!1,L=D>=E,P=D,B=this._workCell;if(u.length>0&&D===u[0][0]&&L){let s=u.shift(),r=this._isCellInSelection(s[0],t);for(v=s[0]+1;v<s[1];v++)L&&(L=r===this._isCellInSelection(v,t));L&&(L=!i||n<s[0]||n>=s[1]),L?(R=!0,B=new El(this._workCell,e.translateToString(!0,s[0],s[1]),s[1]-s[0]),P=s[1]-1,f=B.getWidth()):E=s[1]}let T=this._isCellInSelection(D,t),j=i&&D===n,O=N&&D>=h&&D<=c,A=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{A=!0});let I=B.getChars()||cn;if(" "===I&&(B.isUnderline()||B.isOverline())&&(I=" "),k=f*a-l.get(I,B.isBold(),B.isItalic()),p){if(m&&(T&&C||!T&&!C&&B.bg===S)&&(T&&C&&_.selectionForeground||B.fg===b)&&B.extended.ext===w&&O===x&&k===y&&!j&&!R&&!A&&L){B.isInvisible()?g+=cn:g+=I,m++;continue}m&&(p.textContent=g),p=this._document.createElement("span"),m=0,g=""}else p=this._document.createElement("span");if(S=B.bg,b=B.fg,w=B.extended.ext,x=O,y=k,C=T,R&&n>=D&&n<=P&&(n=D),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized)if(M.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&M.push("xterm-cursor-blink"),M.push("bar"===s?"xterm-cursor-bar":"underline"===s?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":M.push("xterm-cursor-outline");break;case"block":M.push("xterm-cursor-block");break;case"bar":M.push("xterm-cursor-bar");break;case"underline":M.push("xterm-cursor-underline")}if(B.isBold()&&M.push("xterm-bold"),B.isItalic()&&M.push("xterm-italic"),B.isDim()&&M.push("xterm-dim"),g=B.isInvisible()?cn:B.getChars()||cn,B.isUnderline()&&(M.push(`xterm-underline-${B.extended.underlineStyle}`)," "===g&&(g=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${dn.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let e=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&e<8&&(e+=8),p.style.textDecorationColor=_.ansi[e].css}B.isOverline()&&(M.push("xterm-overline")," "===g&&(g=" ")),B.isStrikethrough()&&M.push("xterm-strikethrough"),O&&(p.style.textDecoration="underline");let z=B.getFgColor(),W=B.getFgColorMode(),H=B.getBgColor(),F=B.getBgColorMode(),$=!!B.isInverse();if($){let e=z;z=H,H=e;let t=W;W=F,F=t}let K,U,q,V=!1;switch(this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{"top"!==e.options.layer&&V||(e.backgroundColorRGB&&(F=50331648,H=e.backgroundColorRGB.rgba>>8&16777215,K=e.backgroundColorRGB),e.foregroundColorRGB&&(W=50331648,z=e.foregroundColorRGB.rgba>>8&16777215,U=e.foregroundColorRGB),V="top"===e.options.layer)}),!V&&T&&(K=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,H=K.rgba>>8&16777215,F=50331648,V=!0,_.selectionForeground&&(W=50331648,z=_.selectionForeground.rgba>>8&16777215,U=_.selectionForeground)),V&&M.push("xterm-decoration-top"),F){case 16777216:case 33554432:q=_.ansi[H],M.push(`xterm-bg-${H}`);break;case 50331648:q=fl.toColor(H>>16,H>>8&255,255&H),this._addStyle(p,`background-color:#${Dl((H>>>0).toString(16),"0",6)}`);break;default:$?(q=_.foreground,M.push("xterm-bg-257")):q=_.background}switch(K||B.isDim()&&(K=pl.multiplyOpacity(q,.5)),W){case 16777216:case 33554432:B.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(p,q,_.ansi[z],B,K,void 0)||M.push(`xterm-fg-${z}`);break;case 50331648:let e=fl.toColor(z>>16&255,z>>8&255,255&z);this._applyMinimumContrast(p,q,e,B,K,U)||this._addStyle(p,`color:#${Dl(z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,q,_.foreground,B,K,U)||$&&M.push("xterm-fg-257")}M.length&&(p.className=M.join(" "),M.length=0),j||R||A||!L?p.textContent=g:m++,k!==this.defaultSpacing&&(p.style.letterSpacing=`${k}px`),d.push(p),D=P}return p&&m&&(p.textContent=g),d}_applyMinimumContrast(e,t,i,s,r,n){if(1===this._optionsService.rawOptions.minimumContrastRatio||(function(e){return 57508<=e&&e<=57558}(o=s.getCode())||function(e){return 9472<=e&&e<=9631}(o)))return!1;var o;let a,l=this._getContrastCache(s);if(!r&&!n&&(a=l.getColor(t.rgba,i.rgba)),void 0===a){let e=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=pl.ensureContrastRatio(r||t,n||i,e),l.setColor((r||t).rgba,(n||i).rgba,a??null)}return!!a&&(this._addStyle(e,`color:${a.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!(!i||!s)&&(this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0])}};function Dl(e,t,i){for(;e.length<i;)e=t+e;return e}Nl=Yr([Gr(1,jn),Gr(2,Cn),Gr(3,Ln),Gr(4,bn),Gr(5,Mn),Gr(6,On)],Nl);var Rl=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&1===e.length&&(s=e.charCodeAt(0))<256){if(-9999!==this._flat[s])return this._flat[s];let t=this._measure(e,0);return t>0&&(this._flat[s]=t),t}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(void 0===n){let s=0;t&&(s|=1),i&&(s|=2),n=this._measure(e,s),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Ll=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1])return void this.clear();let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0])}isCellSelected(e,t,i){return!!this.hasSelection&&(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol)}};var Pl="xterm-dom-renderer-owner-",Bl="xterm-rows",Tl="xterm-fg-",jl="xterm-bg-",Ol="xterm-focus",Al="xterm-selection",Il=1,zl=class extends Qn{constructor(e,t,i,s,r,n,o,a,l,h,c,d,u,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=l,this._optionsService=h,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=_,this._terminalClass=Il++,this._rowElements=[],this._selectionRenderModel=new Ll,this.onRequestRedraw=this._register(new vo).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Bl),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(Al),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Nl,document),this._element.classList.add(Pl+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(Xn(()=>{this._element.classList.remove(Pl+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Rl(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Bl} 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} .${Bl} { 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} .${Bl} .xterm-dim { color: ${pl.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Bl}.${Ol} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Bl}.${Ol} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Bl}.${Ol} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Bl} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Bl} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Bl} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Bl} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Bl} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Al} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Al} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Al} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Tl}${n} { color: ${o.css}; }${this._terminalSelector} .${Tl}${n}.xterm-dim { color: ${pl.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${jl}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Tl}257 { color: ${pl.opaque(e.background).css}; }${this._terminalSelector} .${Tl}257.xterm-dim { color: ${pl.multiplyOpacity(pl.opaque(e.background),.5).css}; }${this._terminalSelector} .${jl}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}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(Ol),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ol),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let i=e[0]>t[0];a.appendChild(this._createSelectionElement(n,i?t[0]:e[0],i?e[0]:t[0],o-n+1))}else{let i=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,i,l));let h=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,h)),n!==o){let e=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=s*this.dimensions.css.cell.height+"px",r.style.top=e*this.dimensions.css.cell.height+"px",r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let e=l+i.ydisp,t=this._rowElements[l],h=i.lines.get(e);if(!t||!h)break;t.replaceChildren(...this._rowFactory.createRow(h,e,e===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Pl}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,h=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=s;++_){let o=_+a.ydisp,f=this._rowElements[_],p=a.lines.get(o);if(!f||!p)break;f.replaceChildren(...this._rowFactory.createRow(p,o,o===l,d,u,h,c,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===s?t:r)-1:-1))}}};zl=Yr([Gr(7,xn),Gr(8,Rn),Gr(9,Cn),Gr(10,vn),Gr(11,bn),Gr(12,Ln),Gr(13,On)],zl);var Wl=class extends Qn{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new vo),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new $l(this._optionsService))}catch{this._measureStrategy=this._register(new Fl(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())}};Wl=Yr([Gr(2,Cn)],Wl);var Hl=class extends Qn{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){void 0!==e&&e>0&&void 0!==t&&t>0&&(this._result.width=e,this._result.height=t)}},Fl=class extends Hl{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},$l=class extends Hl{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}},Kl=class extends Qn{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Ul(this._window)),this._onDprChange=this._register(new vo),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new vo),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(so.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ca(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ca(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 void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Ul=class extends Qn{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new eo),this._onDprChange=this._register(new vo),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Xn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ca(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&(null==(e=this._resolutionMediaMatchList)||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)}},ql=class extends Qn{constructor(){super(),this.linkProviders=[],this._register(Xn(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);-1!==t&&this.linkProviders.splice(t,1)}}}};function Vl(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}var Yl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return function(e,t,i,s,r,n,o,a,l){if(!n)return;let h=Vl(e,t,i);return h?(h[0]=Math.ceil((h[0]+(l?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),s+(l?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h):void 0}(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Vl(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Yl=Yr([Gr(0,Bn),Gr(1,Rn)],Yl);var Gl=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();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=[]}},Xl={};((e,t)=>{for(var i in t)qr(e,i,{get:t[i],enumerable:!0})})(Xl,{getSafariVersion:()=>sh,isChromeOS:()=>hh,isFirefox:()=>eh,isIpad:()=>nh,isIphone:()=>oh,isLegacyEdge:()=>th,isLinux:()=>lh,isMac:()=>rh,isNode:()=>Jl,isSafari:()=>ih,isWindows:()=>ah});var Jl=typeof process<"u"&&"title"in process,Zl=Jl?"node":navigator.userAgent,Ql=Jl?"node":navigator.platform,eh=Zl.includes("Firefox"),th=Zl.includes("Edge"),ih=/^((?!chrome|android).)*safari/i.test(Zl);function sh(){if(!ih)return 0;let e=Zl.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var rh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ql),nh="iPad"===Ql,oh="iPhone"===Ql,ah=["Windows","Win16","Win32","WinCE"].includes(Ql),lh=Ql.indexOf("Linux")>=0,hh=/\bCrOS\b/.test(Zl),ch=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),1.5*i>r)return s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),void this._start();s=r}this.clear()}},dh=!Jl&&"requestIdleCallback"in window?class extends ch{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends ch{_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())}}},uh=class{constructor(){this._queue=new dh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_h=class extends Qn{constructor(e,t,i,s,r,n,o,a,l){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new eo),this._pausedResizeTask=new uh,this._observerDisposable=this._register(new eo),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 vo),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new vo),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new vo),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new vo),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Gl((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new fh(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Xn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var e;return null==(e=this._renderer.value)?void 0:e.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=Xn(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused)return void(this._needsFullRefresh=!0);if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,t);let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,t);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(e=>this.refreshRows(e.start,e.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&&(null==(t=(e=this._renderer.value).clearTextureAtlas)||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return null==(i=this._renderer.value)?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;null==(e=this._renderer.value)||e.handleCharSizeChanged()}handleBlur(){var e;null==(e=this._renderer.value)||e.handleBlur()}handleFocus(){var e;null==(e=this._renderer.value)||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,null==(s=this._renderer.value)||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;null==(e=this._renderer.value)||e.handleCursorMove()}clear(){var e;null==(e=this._renderer.value)||e.clear()}};_h=Yr([Gr(2,Cn),Gr(3,Rn),Gr(4,bn),Gr(5,Mn),Gr(6,vn),Gr(7,Ln),Gr(8,On)],_h);var fh=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(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(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function ph(e,t,i,s){let r,n=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return function(e,t,i,s,r,n){return 0===mh(t,s,r,n).length?"":wh(Sh(e,t,e,t-gh(t,r),!1,r).length,bh("D",n))}(n,o,0,t,i,s)+mh(o,t,i,s)+function(e,t,i,s,r,n){let o;o=mh(t,s,r,n).length>0?s-gh(s,r):t;let a=s,l=function(e,t,i,s,r,n){let o;return o=mh(i,s,r,n).length>0?s-gh(s,r):t,e<i&&o<=s||e>=i&&o<s?"C":"D"}(e,t,i,s,r,n);return wh(Sh(e,o,i,a,"C"===l,r).length,bh(l,n))}(n,o,e,t,i,s);if(o===t)return r=n>e?"D":"C",wh(Math.abs(n-e),bh(r,s));r=o>t?"D":"C";let a=Math.abs(o-t),l=function(e,t){return t.cols-e}(o>t?e:n,i)+(a-1)*i.cols+1+function(e){return e-1}(o>t?n:e);return wh(l,bh(r,s))}function mh(e,t,i,s){let r=e-gh(e,i),n=t-gh(t,i),o=Math.abs(r-n)-function(e,t,i){var s;let r=0,n=e-gh(e,i),o=t-gh(t,i);for(let a=0;a<Math.abs(n-o);a++){let o="A"===vh(e,t)?-1:1;(null==(s=i.buffer.lines.get(n+o*a))?void 0:s.isWrapped)&&r++}return r}(e,t,i);return wh(o,bh(vh(e,t),s))}function gh(e,t){let i=0,s=t.buffer.lines.get(e),r=null==s?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=null==s?void 0:s.isWrapped;return i}function vh(e,t){return e>t?"A":"B"}function Sh(e,t,i,s,r,n){let o=e,a=t,l="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(l+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,e,o)}function bh(e,t){let i=t?"O":"[";return sl.ESC+i+e}function wh(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var xh=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.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)&&(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 yh(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 Ch=new RegExp(" ","g"),kh=class extends Qn{constructor(e,t,i,s,r,n,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new _n,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new vo),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new vo),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new vo),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new vo),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new xh(this._bufferService),this._activeSelectionMode=0,this._register(Xn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.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)&&(e[0]!==t[0]||e[1]!==t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=i.translateBufferLineToString(o,!0,r,n);s.push(e)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let e=i.lines.get(n),t=i.translateBufferLineToString(n,!0);(null==e?void 0:e.isWrapped)?s[s.length-1]+=t:s.push(t)}if(e[1]!==t[1]){let e=i.lines.get(t[1]),r=i.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?s[s.length-1]+=r:s.push(r)}}return s.map(e=>e.replace(Ch," ")).join(ah?"\r\n":"\n")}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),lh&&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:3===this._activeSelectionMode})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!(i&&s&&t)&&this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!(!i||!s)&&this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var i,s;let r=null==(s=null==(i=this._linkifier.currentLink)?void 0:i.link)?void 0:s.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=yh(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return!!n&&(this._selectWordAt(n,t),this._model.selectionEnd=void 0,!0)}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=Vl(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return rh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&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(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(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]&&0===t.hasWidth(this._model.selectionStart[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&&!(rh&&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)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let e=i.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[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?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(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<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&void 0!==t[0]&&void 0!==t[1]){let e=ph(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);i?!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i):this._oldHasSelection&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;0===this._workCell.getWidth()?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),l=a,h=e[0]-a,c=0,d=0,u=0,_=0;if(" "===o.charAt(a)){for(;a>0&&" "===o.charAt(a-1);)a--;for(;l<o.length&&" "===o.charAt(l+1);)l++}else{let t=e[0],i=e[0];0===n.getWidth(t)&&(c++,t--),2===n.getWidth(i)&&(d++,i++);let s=n.getString(i).length;for(s>1&&(_+=s-1,l+=s-1);t>0&&a>0&&!this._isCharWordSeparator(n.loadCell(t-1,this._workCell));){n.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(c++,t--):e>1&&(u+=e-1,a-=e-1),a--,t--}for(;i<n.length&&l+1<o.length&&!this._isCharWordSeparator(n.loadCell(i+1,this._workCell));){n.loadCell(i+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(d++,i++):e>1&&(_+=e-1,l+=e-1),l++,i++}}l++;let f=a+h-c+u,p=Math.min(this._bufferService.cols,l-a+c+d-u-_);if(t||""!==o.slice(a,l).trim()){if(i&&0===f&&32!==n.getCodePoint(0)){let t=r.lines.get(e[1]-1);if(t&&n.isWrapped&&32!==t.getCodePoint(this._bufferService.cols-1)){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;f-=e,p+=e}}}if(s&&f+p===this._bufferService.cols&&32!==n.getCodePoint(this._bufferService.cols-1)){let t=r.lines.get(e[1]+1);if((null==t?void 0:t.isWrapped)&&32!==t.getCodePoint(0)){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(p+=t.length)}}return{start:f,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=yh(i,this._bufferService.cols)}};kh=Yr([Gr(3,vn),Gr(4,bn),Gr(5,Pn),Gr(6,Cn),Gr(7,Bn),Gr(8,Ln)],kh);var Eh=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Mh=class{constructor(){this._color=new Eh,this._css=new Eh}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Nh=Object.freeze((()=>{let e=[ml.toColor("#2e3436"),ml.toColor("#cc0000"),ml.toColor("#4e9a06"),ml.toColor("#c4a000"),ml.toColor("#3465a4"),ml.toColor("#75507b"),ml.toColor("#06989a"),ml.toColor("#d3d7cf"),ml.toColor("#555753"),ml.toColor("#ef2929"),ml.toColor("#8ae234"),ml.toColor("#fce94f"),ml.toColor("#729fcf"),ml.toColor("#ad7fa8"),ml.toColor("#34e2e2"),ml.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:fl.toCss(s,r,n),rgba:fl.toRgba(s,r,n)})}for(let i=0;i<24;i++){let t=8+10*i;e.push({css:fl.toCss(t,t,t),rgba:fl.toRgba(t,t,t)})}return e})()),Dh=ml.toColor("#ffffff"),Rh=ml.toColor("#000000"),Lh=ml.toColor("#ffffff"),Ph=Rh,Bh={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Th=Dh,jh=class extends Qn{constructor(e){super(),this._optionsService=e,this._contrastCache=new Mh,this._halfContrastCache=new Mh,this._onChangeColors=this._register(new vo),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Dh,background:Rh,cursor:Lh,cursorAccent:Ph,selectionForeground:void 0,selectionBackgroundTransparent:Bh,selectionBackgroundOpaque:pl.blend(Rh,Bh),selectionInactiveBackgroundTransparent:Bh,selectionInactiveBackgroundOpaque:pl.blend(Rh,Bh),scrollbarSliderBackground:pl.opacity(Dh,.2),scrollbarSliderHoverBackground:pl.opacity(Dh,.4),scrollbarSliderActiveBackground:pl.opacity(Dh,.5),overviewRulerBorder:Dh,ansi:Nh.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=Oh(e.foreground,Dh),t.background=Oh(e.background,Rh),t.cursor=pl.blend(t.background,Oh(e.cursor,Lh)),t.cursorAccent=pl.blend(t.background,Oh(e.cursorAccent,Ph)),t.selectionBackgroundTransparent=Oh(e.selectionBackground,Bh),t.selectionBackgroundOpaque=pl.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Oh(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pl.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Oh(e.selectionForeground,yl):void 0,t.selectionForeground===yl&&(t.selectionForeground=void 0),pl.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pl.opacity(t.selectionBackgroundTransparent,.3)),pl.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pl.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Oh(e.scrollbarSliderBackground,pl.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Oh(e.scrollbarSliderHoverBackground,pl.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Oh(e.scrollbarSliderActiveBackground,pl.opacity(t.foreground,.5)),t.overviewRulerBorder=Oh(e.overviewRulerBorder,Th),t.ansi=Nh.slice(),t.ansi[0]=Oh(e.black,Nh[0]),t.ansi[1]=Oh(e.red,Nh[1]),t.ansi[2]=Oh(e.green,Nh[2]),t.ansi[3]=Oh(e.yellow,Nh[3]),t.ansi[4]=Oh(e.blue,Nh[4]),t.ansi[5]=Oh(e.magenta,Nh[5]),t.ansi[6]=Oh(e.cyan,Nh[6]),t.ansi[7]=Oh(e.white,Nh[7]),t.ansi[8]=Oh(e.brightBlack,Nh[8]),t.ansi[9]=Oh(e.brightRed,Nh[9]),t.ansi[10]=Oh(e.brightGreen,Nh[10]),t.ansi[11]=Oh(e.brightYellow,Nh[11]),t.ansi[12]=Oh(e.brightBlue,Nh[12]),t.ansi[13]=Oh(e.brightMagenta,Nh[13]),t.ansi[14]=Oh(e.brightCyan,Nh[14]),t.ansi[15]=Oh(e.brightWhite,Nh[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Oh(e.extendedAnsi[s],Nh[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0!==e)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function Oh(e,t){if(void 0!==e)try{return ml.toColor(e)}catch{}return t}jh=Yr([Gr(0,Cn)],jh);var Ah=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Ih=class{constructor(){this._services=new Ah,this._services.set(xn,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=(r=e,r[pn]||[]).sort((e,t)=>e.index-t.index),s=[];var r;for(let o of i){let t=this._services.get(o.id);if(!t)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(t)}let n=i.length>0?i[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,...s)}},zh={trace:0,debug:1,info:2,warn:3,error:4,off:5},Wh=class extends Qn{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=zh[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Wh=Yr([Gr(0,Cn)],Wh);var Hh=class extends Qn{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new vo),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new vo),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new vo),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let 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 s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let e=this._length+i.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Fh=Object.freeze(new dn),$h=0,Kh=class e{constructor(e,t,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let s=t||_n.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,s);this.length=e}get(e){let t=this._data[3*e+0],i=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:i?on(i):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,t){this._data[3*e+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[2]<<22):this._data[3*e+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?on(2097151&t):""}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return $h=3*e,t.content=this._data[$h+0],t.fg=this._data[$h+1],t.bg=this._data[$h+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,i,s){268435456&s.bg&&(this._extendedAttrs[e]=s.extended),this._data[3*e+0]=t|i<<22,this._data[3*e+1]=s.fg,this._data[3*e+2]=s.bg}addCodepointToCell(e,t,i){let s=this._data[3*e+0];2097152&s?this._combined[e]+=on(t):2097151&s?(this._combined[e]=on(2097151&s)+on(t),s&=-2097152,s|=2097152):s=t|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[3*e+0]=s}insertCells(e,t,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length-e){let s=new _n;for(let i=this.length-e-t-1;i>=0;--i)this.setCell(e+t+i,this.loadCell(e+i,s));for(let r=0;r<t;++r)this.setCell(e+r,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,t,i){if(e%=this.length,t<this.length-e){let s=new _n;for(let i=0;i<this.length-e-t;++i)this.setCell(e+i,this.loadCell(e+t+i,s));for(let e=this.length-t;e<this.length;++e)this.setCell(e,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),0===this.getWidth(e)&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,t,i,s=!1){if(s)for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;else for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.setCell(e++,i)}resize(e,t){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let i=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*i)this._data=new Uint32Array(this._data.buffer,0,i);else{let e=new Uint32Array(i);e.set(this._data),this._data=e}for(let i=this.length;i<e;++i)this.setCell(i,t)}else{this._data=this._data.subarray(0,i);let t=Object.keys(this._combined);for(let i=0;i<t.length;i++){let s=parseInt(t[i],10);s>=e&&delete this._combined[s]}let s=Object.keys(this._extendedAttrs);for(let i=0;i<s.length;i++){let t=parseInt(s[i],10);t>=e&&delete this._extendedAttrs[t]}}return this.length=e,4*i*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,t,i,s,r){let n=e._data;if(r)for(let a=s-1;a>=0;a--){for(let e=0;e<3;e++)this._data[3*(i+a)+e]=n[3*(t+a)+e];268435456&n[3*(t+a)+2]&&(this._extendedAttrs[i+a]=e._extendedAttrs[t+a])}else for(let a=0;a<s;a++){for(let e=0;e<3;e++)this._data[3*(i+a)+e]=n[3*(t+a)+e];268435456&n[3*(t+a)+2]&&(this._extendedAttrs[i+a]=e._extendedAttrs[t+a])}let o=Object.keys(e._combined);for(let a=0;a<o.length;a++){let s=parseInt(o[a],10);s>=t&&(this._combined[s-t+i]=e._combined[s])}}translateToString(e,t,i,s){t=t??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let r="";for(;t<i;){let e=this._data[3*t+0],i=2097151&e,n=2097152&e?this._combined[t]:i?on(i):cn;if(r+=n,s)for(let r=0;r<n.length;++r)s.push(t);t+=e>>22||1}return s&&s.push(t),r}};function Uh(e,t,i){let s=[],r=e.map((i,s)=>qh(e,s,t)).reduce((e,t)=>e+t),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let l=qh(e,o,t);n>l&&(n-=l,o++);let h=2===e[o].getWidth(n-1);h&&n--;let c=h?i-1:i;s.push(c),a+=c}return s}function qh(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&1===e[t].getWidth(i-1),r=2===e[t+1].getWidth(0);return s&&r?i-1:i}var Vh=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new vo),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Gn(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Vh._nextId=1;var Yh=Vh,Gh={},Xh=Gh.B;Gh[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:"≥","{":"π","|":"≠","}":"£","~":"·"},Gh.A={"#":"£"},Gh.B=void 0,Gh[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},Gh.C=Gh[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Gh.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},Gh.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},Gh.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},Gh.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},Gh.E=Gh[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},Gh.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},Gh.H=Gh[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Gh["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Jh=4294967295,Zh=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Fh.clone(),this.savedCharset=Xh,this.markers=[],this._nullCell=_n.fromCharData([0,"",1,0]),this._whitespaceCell=_n.fromCharData([0,cn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new dh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Hh(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 un),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 un),this._whitespaceCell}getBlankLine(e,t){return new Kh(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>Jh?Jh:t}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=Fh);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 Hh(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Fh),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)s+=+this.lines.get(t).resize(e,i);let n=0;if(this._rows<t)for(let s=this._rows;s<t;s++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new Kh(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Kh(e,i)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let e=this.lines.length-r;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=function(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let l=a,h=e.get(++l);if(!h.isWrapped)continue;let c=[e.get(a)];for(;l<e.length&&h.isWrapped;)c.push(h),h=e.get(++l);if(!n&&s>=a&&s<l){a+=c.length-1;continue}let d=0,u=qh(c,d,t),_=1,f=0;for(;_<c.length;){let e=qh(c,_,t),s=e-f,n=i-u,o=Math.min(s,n);c[d].copyCellsFrom(c[_],f,u,o,!1),u+=o,u===i&&(d++,u=0),f+=o,f===e&&(_++,f=0),0===u&&0!==d&&2===c[d-1].getWidth(i-1)&&(c[d].copyCellsFrom(c[d-1],i-1,u++,1,!1),c[d-1].setCell(i-1,r))}c[d].replaceCells(u,i,r);let p=0;for(let e=c.length-1;e>0&&(e>d||0===c[e].getTrimmedLength());e--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Fh),i);if(s.length>0){let i=function(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let i=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:i}),o+=i-1,n+=i,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}(this.lines,s);(function(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length})(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Fh),r=i;for(;r-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Kh(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Fh),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let e=this.ybase+this.y;if(e>=o&&e<o+l.length)continue}let h,c=l[l.length-1].getTrimmedLength(),d=Uh(l,this._cols,e),u=d.length-l.length;h=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let e=0;e<u;e++){let e=this.getBlankLine(Fh,!0);_.push(e)}_.length>0&&(r.push({start:o+l.length+n,newLines:_}),n+=_.length),l.push(..._);let f=d.length-1,p=d[f];0===p&&(f--,p=d[f]);let m=l.length-u-1,g=c;for(;m>=0;){let e=Math.min(g,p);if(void 0===l[f])break;if(l[f].copyCellsFrom(l[m],g-e,p-e,e,!0),p-=e,0===p&&(f--,p=d[f]),g-=e,0===g){m--,g=qh(l,Math.max(m,0),this._cols)}}for(let t=0;t<l.length;t++)d[t]<e&&l[t].setCell(d[t],s);let v=u-h;for(;v-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(r.length>0){let e=[],t=[];for(let r=0;r<this.lines.length;r++)t.push(this.lines.get(r));let i=this.lines.length,s=i-1,o=0,a=r[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let l=0;for(let d=Math.min(this.lines.maxLength-1,i+n-1);d>=0;d--)if(a&&a.start>s+l){for(let e=a.newLines.length-1;e>=0;e--)this.lines.set(d--,a.newLines[e]);d++,e.push({index:s+1,amount:a.newLines.length}),l+=a.newLines.length,a=r[++o]}else this.lines.set(d,t[s--]);let h=0;for(let r=e.length-1;r>=0;r--)e[r].index+=h,this.lines.onInsertEmitter.fire(e[r]),h+=e[r].amount;let c=Math.max(0,i+n-this.lines.maxLength);c>0&&this.lines.onTrimEmitter.fire(c)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(null!=e?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(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(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 Yh(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Qh=class extends Qn{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new vo),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 Zh(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Zh(!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)}},ec=class extends Qn{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new vo),this.onResize=this._onResize.event,this._onScroll=this._register(new vo),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new Qh(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i,s=this.buffer;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;n===s.lines.length-1?e?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=n-r+1;s.lines.shiftElements(r+1,e-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(0===i.ydisp)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};ec=Yr([Gr(0,Cn)],ec);var tc={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:rh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ic=["normal","bold","100","200","300","400","500","600","700","800","900"],sc=class extends Qn{constructor(e){super(),this._onOptionChange=this._register(new vo),this.onOptionChange=this._onOptionChange.event;let t={...tc};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(Ta){console.error(Ta)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Xn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{-1!==e.indexOf(i)&&t()})}_setupOptions(){let e=e=>{if(!(e in tc))throw new Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in tc))throw new Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=tc[e]),"block"!==(i=t)&&"underline"!==i&&"bar"!==i)throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=tc[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof t&&1<=t&&t<=1e3)break;t=ic.includes(t)?t:tc[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(10*t)/10));break;case"scrollback":if((t=Math.min(t,4294967295))<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&&0!==t)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{}}var i;return t}};function rc(e,t=5){if("object"!=typeof e)return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&rc(e[s],t-1);return i}var nc=Object.freeze({insertMode:!1}),oc=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ac=class extends Qn{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new vo),this.onData=this._onData.event,this._onUserInput=this._register(new vo),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new vo),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new vo),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=rc(nc),this.decPrivateModes=rc(oc)}reset(){this.modes=rc(nc),this.decPrivateModes=rc(oc)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.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(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};ac=Yr([Gr(0,vn),Gr(1,yn),Gr(2,Cn)],ac);var lc={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>!(32===e.action&&3===e.button)},ANY:{events:31,restrict:e=>!0}};function hc(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(i|=64,i|=e.action):(i|=3&e.button,4&e.button&&(i|=64),8&e.button&&(i|=128),32===e.action?i|=32:0===e.action&&!t&&(i|=3)),i}var cc=String.fromCharCode,dc={DEFAULT:e=>{let t=[hc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`[M${cc(t[0])}${cc(t[1])}${cc(t[2])}`},SGR:e=>{let t=0===e.action&&4!==e.button?"m":"M";return`[<${hc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=0===e.action&&4!==e.button?"m":"M";return`[<${hc(e,!0)};${e.x};${e.y}${t}`}},uc=class extends Qn{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new vo),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(lc))this.addProtocol(s,lc[s]);for(let s of Object.keys(dc))this.addEncoding(s,dc[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(0===e.deltaY||e.shiftKey||void 0===t||void 0===i)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};uc=Yr([Gr(0,vn),Gr(1,bn),Gr(2,Cn)],uc);var _c,fc=[[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]],pc=[[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]];var mc=class{constructor(){if(this.version="6",!_c){(_c=new Uint8Array(65536)).fill(1),_c[0]=0,_c.fill(0,1,32),_c.fill(0,127,160),_c.fill(2,4352,4448),_c[9001]=2,_c[9002]=2,_c.fill(2,11904,42192),_c[12351]=1,_c.fill(2,44032,55204),_c.fill(2,63744,64256),_c.fill(2,65040,65050),_c.fill(2,65072,65136),_c.fill(2,65280,65377),_c.fill(2,65504,65511);for(let e=0;e<fc.length;++e)_c.fill(0,fc[e][0],fc[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?_c[e]:function(e,t){let i,s=0,r=t.length-1;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else{if(!(e<t[i][0]))return!0;r=i-1}return!1}(e,pc)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=0===i&&0!==t;if(s){let e=gc.extractWidth(t);0===e?s=!1:e>i&&(i=e)}return gc.createPropertyValue(0,i,s)}},gc=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new vo,this.onChange=this._onChange.event;let e=new mc;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(1&e)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,i=!1){return(16777215&e)<<3|(3&t)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let e=t.charCodeAt(n);56320<=e&&e<=57343?o=1024*(o-55296)+e-56320+65536:i+=this.wcwidth(e)}let a=this.charProperties(o,s),l=e.extractWidth(a);e.extractShouldJoin(a)&&(l-=e.extractWidth(s)),i+=l,s=a}return i}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},vc=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 Sc(e){var t;let i=null==(t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))?void 0:t.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&i&&(s.isWrapped=0!==i[3]&&32!==i[3])}var bc=2147483647,wc=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new e;if(!t.length)return i;for(let e=Array.isArray(t[0])?1:0;e<t.length;++e){let s=t[e];if(Array.isArray(s))for(let e=0;e<s.length;++e)i.addSubParam(s[e]);else i.addParam(s)}return i}clone(){let t=new e(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 e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>bc?bc:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)return void(this._rejectSubDigits=!0);if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>bc?bc:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,i=255&this._subParamsIdx[e];return i-t>0?this._subParams.subarray(t,i):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&(e[t]=this._subParams.slice(i,s))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[t-1];i[t-1]=~s?Math.min(10*s+e,bc):e}},xc=[],yc=class{constructor(){this._state=0,this._active=xc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let e=i.indexOf(t);-1!==e&&i.splice(e,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=xc}reset(){if(2===this._state)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=xc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||xc,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._id,"PUT",an(e,t,i))}start(){this.reset(),this._state=1}put(e,t,i){if(3!==this._state){if(1===this._state)for(;t<i;){let i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].end(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._id,"END",e);this._active=xc,this._id=-1,this._state=0}}},Cc=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=an(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,t}},kc=[],Ec=class{constructor(){this._handlers=Object.create(null),this._active=kc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kc}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let e=i.indexOf(t);-1!==e&&i.splice(e,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=kc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||kc,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t);else this._handlerFb(this._ident,"HOOK",t)}put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._ident,"PUT",an(e,t,i))}unhook(e,t=!0){if(this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].unhook(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",e);this._active=kc,this._ident=0}},Mc=new wc;Mc.addParam(0);var Nc=class{constructor(e){this._handler=e,this._data="",this._params=Mc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Mc,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=an(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=Mc,this._data="",this._hitLimit=!1,e));return this._params=Mc,this._data="",this._hitLimit=!1,t}},Dc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Rc=160,Lc=function(){let e=new Dc(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),i=(e,i)=>t.slice(e,i),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n,o=i(0,14);for(n in e.setDefault(1,0),e.addMany(s,0,2,0),o)e.addMany([24,26,153,154],n,3,0),e.addMany(i(128,144),n,3,0),e.addMany(i(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Rc,0,2,0),e.add(Rc,8,5,8),e.add(Rc,6,0,6),e.add(Rc,11,0,11),e.add(Rc,13,13,13),e}(),Pc=class extends Qn{constructor(e=Lc){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 wc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Xn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new yc),this._dcsParser=this._register(new Ec),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let t=0;t<e.intermediates.length;++t){let s=e.intermediates.charCodeAt(t);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=s}}if(1!==e.final.length)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);void 0===this._escHandlers[i]&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);void 0===this._csiHandlers[i]&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s,r=0,n=0,o=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===i||1===this._parseStack.state)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let t=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](this._params),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 4:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],s=this._dcsParser.unhook(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],s=this._oscParser.end(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let a=o;a<t;++a){switch(r=e[a],n=this._transitions.table[this.currentState<<8|(r<160?r:Rc)],n>>4){case 2:for(let s=a+1;;++s){if(s>=t||(r=e[s])<32||r>126&&r<Rc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Rc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Rc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Rc){this._printHandler(e,a,s),a=s-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let i=this._csiHandlers[this._collect<<8|r],o=i?i.length-1:-1;for(;o>=0&&(s=i[o](this._params),!0!==s);o--)if(s instanceof Promise)return this._preserveStack(3,i,o,n,a),s;o<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do{switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}}while(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let l=this._escHandlers[this._collect<<8|r],h=l?l.length-1:-1;for(;h>=0&&(s=l[h](),!0!==s);h--)if(s instanceof Promise)return this._preserveStack(4,l,h,n,a),s;h<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let s=a+1;;++s)if(s>=t||24===(r=e[s])||26===r||27===r||r>127&&r<Rc){this._dcsParser.put(e,a,s),a=s-1;break}break;case 14:if(s=this._dcsParser.unhook(24!==r&&26!==r),s)return this._preserveStack(6,[],0,n,a),s;27===r&&(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 s=a+1;;s++)if(s>=t||(r=e[s])<32||r>127&&r<Rc){this._oscParser.put(e,a,s),a=s-1;break}break;case 6:if(s=this._oscParser.end(24!==r&&26!==r),s)return this._preserveStack(5,[],0,n,a),s;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},Bc=/^([\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})$/,Tc=/^[\da-f]+$/;function jc(e){if(!e)return;let t=e.toLowerCase();if(0===t.indexOf("rgb:")){t=t.slice(4);let e=Bc.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(0===t.indexOf("#")&&(t=t.slice(1),Tc.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,i=[0,0,0];for(let s=0;s<3;++s){let r=parseInt(t.slice(e*s,e*s+e),16);i[s]=1===e?r<<4:2===e?r:3===e?r>>4:r>>8}return i}}function Oc(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Ac(e,t=16){let[i,s,r]=e;return`rgb:${Oc(i,t)}/${Oc(s,t)}/${Oc(r,t)}`}var Ic={"(":0,")":1,"*":2,"+":3,"-":1,".":2},zc=131072;function Wc(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 Hc=0,Fc=class extends Qn{constructor(e,t,i,s,r,n,o,a,l=new Pc){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ln,this._utf8Decoder=new hn,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Fh.clone(),this._eraseAttrDataInternal=Fh.clone(),this._onRequestBell=this._register(new vo),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new vo),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new vo),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new vo),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new vo),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new vo),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new vo),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new vo),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new vo),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new vo),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new vo),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new vo),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new vo),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 $c(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,t,i)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:i})}),this._parser.setDcsHandlerFallback((e,t,i)=>{"HOOK"===t&&(i=i.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:t,payload:i})}),this._parser.setPrintHandler((e,t,i)=>this.print(e,t,i)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(sl.BEL,()=>this.bell()),this._parser.setExecuteHandler(sl.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(sl.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(sl.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(sl.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(sl.BS,()=>this.backspace()),this._parser.setExecuteHandler(sl.HT,()=>this.tab()),this._parser.setExecuteHandler(sl.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(sl.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(nl.IND,()=>this.index()),this._parser.setExecuteHandler(nl.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(nl.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Cc(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Cc(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Cc(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Cc(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Cc(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Cc(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Cc(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Cc(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Cc(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Cc(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Cc(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Cc(e=>this.restoreCursorColor(e))),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 h in Gh)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Nc((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>zc&&(n=this._parseStack.position+zc)}if(this._logService.logLevel<=1&&this._logService.debug("parsing data "+("string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`)),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<zc&&(this._parseBuffer=new Uint32Array(Math.min(e.length,zc))),o||this._dirtyRowTracker.clearRange(),e.length>zc)for(let h=n;h<e.length;h+=zc){let t=h+zc<e.length?h+zc:e.length,n="string"==typeof e?this._stringDecoder.decode(e.substring(h,t),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,t),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,n))return this._preserveStack(s,r,n,h),this._logSlowResolvingAsync(i),i}else if(!o){let t="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,t))return this._preserveStack(s,r,t,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,c=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&2===d.getWidth(this._activeBuffer.x-1)&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let _=t;_<i;++_){if(s=e[_],s<127&&n){let e=n[String.fromCharCode(s)];e&&(s=e.charCodeAt(0))}let t=this._unicodeService.charProperties(s,u);r=gc.extractWidth(t);let i=gc.extractShouldJoin(t),f=i?gc.extractWidth(u):0;if(u=t,o&&this._onA11yChar.fire(on(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-f>a)if(l){let e=d,t=this._activeBuffer.x-f;for(this._activeBuffer.x=f,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),f>0&&d instanceof Kh&&d.copyCellsFrom(e,t,0,f,!1);t<a;)e.setCellFromCodepoint(t++,0,1,c)}else if(this._activeBuffer.x=a-1,2===r)continue;if(i&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,s,r);for(let t=r-f;--t>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(d.insertCells(this._activeBuffer.x,r-f,this._activeBuffer.getNullCell(c)),2===d.getWidth(a-1)&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x<a&&i-t>0&&0===d.getWidth(this._activeBuffer.x)&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,e=>!Wc(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Nc(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Cc(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(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(null==(e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))?void 0: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 e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.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 0===t?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===t&&(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 1===t&&(this._curAttrData.bg|=536870912),(2===t||0===t)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,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--&&!(null==(i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))?void 0: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 e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}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,0===this._activeBuffer.x,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)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i,s=this._activeBuffer.ybase+this._activeBuffer.y;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(Fh));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=gc.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let h=0;h<n.length;){let e=n.codePointAt(h)||0;o[a++]=e,h+=e>65535?2:1}let l=a;for(let h=1;h<i;++h)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(sl.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(sl.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(sl.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(sl.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(sl.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}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}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,Xh),this._charsetService.setgCharset(1,Xh),this._charsetService.setgCharset(2,Xh),this._charsetService.setgCharset(3,Xh);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}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}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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[t]&&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)}return!0}requestMode(e,t){let i;var s;(s=i||(i={}))[s.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",s[s.SET=1]="SET",s[s.RESET=2]="RESET",s[s.PERMANENTLY_SET=3]="PERMANENTLY_SET",s[s.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let r=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,_=(e,i)=>(a.triggerDataEvent(`${sl.ESC}[${t?"":"?"}${e};${i}$y`),!0),f=e=>e?1:2,p=e.params[0];return _(p,t?2===p?4:4===p?f(a.modes.insertMode):12===p?3:20===p?f(u.convertEol):0:1===p?f(r.applicationCursorKeys):3===p?u.windowOptions.setWinLines?80===h?2:132===h?1:0:0:6===p?f(r.origin):7===p?f(r.wraparound):8===p?3:9===p?f("X10"===n):12===p?f(u.cursorBlink):25===p?f(!a.isCursorHidden):45===p?f(r.reverseWraparound):66===p?f(r.applicationKeypad):67===p?4:1e3===p?f("VT200"===n):1002===p?f("DRAG"===n):1003===p?f("ANY"===n):1004===p?f(r.sendFocus):1005===p?4:1006===p?f("SGR"===o):1015===p?4:1016===p?f("SGR_PIXELS"===o):1048===p?1:47===p||1047===p||1049===p?f(c===d):2004===p?f(r.bracketedPasteMode):2026===p?f(r.synchronizedOutput):0)}_updateAttrColor(e,t,i,s,r){return 2===t?(e|=50331648,e&=-16777216,e|=dn.fromColorRGB([i,s,r])):5===t&&(e&=-50331904,e|=33554432|255&i),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let i=e.getSubParams(t+n),o=0;do{5===s[1]&&(r=1),s[n+o+1+r]=i[o]}while(++o<i.length&&o+n+1+r<s.length);break}if(5===s[1]&&n+r>=2||2===s[1]&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)-1===s[o]&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,0===e&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Fh.fg,e.bg=Fh.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let t,i=e.length,s=this._curAttrData;for(let r=0;r<i;r++)t=e.params[r],t>=30&&t<=37?(s.fg&=-50331904,s.fg|=16777216|t-30):t>=40&&t<=47?(s.bg&=-50331904,s.bg|=16777216|t-40):t>=90&&t<=97?(s.fg&=-50331904,s.fg|=16777224|t-90):t>=100&&t<=107?(s.bg&=-50331904,s.bg|=16777224|t-100):0===t?this._processSGR0(s):1===t?s.fg|=134217728:3===t?s.bg|=67108864:4===t?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):5===t?s.fg|=536870912:7===t?s.fg|=67108864:8===t?s.fg|=1073741824:9===t?s.fg|=2147483648:2===t?s.bg|=134217728:21===t?this._processUnderline(2,s):22===t?(s.fg&=-134217729,s.bg&=-134217729):23===t?s.bg&=-67108865:24===t?(s.fg&=-268435457,this._processUnderline(0,s)):25===t?s.fg&=-536870913:27===t?s.fg&=-67108865:28===t?s.fg&=-1073741825:29===t?s.fg&=2147483647:39===t?(s.fg&=-67108864,s.fg|=16777215&Fh.fg):49===t?(s.bg&=-67108864,s.bg|=16777215&Fh.bg):38===t||48===t||58===t?r+=this._extractColor(e,r,s):53===t?s.bg|=1073741824:55===t?s.bg&=-1073741825:59===t?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):100===t?(s.fg&=-67108864,s.fg|=16777215&Fh.fg,s.bg&=-67108864,s.bg|=16777215&Fh.bg):this._logService.debug("Unknown SGR attribute: %d.",t);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${sl.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${sl.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${sl.ESC}[?${e};${t}R`)}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=Fh.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=0===e.length?1:e.params[0];if(0===t)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"}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t,i=e.params[0]||1;return(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Wc(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==t&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${sl.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===t||2===t)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===t||1===t)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===t||2===t)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===t||1===t)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let e=i.shift(),s=i.shift();if(/^\d+$/.exec(e)){let i=parseInt(e);if(Kc(i))if("?"===s)t.push({type:0,index:i});else{let e=jc(s);e&&t.push({type:1,index:i,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(-1===t)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):!i.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i,s=e.split(":"),r=s.findIndex(e=>e.startsWith("id="));return-1!==r&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if("?"===i[s])this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let e=jc(i[s]);e&&this._onColor.fire([{type:1,index:this._specialColors[t],color:e}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let e=parseInt(i[s]);Kc(e)&&t.push({type:2,index:e})}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,Xh),!0}selectCharset(e){return 2!==e.length?(this.selectDefaultCharset(),!0):("/"===e[0]||this._charsetService.setgCharset(Ic[e[0]],Gh[e[1]]||Xh),!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=Fh.clone(),this._eraseAttrDataInternal=Fh.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new _n;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=this._bufferService.buffer,s=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${sl.ESC}${e}${sl.ESC}\\`),!0))('"q'===e?`P1$r${this._curAttrData.isProtected()?1:0}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},$c=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&&(Hc=e,e=t,t=Hc),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Kc(e){return 0<=e&&e<256}$c=Yr([Gr(0,vn)],$c);var Uc=class extends Qn{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 vo),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(void 0!==t&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let i;for(this._isSyncWriting=!0;i=this._writeBuffer.shift();){this._action(i);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],s=this._action(e,t);if(s){let e=e=>performance.now()-i>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(i,e);return void s.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e)}let r=this._callbacks[this._bufferOffset];if(r&&r(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-i>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},qc=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(void 0===e.id){let i=t.addMarker(t.ybase+t.y),s={data:e,id:this._nextId++,lines:[i]};return i.onDispose(()=>this._removeMarkerFromLink(s,i)),this._dataByLinkId.set(s.id,s),s.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);i.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(i,e))}}getLinkData(e){var t;return null==(t=this._dataByLinkId.get(e))?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);-1!==i&&(e.lines.splice(i,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};qc=Yr([Gr(0,vn)],qc);var Vc=!1,Yc=class extends Qn{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new eo),this._onBinary=this._register(new vo),this.onBinary=this._onBinary.event,this._onData=this._register(new vo),this.onData=this._onData.event,this._onLineFeed=this._register(new vo),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new vo),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new vo),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new vo),this._instantiationService=new Ih,this.optionsService=this._register(new sc(e)),this._instantiationService.setService(Cn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ec)),this._instantiationService.setService(vn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Wh)),this._instantiationService.setService(yn,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ac)),this._instantiationService.setService(bn,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(uc)),this._instantiationService.setService(Sn,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(gc)),this._instantiationService.setService(En,this.unicodeService),this._charsetService=this._instantiationService.createInstance(vc),this._instantiationService.setService(wn,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qc),this._instantiationService.setService(kn,this._oscLinkService),this._inputHandler=this._register(new Fc(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(so.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(so.forward(this._bufferService.onResize,this._onResize)),this._register(so.forward(this.coreService.onData,this._onData)),this._register(so.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 Uc((e,t)=>this._inputHandler.parse(e,t))),this._register(so.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new vo),this._onScroll.event(e=>{var t;null==(t=this._onScrollApi)||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&&!Vc&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Vc=!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,2),t=Math.max(t,1),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;0!==t&&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&&void 0!==t.buildNumber&&void 0!==t.buildNumber?e="conpty"===t.backend&&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(Sc.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Sc(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Xn(()=>{for(let t of e)t.dispose()})}}},Gc={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:["'",'"']};var Xc=0,Jc=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new dh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new dh,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(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let t=this._getKey(e);if(void 0===t||-1===(Xc=this._search(t))||this._getKey(this._array[Xc])!==t)return!1;do{if(this._array[Xc]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Xc),!0}while(++Xc<this._array.length&&this._getKey(this._array[Xc])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&(!((Xc=this._search(e))<0||Xc>=this._array.length)&&this._getKey(this._array[Xc])===e))do{yield this._array[Xc]}while(++Xc<this._array.length&&this._getKey(this._array[Xc])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&(!((Xc=this._search(e))<0||Xc>=this._array.length)&&this._getKey(this._array[Xc])===e))do{t(this._array[Xc])}while(++Xc<this._array.length&&this._getKey(this._array[Xc])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else{if(!(r<e)){for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}t=s+1}}return t}},Zc=0,Qc=0,ed=class extends Qn{constructor(){super(),this._decorations=new Jc(e=>null==e?void 0:e.marker.line),this._onDecorationRegistered=this._register(new vo),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new vo),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Xn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new td(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,t=>{Zc=t.options.x??0,Qc=Zc+(t.options.width??1),e>=Zc&&e<Qc&&(!i||(t.options.layer??"bottom")===i)&&s(t)})}},td=class extends Zn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new vo),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new vo),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 null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=ml.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=ml.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},id=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=s-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)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)}},sd=class extends Qn{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new id(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(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar("\n"))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ca(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Xn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=en())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let e=i.lines.get(i.ydisp+r),t=[],n=(null==e?void 0:e.translateToString(!0,void 0,void 0,t))||"",o=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(0===n.length?(a.textContent=" ",this._rowColumns.set(a,[0,1])):(a.textContent=n,this._rowColumns.set(a,t)),a.setAttribute("aria-posinset",o),a.setAttribute("aria-setsize",s),this._alignRowWidth(a))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i,s,r=e.target,n=this._rowElements[0===t?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===t?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===n){if(0===t?(i=r,s=this._rowElements.pop(),this._rowContainer.removeChild(s)):(i=this._rowElements.shift(),s=r,this._rowContainer.removeChild(i)),i.removeEventListener("focus",this._topBoundaryFocusListener),s.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){var e;if(0===this._rowElements.length)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed)return void(this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection());if(!t.anchorNode||!t.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:(null==(e=r.textContent)?void 0:e.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:t})=>{let i=e instanceof Text?e.parentNode:e,s=parseInt(null==i?void 0:i.getAttribute("aria-posinset"),10)-1;if(isNaN(s))return console.warn("row is invalid. Race condition?"),null;let r=this._rowColumns.get(i);if(!r)return console.warn("columns is null. Race condition?"),null;let n=t<r.length?r[t]:r.slice(-1)[0]+1;return n>=this._terminal.cols&&(++s,n=0),{row:s,column:n}},o=n(i),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 t,i;e.style.transform="";let s=e.getBoundingClientRect().width,r=null==(i=null==(t=this._rowColumns.get(e))?void 0:t.slice(-1))?void 0:i[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/s})`}};sd=Yr([Gr(1,xn),Gr(2,Ln),Gr(3,Bn)],sd);var rd=class extends Qn{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new vo),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new vo),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Xn(()=>{var e;Gn(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,null==(e=this._activeProviderReplies)||e.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ca(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ca(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ca(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ca(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let e=i[s];if(e.classList.contains("xterm"))break;if(e.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)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,s;(!this._activeProviderReplies||!t)&&(null==(i=this._activeProviderReplies)||i.forEach(e=>{null==e||e.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(null==(s=this._activeProviderReplies)?void 0:s.get(n))&&(r=this._checkLinkProviderResult(n,e,r)):o.provideLinks(e.y,t=>{var i,s;if(this._isMouseOut)return;let o=null==t?void 0:t.map(e=>({link:e}));null==(i=this._activeProviderReplies)||i.set(n,o),r=this._checkLinkProviderResult(n,e,r),(null==(s=this._activeProviderReplies)?void 0:s.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let t=0;t<r.length;t++){let s=r[t],n=s.link.range.start.y<e?0:s.link.range.start.x,o=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let e=n;e<=o;e++){if(i.has(e)){r.splice(t--,1);break}i.add(e)}}}}_checkLinkProviderResult(e,t,i){var s;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(e),n=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(n=!0);if(!n&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(i=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let e=null==(s=this._activeProviderReplies.get(o))?void 0:s.find(e=>this._linkAtPosition(e.link,t));if(e){i=!0,this._handleNewLink(e);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);var i,s;t&&this._mouseDownLink&&(i=this._mouseDownLink.link,s=this._currentLink.link,i.text===s.text&&i.range.start.x===s.range.start.x&&i.range.start.y===s.range.start.y&&i.range.end.x===s.range.end.x&&i.range.end.y===s.range.end.y)&&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,Gn(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:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||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 e,t;return null==(t=null==(e=this._currentLink)?void 0:e.state)?void 0:t.decorations.pointerCursor},set:e=>{var t;(null==(t=this._currentLink)?void 0:t.state)&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>{var e,t;return null==(t=null==(e=this._currentLink)?void 0:e.state)?void 0:t.decorations.underline},set:t=>{var i,s,r;(null==(i=this._currentLink)?void 0:i.state)&&(null==(r=null==(s=this._currentLink)?void 0:s.state)?void 0:r.decorations.underline)!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(t,i),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,i){var s;(null==(s=this._currentLink)?void 0:s.state)&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(null==(s=this._currentLink)?void 0:s.state)&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};rd=Yr([Gr(1,Pn),Gr(2,Bn),Gr(3,vn),Gr(4,An)],rd);var nd=class extends Yc{constructor(e={}){super(e),this._linkifier=this._register(new eo),this.browser=Xl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new eo),this._onCursorMove=this._register(new vo),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new vo),this.onKey=this._onKey.event,this._onRender=this._register(new vo),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new vo),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new vo),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new vo),this.onBell=this._onBell.event,this._onFocus=this._register(new vo),this._onBlur=this._register(new vo),this._onA11yCharEmitter=this._register(new vo),this._onA11yTabEmitter=this._register(new vo),this._onWillOpen=this._register(new vo),this._setup(),this._decorationService=this._instantiationService.createInstance(ed),this._instantiationService.setService(Mn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ql),this._instantiationService.setService(An,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Nn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh((null==e?void 0:e.start)??0,(null==e?void 0:e.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(so.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(so.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(so.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(so.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Xn(()=>{var e,t;this._customKeyEventHandler=void 0,null==(t=null==(e=this.element)?void 0:e.parentNode)||t.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 e,i="";switch(t.index){case 256:e="foreground",i="10";break;case 257:e="background",i="11";break;case 258:e="cursor",i="12";break;default:e="ansi",i="4;"+t.index}switch(t.type){case 0:let s=pl.toColorRGB("ansi"===e?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${sl.ESC}]${i};${Ac(s)}${al.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[t.index]=fl.toColor(...t.color));else{let i=e;this._themeService.modifyColors(e=>e[i]=fl.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_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(sd,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(sl.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return null==(e=this.textarea)?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(sl.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ca(this.element,"copy",e=>{var t,i;this.hasSelection()&&(t=e,i=this._selectionService,t.clipboardData&&t.clipboardData.setData("text/plain",i.selectionText),t.preventDefault())}));let e=e=>function(e,t,i,s){e.stopPropagation(),e.clipboardData&&sn(e.clipboardData.getData("text/plain"),t,i,s)}(e,this.textarea,this.coreService,this.optionsService);this._register(Ca(this.textarea,"paste",e)),this._register(Ca(this.element,"paste",e)),eh?this._register(Ca(this.element,"mousedown",e=>{2===e.button&&nn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ca(this.element,"contextmenu",e=>{nn(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),lh&&this._register(Ca(this.element,"auxclick",e=>{1===e.button&&rn(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ca(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ca(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ca(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ca(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ca(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ca(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ca(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var t;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"),(null==(t=this.element)?void 0:t.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));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 i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ca(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Jr()),hh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Kl,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ln,this._coreBrowserService),this._register(Ca(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(Ca(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wl,this._document,this._helperContainer),this._instantiationService.setService(Rn,this._charSizeService),this._themeService=this._instantiationService.createInstance(jh),this._instantiationService.setService(On,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ml),this._instantiationService.setService(jn,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(_h,this.rows,this.screenElement)),this._instantiationService.setService(Bn,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(_l,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Yl),this._instantiationService.setService(Pn,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(rd,this.screenElement));this.element.appendChild(i);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(tl,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(kh,this.element,this.screenElement,r)),this._instantiationService.setService(Tn,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(so.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var e;this._selectionService.refresh(),null==(e=this._viewport)||e.queueSync()})),this._register(this._instantiationService.createInstance(il,this.screenElement)),this._register(Ca(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),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(sd,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ul,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(t){var i,s,r,n,o;let a,l,h=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!h)return!1;switch(t.overrideType||t.type){case"mousemove":l=32,void 0===t.buttons?(a=3,void 0!==t.button&&(a=t.button<3?t.button:3)):a=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case"mouseup":l=0,a=t.button<3?t.button:3;break;case"mousedown":l=1,a=t.button<3?t.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t))return!1;let h=t.deltaY;if(0===h||0===e.coreMouseService.consumeWheelEvent(t,null==(n=null==(r=null==(s=null==(i=e._renderService)?void 0:i.dimensions)?void 0:s.device)?void 0:r.cell)?void 0:n.height,null==(o=e._coreBrowserService)?void 0:o.dpr))return!1;l=h<0?0:1,a=4;break;default:return!1}return!(void 0===l||void 0===a||a>4)&&e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:a,action:l,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:e=>(i(e),e.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(e)),wheel:e=>(i(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&i(e)},mousemove:e=>{e.buttons||i(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),16&e?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),2&e?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),4&e?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ca(t,"mousedown",e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return i(e),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(e)})),this._register(Ca(t,"wheel",t=>{var i,r,n,o,a;if(!s.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(t))return!1;if(!this.buffer.hasScrollback){if(0===t.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(t,null==(o=null==(n=null==(r=null==(i=e._renderService)?void 0:i.dimensions)?void 0:r.device)?void 0:n.cell)?void 0:o.height,null==(a=e._coreBrowserService)?void 0:a.dpr))return this.cancel(t,!0);let s=sl.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){var i;null==(i=this._renderService)||i.refreshRows(e,t)}updateCursorStyle(e){var t;(null==(t=this._selectionService)?void 0: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;0!==t&&this.scrollLines(t)}paste(e){sn(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}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;null==(e=this._selectionService)||e.clearSelection()}selectAll(){var e;null==(e=this._selectionService)||e.selectAll()}selectLines(e,t){var i;null==(i=this._selectionService)||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))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&&("Dead"===e.key||"AltGraph"===e.key)&&(this._unprocessedDeadKey=!0);let i=function(e,t,i,s){var r;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:"UIKeyInputUpArrow"===e.key?n.key=t?sl.ESC+"OA":sl.ESC+"[A":"UIKeyInputLeftArrow"===e.key?n.key=t?sl.ESC+"OD":sl.ESC+"[D":"UIKeyInputRightArrow"===e.key?n.key=t?sl.ESC+"OC":sl.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(n.key=t?sl.ESC+"OB":sl.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":sl.DEL,e.altKey&&(n.key=sl.ESC+n.key);break;case 9:if(e.shiftKey){n.key=sl.ESC+"[Z";break}n.key=sl.HT,n.cancel=!0;break;case 13:n.key=e.altKey?sl.ESC+sl.CR:sl.CR,n.cancel=!0;break;case 27:n.key=sl.ESC,e.altKey&&(n.key=sl.ESC+sl.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;n.key=o?sl.ESC+"[1;"+(o+1)+"D":t?sl.ESC+"OD":sl.ESC+"[D";break;case 39:if(e.metaKey)break;n.key=o?sl.ESC+"[1;"+(o+1)+"C":t?sl.ESC+"OC":sl.ESC+"[C";break;case 38:if(e.metaKey)break;n.key=o?sl.ESC+"[1;"+(o+1)+"A":t?sl.ESC+"OA":sl.ESC+"[A";break;case 40:if(e.metaKey)break;n.key=o?sl.ESC+"[1;"+(o+1)+"B":t?sl.ESC+"OB":sl.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=sl.ESC+"[2~");break;case 46:n.key=o?sl.ESC+"[3;"+(o+1)+"~":sl.ESC+"[3~";break;case 36:n.key=o?sl.ESC+"[1;"+(o+1)+"H":t?sl.ESC+"OH":sl.ESC+"[H";break;case 35:n.key=o?sl.ESC+"[1;"+(o+1)+"F":t?sl.ESC+"OF":sl.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=sl.ESC+"[5;"+(o+1)+"~":n.key=sl.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=sl.ESC+"[6;"+(o+1)+"~":n.key=sl.ESC+"[6~";break;case 112:n.key=o?sl.ESC+"[1;"+(o+1)+"P":sl.ESC+"OP";break;case 113:n.key=o?sl.ESC+"[1;"+(o+1)+"Q":sl.ESC+"OQ";break;case 114:n.key=o?sl.ESC+"[1;"+(o+1)+"R":sl.ESC+"OR";break;case 115:n.key=o?sl.ESC+"[1;"+(o+1)+"S":sl.ESC+"OS";break;case 116:n.key=o?sl.ESC+"[15;"+(o+1)+"~":sl.ESC+"[15~";break;case 117:n.key=o?sl.ESC+"[17;"+(o+1)+"~":sl.ESC+"[17~";break;case 118:n.key=o?sl.ESC+"[18;"+(o+1)+"~":sl.ESC+"[18~";break;case 119:n.key=o?sl.ESC+"[19;"+(o+1)+"~":sl.ESC+"[19~";break;case 120:n.key=o?sl.ESC+"[20;"+(o+1)+"~":sl.ESC+"[20~";break;case 121:n.key=o?sl.ESC+"[21;"+(o+1)+"~":sl.ESC+"[21~";break;case 122:n.key=o?sl.ESC+"[23;"+(o+1)+"~":sl.ESC+"[23~";break;case 123:n.key=o?sl.ESC+"[24;"+(o+1)+"~":sl.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(i&&!s||!e.altKey||e.metaKey)!i||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?n.key=e.key:e.key&&e.ctrlKey&&("_"===e.key&&(n.key=sl.US),"@"===e.key&&(n.key=sl.NUL)):65===e.keyCode&&(n.type=1);else{let t=null==(r=Gc[e.keyCode])?void 0:r[e.shiftKey?1:0];if(t)n.key=sl.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,i=String.fromCharCode(t);e.shiftKey&&(i=i.toUpperCase()),n.key=sl.ESC+i}else if(32===e.keyCode)n.key=sl.ESC+(e.ctrlKey?sl.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),n.key=sl.ESC+t,n.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=sl.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=sl.DEL:219===e.keyCode?n.key=sl.ESC:220===e.keyCode?n.key=sl.FS:221===e.keyCode&&(n.key=sl.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===i.type||2===i.type){let t=this.rows-1;return this.scrollLines(2===i.type?-t:t),this.cancel(e,!0)}return 1===i.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((i.key===sl.ETX||i.key===sl.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0)))}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return"keypress"===t.type?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){var t;this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(e))&&(16===(t=e).keyCode||17===t.keyCode||18===t.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null===e.which||void 0===e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e))&&(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&&"insertText"===e.inputType&&(!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){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){var i;null==(i=this._charSizeService)||i.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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(Fh));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var e;this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),null==(e=this._selectionService)||e.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;null==(e=this._renderService)||e.clearTextureAtlas()}_reportFocus(){var e;(null==(e=this.element)?void 0:e.classList.contains("focus"))?this.coreService.triggerDataEvent(sl.ESC+"[I"):this.coreService.triggerDataEvent(sl.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${sl.ESC}[4;${t};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${sl.ESC}[6;${s};${i}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};var od=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(-1===t)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)}},ad=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 _n)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},ld=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 ad(t)}getNullCell(){return new _n}},hd=class extends Qn{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new vo),this.onBufferChange=this._onBufferChange.event,this._normal=new ld(this._core.buffers.normal,"normal"),this._alternate=new ld(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)}},cd=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,i)=>t(e,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)}},dd=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}},ud=["cols","rows"],_d=0,fd=class extends Qn{constructor(e){super(),this._core=this._register(new nd(e)),this._addonManager=this._register(new od),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],i=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let s in this._core.options){let e={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,e)}}_checkReadonlyOptions(e){if(ud.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 cd(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new dd(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 hd(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"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write("\r\n",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 Jr()},set promptLabel(e){Zr(e)},get tooMuchOutput(){return en()},set tooMuchOutput(e){tn(e)}}}_verifyIntegers(...e){for(_d of e)if(_d===1/0||isNaN(_d)||_d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(_d of e)if(_d&&(_d===1/0||isNaN(_d)||_d%1!=0||_d<0))throw new Error("This API only accepts positive integers")}},pd=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 e;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:(null==(e=this._terminal.options.overviewRuler)?void 0:e.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),l=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-i;return{cols:Math.max(2,Math.floor(l/t.css.cell.width)),rows:Math.max(1,Math.floor(a/t.css.cell.height))}}},md=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?yd.isErrorNoTelemetry(e)?new yd(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function gd(e){(function(e){return e instanceof xd||e instanceof Error&&e.name===vd&&e.message===vd})(e)||md.onUnexpectedError(e)}var vd="Canceled";var Sd,bd,wd,xd=class extends Error{constructor(){super(vd),this.name=this.message}},yd=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function Cd(e,t){let i,s=this,r=!1;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}function kd(e){if(wd.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(Ta){t.push(Ta)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Ed(...e){return Md(()=>kd(e))}function Md(e){return{dispose:Cd(()=>{e()})}}(bd=Sd||(Sd={})).isLessThan=function(e){return e<0},bd.isLessThanOrEqual=function(e){return e<=0},bd.isGreaterThan=function(e){return e>0},bd.isNeitherLessOrGreaterThan=function(e){return 0===e},bd.greaterThan=1,bd.lessThan=-1,bd.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*s(e){yield e}e.empty=function(){return i},e.single=s,e.wrap=function(e){return t(e)?e:s(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let s of e)if(t(s,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let s of e)yield t(s,i++)},e.flatMap=function*(e,t){let i=0;for(let s of e)yield*t(s,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let s=i;for(let r of e)s=t(s,r);return s},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let s=[];if(0===i)return[s,t];let r=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=r.next();if(t.done)return[s,e.empty()];s.push(t.value)}return[s,{[Symbol.iterator]:()=>r}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(wd||(wd={}));var Nd=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{kd(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?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};Nd.DISABLE_DISPOSED_WARNING=!1;var Dd=Nd,Rd=class{constructor(){this._store=new Dd,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)}};Rd.None=Object.freeze({dispose(){}});var Ld,Pd=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Bd=globalThis.performance&&"function"==typeof globalThis.performance.now,Td=class e{static create(t){return new e(t)}constructor(e){this._now=Bd&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,s)=>{let r,n=!1;return r=e(e=>{if(!n)return r?r.dispose():n=!0,t.call(i,e)},null,s),n&&r.dispose(),r}}function i(e,t,i){return r((i,s=null,r)=>e(e=>i.call(s,t(e)),null,r),i)}function s(e,t,i){return r((i,s=null,r)=>e(e=>t(e)&&i.call(s,e),null,r),i)}function r(e,t){let i,s=new Ud({onWillAddFirstListener(){i=e(s.fire,s)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(s),s.event}function n(e,t,i=100,s=!1,r=!1,n,o){let a,l,h,c,d=0,u=new Ud({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{d++,l=t(l,e),s&&!h&&(u.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!s||d>1)&&u.fire(e),d=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){r&&d>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(u),u.event}e.None=()=>Rd.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return r((i,s=null,r)=>e(e=>{t(e),i.call(s,e)},null,r),i)},e.filter=s,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,s)=>{let r=Ed(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(r,s)}},e.reduce=function(e,t,s,r){let n=s;return i(e,e=>(n=t(n,e),n),r)},e.debounce=n,e.accumulate=function(t,i=0,s){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,s)},e.latch=function(e,t=(e,t)=>e===t,i){let r,n=!0;return s(e,e=>{let i=n||!t(e,r);return n=!1,r=e,i},i)},e.split=function(t,i,s){return[e.filter(t,i,s),e.filter(t,e=>!i(e),s)]},e.buffer=function(e,t=!1,i=[],s){let r=i.slice(),n=e(e=>{r?r.push(e):a.fire(e)});s&&s.add(n);let o=()=>{null==r||r.forEach(e=>a.fire(e)),r=null},a=new Ud({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),s&&s.add(n))},onDidAddFirstListener(){r&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return s&&s.add(a),a.event},e.chain=function(e,t){return(i,s,r)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(s,t)},void 0,r)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(s=>{let r=i||!e(s,t);return i=!1,t=s,r?s:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new Ud({onWillAddFirstListener:()=>e.on(t,s),onDidRemoveLastListener:()=>e.removeListener(t,s)});return r.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new Ud({onWillAddFirstListener:()=>e.addEventListener(t,s),onDidRemoveLastListener:()=>e.removeEventListener(t,s)});return r.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Ud;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Ud(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,s)=>{let r=0,n=!1,o={beginUpdate(){r++},endUpdate(){r--,0===r&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return s instanceof Dd?s.add(a):Array.isArray(s)&&s.push(a),a}}})(Ld||(Ld={}));var jd=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Td,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};jd.all=new Set,jd._idPool=0;var Od=jd,Ad=class e{constructor(t,i,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,s]=this.getMostFrequentStack(),r=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${s}):`;console.warn(r),console.warn(e);let n=new Hd(r,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,s]of this._stacks)(!e||t<s)&&(e=[i,s],t=s);return e}};Ad._idPool=1;var Id,zd=Ad,Wd=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Hd=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Fd=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},$d=0,Kd=class{constructor(e){this.value=e,this.id=$d++}},Ud=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new zd((null==e?void 0:e.onListenerError)??gd,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(s=this._options)?void 0:s._profName)?new Od(this._options._profName):void 0,this._deliveryQueue=null==(r=this._options)?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(s=this._leakageMon)||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var s,r,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new Fd(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(s=this._options)?void 0:s.onListenerError)||gd)(i),Rd.None}if(this._disposed)return Rd.None;t&&(e=e.bind(t));let l,h=new Kd(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Wd.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof Kd?(this._deliveryQueue??(this._deliveryQueue=new qd),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(r=this._options)?void 0:r.onWillAddFirstListener)||n.call(r,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=Md(()=>{null==l||l(),this._removeListener(h)});return i instanceof Dd?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,s,r;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(r=null==(s=this._options)?void 0:s.onDidRemoveLastListener)||r.call(s,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let s=(null==(i=this._options)?void 0:i.onListenerError)||gd;if(s)try{e.value(t)}catch(zo){s(zo)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(s=this._perfMon)||s.start(this._size),this._listeners)if(this._listeners instanceof Kd)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(r=this._perfMon)||r.stop()}hasListeners(){return this._size>0}},qd=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vd=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Xd||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ld.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vd})})(Id||(Id={}));var Yd,Gd,Xd=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?Vd:(this._emitter||(this._emitter=new Ud),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Jd="en",Zd=Jd,Qd=globalThis;typeof Qd.vscode<"u"&&typeof Qd.vscode.process<"u"?Gd=Qd.vscode.process:typeof process<"u"&&"string"==typeof(null==(s=null==process?void 0:process.versions)?void 0:s.node)&&(Gd=process);var eu="string"==typeof(null==(r=null==Gd?void 0:Gd.versions)?void 0:r.electron)&&"renderer"===(null==Gd?void 0:Gd.type);if("object"==typeof Gd){Gd.platform,Gd.platform,"linux"===Gd.platform&&!!Gd.env.SNAP&&Gd.env.SNAP_REVISION,!!Gd.env.CI||Gd.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zd=Jd;let e=Gd.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Zd=t.resolvedLanguage||Jd,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||eu?console.error("Unable to resolve platform."):((Yd=navigator.userAgent).indexOf("Windows"),Yd.indexOf("Macintosh"),(Yd.indexOf("Macintosh")>=0||Yd.indexOf("iPad")>=0||Yd.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Yd.indexOf("Linux")>=0,null==Yd||Yd.indexOf("Mobi"),Zd=globalThis._VSCODE_NLS_LANGUAGE||Jd,navigator.language.toLowerCase());var tu,iu=Yd,su=Zd;(e=>{e.value=function(){return su},e.isDefaultVariant=function(){return 2===su.length?"en"===su:su.length>=3&&("e"===su[0]&&"n"===su[1]&&"-"===su[2])},e.isDefault=function(){return"en"===su}})(tu||(tu={}));var ru="function"==typeof Qd.postMessage&&!Qd.importScripts;(()=>{if(ru){let e=[];Qd.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let s=e[i];if(s.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void s.callback()}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Qd.postMessage({vscodeScheduleAsyncWork:s},"*")}}})();var nu,ou,au=!!(iu&&iu.indexOf("Chrome")>=0);function lu(e,t=0,i){let s=setTimeout(()=>{e()},t);return Md(()=>{clearTimeout(s)})}iu&&iu.indexOf("Firefox"),!au&&iu&&iu.indexOf("Safari"),iu&&iu.indexOf("Edg/"),iu&&iu.indexOf("Android"),(ou=nu||(nu={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},ou.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(s){i(s)}})};var hu=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Ud,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(zo){this.reject(zo)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await Ld.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let s of t)e.emitOne(i(s))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let s of t)i(s)&&e.emitOne(s)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};hu.EMPTY=hu.fromArray([]);var cu=class extends Rd{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Pd),this._linesCacheDisposables=this._register(new Pd),this._register(Md(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Ed(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=lu(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let s=[],r=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(s.push(l),!a)break;r.push(r[r.length-1]+l.length),e++,n=o}return[s.join(""),r]}},du=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},uu=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:r,startCol:n};if(s&&(l.startRow=r=s.start.y,l.startCol=n=s.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=r=s.end.y,l.startCol=n=s.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=r-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(l.startRow=h,a=this._findInLine(e,l,t,o),!a);h--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){var r;let n=t.startRow,o=t.startCol;if(null==(r=this._terminal.buffer.active.getLine(n))?void 0:r.isWrapped)return s?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,h]=a,c=this._bufferColsToStringOffset(n,o),d=e,u=l;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),u=i.caseSensitive?l:l.toLowerCase());let _=-1;if(i.regex){let t,r=RegExp(d,i.caseSensitive?"g":"gi");if(s)for(;t=r.exec(u.slice(0,c));)_=r.lastIndex-t[0].length,e=t[0],r.lastIndex-=e.length-1;else t=r.exec(u.slice(c)),t&&t[0].length>0&&(_=c+(r.lastIndex-t[0].length),e=t[0])}else s?c-d.length>=0&&(_=u.lastIndexOf(d,c-d.length)):_=u.indexOf(d,c);if(_>=0){if(i.wholeWord&&!this._isWholeWord(_,u,e))return;let t=0;for(;t<h.length-1&&_>=h[t+1];)t++;let s=t;for(;s<h.length-1&&_+e.length>=h[s+1];)s++;let r=_-h[t],o=_+e.length-h[s],a=this._stringLengthToBufferSize(n+t,r);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+s,o)-a+this._terminal.cols*(s-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let e=i.getCell(s);if(!e)break;let r=e.getChars();r.length>1&&(t-=r.length-1);let n=i.getCell(s+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=r.getCell(e);if(!t)break;t.getWidth()&&(s+=0===t.getCode()?1:t.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},_u=class extends Rd{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Md(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){kd(i)}}}clearHighlightDecorations(){kd(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],r=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-r,n);s.push([o,r,e]),r=0,n-=e,o++}let a=[];for(let l of s){let e=this._terminal.registerMarker(l[0]),s=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(s){let r=[];r.push(e),r.push(s.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),r.push(s.onDispose(()=>kd(r))),a.push(s)}}return 0===a.length?void 0:a}},fu=class extends Rd{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Ud)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},pu=class extends Rd{constructor(e){super(),this._highlightTimeout=this._register(new Pd),this._lineCache=this._register(new Pd),this._state=new du,this._resultTracker=this._register(new fu),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new cu(e),this._engine=new uu(e,this._lineCache.value),this._decorationManager=new _u(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Md(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=lu(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,s=[],r=this._engine.find(e,0,0,t);for(;r&&((null==i?void 0:i.row)!==r.row||(null==i?void 0:i.col)!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(s,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(s,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}};const mu={background:"#09090b",foreground:"#e4e4e7",cursor:"#a1a1aa",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#18181b",brightBlack:"#3f3f46",red:"#ef4444",brightRed:"#f87171",green:"#22c55e",brightGreen:"#4ade80",yellow:"#eab308",brightYellow:"#facc15",blue:"#3b82f6",brightBlue:"#60a5fa",magenta:"#a855f7",brightMagenta:"#c084fc",cyan:"#06b6d4",brightCyan:"#22d3ee",white:"#e4e4e7",brightWhite:"#f4f4f5"},gu={background:"#ffffff",foreground:"#1c1c1c",cursor:"#6b7280",cursorAccent:"#ffffff",selectionBackground:"#d1d5db",black:"#1c1c1c",brightBlack:"#6b7280",red:"#dc2626",brightRed:"#ef4444",green:"#16a34a",brightGreen:"#22c55e",yellow:"#ca8a04",brightYellow:"#eab308",blue:"#2563eb",brightBlue:"#3b82f6",magenta:"#9333ea",brightMagenta:"#a855f7",cyan:"#0891b2",brightCyan:"#06b6d4",white:"#e5e7eb",brightWhite:"#f9fafb"},vu=l.forwardRef(({onInput:e,onResize:t,onReady:i,cliTool:s="claude"},r)=>{const n=l.useRef(null),o=l.useRef(null),a=l.useRef(null),c=l.useRef(null),d=l.useRef(e),u=l.useRef(t),_=l.useRef(i),p=l.useRef(!1),m=l.useRef(null);d.current=e,u.current=t,_.current=i;const{resolved:g}=h();return l.useImperativeHandle(r,()=>({write:e=>{var t;null==(t=o.current)||t.write(e)},reset:()=>{const e=o.current;e&&(e.reset(),e.clear())},search:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findNext(e,t))??!1},searchNext:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findNext(e,t))??!1},searchPrevious:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findPrevious(e,t))??!1},clearSearch:()=>{var e;null==(e=c.current)||e.clearDecorations()}})),l.useEffect(()=>{if(!n.current)return;const e=new fd({theme:"dark"===g?mu:gu,fontFamily:'"JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace',fontSize:13,lineHeight:1.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0}),t=new pd;e.loadAddon(t);const i=new pu;e.loadAddon(i),c.current=i,e.open(n.current),requestAnimationFrame(()=>{var i;t.fit();const{cols:s,rows:r}=e;p.current||(p.current=!0,null==(i=_.current)||i.call(_,s,r)),u.current(s,r)}),o.current=e,a.current=t,m.current=g,e.onData(e=>{d.current(e)});const s=new ResizeObserver(()=>{requestAnimationFrame(()=>{n.current&&null!==n.current.offsetParent&&(t.fit(),u.current(e.cols,e.rows))})});return s.observe(n.current),()=>{s.disconnect(),e.dispose(),o.current=null,a.current=null,c.current=null}},[]),l.useEffect(()=>{const e=o.current;if(e&&m.current!==g)if(m.current=g,e.options.theme="dark"===g?mu:gu,"claude"===s){const e="dark"===g?"dark":"light";d.current(`/theme ${e}\r`)}else if("gemini"===s){const e="dark"===g?"dark":"light";d.current(`/settings theme ${e}\r`)}else if("codex"===s){const e="dark"===g?"dark":"light";d.current(`/theme ${e}\r`)}},[g,s]),f.jsx("div",{ref:n,className:"h-full w-full bg-background",style:{overflow:"hidden",padding:"4px"}})});function Su({onSearch:e,onSearchNext:t,onSearchPrev:i,onClear:s,onClose:r}){const[n,o]=l.useState(""),[a,h]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{var e;null==(e=u.current)||e.focus()},[]);const _=l.useMemo(()=>({caseSensitive:a,regex:c}),[a,c]);return f.jsxs("div",{className:"absolute top-2 right-2 z-20 flex items-center gap-1 bg-background border border-border rounded-md shadow-sm px-2 py-1",children:[f.jsx($t,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsx(K,{ref:u,value:n,onChange:t=>{return i=t.target.value,o(i),void(i?e(i,_):s());var i},onKeyDown:e=>{if("Enter"===e.key){if(!n)return;e.shiftKey?i(n,_):t(n,_)}"Escape"===e.key&&(s(),r())},placeholder:"搜索...",className:"h-6 w-44 text-xs border-0 p-0 focus-visible:ring-0 bg-transparent"}),f.jsx("button",{title:"区分大小写",onClick:()=>{const t=!a;h(t),n&&e(n,{..._,caseSensitive:t})},className:p("text-[10px] px-1 rounded font-mono transition-colors",a?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground"),children:"Aa"}),f.jsx("button",{title:"正则表达式",onClick:()=>{const t=!c;d(t),n&&e(n,{..._,regex:t})},className:p("text-[10px] px-1 rounded font-mono transition-colors",c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground"),children:".*"}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{n&&i(n,_)},disabled:!n,children:f.jsx(Ft,{className:"h-3 w-3"})}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{n&&t(n,_)},disabled:!n,children:f.jsx(Wt,{className:"h-3 w-3"})}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{s(),r()},children:f.jsx(b,{className:"h-3 w-3"})})]})}vu.displayName="WebTerminal";const bu=l.forwardRef(({projectId:e,project:t,onStatusChange:i,onChatMessage:s,onWsConnected:r,onWsDisconnected:n,onApprovalRequest:o,onApprovalResolved:a,onSemanticUpdate:h},c)=>{const d=l.useRef([]),[u,_]=l.useState(!1),[p,m]=l.useState(null),g=l.useRef(null),v=l.useRef(null),S=l.useRef(null),b=l.useRef(null),w=l.useCallback(e=>{var t;null==(t=g.current)||t.write(e)},[]),x=l.useCallback(()=>{var e;const t=v.current;t&&S.current&&S.current(t.cols,t.rows),null==(e=b.current)||e.call(b)},[]),y=l.useCallback(()=>{var e;null==(e=g.current)||e.reset()},[]),{subscribeTerminal:C,sendTerminalInput:k,sendTerminalResize:E,subscribeChatMessages:M}=ot(e,{onTerminalData:w,onTerminalReset:y,onStatus:i,onConnected:()=>{d.current=[],null==r||r(),x()},onDisconnected:()=>{null==n||n()},onChatMessage:e=>{d.current.push(e),null==s||s(e)},onApprovalRequest:e=>null==o?void 0:o(e),onApprovalResolved:e=>null==a?void 0:a(e),onContextUpdate:e=>m(e),onSemanticUpdate:e=>null==h?void 0:h(e)});l.useEffect(()=>{S.current=C},[C]),l.useEffect(()=>{b.current=M},[M]),l.useEffect(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),_(e=>!e))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);const N=l.useCallback((e,t)=>{v.current={cols:e,rows:t},x()},[x]);return l.useImperativeHandle(c,()=>({sendTerminalInput:k}),[k]),f.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex flex-col",children:[f.jsxs("div",{className:"relative flex-1 min-h-0",children:[f.jsx(vu,{ref:g,onInput:k,onResize:(e,t)=>{v.current={cols:e,rows:t},E(e,t)},onReady:N,cliTool:null==t?void 0:t.cliTool}),u&&f.jsx(Su,{onSearch:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.search(e,t))??!1},onSearchNext:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.searchNext(e,t))??!1},onSearchPrev:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.searchPrevious(e,t))??!1},onClear:()=>{var e;return null==(e=g.current)?void 0:e.clearSearch()},onClose:()=>_(!1)})]}),f.jsxs("div",{className:"flex-shrink-0 flex items-center px-3 h-7 border-t border-border bg-muted/30 gap-3",children:[f.jsx(at,{}),p&&f.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[f.jsx("span",{className:"text-muted-foreground",children:"上下文"}),f.jsx("div",{className:"w-20 h-1.5 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all "+(p.usedPercentage<50?"bg-green-500":p.usedPercentage<80?"bg-yellow-500":"bg-red-500"),style:{width:`${Math.min(p.usedPercentage,100)}%`}})}),f.jsxs("span",{className:"font-medium "+(p.usedPercentage<50?"text-green-500":p.usedPercentage<80?"text-yellow-500":"text-red-500"),children:[Math.round(p.usedPercentage),"%"]}),f.jsx("span",{className:"text-muted-foreground/50",children:p.contextWindowSize>=1e6?`${(p.contextWindowSize/1e6).toFixed(0)}M`:`${Math.round(p.contextWindowSize/1e3)}K`})]})]})]})});bu.displayName="TerminalView";const wu=200,xu=520;const yu=Object.freeze(Object.defineProperty({__proto__:null,ProjectPage:function(){const{id:e}=lt(),t=Ve(),[i,s]=l.useState(null),[r,n]=l.useState(!0),[o,a]=Q(y.panelFileTree,"true"),[h,c]=Q(y.panelShortcuts,"true"),[d,u]=Q(y.chatOverlay(e??""),"true"),_=l.useCallback(()=>u(e=>"true"===e?"false":"true"),[u]),[m,g]=l.useState([]),[v,S]=l.useState(!1),[b,w]=l.useState([]),x=l.useRef(0),C=l.useCallback(e=>{x.current+=1;const t={...e,seq:x.current};w(e=>{const i=[...e,t];return i.length>500?i.slice(-500):i})},[]),[k,E]=l.useState(null),M=l.useCallback(e=>C(e),[C]),N=l.useCallback(e=>C(e),[C]),D=l.useCallback(e=>{g(t=>{const i=[...t,e];return i.length>200?i.slice(-200):i})},[]),R=l.useCallback(()=>{g([]),E(null),S(!0)},[]),L=l.useCallback(()=>{S(!1)},[]),B=l.useCallback(async e=>{var t,i;if(e.endsWith("\r")){const i=e.slice(0,-1);if(q.current){if("failed"===await q.current.sendCommand(i))throw new Error("chat send failed");return}const s=i.trimStart().startsWith("/")?i.replace(/\n/g,"\r")+"\r":ht(i);return void(null==(t=U.current)||t.sendTerminalInput(s))}null==(i=U.current)||i.sendTerminalInput(e)},[]),[T,j]=Q(y.panelLeftWidth,String(224)),[O,z]=Q(y.panelRightWidth,String(208)),W=parseInt(T,10)||224,F=parseInt(O,10)||208,$=l.useRef(null),K=l.useRef(null),U=l.useRef(null),q=l.useRef(null);l.useEffect(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"i"===e.key&&"terminal"!==(null==i?void 0:i.cliTool)&&(e.preventDefault(),_())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[_,null==i?void 0:i.cliTool]);const V=l.useRef(null);l.useEffect(()=>{const e=(null==i?void 0:i.cliTool)??null;e&&V.current&&e!==V.current&&(g([]),w([]),x.current=0,E(null)),V.current=e},[null==i?void 0:i.cliTool]);const[Y,G]=l.useState("terminal"),[X,J]=l.useState(()=>window.innerWidth<768);l.useEffect(()=>{const e=()=>J(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{fetchProjects:Z,hasFetched:ee}=Ge();return l.useEffect(()=>{if(!e)return;(async()=>{ee||await Z();const t=Ge.getState().projects.find(t=>t.id===e)??null;s(t),n(!1)})()},[e,ee,Z]),r?f.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:f.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})}):i&&e?f.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[f.jsx(Ur,{project:i,projectId:e,showFileTree:"true"===o,showShortcuts:"true"===h,showChatOverlay:"true"===d,onToggleFileTree:()=>a(e=>"true"===e?"false":"true"),onToggleShortcuts:()=>c(e=>"true"===e?"false":"true"),onToggleChatOverlay:_,onProjectUpdate:s}),X?f.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0",children:[f.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:["files"===Y&&f.jsx(Ri,{projectPath:i.folderPath,projectId:e,cliTool:i.cliTool,onSend:B}),"terminal"===Y&&f.jsx(bu,{ref:U,projectId:e,project:i,onStatusChange:e=>s(t=>t?{...t,status:e}:t)}),"panel"===Y&&f.jsx(Br,{projectId:e,onSend:B})]}),f.jsx("div",{className:"flex-shrink-0 flex border-t border-border bg-background pb-[env(safe-area-inset-bottom)]",children:[{id:"files",icon:P,label:"文件"},{id:"terminal",icon:ct,label:"终端"},{id:"panel",icon:si,label:"快捷"}].map(({id:e,icon:t,label:i})=>f.jsxs("button",{onClick:()=>G(e),className:p("flex-1 flex flex-col items-center gap-0.5 py-2 text-[10px] transition-colors",Y===e?"text-blue-400":"text-muted-foreground hover:text-foreground"),children:[f.jsx(t,{className:"h-4 w-4"}),i]},e))})]}):f.jsxs("div",{className:"flex-1 overflow-hidden flex min-h-0",children:[f.jsx(A,{initial:!1,children:"true"===o&&f.jsx(I.div,{ref:$,initial:{width:0,opacity:0},animate:{width:W,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"flex-shrink-0 overflow-hidden",children:f.jsx(Ri,{projectPath:i.folderPath,projectId:e,cliTool:i.cliTool,onSend:B})})}),"true"===o&&f.jsx("div",{onMouseDown:e=>{var t;e.preventDefault();const i=e.clientX,s=(null==(t=$.current)?void 0:t.offsetWidth)??W;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const r=e=>{const t=Math.max(wu,Math.min(xu,s+(e.clientX-i)));$.current&&($.current.style.width=t+"px")},n=e=>{const t=Math.max(wu,Math.min(xu,s+(e.clientX-i)));j(String(t)),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)},className:"w-1 flex-shrink-0 bg-border hover:bg-blue-500/60 active:bg-blue-500/80 cursor-col-resize transition-colors"}),f.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 relative flex flex-col",children:[f.jsx(bu,{ref:U,projectId:e,project:i,onStatusChange:e=>s(t=>t?{...t,status:e}:t),onChatMessage:D,onWsConnected:R,onWsDisconnected:L,onApprovalRequest:M,onApprovalResolved:N,onSemanticUpdate:E}),f.jsx(A,{children:"true"===d&&"terminal"!==i.cliTool&&f.jsx(Ct,{ref:q,projectId:e,project:i,liveMessages:m,approvalEvents:b,semanticUpdate:k,wsConnected:v,onSend:e=>{var t;return null==(t=U.current)?void 0:t.sendTerminalInput(e)},onClose:_},"chat-overlay")})]}),"true"===h&&f.jsx("div",{onMouseDown:e=>{var t;e.preventDefault();const i=e.clientX,s=(null==(t=K.current)?void 0:t.offsetWidth)??F;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const r=e=>{const t=Math.max(wu,Math.min(xu,s-(e.clientX-i)));K.current&&(K.current.style.width=t+"px")},n=e=>{const t=Math.max(wu,Math.min(xu,s-(e.clientX-i)));z(String(t)),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)},className:"w-1 flex-shrink-0 bg-border hover:bg-blue-500/60 active:bg-blue-500/80 cursor-col-resize transition-colors"}),f.jsx(A,{initial:!1,children:"true"===h&&f.jsx(I.div,{ref:K,initial:{width:0,opacity:0},animate:{width:F,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"flex-shrink-0 overflow-hidden",children:f.jsx(Br,{projectId:e,onSend:B})})})]})]}):f.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 bg-background",children:[f.jsx("p",{className:"text-muted-foreground",children:"Project not found."}),f.jsxs(H,{variant:"outline",onClick:()=>t("/"),children:[f.jsx(Xe,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]})]})}},Symbol.toStringTag,{value:"Module"}));export{yu as P,oi as Z,ai as a};
|
|
26
|
+
*/var Yr=Object.defineProperty,Gr=Object.getOwnPropertyDescriptor,Xr=(e,t,i,s)=>{for(var r,n=s>1?void 0:s?Gr(t,i):t,o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s?r(t,i,n):r(n))||n);return s&&n&&Yr(t,i,n),n},Jr=(e,t)=>(i,s)=>t(i,s,e),Zr="Terminal input",Qr=()=>Zr,en=e=>Zr=e,tn="Too much output to announce, navigate to rows manually to read",sn=()=>tn,rn=e=>tn=e;function nn(e,t,i,s){e=function(e,t){return t?"[200~"+e+"[201~":e}(e=function(e){return e.replace(/\r?\n/g,"\r")}(e),i.decPrivateModes.bracketedPasteMode&&!0!==s.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=""}function on(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function an(e,t,i,s,r){on(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function ln(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function hn(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let t=e[r];t>65535?(t-=65536,s+=String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):s+=String.fromCharCode(t)}return s}var cn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let i=e.charCodeAt(r++);56320<=i&&i<=57343?t[s++]=1024*(this._interim-55296)+i-56320+65536:(t[s++]=this._interim,t[s++]=i),this._interim=0}for(let n=r;n<i;++n){let r=e.charCodeAt(n);if(55296<=r&&r<=56319){if(++n>=i)return this._interim=r,s;let o=e.charCodeAt(n);56320<=o&&o<=57343?t[s++]=1024*(r-55296)+o-56320+65536:(t[s++]=r,t[s++]=o);continue}65279!==r&&(t[s++]=r)}return s}},dn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s,r,n,o,a=0,l=0,h=0;if(this.interim[0]){let s=!1,r=this.interim[0];r&=192==(224&r)?31:224==(240&r)?15:7;let n,o=0;for(;(n=63&this.interim[++o])&&o<4;)r<<=6,r|=n;let l=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,c=l-o;for(;h<c;){if(h>=i)return 0;if(n=e[h++],128!=(192&n)){h--,s=!0;break}this.interim[o++]=n,r<<=6,r|=63&n}s||(2===l?r<128?h--:t[a++]=r:3===l?r<2048||r>=55296&&r<=57343||65279===r||(t[a++]=r):r<65536||r>1114111||(t[a++]=r)),this.interim.fill(0)}let c=i-4,d=h;for(;d<i;){for(;!(!(d<c)||128&(s=e[d])||128&(r=e[d+1])||128&(n=e[d+2])||128&(o=e[d+3]));)t[a++]=s,t[a++]=r,t[a++]=n,t[a++]=o,d+=4;if(s=e[d++],s<128)t[a++]=s;else if(192==(224&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(l=(31&s)<<6|63&r,l<128){d--;continue}t[a++]=l}else if(224==(240&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[d++],128!=(192&n)){d--;continue}if(l=(15&s)<<12|(63&r)<<6|63&n,l<2048||l>=55296&&l<=57343||65279===l)continue;t[a++]=l}else if(240==(248&s)){if(d>=i)return this.interim[0]=s,a;if(r=e[d++],128!=(192&r)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,a;if(n=e[d++],128!=(192&n)){d--;continue}if(d>=i)return this.interim[0]=s,this.interim[1]=r,this.interim[2]=n,a;if(o=e[d++],128!=(192&o)){d--;continue}if(l=(7&s)<<18|(63&r)<<12|(63&n)<<6|63&o,l<65536||l>1114111)continue;t[a++]=l}}return a}},un=" ",_n=class e{constructor(){this.fg=0,this.bg=0,this.extended=new fn}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},fn=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},pn=class e extends _n{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new fn,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?ln(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=1024*(i-55296)+s-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},mn="di$target",gn="di$dependencies",vn=new Map;function Sn(e){if(vn.has(e))return vn.get(e);let t=function(e,i,s){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[mn]===t?t[gn].push({id:e,index:i}):(t[gn]=[{id:e,index:i}],t[mn]=t)}(t,e,s)};return t._id=e,vn.set(e,t),t}var bn=Sn("BufferService"),wn=Sn("CoreMouseService"),xn=Sn("CoreService"),yn=Sn("CharsetService"),Cn=Sn("InstantiationService"),kn=Sn("LogService"),En=Sn("OptionsService"),Mn=Sn("OscLinkService"),Nn=Sn("UnicodeService"),Dn=Sn("DecorationService"),Rn=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var i;let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void t(void 0);let r=[],n=this._optionsService.rawOptions.linkHandler,o=new pn,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(-1!==h||s.hasContent(d)){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId){if(-1===h){h=d,l=o.extended.urlId;continue}c=o.extended.urlId!==l}else-1!==h&&(c=!0);if(c||-1!==h&&d===a-1){let t=null==(i=this._oscLinkService.getLinkData(l))?void 0:i.uri;if(t){let i={start:{x:h+1,y:e},end:{x:d+(c||d!==a-1?0:1),y:e}},s=!1;if(!(null==n?void 0:n.allowNonHttpProtocols))try{let e=new URL(t);["http:","https:"].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:t,range:i,activate:(e,t)=>n?n.activate(e,t,i):Ln(e,t),hover:(e,t)=>{var s;return null==(s=null==n?void 0:n.hover)?void 0:s.call(n,e,t,i)},leave:(e,t)=>{var s;return null==(s=null==n?void 0:n.leave)?void 0:s.call(n,e,t,i)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}t(r)}};function Ln(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}Rn=Xr([Jr(0,bn),Jr(1,En),Jr(2,Mn)],Rn);var Pn=Sn("CharSizeService"),Bn=Sn("CoreBrowserService"),Tn=Sn("MouseService"),jn=Sn("RenderService"),On=Sn("SelectionService"),An=Sn("CharacterJoinerService"),In=Sn("ThemeService"),zn=Sn("LinkProviderService"),Wn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Vn.isErrorNoTelemetry(e)?new Vn(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function Hn(e){(function(e){return e instanceof $n||e instanceof Error&&e.name===Fn&&e.message===Fn})(e)||Wn.onUnexpectedError(e)}var Fn="Canceled";var $n=class extends Error{constructor(){super(Fn),this.name=this.message}};var Kn,Un,qn,Vn=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},Yn=class e extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function Gn(e,t=0){return e[e.length-(1+t)]}function Xn(e,t){let i,s=this,r=!1;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}function Jn(e){if(qn.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(Ho){t.push(Ho)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Zn(e){return{dispose:Xn(()=>{e()})}}(Un=Kn||(Kn={})).isLessThan=function(e){return e<0},Un.isLessThanOrEqual=function(e){return e<=0},Un.isGreaterThan=function(e){return e>0},Un.isNeitherLessOrGreaterThan=function(e){return 0===e},Un.greaterThan=1,Un.lessThan=-1,Un.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*s(e){yield e}e.empty=function(){return i},e.single=s,e.wrap=function(e){return t(e)?e:s(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let s of e)if(t(s,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let s of e)yield t(s,i++)},e.flatMap=function*(e,t){let i=0;for(let s of e)yield*t(s,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let s=i;for(let r of e)s=t(s,r);return s},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let s=[];if(0===i)return[s,t];let r=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=r.next();if(t.done)return[s,e.empty()];s.push(t.value)}return[s,{[Symbol.iterator]:()=>r}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(qn||(qn={}));var Qn=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Jn(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?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};Qn.DISABLE_DISPOSED_WARNING=!1;var eo=Qn,to=class{constructor(){this._store=new eo,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)}};to.None=Object.freeze({dispose(){}});var io=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},so="object"==typeof window?window:globalThis,ro=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};ro.Undefined=new ro(void 0);var no,oo=ro,ao=class{constructor(){this._first=oo.Undefined,this._last=oo.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===oo.Undefined}clear(){let e=this._first;for(;e!==oo.Undefined;){let t=e.next;e.prev=oo.Undefined,e.next=oo.Undefined,e=t}this._first=oo.Undefined,this._last=oo.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new oo(e);if(this._first===oo.Undefined)this._first=i,this._last=i;else if(t){let e=this._last;this._last=i,i.prev=e,e.next=i}else{let e=this._first;this._first=i,i.next=e,e.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==oo.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==oo.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==oo.Undefined&&e.next!==oo.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===oo.Undefined&&e.next===oo.Undefined?(this._first=oo.Undefined,this._last=oo.Undefined):e.next===oo.Undefined?(this._last=this._last.prev,this._last.next=oo.Undefined):e.prev===oo.Undefined&&(this._first=this._first.next,this._first.prev=oo.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==oo.Undefined;)yield e.element,e=e.next}},lo=globalThis.performance&&"function"==typeof globalThis.performance.now,ho=class e{static create(t){return new e(t)}constructor(e){this._now=lo&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,s)=>{let r,n=!1;return r=e(e=>{if(!n)return r?r.dispose():n=!0,t.call(i,e)},null,s),n&&r.dispose(),r}}function i(e,t,i){return r((i,s=null,r)=>e(e=>i.call(s,t(e)),null,r),i)}function s(e,t,i){return r((i,s=null,r)=>e(e=>t(e)&&i.call(s,e),null,r),i)}function r(e,t){let i,s=new bo({onWillAddFirstListener(){i=e(s.fire,s)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(s),s.event}function n(e,t,i=100,s=!1,r=!1,n,o){let a,l,h,c,d=0,u=new bo({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{d++,l=t(l,e),s&&!h&&(u.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!s||d>1)&&u.fire(e),d=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){r&&d>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(u),u.event}e.None=()=>to.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return r((i,s=null,r)=>e(e=>{t(e),i.call(s,e)},null,r),i)},e.filter=s,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,s)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(function(...e){return Zn(()=>Jn(e))}(...e.map(e=>e(e=>t.call(i,e)))),s)},e.reduce=function(e,t,s,r){let n=s;return i(e,e=>(n=t(n,e),n),r)},e.debounce=n,e.accumulate=function(t,i=0,s){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,s)},e.latch=function(e,t=(e,t)=>e===t,i){let r,n=!0;return s(e,e=>{let i=n||!t(e,r);return n=!1,r=e,i},i)},e.split=function(t,i,s){return[e.filter(t,i,s),e.filter(t,e=>!i(e),s)]},e.buffer=function(e,t=!1,i=[],s){let r=i.slice(),n=e(e=>{r?r.push(e):a.fire(e)});s&&s.add(n);let o=()=>{null==r||r.forEach(e=>a.fire(e)),r=null},a=new bo({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),s&&s.add(n))},onDidAddFirstListener(){r&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return s&&s.add(a),a.event},e.chain=function(e,t){return(i,s,r)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(s,t)},void 0,r)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(s=>{let r=i||!e(s,t);return i=!1,t=s,r?s:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new bo({onWillAddFirstListener:()=>e.on(t,s),onDidRemoveLastListener:()=>e.removeListener(t,s)});return r.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new bo({onWillAddFirstListener:()=>e.addEventListener(t,s),onDidRemoveLastListener:()=>e.removeEventListener(t,s)});return r.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new bo;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new bo(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,s)=>{let r=0,n=!1,o={beginUpdate(){r++},endUpdate(){r--,0===r&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return s instanceof eo?s.add(a):Array.isArray(s)&&s.push(a),a}}})(no||(no={}));var co=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new ho,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};co.all=new Set,co._idPool=0;var uo=co,_o=class e{constructor(t,i,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,s]=this.getMostFrequentStack(),r=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${s}):`;console.warn(r),console.warn(e);let n=new mo(r,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,s]of this._stacks)(!e||t<s)&&(e=[i,s],t=s);return e}};_o._idPool=1;var fo=_o,po=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},mo=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},go=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},vo=0,So=class{constructor(e){this.value=e,this.id=vo++}},bo=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new fo((null==e?void 0:e.onListenerError)??Hn,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(s=this._options)?void 0:s._profName)?new uo(this._options._profName):void 0,this._deliveryQueue=null==(r=this._options)?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(s=this._leakageMon)||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var s,r,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new go(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(s=this._options)?void 0:s.onListenerError)||Hn)(i),to.None}if(this._disposed)return to.None;t&&(e=e.bind(t));let l,h=new So(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=po.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof So?(this._deliveryQueue??(this._deliveryQueue=new wo),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(r=this._options)?void 0:r.onWillAddFirstListener)||n.call(r,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=Zn(()=>{null==l||l(),this._removeListener(h)});return i instanceof eo?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,s,r;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(r=null==(s=this._options)?void 0:s.onDidRemoveLastListener)||r.call(s,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let s=(null==(i=this._options)?void 0:i.onListenerError)||Hn;if(s)try{e.value(t)}catch(r){s(r)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(s=this._perfMon)||s.start(this._size),this._listeners)if(this._listeners instanceof So)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(r=this._perfMon)||r.stop()}hasListeners(){return this._size>0}},wo=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},xo=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new bo,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new bo,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};xo.INSTANCE=new xo;var yo=xo;yo.INSTANCE.onDidChangeZoomLevel,yo.INSTANCE.onDidChangeFullscreen;var Co="object"==typeof navigator?navigator.userAgent:"",ko=Co.indexOf("Firefox")>=0,Eo=Co.indexOf("AppleWebKit")>=0,Mo=Co.indexOf("Chrome")>=0,No=!Mo&&Co.indexOf("Safari")>=0;Co.indexOf("Electron/"),Co.indexOf("Android");var Do=!1;if("function"==typeof so.matchMedia){let e=so.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=so.matchMedia("(display-mode: fullscreen)");Do=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(so,e,({matches:e})=>{Do&&t.matches||(Do=e)})}var Ro,Lo,Po="en",Bo=!1,To=!1,jo=!1,Oo=!1,Ao=Po,Io=globalThis;typeof Io.vscode<"u"&&typeof Io.vscode.process<"u"?Lo=Io.vscode.process:typeof process<"u"&&"string"==typeof(null==(e=null==process?void 0:process.versions)?void 0:e.node)&&(Lo=process);var zo="string"==typeof(null==(t=null==Lo?void 0:Lo.versions)?void 0:t.electron)&&"renderer"===(null==Lo?void 0:Lo.type);if("object"==typeof Lo){Bo="win32"===Lo.platform,To="darwin"===Lo.platform,(jo="linux"===Lo.platform)&&!!Lo.env.SNAP&&Lo.env.SNAP_REVISION,!!Lo.env.CI||Lo.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ao=Po;let e=Lo.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Ao=t.resolvedLanguage||Po,null==(i=t.languagePack)?void 0:i.translationsConfigFile}catch{}Oo=!0}else"object"!=typeof navigator||zo?console.error("Unable to resolve platform."):(Bo=(Ro=navigator.userAgent).indexOf("Windows")>=0,To=Ro.indexOf("Macintosh")>=0,(Ro.indexOf("Macintosh")>=0||Ro.indexOf("iPad")>=0||Ro.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,jo=Ro.indexOf("Linux")>=0,null==Ro||Ro.indexOf("Mobi"),Ao=globalThis._VSCODE_NLS_LANGUAGE||Po,navigator.language.toLowerCase());var Wo,Ho,Fo=Bo,$o=To,Ko=jo,Uo=Oo,qo=Ro,Vo=Ao;(Ho=Wo||(Wo={})).value=function(){return Vo},Ho.isDefaultVariant=function(){return 2===Vo.length?"en"===Vo:Vo.length>=3&&"e"===Vo[0]&&"n"===Vo[1]&&"-"===Vo[2]},Ho.isDefault=function(){return"en"===Vo};var Yo="function"==typeof Io.postMessage&&!Io.importScripts;(()=>{if(Yo){let e=[];Io.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let s=e[i];if(s.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void s.callback()}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Io.postMessage({vscodeScheduleAsyncWork:s},"*")}}})();var Go=!!(qo&&qo.indexOf("Chrome")>=0);qo&&qo.indexOf("Firefox"),!Go&&qo&&qo.indexOf("Safari"),qo&&qo.indexOf("Edg/"),qo&&qo.indexOf("Android");var Xo="object"==typeof navigator?navigator:{};Uo||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xo&&Xo.clipboard&&Xo.clipboard.writeText,Uo||Xo&&Xo.clipboard&&Xo.clipboard.readText;var Jo,Zo,Qo=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}},ea=new Qo,ta=new Qo,ia=new Qo,sa=new Array(230);(Zo=Jo||(Jo={})).toString=function(e){return ea.keyCodeToStr(e)},Zo.fromString=function(e){return ea.strToKeyCode(e)},Zo.toUserSettingsUS=function(e){return ta.keyCodeToStr(e)},Zo.toUserSettingsGeneral=function(e){return ia.keyCodeToStr(e)},Zo.fromUserSettings=function(e){return ta.strToKeyCode(e)||ia.strToKeyCode(e)},Zo.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ea.keyCodeToStr(e)};var ra=class e{constructor(e,t,i,s,r){this.ctrlKey=e,this.shiftKey=t,this.altKey=i,this.metaKey=s,this.keyCode=r}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?"1":"0"}${this.shiftKey?"1":"0"}${this.altKey?"1":"0"}${this.metaKey?"1":"0"}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new na([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},na=class{constructor(e){if(0===e.length)throw new Error(`Illegal argument: ${"chords"}`);this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)0!==t&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(null===e||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}};var oa=$o?256:2048,aa=$o?2048:256,la=class{constructor(e){var t;this._standardKeyboardEventBrand=!0;let i=e;this.browserEvent=i,this.target=i.target,this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.altGraphKey=null==(t=i.getModifierState)?void 0:t.call(i,"AltGraph"),this.keyCode=function(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return Jo.fromString(t)}let t=e.keyCode;if(3===t)return 7;if(ko)switch(t){case 59:return 85;case 60:if(Ko)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if($o)return 57}else if(Eo){if($o&&93===t)return 57;if(!$o&&92===t)return 57}return sa[t]||0}(i),this.code=i.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,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;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=oa),this.altKey&&(t|=512),this.shiftKey&&(t|=1024),this.metaKey&&(t|=aa),t|=e,t}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new ra(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},ha=new WeakMap;function ca(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if("null"!==t.origin&&"null"!==i.origin&&t.origin!==i.origin)return null}catch{return null}return e.parent}var da,ua=class{static getSameOriginWindowChain(e){let t=ha.get(e);if(!t){t=[],ha.set(e,t);let i,s=e;do{i=ca(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 i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let e=n.window.deref();if(i+=(null==e?void 0:e.scrollY)??0,s+=(null==e?void 0:e.scrollX)??0,e===t||!n.iframeElement)break;let r=n.iframeElement.getBoundingClientRect();i+=r.top,s+=r.left}return{top:i,left:s}}},_a=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=0===t.button,this.middleButton=1===t.button,this.rightButton=2===t.button,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,"dblclick"===t.type&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,"number"==typeof t.pageX?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=ua.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},fa=class{constructor(e,t=0,i=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let r=!1;if(Mo){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,i=e,n=(null==(s=e.view)?void 0:s.devicePixelRatio)||1;if(typeof t.wheelDeltaY<"u")this.deltaY=r?t.wheelDeltaY/(120*n):t.wheelDeltaY/120;else if(typeof i.VERTICAL_AXIS<"u"&&i.axis===i.VERTICAL_AXIS)this.deltaY=-i.detail/3;else if("wheel"===e.type){let t=e;t.deltaMode===t.DOM_DELTA_LINE?this.deltaY=ko&&!$o?-e.deltaY/3:-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof t.wheelDeltaX<"u")this.deltaX=No&&Fo?-t.wheelDeltaX/120:r?t.wheelDeltaX/(120*n):t.wheelDeltaX/120;else if(typeof i.HORIZONTAL_AXIS<"u"&&i.axis===i.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if("wheel"===e.type){let t=e;t.deltaMode===t.DOM_DELTA_LINE?this.deltaX=ko&&!$o?-e.deltaX/3:-e.deltaX:this.deltaX=-e.deltaX/40}0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*n):e.wheelDelta/120)}}preventDefault(){var e;null==(e=this.browserEvent)||e.preventDefault()}stopPropagation(){var e;null==(e=this.browserEvent)||e.stopPropagation()}},pa=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof va||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:no.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:pa})})(da||(da={}));var ma,ga,va=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?pa:(this._emitter||(this._emitter=new bo),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Sa=class{constructor(e,t){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof t&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Yn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Yn("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},ba=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;null==(e=this.disposable)||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Yn("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=Zn(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(ga=ma||(ma={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},ga.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(Zo){i(Zo)}})};var wa=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new bo,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await no.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let s of t)e.emitOne(i(s))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let s of t)i(s)&&e.emitOne(s)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};wa.EMPTY=wa.fromArray([]);var{getWindow:xa,getWindowId:ya,onDidRegisterWindow:Ca}=function(){let e=new Map,t={window:so,disposables:new eo};e.set(so.vscodeWindowId,t);let i=new bo,s=new bo,r=new bo;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(t){if(e.has(t.vscodeWindowId))return to.None;let n=new eo,o={window:t,disposables:n.add(new eo)};return e.set(t.vscodeWindowId,o),n.add(Zn(()=>{e.delete(t.vscodeWindowId),s.fire(t)})),n.add(Ea(t,La.BEFORE_UNLOAD,()=>{r.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,s){return("number"==typeof i?e.get(i):void 0)??(s?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let s=e;return(null==s?void 0:s.view)?s.view.window:so},getDocument:e=>xa(e).document}}(),ka=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ea(e,t,i,s){return new ka(e,t,i,s)}var Ma,Na=function(e,t,i,s){return Ea(e,t,i,s)},Da=class extends ba{constructor(e){super(),this.defaultTarget=e&&xa(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Ra=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(lu){Hn(lu)}}static sort(e,t){return t.priority-e.priority}};!function(){let e=new Map,t=new Map,i=new Map,s=new Map;Ma=(r,n,o=0)=>{let a=ya(r),l=new Ra(n,o),h=e.get(a);return h||(h=[],e.set(a,h)),h.push(l),i.get(a)||(i.set(a,!0),r.requestAnimationFrame(()=>(r=>{i.set(r,!1);let n=e.get(r)??[];for(t.set(r,n),e.set(r,[]),s.set(r,!0);n.length>0;)n.sort(Ra.sort),n.shift().execute();s.set(r,!1)})(a))),l}}();var La={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"},Pa=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=Ba(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ba(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ba(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ba(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ba(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ba(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ba(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ba(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ba(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ba(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ba(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=Ba(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=Ba(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ba(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 Ba(e){return"number"==typeof e?`${e}px`:e}function Ta(e){return new Pa(e)}var ja,Oa,Aa=class{constructor(){this._hooks=new eo,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(Zn(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=xa(e)}this._hooks.add(Ea(n,La.POINTER_MOVE,e=>{e.buttons===i?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(Ea(n,La.POINTER_UP,e=>this.stopMonitoring(!0)))}};(Oa=ja||(ja={})).Tap="-xterm-gesturetap",Oa.Change="-xterm-gesturechange",Oa.Start="-xterm-gesturestart",Oa.End="-xterm-gesturesend",Oa.Contextmenu="-xterm-gesturecontextmenu";var Ia=class e extends to{constructor(){super(),this.dispatched=!1,this.targets=new ao,this.ignoreTargets=new ao,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(no.runAndSubscribe(Ca,({window:e,disposables:t})=>{t.add(Ea(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),t.add(Ea(e.document,"touchend",t=>this.onTouchEnd(e,t))),t.add(Ea(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:so,disposables:this._store}))}static addTarget(t){if(!e.isTouchDevice())return to.None;return e.INSTANCE||(e.INSTANCE=new e),Zn(e.INSTANCE.targets.push(t))}static ignoreTarget(t){if(!e.isTouchDevice())return to.None;return e.INSTANCE||(e.INSTANCE=new e),Zn(e.INSTANCE.ignoreTargets.push(t))}static isTouchDevice(){return"ontouchstart"in so||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,s=e.targetTouches.length;i<s;i++){let s=e.targetTouches.item(i);this.activeTouches[s.identifier]={id:s.identifier,initialTarget:s.target,initialTimeStamp:t,initialPageX:s.pageX,initialPageY:s.pageY,rollingTimestamps:[t],rollingPageX:[s.pageX],rollingPageY:[s.pageY]};let r=this.newGestureEvent(ja.Start,s.target);r.pageX=s.pageX,r.pageY=s.pageY,this.dispatchEvent(r)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let o=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("move of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=Date.now()-a.initialTimeStamp;if(l<e.HOLD_DELAY&&Math.abs(a.initialPageX-Gn(a.rollingPageX))<30&&Math.abs(a.initialPageY-Gn(a.rollingPageY))<30){let e=this.newGestureEvent(ja.Tap,a.initialTarget);e.pageX=Gn(a.rollingPageX),e.pageY=Gn(a.rollingPageY),this.dispatchEvent(e)}else if(l>=e.HOLD_DELAY&&Math.abs(a.initialPageX-Gn(a.rollingPageX))<30&&Math.abs(a.initialPageY-Gn(a.rollingPageY))<30){let e=this.newGestureEvent(ja.Contextmenu,a.initialTarget);e.pageX=Gn(a.rollingPageX),e.pageY=Gn(a.rollingPageY),this.dispatchEvent(e)}else if(1===r){let e=Gn(a.rollingPageX),i=Gn(a.rollingPageY),r=Gn(a.rollingTimestamps)-a.rollingTimestamps[0],n=e-a.rollingPageX[0],o=i-a.rollingPageY[0],l=[...this.targets].filter(e=>a.initialTarget instanceof Node&&e.contains(a.initialTarget));this.inertia(t,l,s,Math.abs(n)/r,n>0?1:-1,e,Math.abs(o)/r,o>0?1:-1,i)}this.dispatchEvent(this.newGestureEvent(ja.End,a.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,t){let i=document.createEvent("CustomEvent");return i.initEvent(e,!1,!0),i.initialTarget=t,i.tapCount=0,i}dispatchEvent(t){if(t.type===ja.Tap){let i=(new Date).getTime(),s=0;s=i-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===ja.Change||t.type===ja.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let e=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let s=0,r=t.initialTarget;for(;r&&r!==i;)s++,r=r.parentElement;e.push([s,i])}e.sort((e,t)=>e[0]-t[0]);for(let[i,s]of e)s.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,l,h){this.handle=Ma(t,()=>{let c=Date.now(),d=c-s,u=0,_=0,f=!0;r+=e.SCROLL_FRICTION*d,a+=e.SCROLL_FRICTION*d,r>0&&(f=!1,u=n*r*d),a>0&&(f=!1,_=l*a*d);let p=this.newGestureEvent(ja.Change);p.translationX=u,p.translationY=_,i.forEach(e=>e.dispatchEvent(p)),f||this.inertia(t,i,c,r,n,o+u,a,l,h+_)})}onTouchMove(e){let t=Date.now();for(let i=0,s=e.changedTouches.length;i<s;i++){let s=e.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(s.identifier))){console.warn("end of an UNKNOWN touch",s);continue}let r=this.activeTouches[s.identifier],n=this.newGestureEvent(ja.Change,r.initialTarget);n.translationX=s.pageX-Gn(r.rollingPageX),n.translationY=s.pageY-Gn(r.rollingPageY),n.pageX=s.pageX,n.pageY=s.pageY,this.dispatchEvent(n),r.rollingPageX.length>3&&(r.rollingPageX.shift(),r.rollingPageY.shift(),r.rollingTimestamps.shift()),r.rollingPageX.push(s.pageX),r.rollingPageY.push(s.pageY),r.rollingTimestamps.push(t)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};Ia.SCROLL_FRICTION=-.005,Ia.HOLD_DELAY=700,Ia.CLEAR_TAP_COUNT_TIME=400,Xr([function(e,t,i){let s=null,r=null;if("function"==typeof i.value?(s="value",r=i.value,0!==r.length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof i.get&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...e){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,e)}),this[n]}}],Ia,"isTouchDevice",1);var za=Ia,Wa=class extends to{onclick(e,t){this._register(Ea(e,La.CLICK,i=>t(new _a(xa(e),i))))}onmousedown(e,t){this._register(Ea(e,La.MOUSE_DOWN,i=>t(new _a(xa(e),i))))}onmouseover(e,t){this._register(Ea(e,La.MOUSE_OVER,i=>t(new _a(xa(e),i))))}onmouseleave(e,t){this._register(Ea(e,La.MOUSE_LEAVE,i=>t(new _a(xa(e),i))))}onkeydown(e,t){this._register(Ea(e,La.KEY_DOWN,e=>t(new la(e))))}onkeyup(e,t){this._register(Ea(e,La.KEY_UP,e=>t(new la(e))))}oninput(e,t){this._register(Ea(e,La.INPUT,t))}onblur(e,t){this._register(Ea(e,La.BLUR,t))}onfocus(e,t){this._register(Ea(e,La.FOCUS,t))}onchange(e,t){this._register(Ea(e,La.CHANGE,t))}ignoreGesture(e){return za.ignoreTarget(e)}},Ha=class extends Wa{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="11px",this.domNode.style.height="11px",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 Aa),this._register(Na(this.bgDomNode,La.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Na(this.domNode,La.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Da),this._pointerdownScheduleRepeatTimer=this._register(new Sa)}_arrowPointerDown(e){if(!(e.target&&e.target instanceof Element))return;this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,xa(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Fa=class e{constructor(e,t,i,s,r,n,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,i|=0,s|=0,r|=0,n|=0,o|=0),this.rawScrollLeft=s,this.rawScrollTop=o,t<0&&(t=0),s+t>i&&(s=i-t),s<0&&(s=0),r<0&&(r=0),o+r>n&&(o=n-r),o<0&&(o=0),this.width=t,this.scrollWidth=i,this.scrollLeft=s,this.height=r,this.scrollHeight=n,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,i){return new e(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(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(e,t){let i=this.width!==e.width,s=this.scrollWidth!==e.scrollWidth,r=this.scrollLeft!==e.scrollLeft,n=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,a=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:s,scrollLeftChanged:r,heightChanged:n,scrollHeightChanged:o,scrollTopChanged:a}}},$a=class extends to{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new bo),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Fa(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),null==(i=this._smoothScrolling)||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(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i,s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;i=t?new qa(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=qa.start(this._state,t,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)return this._smoothScrolling.dispose(),void(this._smoothScrolling=null);this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Ka=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ua(e,t){let i=t-e;return function(t){return e+i*function(e){return 1-function(e){return Math.pow(e,3)}(1-e)}(t)}}var qa=class e{constructor(e,t,i,s){this.from=e,this.to=t,this.duration=s,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(e,t,i){if(Math.abs(e-t)>2.5*i){let s,r;return e<t?(s=e+.75*i,r=t-.75*i):(s=e-.75*i,r=t+.75*i),function(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}(Ua(e,s),Ua(r,t),.33)}return Ua(e,t)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;if(t<1){let e=this.scrollLeft(t),i=this.scrollTop(t);return new Ka(e,i,!1)}return new Ka(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return e.start(t,i,s)}static start(t,i,s){s+=10;let r=Date.now()-10;return new e(t,i,r,s)}};var Va=class extends to{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Sa)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||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(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;null==(e=this._domNode)||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,null==(t=this._domNode)||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Ya=class extends Wa{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 Va(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Aa),this._shouldRender=!0,this.domNode=Ta(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(Ea(this.domNode.domNode,La.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Ha(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Ta(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),"number"==typeof i&&this.slider.setWidth(i),"number"==typeof s&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ea(this.slider.domNode,La.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)t=e.offsetX,i=e.offsetY;else{let s=function(e){let t=e.getBoundingClientRect(),i=xa(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}(this.domNode.domNode);t=e.pageX-s.left,i=e.pageY-s.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!(e.target&&e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let r=this._sliderOrthogonalPointerPosition(e),n=Math.abs(r-i);if(Fo&&n>140)return void this._setDesiredScrollPositionNow(s.getScrollPosition());let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ga=class e{constructor(e,t,i,s,r,n){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(e),this._visibleSize=s,this._scrollSize=r,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,i,s,r){let n=Math.max(0,i-e),o=Math.max(0,n-2*t),a=s>0&&s>i;if(!a)return{computedAvailableSize:Math.round(n),computedIsNeeded:a,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*o/s))),h=(o-l)/(s-i),c=r*h;return{computedAvailableSize:Math.round(n),computedIsNeeded:a,computedSliderSize:Math.round(l),computedSliderRatio:h,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let t=e._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(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,i=this._scrollPosition;return t<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},Xa=class extends Ya{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ga(t.horizontalHasArrows?t.arrowSize:0,2===t.horizontal?0:t.horizontalScrollbarSize,2===t.vertical?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Ja=class extends Ya{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ga(t.verticalHasArrows?t.arrowSize:0,2===t.vertical?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Za=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Qa=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,t=0,i=1,s=this._rear;for(;;){let r=s===this._front?e:Math.pow(2,-i);if(e-=r,t+=this._memory[s].score*r,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}return t<=.5}acceptStandardWheelEvent(e){if(Mo){let i=xa(e.browserEvent),s=(t=i,yo.INSTANCE.getZoomFactor(t));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY);var t}accept(e,t,i){let s=null,r=new Za(e,t,i);-1===this._front&&-1===this._rear?(this._memory[0]=r,this._front=0,this._rear=0):(s=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]=r),r.score=this._computeScore(r,s)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(i+=.25),t){let s=Math.abs(e.deltaX),r=Math.abs(e.deltaY),n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.max(Math.min(s,n),1),l=Math.max(Math.min(r,o),1),h=Math.max(s,n),c=Math.max(r,o);h%a===0&&c%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Qa.INSTANCE=new Qa;var el=Qa,tl=class extends Wa{constructor(e,t,i){super(),this._onScroll=this._register(new bo),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new bo),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let t={lazyRender:typeof e.lazyRender<"u"&&e.lazyRender,className:typeof e.className<"u"?e.className:"",useShadows:!(typeof e.useShadows<"u")||e.useShadows,handleMouseWheel:!(typeof e.handleMouseWheel<"u")||e.handleMouseWheel,flipAxes:typeof e.flipAxes<"u"&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<"u"&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:!(typeof e.scrollPredominantAxis<"u")||e.scrollPredominantAxis,mouseWheelSmoothScroll:!(typeof e.mouseWheelSmoothScroll<"u")||e.mouseWheelSmoothScroll,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,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,$o&&(t.className+=" mac"),t}(t),this._scrollable=i,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let s={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Ja(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Xa(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ta(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ta(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ta(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,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new Sa),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Jn(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,$o&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new fa(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Jn(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new fa(e))};this._mouseWheelToDispose.push(Ea(this._listenOnDomNode,La.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){var t;if(null==(t=e.browserEvent)?void 0:t.defaultPrevented)return;let i=el.INSTANCE;i.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let t=e.deltaY*this._options.mouseWheelScrollSensitivity,r=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&r+t===0?r=t=0:Math.abs(t)>=Math.abs(r)?r=0:t=0),this._options.flipAxes&&([t,r]=[r,t]);let n=!$o&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!r&&(r=t,t=0),e.browserEvent&&e.browserEvent.altKey&&(r*=this._options.fastScrollSensitivity,t*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),a={};if(t){let e=50*t,i=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(a,i)}if(r){let e=50*r,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(a,t)}a=this._scrollable.validateScrollPosition(a),(o.scrollLeft!==a.scrollLeft||o.scrollTop!==a.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(a):this._scrollable.setScrollPositionNow(a),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},il=class extends tl{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};var sl=class extends to{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new bo),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new $a({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Ma(s.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new il(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(no.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Zn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Zn(()=>this._styleElement.remove())),this._register(no.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join("\n")})),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(e=>this._handleScroll(e)))}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:(null==(e=this._optionsService.rawOptions.overviewRuler)?void 0:e.width)||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;0!==i&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};sl=Xr([Jr(2,bn),Jr(3,Bn),Jr(4,wn),Jr(5,In),Jr(6,En),Jr(7,jn)],sl);var rl=class extends to{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(Zn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(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 t;let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer","top"===(null==(t=null==e?void 0:e.options)?void 0:t.layer)),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=t*this._renderService.dimensions.css.cell.height+"px",i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;"right"===(e.options.anchor||"left")?t.style.right=i?i*this._renderService.dimensions.css.cell.width+"px":"":t.style.left=i?i*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(e){var t;null==(t=this._decorationElements.get(e))||t.remove(),this._decorationElements.delete(e),e.dispose()}};rl=Xr([Jr(1,bn),Jr(2,Bn),Jr(3,Dn),Jr(4,jn)],rl);var nl,ol,al,ll,hl,cl=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))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return 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,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},dl={full:0,left:0,center:0,right:0},ul={full:0,left:0,center:0,right:0},_l={full:0,left:0,center:0,right:0},fl=class extends to{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new cl,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(),null==(l=this._viewportElement.parentElement)||l.insertBefore(this._canvas,this._viewportElement),this._register(Zn(()=>{var e;return null==(e=this._canvas)?void 0:e.remove()}));let h=this._canvas.getContext("2d");if(!h)throw new Error("Ctx cannot be null");this._ctx=h,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(null==(e=this._optionsService.options.overviewRuler)?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ul.full=this._canvas.width,ul.left=e,ul.center=t,ul.right=e,this._refreshDrawHeightConstants(),_l.full=1,_l.left=1,_l.center=1+ul.left,_l.right=1+ul.left+ul.center}_refreshDrawHeightConstants(){dl.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);dl.left=t,dl.center=t,dl.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dl.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dl.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dl.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*dl.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)"full"!==t.position&&this._renderColorZone(t);for(let t of e)"full"===t.position&&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(_l[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-dl[e.position||"full"]/2),ul[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+dl[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};fl=Xr([Jr(2,bn),Jr(3,Dn),Jr(4,jn),Jr(5,En),Jr(6,In),Jr(7,Bn)],fl),(ol=nl||(nl={})).NUL="\0",ol.SOH="",ol.STX="",ol.ETX="",ol.EOT="",ol.ENQ="",ol.ACK="",ol.BEL="",ol.BS="\b",ol.HT="\t",ol.LF="\n",ol.VT="\v",ol.FF="\f",ol.CR="\r",ol.SO="",ol.SI="",ol.DLE="",ol.DC1="",ol.DC2="",ol.DC3="",ol.DC4="",ol.NAK="",ol.SYN="",ol.ETB="",ol.CAN="",ol.EM="",ol.SUB="",ol.ESC="",ol.FS="",ol.GS="",ol.RS="",ol.US="",ol.SP=" ",ol.DEL="",(ll=al||(al={})).PAD="",ll.HOP="",ll.BPH="",ll.NBH="",ll.IND="",ll.NEL="
",ll.SSA="",ll.ESA="",ll.HTS="",ll.HTJ="",ll.VTS="",ll.PLD="",ll.PLU="",ll.RI="",ll.SS2="",ll.SS3="",ll.DCS="",ll.PU1="",ll.PU2="",ll.STS="",ll.CCH="",ll.MW="",ll.SPA="",ll.EPA="",ll.SOS="",ll.SGCI="",ll.SCI="",ll.CSI="",ll.ST="",ll.OSC="",ll.PM="",ll.APC="",(hl||(hl={})).ST=`${nl.ESC}\\`;var pl=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${nl.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 e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let r=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(r.width,1)+"px",this._textarea.style.height=Math.max(r.height,1)+"px",this._textarea.style.lineHeight=r.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};pl=Xr([Jr(2,bn),Jr(3,En),Jr(4,xn),Jr(5,jn)],pl);var ml,gl,vl,Sl,bl,wl=0,xl=0,yl=0,Cl=0,kl={css:"#00000000",rgba:0};function El(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Ml(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}(e=>{e.toCss=function(e,t,i,s){return void 0!==s?`#${El(e)}${El(t)}${El(i)}${El(s)}`:`#${El(e)}${El(t)}${El(i)}`},e.toRgba=function(e,t,i,s=255){return(e<<24|t<<16|i<<8|s)>>>0},e.toColor=function(t,i,s,r){return{css:e.toCss(t,i,s,r),rgba:e.toRgba(t,i,s,r)}}})(ml||(ml={})),(e=>{function t(e,t){return Cl=Math.round(255*t),[wl,xl,yl]=bl.toChannels(e.rgba),{css:ml.toCss(wl,xl,yl,Cl),rgba:ml.toRgba(wl,xl,yl,Cl)}}e.blend=function(e,t){if(1===(Cl=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,s=t.rgba>>16&255,r=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return wl=n+Math.round((i-n)*Cl),xl=o+Math.round((s-o)*Cl),yl=a+Math.round((r-a)*Cl),{css:ml.toCss(wl,xl,yl),rgba:ml.toRgba(wl,xl,yl)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let s=bl.ensureContrastRatio(e.rgba,t.rgba,i);if(s)return ml.toColor(s>>24&255,s>>16&255,s>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[wl,xl,yl]=bl.toChannels(t),{css:ml.toCss(wl,xl,yl),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(Cl=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(gl||(gl={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let s=e.getContext("2d",{willReadFrequently:!0});s&&(t=s,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return wl=parseInt(e.slice(1,2).repeat(2),16),xl=parseInt(e.slice(2,3).repeat(2),16),yl=parseInt(e.slice(3,4).repeat(2),16),ml.toColor(wl,xl,yl);case 5:return wl=parseInt(e.slice(1,2).repeat(2),16),xl=parseInt(e.slice(2,3).repeat(2),16),yl=parseInt(e.slice(3,4).repeat(2),16),Cl=parseInt(e.slice(4,5).repeat(2),16),ml.toColor(wl,xl,yl,Cl);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let s=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(s)return wl=parseInt(s[1]),xl=parseInt(s[2]),yl=parseInt(s[3]),Cl=Math.round(255*(void 0===s[5]?1:parseFloat(s[5]))),ml.toColor(wl,xl,yl,Cl);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[wl,xl,yl,Cl]=t.getImageData(0,0,1,1).data,255!==Cl)throw new Error("css.toColor: Unsupported css format");return{rgba:ml.toRgba(wl,xl,yl,Cl),css:e}}})(vl||(vl={})),(e=>{function t(e,t,i){let s=e/255,r=t/255,n=i/255;return.2126*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.7152*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(Sl||(Sl={})),(e=>{function t(e,t,i){let s=e>>24&255,r=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Ml(Sl.relativeLuminance2(o,a,l),Sl.relativeLuminance2(s,r,n));for(;h<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h=Ml(Sl.relativeLuminance2(o,a,l),Sl.relativeLuminance2(s,r,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let s=e>>24&255,r=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Ml(Sl.relativeLuminance2(o,a,l),Sl.relativeLuminance2(s,r,n));for(;h<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=Ml(Sl.relativeLuminance2(o,a,l),Sl.relativeLuminance2(s,r,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(Cl=(255&t)/255))return t;let i=t>>24&255,s=t>>16&255,r=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return wl=n+Math.round((i-n)*Cl),xl=o+Math.round((s-o)*Cl),yl=a+Math.round((r-a)*Cl),ml.toRgba(wl,xl,yl)},e.ensureContrastRatio=function(e,s,r){let n=Sl.relativeLuminance(e>>8),o=Sl.relativeLuminance(s>>8);if(Ml(n,o)<r){if(o<n){let o=t(e,s,r),a=Ml(n,Sl.relativeLuminance(o>>8));if(a<r){let t=i(e,s,r);return a>Ml(n,Sl.relativeLuminance(t>>8))?o:t}return o}let a=i(e,s,r),l=Ml(n,Sl.relativeLuminance(a>>8));if(l<r){let i=t(e,s,r);return l>Ml(n,Sl.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(bl||(bl={}));var Nl=class extends _n{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Dl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new pn}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(0===this._characterJoiners.length)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||0===t.length)return[];let i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),l=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let e=this._getJoinedRanges(s,o,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||1}if(this._bufferService.cols-r>1){let e=this._getJoinedRanges(s,o,n,t,r);for(let t=0;t<e.length;t++)i.push(e[t])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let h=1;h<this._characterJoiners.length;h++)try{let e=this._characterJoiners[h].handler(n);for(let t=0;t<e.length;t++)Dl._mergeRanges(o,e[t])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let i=t.getWidth(a),l=t.getString(a).length||1;if(0!==i){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0)}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Dl=Xr([Jr(0,bn)],Dl);var Rl=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new pn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,l,h,c){let d=[],u=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let p,m=0,g="",v=0,S=0,b=0,w=0,x=!1,y=0,C=!1,k=0,E=0,M=[],N=-1!==h&&-1!==c;for(let D=0;D<f;D++){e.loadCell(D,this._workCell);let f=this._workCell.getWidth();if(0===f)continue;let R=!1,L=D>=E,P=D,B=this._workCell;if(u.length>0&&D===u[0][0]&&L){let s=u.shift(),r=this._isCellInSelection(s[0],t);for(v=s[0]+1;v<s[1];v++)L&&(L=r===this._isCellInSelection(v,t));L&&(L=!i||n<s[0]||n>=s[1]),L?(R=!0,B=new Nl(this._workCell,e.translateToString(!0,s[0],s[1]),s[1]-s[0]),P=s[1]-1,f=B.getWidth()):E=s[1]}let T=this._isCellInSelection(D,t),j=i&&D===n,O=N&&D>=h&&D<=c,A=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{A=!0});let I=B.getChars()||un;if(" "===I&&(B.isUnderline()||B.isOverline())&&(I=" "),k=f*a-l.get(I,B.isBold(),B.isItalic()),p){if(m&&(T&&C||!T&&!C&&B.bg===S)&&(T&&C&&_.selectionForeground||B.fg===b)&&B.extended.ext===w&&O===x&&k===y&&!j&&!R&&!A&&L){B.isInvisible()?g+=un:g+=I,m++;continue}m&&(p.textContent=g),p=this._document.createElement("span"),m=0,g=""}else p=this._document.createElement("span");if(S=B.bg,b=B.fg,w=B.extended.ext,x=O,y=k,C=T,R&&n>=D&&n<=P&&(n=D),!this._coreService.isCursorHidden&&j&&this._coreService.isCursorInitialized)if(M.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&M.push("xterm-cursor-blink"),M.push("bar"===s?"xterm-cursor-bar":"underline"===s?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":M.push("xterm-cursor-outline");break;case"block":M.push("xterm-cursor-block");break;case"bar":M.push("xterm-cursor-bar");break;case"underline":M.push("xterm-cursor-underline")}if(B.isBold()&&M.push("xterm-bold"),B.isItalic()&&M.push("xterm-italic"),B.isDim()&&M.push("xterm-dim"),g=B.isInvisible()?un:B.getChars()||un,B.isUnderline()&&(M.push(`xterm-underline-${B.extended.underlineStyle}`)," "===g&&(g=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${_n.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let e=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&e<8&&(e+=8),p.style.textDecorationColor=_.ansi[e].css}B.isOverline()&&(M.push("xterm-overline")," "===g&&(g=" ")),B.isStrikethrough()&&M.push("xterm-strikethrough"),O&&(p.style.textDecoration="underline");let z=B.getFgColor(),W=B.getFgColorMode(),H=B.getBgColor(),F=B.getBgColorMode(),$=!!B.isInverse();if($){let e=z;z=H,H=e;let t=W;W=F,F=t}let K,U,q,V=!1;switch(this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{"top"!==e.options.layer&&V||(e.backgroundColorRGB&&(F=50331648,H=e.backgroundColorRGB.rgba>>8&16777215,K=e.backgroundColorRGB),e.foregroundColorRGB&&(W=50331648,z=e.foregroundColorRGB.rgba>>8&16777215,U=e.foregroundColorRGB),V="top"===e.options.layer)}),!V&&T&&(K=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,H=K.rgba>>8&16777215,F=50331648,V=!0,_.selectionForeground&&(W=50331648,z=_.selectionForeground.rgba>>8&16777215,U=_.selectionForeground)),V&&M.push("xterm-decoration-top"),F){case 16777216:case 33554432:q=_.ansi[H],M.push(`xterm-bg-${H}`);break;case 50331648:q=ml.toColor(H>>16,H>>8&255,255&H),this._addStyle(p,`background-color:#${Ll((H>>>0).toString(16),"0",6)}`);break;default:$?(q=_.foreground,M.push("xterm-bg-257")):q=_.background}switch(K||B.isDim()&&(K=gl.multiplyOpacity(q,.5)),W){case 16777216:case 33554432:B.isBold()&&z<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(z+=8),this._applyMinimumContrast(p,q,_.ansi[z],B,K,void 0)||M.push(`xterm-fg-${z}`);break;case 50331648:let e=ml.toColor(z>>16&255,z>>8&255,255&z);this._applyMinimumContrast(p,q,e,B,K,U)||this._addStyle(p,`color:#${Ll(z.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(p,q,_.foreground,B,K,U)||$&&M.push("xterm-fg-257")}M.length&&(p.className=M.join(" "),M.length=0),j||R||A||!L?p.textContent=g:m++,k!==this.defaultSpacing&&(p.style.letterSpacing=`${k}px`),d.push(p),D=P}return p&&m&&(p.textContent=g),d}_applyMinimumContrast(e,t,i,s,r,n){if(1===this._optionsService.rawOptions.minimumContrastRatio||(function(e){return 57508<=e&&e<=57558}(o=s.getCode())||function(e){return 9472<=e&&e<=9631}(o)))return!1;var o;let a,l=this._getContrastCache(s);if(!r&&!n&&(a=l.getColor(t.rgba,i.rgba)),void 0===a){let e=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=gl.ensureContrastRatio(r||t,n||i,e),l.setColor((r||t).rgba,(n||i).rgba,a??null)}return!!a&&(this._addStyle(e,`color:${a.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!(!i||!s)&&(this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0])}};function Ll(e,t,i){for(;e.length<i;)e=t+e;return e}Rl=Xr([Jr(1,An),Jr(2,En),Jr(3,Bn),Jr(4,xn),Jr(5,Dn),Jr(6,In)],Rl);var Pl=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&1===e.length&&(s=e.charCodeAt(0))<256){if(-9999!==this._flat[s])return this._flat[s];let t=this._measure(e,0);return t>0&&(this._flat[s]=t),t}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(void 0===n){let s=0;t&&(s|=1),i&&(s|=2),n=this._measure(e,s),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Bl=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1])return void this.clear();let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0])}isCellSelected(e,t,i){return!!this.hasSelection&&(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol)}};var Tl="xterm-dom-renderer-owner-",jl="xterm-rows",Ol="xterm-fg-",Al="xterm-bg-",Il="xterm-focus",zl="xterm-selection",Wl=1,Hl=class extends to{constructor(e,t,i,s,r,n,o,a,l,h,c,d,u,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=l,this._optionsService=h,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=_,this._terminalClass=Wl++,this._rowElements=[],this._selectionRenderModel=new Bl,this.onRequestRedraw=this._register(new bo).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(jl),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(zl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(Rl,document),this._element.classList.add(Tl+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(Zn(()=>{this._element.classList.remove(Tl+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Pl(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${jl} 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} .${jl} { 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} .${jl} .xterm-dim { color: ${gl.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${jl}.${Il} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${jl}.${Il} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${jl}.${Il} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${jl} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${jl} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${jl} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${jl} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${jl} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${zl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${zl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${zl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ol}${n} { color: ${o.css}; }${this._terminalSelector} .${Ol}${n}.xterm-dim { color: ${gl.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Al}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ol}257 { color: ${gl.opaque(e.background).css}; }${this._terminalSelector} .${Ol}257.xterm-dim { color: ${gl.multiplyOpacity(gl.opaque(e.background),.5).css}; }${this._terminalSelector} .${Al}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}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(Il),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Il),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let i=e[0]>t[0];a.appendChild(this._createSelectionElement(n,i?t[0]:e[0],i?e[0]:t[0],o-n+1))}else{let i=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,i,l));let h=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,h)),n!==o){let e=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=s*this.dimensions.css.cell.height+"px",r.style.top=e*this.dimensions.css.cell.height+"px",r.style.left=`${n}px`,r.style.width=`${o}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=e;l<=t;l++){let e=l+i.ydisp,t=this._rowElements[l],h=i.lines.get(e);if(!t||!h)break;t.replaceChildren(...this._rowFactory.createRow(h,e,e===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Tl}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,l=a.ybase+a.y,h=Math.min(a.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=s;++_){let o=_+a.ydisp,f=this._rowElements[_],p=a.lines.get(o);if(!f||!p)break;f.replaceChildren(...this._rowFactory.createRow(p,o,o===l,d,u,h,c,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===s?t:r)-1:-1))}}};Hl=Xr([Jr(7,Cn),Jr(8,Pn),Jr(9,En),Jr(10,bn),Jr(11,xn),Jr(12,Bn),Jr(13,In)],Hl);var Fl=class extends to{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new bo),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Ul(this._optionsService))}catch{this._measureStrategy=this._register(new Kl(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())}};Fl=Xr([Jr(2,En)],Fl);var $l=class extends to{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){void 0!==e&&e>0&&void 0!==t&&t>0&&(this._result.width=e,this._result.height=t)}},Kl=class extends $l{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Ul=class extends $l{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}},ql=class extends to{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Vl(this._window)),this._onDprChange=this._register(new bo),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new bo),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(no.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ea(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ea(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 void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Vl=class extends to{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new io),this._onDprChange=this._register(new bo),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Zn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ea(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&(null==(e=this._resolutionMediaMatchList)||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)}},Yl=class extends to{constructor(){super(),this.linkProviders=[],this._register(Zn(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);-1!==t&&this.linkProviders.splice(t,1)}}}};function Gl(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}var Xl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return function(e,t,i,s,r,n,o,a,l){if(!n)return;let h=Gl(e,t,i);return h?(h[0]=Math.ceil((h[0]+(l?o/2:0))/o),h[1]=Math.ceil(h[1]/a),h[0]=Math.min(Math.max(h[0],1),s+(l?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h):void 0}(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Gl(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Xl=Xr([Jr(0,jn),Jr(1,Pn)],Xl);var Jl=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();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=[]}},Zl={};((e,t)=>{for(var i in t)Yr(e,i,{get:t[i],enumerable:!0})})(Zl,{getSafariVersion:()=>nh,isChromeOS:()=>dh,isFirefox:()=>ih,isIpad:()=>ah,isIphone:()=>lh,isLegacyEdge:()=>sh,isLinux:()=>ch,isMac:()=>oh,isNode:()=>Ql,isSafari:()=>rh,isWindows:()=>hh});var Ql=typeof process<"u"&&"title"in process,eh=Ql?"node":navigator.userAgent,th=Ql?"node":navigator.platform,ih=eh.includes("Firefox"),sh=eh.includes("Edge"),rh=/^((?!chrome|android).)*safari/i.test(eh);function nh(){if(!rh)return 0;let e=eh.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var oh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(th),ah="iPad"===th,lh="iPhone"===th,hh=["Windows","Win16","Win32","WinCE"].includes(th),ch=th.indexOf("Linux")>=0,dh=/\bCrOS\b/.test(eh),uh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),1.5*i>r)return s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),void this._start();s=r}this.clear()}},_h=!Ql&&"requestIdleCallback"in window?class extends uh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends uh{_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())}}},fh=class{constructor(){this._queue=new _h}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},ph=class extends to{constructor(e,t,i,s,r,n,o,a,l){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new io),this._pausedResizeTask=new fh,this._observerDisposable=this._register(new io),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 bo),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new bo),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new bo),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new bo),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Jl((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new mh(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Zn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var e;return null==(e=this._renderer.value)?void 0:e.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(l.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=Zn(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused)return void(this._needsFullRefresh=!0);if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,t);let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,t);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(e=>this.refreshRows(e.start,e.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&&(null==(t=(e=this._renderer.value).clearTextureAtlas)||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return null==(i=this._renderer.value)?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;null==(e=this._renderer.value)||e.handleCharSizeChanged()}handleBlur(){var e;null==(e=this._renderer.value)||e.handleBlur()}handleFocus(){var e;null==(e=this._renderer.value)||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,null==(s=this._renderer.value)||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;null==(e=this._renderer.value)||e.handleCursorMove()}clear(){var e;null==(e=this._renderer.value)||e.clear()}};ph=Xr([Jr(2,En),Jr(3,Pn),Jr(4,xn),Jr(5,Dn),Jr(6,bn),Jr(7,Bn),Jr(8,In)],ph);var mh=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(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(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function gh(e,t,i,s){let r,n=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return function(e,t,i,s,r,n){return 0===vh(t,s,r,n).length?"":yh(wh(e,t,e,t-Sh(t,r),!1,r).length,xh("D",n))}(n,o,0,t,i,s)+vh(o,t,i,s)+function(e,t,i,s,r,n){let o;o=vh(t,s,r,n).length>0?s-Sh(s,r):t;let a=s,l=function(e,t,i,s,r,n){let o;return o=vh(i,s,r,n).length>0?s-Sh(s,r):t,e<i&&o<=s||e>=i&&o<s?"C":"D"}(e,t,i,s,r,n);return yh(wh(e,o,i,a,"C"===l,r).length,xh(l,n))}(n,o,e,t,i,s);if(o===t)return r=n>e?"D":"C",yh(Math.abs(n-e),xh(r,s));r=o>t?"D":"C";let a=Math.abs(o-t),l=function(e,t){return t.cols-e}(o>t?e:n,i)+(a-1)*i.cols+1+function(e){return e-1}(o>t?n:e);return yh(l,xh(r,s))}function vh(e,t,i,s){let r=e-Sh(e,i),n=t-Sh(t,i),o=Math.abs(r-n)-function(e,t,i){var s;let r=0,n=e-Sh(e,i),o=t-Sh(t,i);for(let a=0;a<Math.abs(n-o);a++){let o="A"===bh(e,t)?-1:1;(null==(s=i.buffer.lines.get(n+o*a))?void 0:s.isWrapped)&&r++}return r}(e,t,i);return yh(o,xh(bh(e,t),s))}function Sh(e,t){let i=0,s=t.buffer.lines.get(e),r=null==s?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=null==s?void 0:s.isWrapped;return i}function bh(e,t){return e>t?"A":"B"}function wh(e,t,i,s,r,n){let o=e,a=t,l="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(l+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,e,o)}function xh(e,t){let i=t?"O":"[";return nl.ESC+i+e}function yh(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var Ch=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.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)&&(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 kh(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 Eh=new RegExp(" ","g"),Mh=class extends to{constructor(e,t,i,s,r,n,o,a,l){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new pn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new bo),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new bo),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new bo),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new bo),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new Ch(this._bufferService),this._activeSelectionMode=0,this._register(Zn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.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)&&(e[0]!==t[0]||e[1]!==t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(3===this._activeSelectionMode){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=i.translateBufferLineToString(o,!0,r,n);s.push(e)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let e=i.lines.get(n),t=i.translateBufferLineToString(n,!0);(null==e?void 0:e.isWrapped)?s[s.length-1]+=t:s.push(t)}if(e[1]!==t[1]){let e=i.lines.get(t[1]),r=i.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?s[s.length-1]+=r:s.push(r)}}return s.map(e=>e.replace(Eh," ")).join(hh?"\r\n":"\n")}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),ch&&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:3===this._activeSelectionMode})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!!(i&&s&&t)&&this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!(!i||!s)&&this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var i,s;let r=null==(s=null==(i=this._linkifier.currentLink)?void 0:i.link)?void 0:s.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=kh(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return!!n&&(this._selectWordAt(n,t),this._model.selectionEnd=void 0,!0)}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=Gl(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(14*t))}shouldForceSelection(e){return oh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,(2!==e.button||!this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&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(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(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]&&0===t.hasWidth(this._model.selectionStart[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&&!(oh&&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)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let e=i.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[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?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(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<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&void 0!==t[0]&&void 0!==t[1]){let e=gh(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!(!e||!t||e[0]===t[0]&&e[1]===t[1]);i?!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i):this._oldHasSelection&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;0===this._workCell.getWidth()?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),l=a,h=e[0]-a,c=0,d=0,u=0,_=0;if(" "===o.charAt(a)){for(;a>0&&" "===o.charAt(a-1);)a--;for(;l<o.length&&" "===o.charAt(l+1);)l++}else{let t=e[0],i=e[0];0===n.getWidth(t)&&(c++,t--),2===n.getWidth(i)&&(d++,i++);let s=n.getString(i).length;for(s>1&&(_+=s-1,l+=s-1);t>0&&a>0&&!this._isCharWordSeparator(n.loadCell(t-1,this._workCell));){n.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(c++,t--):e>1&&(u+=e-1,a-=e-1),a--,t--}for(;i<n.length&&l+1<o.length&&!this._isCharWordSeparator(n.loadCell(i+1,this._workCell));){n.loadCell(i+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(d++,i++):e>1&&(_+=e-1,l+=e-1),l++,i++}}l++;let f=a+h-c+u,p=Math.min(this._bufferService.cols,l-a+c+d-u-_);if(t||""!==o.slice(a,l).trim()){if(i&&0===f&&32!==n.getCodePoint(0)){let t=r.lines.get(e[1]-1);if(t&&n.isWrapped&&32!==t.getCodePoint(this._bufferService.cols-1)){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;f-=e,p+=e}}}if(s&&f+p===this._bufferService.cols&&32!==n.getCodePoint(this._bufferService.cols-1)){let t=r.lines.get(e[1]+1);if((null==t?void 0:t.isWrapped)&&32!==t.getCodePoint(0)){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(p+=t.length)}}return{start:f,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=kh(i,this._bufferService.cols)}};Mh=Xr([Jr(3,bn),Jr(4,xn),Jr(5,Tn),Jr(6,En),Jr(7,jn),Jr(8,Bn)],Mh);var Nh=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Dh=class{constructor(){this._color=new Nh,this._css=new Nh}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Rh=Object.freeze((()=>{let e=[vl.toColor("#2e3436"),vl.toColor("#cc0000"),vl.toColor("#4e9a06"),vl.toColor("#c4a000"),vl.toColor("#3465a4"),vl.toColor("#75507b"),vl.toColor("#06989a"),vl.toColor("#d3d7cf"),vl.toColor("#555753"),vl.toColor("#ef2929"),vl.toColor("#8ae234"),vl.toColor("#fce94f"),vl.toColor("#729fcf"),vl.toColor("#ad7fa8"),vl.toColor("#34e2e2"),vl.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ml.toCss(s,r,n),rgba:ml.toRgba(s,r,n)})}for(let i=0;i<24;i++){let t=8+10*i;e.push({css:ml.toCss(t,t,t),rgba:ml.toRgba(t,t,t)})}return e})()),Lh=vl.toColor("#ffffff"),Ph=vl.toColor("#000000"),Bh=vl.toColor("#ffffff"),Th=Ph,jh={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Oh=Lh,Ah=class extends to{constructor(e){super(),this._optionsService=e,this._contrastCache=new Dh,this._halfContrastCache=new Dh,this._onChangeColors=this._register(new bo),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Lh,background:Ph,cursor:Bh,cursorAccent:Th,selectionForeground:void 0,selectionBackgroundTransparent:jh,selectionBackgroundOpaque:gl.blend(Ph,jh),selectionInactiveBackgroundTransparent:jh,selectionInactiveBackgroundOpaque:gl.blend(Ph,jh),scrollbarSliderBackground:gl.opacity(Lh,.2),scrollbarSliderHoverBackground:gl.opacity(Lh,.4),scrollbarSliderActiveBackground:gl.opacity(Lh,.5),overviewRulerBorder:Lh,ansi:Rh.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=Ih(e.foreground,Lh),t.background=Ih(e.background,Ph),t.cursor=gl.blend(t.background,Ih(e.cursor,Bh)),t.cursorAccent=gl.blend(t.background,Ih(e.cursorAccent,Th)),t.selectionBackgroundTransparent=Ih(e.selectionBackground,jh),t.selectionBackgroundOpaque=gl.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ih(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=gl.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ih(e.selectionForeground,kl):void 0,t.selectionForeground===kl&&(t.selectionForeground=void 0),gl.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=gl.opacity(t.selectionBackgroundTransparent,.3)),gl.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=gl.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ih(e.scrollbarSliderBackground,gl.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ih(e.scrollbarSliderHoverBackground,gl.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ih(e.scrollbarSliderActiveBackground,gl.opacity(t.foreground,.5)),t.overviewRulerBorder=Ih(e.overviewRulerBorder,Oh),t.ansi=Rh.slice(),t.ansi[0]=Ih(e.black,Rh[0]),t.ansi[1]=Ih(e.red,Rh[1]),t.ansi[2]=Ih(e.green,Rh[2]),t.ansi[3]=Ih(e.yellow,Rh[3]),t.ansi[4]=Ih(e.blue,Rh[4]),t.ansi[5]=Ih(e.magenta,Rh[5]),t.ansi[6]=Ih(e.cyan,Rh[6]),t.ansi[7]=Ih(e.white,Rh[7]),t.ansi[8]=Ih(e.brightBlack,Rh[8]),t.ansi[9]=Ih(e.brightRed,Rh[9]),t.ansi[10]=Ih(e.brightGreen,Rh[10]),t.ansi[11]=Ih(e.brightYellow,Rh[11]),t.ansi[12]=Ih(e.brightBlue,Rh[12]),t.ansi[13]=Ih(e.brightMagenta,Rh[13]),t.ansi[14]=Ih(e.brightCyan,Rh[14]),t.ansi[15]=Ih(e.brightWhite,Rh[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Ih(e.extendedAnsi[s],Rh[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0!==e)switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}else for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t]}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function Ih(e,t){if(void 0!==e)try{return vl.toColor(e)}catch{}return t}Ah=Xr([Jr(0,En)],Ah);var zh=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Wh=class{constructor(){this._services=new zh,this._services.set(Cn,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=(r=e,r[gn]||[]).sort((e,t)=>e.index-t.index),s=[];var r;for(let o of i){let t=this._services.get(o.id);if(!t)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(t)}let n=i.length>0?i[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,...s)}},Hh={trace:0,debug:1,info:2,warn:3,error:4,off:5},Fh=class extends to{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=Hh[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Fh=Xr([Jr(0,En)],Fh);var $h=class extends to{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new bo),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new bo),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new bo),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let 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 s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let e=this._length+i.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Kh=Object.freeze(new _n),Uh=0,qh=class e{constructor(e,t,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let s=t||pn.fromCharData([0,"",1,0]);for(let r=0;r<e;++r)this.setCell(r,s);this.length=e}get(e){let t=this._data[3*e+0],i=2097151&t;return[this._data[3*e+1],2097152&t?this._combined[e]:i?ln(i):"",t>>22,2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):i]}set(e,t){this._data[3*e+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[3*e+0]=2097152|e|t[2]<<22):this._data[3*e+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 12582912&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&t}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let t=this._data[3*e+0];return 2097152&t?this._combined[e]:2097151&t?ln(2097151&t):""}isProtected(e){return 536870912&this._data[3*e+2]}loadCell(e,t){return Uh=3*e,t.content=this._data[Uh+0],t.fg=this._data[Uh+1],t.bg=this._data[Uh+2],2097152&t.content&&(t.combinedData=this._combined[e]),268435456&t.bg&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){2097152&t.content&&(this._combined[e]=t.combinedData),268435456&t.bg&&(this._extendedAttrs[e]=t.extended),this._data[3*e+0]=t.content,this._data[3*e+1]=t.fg,this._data[3*e+2]=t.bg}setCellFromCodepoint(e,t,i,s){268435456&s.bg&&(this._extendedAttrs[e]=s.extended),this._data[3*e+0]=t|i<<22,this._data[3*e+1]=s.fg,this._data[3*e+2]=s.bg}addCodepointToCell(e,t,i){let s=this._data[3*e+0];2097152&s?this._combined[e]+=ln(t):2097151&s?(this._combined[e]=ln(2097151&s)+ln(t),s&=-2097152,s|=2097152):s=t|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[3*e+0]=s}insertCells(e,t,i){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length-e){let s=new pn;for(let i=this.length-e-t-1;i>=0;--i)this.setCell(e+t+i,this.loadCell(e+i,s));for(let r=0;r<t;++r)this.setCell(e+r,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(e,t,i){if(e%=this.length,t<this.length-e){let s=new pn;for(let i=0;i<this.length-e-t;++i)this.setCell(e+i,this.loadCell(e+t+i,s));for(let e=this.length-t;e<this.length;++e)this.setCell(e,i)}else for(let s=e;s<this.length;++s)this.setCell(s,i);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),0===this.getWidth(e)&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,i)}replaceCells(e,t,i,s=!1){if(s)for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,i),e++;else for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,i),t<this.length&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t,0,1,i);e<t&&e<this.length;)this.setCell(e++,i)}resize(e,t){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let i=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*i)this._data=new Uint32Array(this._data.buffer,0,i);else{let e=new Uint32Array(i);e.set(this._data),this._data=e}for(let i=this.length;i<e;++i)this.setCell(i,t)}else{this._data=this._data.subarray(0,i);let t=Object.keys(this._combined);for(let i=0;i<t.length;i++){let s=parseInt(t[i],10);s>=e&&delete this._combined[s]}let s=Object.keys(this._extendedAttrs);for(let i=0;i<s.length;i++){let t=parseInt(s[i],10);t>=e&&delete this._extendedAttrs[t]}}return this.length=e,4*i*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||50331648&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,t,i,s,r){let n=e._data;if(r)for(let a=s-1;a>=0;a--){for(let e=0;e<3;e++)this._data[3*(i+a)+e]=n[3*(t+a)+e];268435456&n[3*(t+a)+2]&&(this._extendedAttrs[i+a]=e._extendedAttrs[t+a])}else for(let a=0;a<s;a++){for(let e=0;e<3;e++)this._data[3*(i+a)+e]=n[3*(t+a)+e];268435456&n[3*(t+a)+2]&&(this._extendedAttrs[i+a]=e._extendedAttrs[t+a])}let o=Object.keys(e._combined);for(let a=0;a<o.length;a++){let s=parseInt(o[a],10);s>=t&&(this._combined[s-t+i]=e._combined[s])}}translateToString(e,t,i,s){t=t??0,i=i??this.length,e&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let r="";for(;t<i;){let e=this._data[3*t+0],i=2097151&e,n=2097152&e?this._combined[t]:i?ln(i):un;if(r+=n,s)for(let r=0;r<n.length;++r)s.push(t);t+=e>>22||1}return s&&s.push(t),r}};function Vh(e,t,i){let s=[],r=e.map((i,s)=>Yh(e,s,t)).reduce((e,t)=>e+t),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let l=Yh(e,o,t);n>l&&(n-=l,o++);let h=2===e[o].getWidth(n-1);h&&n--;let c=h?i-1:i;s.push(c),a+=c}return s}function Yh(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&1===e[t].getWidth(i-1),r=2===e[t+1].getWidth(0);return s&&r?i-1:i}var Gh=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new bo),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Jn(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Gh._nextId=1;var Xh=Gh,Jh={},Zh=Jh.B;Jh[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:"≥","{":"π","|":"≠","}":"£","~":"·"},Jh.A={"#":"£"},Jh.B=void 0,Jh[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},Jh.C=Jh[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Jh.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},Jh.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},Jh.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},Jh.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},Jh.E=Jh[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},Jh.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},Jh.H=Jh[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Jh["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Qh=4294967295,ec=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Kh.clone(),this.savedCharset=Zh,this.markers=[],this._nullCell=pn.fromCharData([0,"",1,0]),this._whitespaceCell=pn.fromCharData([0,un,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new _h,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $h(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 fn),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 fn),this._whitespaceCell}getBlankLine(e,t){return new qh(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>Qh?Qh:t}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=Kh);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 $h(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Kh),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)s+=+this.lines.get(t).resize(e,i);let n=0;if(this._rows<t)for(let s=this._rows;s<t;s++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new qh(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new qh(e,i)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let e=this.lines.length-r;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=function(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let l=a,h=e.get(++l);if(!h.isWrapped)continue;let c=[e.get(a)];for(;l<e.length&&h.isWrapped;)c.push(h),h=e.get(++l);if(!n&&s>=a&&s<l){a+=c.length-1;continue}let d=0,u=Yh(c,d,t),_=1,f=0;for(;_<c.length;){let e=Yh(c,_,t),s=e-f,n=i-u,o=Math.min(s,n);c[d].copyCellsFrom(c[_],f,u,o,!1),u+=o,u===i&&(d++,u=0),f+=o,f===e&&(_++,f=0),0===u&&0!==d&&2===c[d-1].getWidth(i-1)&&(c[d].copyCellsFrom(c[d-1],i-1,u++,1,!1),c[d-1].setCell(i-1,r))}c[d].replaceCells(u,i,r);let p=0;for(let e=c.length-1;e>0&&(e>d||0===c[e].getTrimmedLength());e--)p++;p>0&&(o.push(a+c.length-p),o.push(p)),a+=c.length-1}return o}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Kh),i);if(s.length>0){let i=function(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let i=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:i}),o+=i-1,n+=i,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}(this.lines,s);(function(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length})(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Kh),r=i;for(;r-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new qh(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Kh),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let e=this.ybase+this.y;if(e>=o&&e<o+l.length)continue}let h,c=l[l.length-1].getTrimmedLength(),d=Vh(l,this._cols,e),u=d.length-l.length;h=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let e=0;e<u;e++){let e=this.getBlankLine(Kh,!0);_.push(e)}_.length>0&&(r.push({start:o+l.length+n,newLines:_}),n+=_.length),l.push(..._);let f=d.length-1,p=d[f];0===p&&(f--,p=d[f]);let m=l.length-u-1,g=c;for(;m>=0;){let e=Math.min(g,p);if(void 0===l[f])break;if(l[f].copyCellsFrom(l[m],g-e,p-e,e,!0),p-=e,0===p&&(f--,p=d[f]),g-=e,0===g){m--,g=Yh(l,Math.max(m,0),this._cols)}}for(let t=0;t<l.length;t++)d[t]<e&&l[t].setCell(d[t],s);let v=u-h;for(;v-- >0;)0===this.ybase?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(r.length>0){let e=[],t=[];for(let r=0;r<this.lines.length;r++)t.push(this.lines.get(r));let i=this.lines.length,s=i-1,o=0,a=r[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let l=0;for(let d=Math.min(this.lines.maxLength-1,i+n-1);d>=0;d--)if(a&&a.start>s+l){for(let e=a.newLines.length-1;e>=0;e--)this.lines.set(d--,a.newLines[e]);d++,e.push({index:s+1,amount:a.newLines.length}),l+=a.newLines.length,a=r[++o]}else this.lines.set(d,t[s--]);let h=0;for(let r=e.length-1;r>=0;r--)e[r].index+=h,this.lines.onInsertEmitter.fire(e[r]),h+=e[r].amount;let c=Math.max(0,i+n-this.lines.maxLength);c>0&&this.lines.onTrimEmitter.fire(c)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(null!=e?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(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(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 Xh(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},tc=class extends to{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new bo),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 ec(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ec(!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)}},ic=class extends to{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new bo),this.onResize=this._onResize.event,this._onScroll=this._register(new bo),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new tc(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i,s=this.buffer;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;n===s.lines.length-1?e?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=n-r+1;s.lines.shiftElements(r+1,e-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(0===i.ydisp)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};ic=Xr([Jr(0,En)],ic);var sc={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:oh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},rc=["normal","bold","100","200","300","400","500","600","700","800","900"],nc=class extends to{constructor(e){super(),this._onOptionChange=this._register(new bo),this.onOptionChange=this._onOptionChange.event;let t={...sc};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(Oa){console.error(Oa)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Zn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{-1!==e.indexOf(i)&&t()})}_setupOptions(){let e=e=>{if(!(e in sc))throw new Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in sc))throw new Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=sc[e]),"block"!==(i=t)&&"underline"!==i&&"bar"!==i)throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=sc[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof t&&1<=t&&t<=1e3)break;t=rc.includes(t)?t:sc[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(10*t)/10));break;case"scrollback":if((t=Math.min(t,4294967295))<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&&0!==t)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{}}var i;return t}};function oc(e,t=5){if("object"!=typeof e)return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&oc(e[s],t-1);return i}var ac=Object.freeze({insertMode:!1}),lc=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),hc=class extends to{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new bo),this.onData=this._onData.event,this._onUserInput=this._register(new bo),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new bo),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new bo),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=oc(ac),this.decPrivateModes=oc(lc)}reset(){this.modes=oc(ac),this.decPrivateModes=oc(lc)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.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(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};hc=Xr([Jr(0,bn),Jr(1,kn),Jr(2,En)],hc);var cc={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>!(32===e.action&&3===e.button)},ANY:{events:31,restrict:e=>!0}};function dc(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return 4===e.button?(i|=64,i|=e.action):(i|=3&e.button,4&e.button&&(i|=64),8&e.button&&(i|=128),32===e.action?i|=32:0===e.action&&!t&&(i|=3)),i}var uc=String.fromCharCode,_c={DEFAULT:e=>{let t=[dc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`[M${uc(t[0])}${uc(t[1])}${uc(t[2])}`},SGR:e=>{let t=0===e.action&&4!==e.button?"m":"M";return`[<${dc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=0===e.action&&4!==e.button?"m":"M";return`[<${dc(e,!0)};${e.x};${e.y}${t}`}},fc=class extends to{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new bo),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(cc))this.addProtocol(s,cc[s]);for(let s of Object.keys(_c))this.addEncoding(s,_c[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(0===e.deltaY||e.shiftKey||void 0===t||void 0===i)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};fc=Xr([Jr(0,bn),Jr(1,xn),Jr(2,En)],fc);var pc,mc=[[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]],gc=[[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]];var vc=class{constructor(){if(this.version="6",!pc){(pc=new Uint8Array(65536)).fill(1),pc[0]=0,pc.fill(0,1,32),pc.fill(0,127,160),pc.fill(2,4352,4448),pc[9001]=2,pc[9002]=2,pc.fill(2,11904,42192),pc[12351]=1,pc.fill(2,44032,55204),pc.fill(2,63744,64256),pc.fill(2,65040,65050),pc.fill(2,65072,65136),pc.fill(2,65280,65377),pc.fill(2,65504,65511);for(let e=0;e<mc.length;++e)pc.fill(0,mc[e][0],mc[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pc[e]:function(e,t){let i,s=0,r=t.length-1;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(i=s+r>>1,e>t[i][1])s=i+1;else{if(!(e<t[i][0]))return!0;r=i-1}return!1}(e,gc)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=0===i&&0!==t;if(s){let e=Sc.extractWidth(t);0===e?s=!1:e>i&&(i=e)}return Sc.createPropertyValue(0,i,s)}},Sc=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new bo,this.onChange=this._onChange.event;let e=new vc;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(1&e)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,i=!1){return(16777215&e)<<3|(3&t)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let e=t.charCodeAt(n);56320<=e&&e<=57343?o=1024*(o-55296)+e-56320+65536:i+=this.wcwidth(e)}let a=this.charProperties(o,s),l=e.extractWidth(a);e.extractShouldJoin(a)&&(l-=e.extractWidth(s)),i+=l,s=a}return i}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},bc=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 wc(e){var t;let i=null==(t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))?void 0:t.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&i&&(s.isWrapped=0!==i[3]&&32!==i[3])}var xc=2147483647,yc=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new e;if(!t.length)return i;for(let e=Array.isArray(t[0])?1:0;e<t.length;++e){let s=t[e];if(Array.isArray(s))for(let e=0;e<s.length;++e)i.addSubParam(s[e]);else i.addParam(s)}return i}clone(){let t=new e(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 e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&e.push(Array.prototype.slice.call(this._subParams,i,s))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>xc?xc:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)return void(this._rejectSubDigits=!0);if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>xc?xc:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,i=255&this._subParamsIdx[e];return i-t>0?this._subParams.subarray(t,i):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];s-i>0&&(e[t]=this._subParams.slice(i,s))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[t-1];i[t-1]=~s?Math.min(10*s+e,xc):e}},Cc=[],kc=class{constructor(){this._state=0,this._active=Cc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let e=i.indexOf(t);-1!==e&&i.splice(e,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=Cc}reset(){if(2===this._state)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=Cc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Cc,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._id,"PUT",hn(e,t,i))}start(){this.reset(),this._state=1}put(e,t,i){if(3!==this._state){if(1===this._state)for(;t<i;){let i=e[t++];if(59===i){this._state=2,this._start();break}if(i<48||57<i)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+i-48}2===this._state&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].end(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._id,"END",e);this._active=Cc,this._id=-1,this._state=0}}},Ec=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=hn(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,t}},Mc=[],Nc=class{constructor(){this._handlers=Object.create(null),this._active=Mc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Mc}registerHandler(e,t){void 0===this._handlers[e]&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let e=i.indexOf(t);-1!==e&&i.splice(e,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=Mc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Mc,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t);else this._handlerFb(this._ident,"HOOK",t)}put(e,t,i){if(this._active.length)for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);else this._handlerFb(this._ident,"PUT",hn(e,t,i))}unhook(e,t=!0){if(this._active.length){let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&!1===i){for(;s>=0&&(i=this._active[s].unhook(e),!0!==i);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",e);this._active=Mc,this._ident=0}},Dc=new yc;Dc.addParam(0);var Rc=class{constructor(e){this._handler=e,this._data="",this._params=Dc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Dc,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=hn(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=Dc,this._data="",this._hitLimit=!1,e));return this._params=Dc,this._data="",this._hitLimit=!1,t}},Lc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Pc=160,Bc=function(){let e=new Lc(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),i=(e,i)=>t.slice(e,i),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n,o=i(0,14);for(n in e.setDefault(1,0),e.addMany(s,0,2,0),o)e.addMany([24,26,153,154],n,3,0),e.addMany(i(128,144),n,3,0),e.addMany(i(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pc,0,2,0),e.add(Pc,8,5,8),e.add(Pc,6,0,6),e.add(Pc,11,0,11),e.add(Pc,13,13,13),e}(),Tc=class extends to{constructor(e=Bc){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 yc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,i)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Zn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kc),this._dcsParser=this._register(new Nc),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let t=0;t<e.intermediates.length;++t){let s=e.intermediates.charCodeAt(t);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=s}}if(1!==e.final.length)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(255&e)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);void 0===this._escHandlers[i]&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);void 0===this._csiHandlers[i]&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let e=s.indexOf(t);-1!==e&&s.splice(e,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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s,r=0,n=0,o=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===i||1===this._parseStack.state)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let t=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](this._params),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 4:if(!1===i&&n>-1)for(;n>=0&&(s=t[n](),!0!==s);n--)if(s instanceof Promise)return this._parseStack.handlerPos=n,s;this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],s=this._dcsParser.unhook(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],s=this._oscParser.end(24!==r&&26!==r,i),s)return s;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let a=o;a<t;++a){switch(r=e[a],n=this._transitions.table[this.currentState<<8|(r<160?r:Pc)],n>>4){case 2:for(let s=a+1;;++s){if(s>=t||(r=e[s])<32||r>126&&r<Pc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Pc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Pc){this._printHandler(e,a,s),a=s-1;break}if(++s>=t||(r=e[s])<32||r>126&&r<Pc){this._printHandler(e,a,s),a=s-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let i=this._csiHandlers[this._collect<<8|r],o=i?i.length-1:-1;for(;o>=0&&(s=i[o](this._params),!0!==s);o--)if(s instanceof Promise)return this._preserveStack(3,i,o,n,a),s;o<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do{switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}}while(++a<t&&(r=e[a])>47&&r<60);a--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let l=this._escHandlers[this._collect<<8|r],h=l?l.length-1:-1;for(;h>=0&&(s=l[h](),!0!==s);h--)if(s instanceof Promise)return this._preserveStack(4,l,h,n,a),s;h<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let s=a+1;;++s)if(s>=t||24===(r=e[s])||26===r||27===r||r>127&&r<Pc){this._dcsParser.put(e,a,s),a=s-1;break}break;case 14:if(s=this._dcsParser.unhook(24!==r&&26!==r),s)return this._preserveStack(6,[],0,n,a),s;27===r&&(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 s=a+1;;s++)if(s>=t||(r=e[s])<32||r>127&&r<Pc){this._oscParser.put(e,a,s),a=s-1;break}break;case 6:if(s=this._oscParser.end(24!==r&&26!==r),s)return this._preserveStack(5,[],0,n,a),s;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},jc=/^([\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})$/,Oc=/^[\da-f]+$/;function Ac(e){if(!e)return;let t=e.toLowerCase();if(0===t.indexOf("rgb:")){t=t.slice(4);let e=jc.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(0===t.indexOf("#")&&(t=t.slice(1),Oc.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,i=[0,0,0];for(let s=0;s<3;++s){let r=parseInt(t.slice(e*s,e*s+e),16);i[s]=1===e?r<<4:2===e?r:3===e?r>>4:r>>8}return i}}function Ic(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function zc(e,t=16){let[i,s,r]=e;return`rgb:${Ic(i,t)}/${Ic(s,t)}/${Ic(r,t)}`}var Wc={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Hc=131072;function Fc(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 $c=0,Kc=class extends to{constructor(e,t,i,s,r,n,o,a,l=new Tc){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cn,this._utf8Decoder=new dn,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Kh.clone(),this._eraseAttrDataInternal=Kh.clone(),this._onRequestBell=this._register(new bo),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new bo),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new bo),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new bo),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new bo),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new bo),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new bo),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new bo),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new bo),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new bo),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new bo),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new bo),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new bo),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 Uc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,t,i)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:t,data:i})}),this._parser.setDcsHandlerFallback((e,t,i)=>{"HOOK"===t&&(i=i.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:t,payload:i})}),this._parser.setPrintHandler((e,t,i)=>this.print(e,t,i)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(nl.BEL,()=>this.bell()),this._parser.setExecuteHandler(nl.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(nl.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(nl.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(nl.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(nl.BS,()=>this.backspace()),this._parser.setExecuteHandler(nl.HT,()=>this.tab()),this._parser.setExecuteHandler(nl.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(nl.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(al.IND,()=>this.index()),this._parser.setExecuteHandler(al.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(al.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ec(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new Ec(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new Ec(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new Ec(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new Ec(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new Ec(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new Ec(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new Ec(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new Ec(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new Ec(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new Ec(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new Ec(e=>this.restoreCursorColor(e))),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 h in Jh)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Rc((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Hc&&(n=this._parseStack.position+Hc)}if(this._logService.logLevel<=1&&this._logService.debug("parsing data "+("string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`)),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Hc&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Hc))),o||this._dirtyRowTracker.clearRange(),e.length>Hc)for(let h=n;h<e.length;h+=Hc){let t=h+Hc<e.length?h+Hc:e.length,n="string"==typeof e?this._stringDecoder.decode(e.substring(h,t),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,t),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,n))return this._preserveStack(s,r,n,h),this._logSlowResolvingAsync(i),i}else if(!o){let t="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,t))return this._preserveStack(s,r,t,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,c=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&2===d.getWidth(this._activeBuffer.x-1)&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let _=t;_<i;++_){if(s=e[_],s<127&&n){let e=n[String.fromCharCode(s)];e&&(s=e.charCodeAt(0))}let t=this._unicodeService.charProperties(s,u);r=Sc.extractWidth(t);let i=Sc.extractShouldJoin(t),f=i?Sc.extractWidth(u):0;if(u=t,o&&this._onA11yChar.fire(ln(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-f>a)if(l){let e=d,t=this._activeBuffer.x-f;for(this._activeBuffer.x=f,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),f>0&&d instanceof qh&&d.copyCellsFrom(e,t,0,f,!1);t<a;)e.setCellFromCodepoint(t++,0,1,c)}else if(this._activeBuffer.x=a-1,2===r)continue;if(i&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,s,r);for(let t=r-f;--t>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(d.insertCells(this._activeBuffer.x,r-f,this._activeBuffer.getNullCell(c)),2===d.getWidth(a-1)&&d.setCellFromCodepoint(a-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=u,this._activeBuffer.x<a&&i-t>0&&0===d.getWidth(this._activeBuffer.x)&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,t):this._parser.registerCsiHandler(e,e=>!Fc(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e))}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Rc(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ec(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(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(null==(e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))?void 0: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 e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.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 0===t?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===t&&(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 1===t&&(this._curAttrData.bg|=536870912),(2===t||0===t)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,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--&&!(null==(i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))?void 0: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 e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}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,0===this._activeBuffer.x,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)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i,s=this._activeBuffer.ybase+this._activeBuffer.y;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(Kh));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);e.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),e.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=Sc.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let h=0;h<n.length;){let e=n.codePointAt(h)||0;o[a++]=e,h+=e>65535?2:1}let l=a;for(let h=1;h<i;++h)o.copyWithin(l,0,a),l+=a;return this.print(o,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(nl.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(nl.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(nl.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(nl.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(nl.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}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}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,Zh),this._charsetService.setgCharset(1,Zh),this._charsetService.setgCharset(2,Zh),this._charsetService.setgCharset(3,Zh);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}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}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:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[t]&&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)}return!0}requestMode(e,t){let i;var s;(s=i||(i={}))[s.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",s[s.SET=1]="SET",s[s.RESET=2]="RESET",s[s.PERMANENTLY_SET=3]="PERMANENTLY_SET",s[s.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let r=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,u=this._optionsService.rawOptions,_=(e,i)=>(a.triggerDataEvent(`${nl.ESC}[${t?"":"?"}${e};${i}$y`),!0),f=e=>e?1:2,p=e.params[0];return _(p,t?2===p?4:4===p?f(a.modes.insertMode):12===p?3:20===p?f(u.convertEol):0:1===p?f(r.applicationCursorKeys):3===p?u.windowOptions.setWinLines?80===h?2:132===h?1:0:0:6===p?f(r.origin):7===p?f(r.wraparound):8===p?3:9===p?f("X10"===n):12===p?f(u.cursorBlink):25===p?f(!a.isCursorHidden):45===p?f(r.reverseWraparound):66===p?f(r.applicationKeypad):67===p?4:1e3===p?f("VT200"===n):1002===p?f("DRAG"===n):1003===p?f("ANY"===n):1004===p?f(r.sendFocus):1005===p?4:1006===p?f("SGR"===o):1015===p?4:1016===p?f("SGR_PIXELS"===o):1048===p?1:47===p||1047===p||1049===p?f(c===d):2004===p?f(r.bracketedPasteMode):2026===p?f(r.synchronizedOutput):0)}_updateAttrColor(e,t,i,s,r){return 2===t?(e|=50331648,e&=-16777216,e|=_n.fromColorRGB([i,s,r])):5===t&&(e&=-50331904,e|=33554432|255&i),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let i=e.getSubParams(t+n),o=0;do{5===s[1]&&(r=1),s[n+o+1+r]=i[o]}while(++o<i.length&&o+n+1+r<s.length);break}if(5===s[1]&&n+r>=2||2===s[1]&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)-1===s[o]&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,0===e&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Kh.fg,e.bg=Kh.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let t,i=e.length,s=this._curAttrData;for(let r=0;r<i;r++)t=e.params[r],t>=30&&t<=37?(s.fg&=-50331904,s.fg|=16777216|t-30):t>=40&&t<=47?(s.bg&=-50331904,s.bg|=16777216|t-40):t>=90&&t<=97?(s.fg&=-50331904,s.fg|=16777224|t-90):t>=100&&t<=107?(s.bg&=-50331904,s.bg|=16777224|t-100):0===t?this._processSGR0(s):1===t?s.fg|=134217728:3===t?s.bg|=67108864:4===t?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):5===t?s.fg|=536870912:7===t?s.fg|=67108864:8===t?s.fg|=1073741824:9===t?s.fg|=2147483648:2===t?s.bg|=134217728:21===t?this._processUnderline(2,s):22===t?(s.fg&=-134217729,s.bg&=-134217729):23===t?s.bg&=-67108865:24===t?(s.fg&=-268435457,this._processUnderline(0,s)):25===t?s.fg&=-536870913:27===t?s.fg&=-67108865:28===t?s.fg&=-1073741825:29===t?s.fg&=2147483647:39===t?(s.fg&=-67108864,s.fg|=16777215&Kh.fg):49===t?(s.bg&=-67108864,s.bg|=16777215&Kh.bg):38===t||48===t||58===t?r+=this._extractColor(e,r,s):53===t?s.bg|=1073741824:55===t?s.bg&=-1073741825:59===t?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):100===t?(s.fg&=-67108864,s.fg|=16777215&Kh.fg,s.bg&=-67108864,s.bg|=16777215&Kh.bg):this._logService.debug("Unknown SGR attribute: %d.",t);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${nl.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${nl.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${nl.ESC}[?${e};${t}R`)}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=Kh.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=0===e.length?1:e.params[0];if(0===t)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"}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t,i=e.params[0]||1;return(e.length<2||(t=e.params[1])>this._bufferService.rows||0===t)&&(t=this._bufferService.rows),t>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Fc(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==t&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${nl.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===t||2===t)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===t||1===t)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===t||2===t)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===t||1===t)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let e=i.shift(),s=i.shift();if(/^\d+$/.exec(e)){let i=parseInt(e);if(qc(i))if("?"===s)t.push({type:0,index:i});else{let e=Ac(s);e&&t.push({type:1,index:i,color:e})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(-1===t)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):!i.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i,s=e.split(":"),r=s.findIndex(e=>e.startsWith("id="));return-1!==r&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if("?"===i[s])this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let e=Ac(i[s]);e&&this._onColor.fire([{type:1,index:this._specialColors[t],color:e}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let e=parseInt(i[s]);qc(e)&&t.push({type:2,index:e})}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,Zh),!0}selectCharset(e){return 2!==e.length?(this.selectDefaultCharset(),!0):("/"===e[0]||this._charsetService.setgCharset(Wc[e[0]],Jh[e[1]]||Zh),!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=Kh.clone(),this._eraseAttrDataInternal=Kh.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new pn;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=this._bufferService.buffer,s=this._optionsService.rawOptions;return(e=>(this._coreService.triggerDataEvent(`${nl.ESC}${e}${nl.ESC}\\`),!0))('"q'===e?`P1$r${this._curAttrData.isProtected()?1:0}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Uc=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&&($c=e,e=t,t=$c),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function qc(e){return 0<=e&&e<256}Uc=Xr([Jr(0,bn)],Uc);var Vc=class extends to{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 bo),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(void 0!==t&&this._syncCalls>t)return void(this._syncCalls=0);if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let i;for(this._isSyncWriting=!0;i=this._writeBuffer.shift();){this._action(i);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],s=this._action(e,t);if(s){let e=e=>performance.now()-i>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(i,e);return void s.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e)}let r=this._callbacks[this._bufferOffset];if(r&&r(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-i>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Yc=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(void 0===e.id){let i=t.addMarker(t.ybase+t.y),s={data:e,id:this._nextId++,lines:[i]};return i.onDispose(()=>this._removeMarkerFromLink(s,i)),this._dataByLinkId.set(s.id,s),s.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);i.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(i,e))}}getLinkData(e){var t;return null==(t=this._dataByLinkId.get(e))?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);-1!==i&&(e.lines.splice(i,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Yc=Xr([Jr(0,bn)],Yc);var Gc=!1,Xc=class extends to{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new io),this._onBinary=this._register(new bo),this.onBinary=this._onBinary.event,this._onData=this._register(new bo),this.onData=this._onData.event,this._onLineFeed=this._register(new bo),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new bo),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new bo),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new bo),this._instantiationService=new Wh,this.optionsService=this._register(new nc(e)),this._instantiationService.setService(En,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ic)),this._instantiationService.setService(bn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Fh)),this._instantiationService.setService(kn,this._logService),this.coreService=this._register(this._instantiationService.createInstance(hc)),this._instantiationService.setService(xn,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(fc)),this._instantiationService.setService(wn,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Sc)),this._instantiationService.setService(Nn,this.unicodeService),this._charsetService=this._instantiationService.createInstance(bc),this._instantiationService.setService(yn,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Yc),this._instantiationService.setService(Mn,this._oscLinkService),this._inputHandler=this._register(new Kc(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(no.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(no.forward(this._bufferService.onResize,this._onResize)),this._register(no.forward(this.coreService.onData,this._onData)),this._register(no.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 Vc((e,t)=>this._inputHandler.parse(e,t))),this._register(no.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new bo),this._onScroll.event(e=>{var t;null==(t=this._onScrollApi)||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&&!Gc&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Gc=!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,2),t=Math.max(t,1),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;0!==t&&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&&void 0!==t.buildNumber&&void 0!==t.buildNumber?e="conpty"===t.backend&&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(wc.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(wc(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Zn(()=>{for(let t of e)t.dispose()})}}},Jc={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:["'",'"']};var Zc=0,Qc=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new _h,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new _h,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(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let t=this._getKey(e);if(void 0===t||-1===(Zc=this._search(t))||this._getKey(this._array[Zc])!==t)return!1;do{if(this._array[Zc]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Zc),!0}while(++Zc<this._array.length&&this._getKey(this._array[Zc])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&(!((Zc=this._search(e))<0||Zc>=this._array.length)&&this._getKey(this._array[Zc])===e))do{yield this._array[Zc]}while(++Zc<this._array.length&&this._getKey(this._array[Zc])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&(!((Zc=this._search(e))<0||Zc>=this._array.length)&&this._getKey(this._array[Zc])===e))do{t(this._array[Zc])}while(++Zc<this._array.length&&this._getKey(this._array[Zc])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else{if(!(r<e)){for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}t=s+1}}return t}},ed=0,td=0,id=class extends to{constructor(){super(),this._decorations=new Qc(e=>null==e?void 0:e.marker.line),this._onDecorationRegistered=this._register(new bo),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new bo),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Zn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new sd(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,t=>{ed=t.options.x??0,td=ed+(t.options.width??1),e>=ed&&e<td&&(!i||(t.options.layer??"bottom")===i)&&s(t)})}},sd=class extends eo{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new bo),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new bo),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 null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=vl.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=vl.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},rd=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=s-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)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)}},nd=class extends to{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new rd(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(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar("\n"))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ea(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Zn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=sn())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let e=i.lines.get(i.ydisp+r),t=[],n=(null==e?void 0:e.translateToString(!0,void 0,void 0,t))||"",o=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(0===n.length?(a.textContent=" ",this._rowColumns.set(a,[0,1])):(a.textContent=n,this._rowColumns.set(a,t)),a.setAttribute("aria-posinset",o),a.setAttribute("aria-setsize",s),this._alignRowWidth(a))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i,s,r=e.target,n=this._rowElements[0===t?1:this._rowElements.length-2];if(r.getAttribute("aria-posinset")!==(0===t?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===n){if(0===t?(i=r,s=this._rowElements.pop(),this._rowContainer.removeChild(s)):(i=this._rowElements.shift(),s=r,this._rowContainer.removeChild(i)),i.removeEventListener("focus",this._topBoundaryFocusListener),s.removeEventListener("focus",this._bottomBoundaryFocusListener),0===t){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===t?-1:1),this._rowElements[0===t?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){var e;if(0===this._rowElements.length)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed)return void(this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection());if(!t.anchorNode||!t.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:(null==(e=r.textContent)?void 0:e.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:t})=>{let i=e instanceof Text?e.parentNode:e,s=parseInt(null==i?void 0:i.getAttribute("aria-posinset"),10)-1;if(isNaN(s))return console.warn("row is invalid. Race condition?"),null;let r=this._rowColumns.get(i);if(!r)return console.warn("columns is null. Race condition?"),null;let n=t<r.length?r[t]:r.slice(-1)[0]+1;return n>=this._terminal.cols&&(++s,n=0),{row:s,column:n}},o=n(i),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 t,i;e.style.transform="";let s=e.getBoundingClientRect().width,r=null==(i=null==(t=this._rowColumns.get(e))?void 0:t.slice(-1))?void 0:i[0];if(!r)return;let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/s})`}};nd=Xr([Jr(1,Cn),Jr(2,Bn),Jr(3,jn)],nd);var od=class extends to{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new bo),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new bo),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Zn(()=>{var e;Jn(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,null==(e=this._activeProviderReplies)||e.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ea(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ea(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ea(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ea(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let e=i[s];if(e.classList.contains("xterm"))break;if(e.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)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,s;(!this._activeProviderReplies||!t)&&(null==(i=this._activeProviderReplies)||i.forEach(e=>{null==e||e.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(null==(s=this._activeProviderReplies)?void 0:s.get(n))&&(r=this._checkLinkProviderResult(n,e,r)):o.provideLinks(e.y,t=>{var i,s;if(this._isMouseOut)return;let o=null==t?void 0:t.map(e=>({link:e}));null==(i=this._activeProviderReplies)||i.set(n,o),r=this._checkLinkProviderResult(n,e,r),(null==(s=this._activeProviderReplies)?void 0:s.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let t=0;t<r.length;t++){let s=r[t],n=s.link.range.start.y<e?0:s.link.range.start.x,o=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let e=n;e<=o;e++){if(i.has(e)){r.splice(t--,1);break}i.add(e)}}}}_checkLinkProviderResult(e,t,i){var s;if(!this._activeProviderReplies)return i;let r=this._activeProviderReplies.get(e),n=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(n=!0);if(!n&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(i=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let e=null==(s=this._activeProviderReplies.get(o))?void 0:s.find(e=>this._linkAtPosition(e.link,t));if(e){i=!0,this._handleNewLink(e);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);var i,s;t&&this._mouseDownLink&&(i=this._mouseDownLink.link,s=this._currentLink.link,i.text===s.text&&i.range.start.x===s.range.start.x&&i.range.start.y===s.range.start.y&&i.range.end.x===s.range.end.x&&i.range.end.y===s.range.end.y)&&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,Jn(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:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||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 e,t;return null==(t=null==(e=this._currentLink)?void 0:e.state)?void 0:t.decorations.pointerCursor},set:e=>{var t;(null==(t=this._currentLink)?void 0:t.state)&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>{var e,t;return null==(t=null==(e=this._currentLink)?void 0:e.state)?void 0:t.decorations.underline},set:t=>{var i,s,r;(null==(i=this._currentLink)?void 0:i.state)&&(null==(r=null==(s=this._currentLink)?void 0:s.state)?void 0:r.decorations.underline)!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(t,i),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,i){var s;(null==(s=this._currentLink)?void 0:s.state)&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(null==(s=this._currentLink)?void 0:s.state)&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};od=Xr([Jr(1,Tn),Jr(2,jn),Jr(3,bn),Jr(4,zn)],od);var ad=class extends Xc{constructor(e={}){super(e),this._linkifier=this._register(new io),this.browser=Zl,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new io),this._onCursorMove=this._register(new bo),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new bo),this.onKey=this._onKey.event,this._onRender=this._register(new bo),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new bo),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new bo),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new bo),this.onBell=this._onBell.event,this._onFocus=this._register(new bo),this._onBlur=this._register(new bo),this._onA11yCharEmitter=this._register(new bo),this._onA11yTabEmitter=this._register(new bo),this._onWillOpen=this._register(new bo),this._setup(),this._decorationService=this._instantiationService.createInstance(id),this._instantiationService.setService(Dn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Yl),this._instantiationService.setService(zn,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Rn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh((null==e?void 0:e.start)??0,(null==e?void 0:e.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(no.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(no.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(no.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(no.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Zn(()=>{var e,t;this._customKeyEventHandler=void 0,null==(t=null==(e=this.element)?void 0:e.parentNode)||t.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 e,i="";switch(t.index){case 256:e="foreground",i="10";break;case 257:e="background",i="11";break;case 258:e="cursor",i="12";break;default:e="ansi",i="4;"+t.index}switch(t.type){case 0:let s=gl.toColorRGB("ansi"===e?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${nl.ESC}]${i};${zc(s)}${hl.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[t.index]=ml.toColor(...t.color));else{let i=e;this._themeService.modifyColors(e=>e[i]=ml.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_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(nd,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(nl.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return null==(e=this.textarea)?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(nl.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ea(this.element,"copy",e=>{var t,i;this.hasSelection()&&(t=e,i=this._selectionService,t.clipboardData&&t.clipboardData.setData("text/plain",i.selectionText),t.preventDefault())}));let e=e=>function(e,t,i,s){e.stopPropagation(),e.clipboardData&&nn(e.clipboardData.getData("text/plain"),t,i,s)}(e,this.textarea,this.coreService,this.optionsService);this._register(Ea(this.textarea,"paste",e)),this._register(Ea(this.element,"paste",e)),ih?this._register(Ea(this.element,"mousedown",e=>{2===e.button&&an(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ea(this.element,"contextmenu",e=>{an(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ch&&this._register(Ea(this.element,"auxclick",e=>{1===e.button&&on(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ea(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ea(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ea(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ea(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ea(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ea(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ea(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var t;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"),(null==(t=this.element)?void 0:t.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));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 i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ea(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Qr()),dh||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(ql,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Bn,this._coreBrowserService),this._register(Ea(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(Ea(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Fl,this._document,this._helperContainer),this._instantiationService.setService(Pn,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ah),this._instantiationService.setService(In,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Dl),this._instantiationService.setService(An,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ph,this.rows,this.screenElement)),this._instantiationService.setService(jn,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(pl,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Xl),this._instantiationService.setService(Tn,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(od,this.screenElement));this.element.appendChild(i);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(sl,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Mh,this.element,this.screenElement,r)),this._instantiationService.setService(On,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(no.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var e;this._selectionService.refresh(),null==(e=this._viewport)||e.queueSync()})),this._register(this._instantiationService.createInstance(rl,this.screenElement)),this._register(Ea(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),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(nd,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Hl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(t){var i,s,r,n,o;let a,l,h=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!h)return!1;switch(t.overrideType||t.type){case"mousemove":l=32,void 0===t.buttons?(a=3,void 0!==t.button&&(a=t.button<3?t.button:3)):a=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case"mouseup":l=0,a=t.button<3?t.button:3;break;case"mousedown":l=1,a=t.button<3?t.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t))return!1;let h=t.deltaY;if(0===h||0===e.coreMouseService.consumeWheelEvent(t,null==(n=null==(r=null==(s=null==(i=e._renderService)?void 0:i.dimensions)?void 0:s.device)?void 0:r.cell)?void 0:n.height,null==(o=e._coreBrowserService)?void 0:o.dpr))return!1;l=h<0?0:1,a=4;break;default:return!1}return!(void 0===l||void 0===a||a>4)&&e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:a,action:l,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:e=>(i(e),e.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(e)),wheel:e=>(i(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&i(e)},mousemove:e=>{e.buttons||i(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),16&e?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),2&e?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),4&e?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ea(t,"mousedown",e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return i(e),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(e)})),this._register(Ea(t,"wheel",t=>{var i,r,n,o,a;if(!s.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(t))return!1;if(!this.buffer.hasScrollback){if(0===t.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(t,null==(o=null==(n=null==(r=null==(i=e._renderService)?void 0:i.dimensions)?void 0:r.device)?void 0:n.cell)?void 0:o.height,null==(a=e._coreBrowserService)?void 0:a.dpr))return this.cancel(t,!0);let s=nl.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){var i;null==(i=this._renderService)||i.refreshRows(e,t)}updateCursorStyle(e){var t;(null==(t=this._selectionService)?void 0: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;0!==t&&this.scrollLines(t)}paste(e){nn(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}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;null==(e=this._selectionService)||e.clearSelection()}selectAll(){var e;null==(e=this._selectionService)||e.selectAll()}selectLines(e,t){var i;null==(i=this._selectionService)||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))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&&("Dead"===e.key||"AltGraph"===e.key)&&(this._unprocessedDeadKey=!0);let i=function(e,t,i,s){var r;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:"UIKeyInputUpArrow"===e.key?n.key=t?nl.ESC+"OA":nl.ESC+"[A":"UIKeyInputLeftArrow"===e.key?n.key=t?nl.ESC+"OD":nl.ESC+"[D":"UIKeyInputRightArrow"===e.key?n.key=t?nl.ESC+"OC":nl.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(n.key=t?nl.ESC+"OB":nl.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":nl.DEL,e.altKey&&(n.key=nl.ESC+n.key);break;case 9:if(e.shiftKey){n.key=nl.ESC+"[Z";break}n.key=nl.HT,n.cancel=!0;break;case 13:n.key=e.altKey?nl.ESC+nl.CR:nl.CR,n.cancel=!0;break;case 27:n.key=nl.ESC,e.altKey&&(n.key=nl.ESC+nl.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;n.key=o?nl.ESC+"[1;"+(o+1)+"D":t?nl.ESC+"OD":nl.ESC+"[D";break;case 39:if(e.metaKey)break;n.key=o?nl.ESC+"[1;"+(o+1)+"C":t?nl.ESC+"OC":nl.ESC+"[C";break;case 38:if(e.metaKey)break;n.key=o?nl.ESC+"[1;"+(o+1)+"A":t?nl.ESC+"OA":nl.ESC+"[A";break;case 40:if(e.metaKey)break;n.key=o?nl.ESC+"[1;"+(o+1)+"B":t?nl.ESC+"OB":nl.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=nl.ESC+"[2~");break;case 46:n.key=o?nl.ESC+"[3;"+(o+1)+"~":nl.ESC+"[3~";break;case 36:n.key=o?nl.ESC+"[1;"+(o+1)+"H":t?nl.ESC+"OH":nl.ESC+"[H";break;case 35:n.key=o?nl.ESC+"[1;"+(o+1)+"F":t?nl.ESC+"OF":nl.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=nl.ESC+"[5;"+(o+1)+"~":n.key=nl.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=nl.ESC+"[6;"+(o+1)+"~":n.key=nl.ESC+"[6~";break;case 112:n.key=o?nl.ESC+"[1;"+(o+1)+"P":nl.ESC+"OP";break;case 113:n.key=o?nl.ESC+"[1;"+(o+1)+"Q":nl.ESC+"OQ";break;case 114:n.key=o?nl.ESC+"[1;"+(o+1)+"R":nl.ESC+"OR";break;case 115:n.key=o?nl.ESC+"[1;"+(o+1)+"S":nl.ESC+"OS";break;case 116:n.key=o?nl.ESC+"[15;"+(o+1)+"~":nl.ESC+"[15~";break;case 117:n.key=o?nl.ESC+"[17;"+(o+1)+"~":nl.ESC+"[17~";break;case 118:n.key=o?nl.ESC+"[18;"+(o+1)+"~":nl.ESC+"[18~";break;case 119:n.key=o?nl.ESC+"[19;"+(o+1)+"~":nl.ESC+"[19~";break;case 120:n.key=o?nl.ESC+"[20;"+(o+1)+"~":nl.ESC+"[20~";break;case 121:n.key=o?nl.ESC+"[21;"+(o+1)+"~":nl.ESC+"[21~";break;case 122:n.key=o?nl.ESC+"[23;"+(o+1)+"~":nl.ESC+"[23~";break;case 123:n.key=o?nl.ESC+"[24;"+(o+1)+"~":nl.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if(i&&!s||!e.altKey||e.metaKey)!i||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&1===e.key.length?n.key=e.key:e.key&&e.ctrlKey&&("_"===e.key&&(n.key=nl.US),"@"===e.key&&(n.key=nl.NUL)):65===e.keyCode&&(n.type=1);else{let t=null==(r=Jc[e.keyCode])?void 0:r[e.shiftKey?1:0];if(t)n.key=nl.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,i=String.fromCharCode(t);e.shiftKey&&(i=i.toUpperCase()),n.key=nl.ESC+i}else if(32===e.keyCode)n.key=nl.ESC+(e.ctrlKey?nl.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),n.key=nl.ESC+t,n.cancel=!0}}else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=nl.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=nl.DEL:219===e.keyCode?n.key=nl.ESC:220===e.keyCode?n.key=nl.FS:221===e.keyCode&&(n.key=nl.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===i.type||2===i.type){let t=this.rows-1;return this.scrollLines(2===i.type?-t:t),this.cancel(e,!0)}return 1===i.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((i.key===nl.ETX||i.key===nl.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0)))}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return"keypress"===t.type?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){var t;this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(e))&&(16===(t=e).keyCode||17===t.keyCode||18===t.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null===e.which||void 0===e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e))&&(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&&"insertText"===e.inputType&&(!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){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){var i;null==(i=this._charSizeService)||i.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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(Kh));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var e;this.options.rows=this.rows,this.options.cols=this.cols;let t=this._customKeyEventHandler;this._setup(),super.reset(),null==(e=this._selectionService)||e.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;null==(e=this._renderService)||e.clearTextureAtlas()}_reportFocus(){var e;(null==(e=this.element)?void 0:e.classList.contains("focus"))?this.coreService.triggerDataEvent(nl.ESC+"[I"):this.coreService.triggerDataEvent(nl.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${nl.ESC}[4;${t};${e}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${nl.ESC}[6;${s};${i}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};var ld=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(-1===t)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)}},hd=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 pn)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},cd=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 hd(t)}getNullCell(){return new pn}},dd=class extends to{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new bo),this.onBufferChange=this._onBufferChange.event,this._normal=new cd(this._core.buffers.normal,"normal"),this._alternate=new cd(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)}},ud=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,i)=>t(e,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)}},_d=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}},fd=["cols","rows"],pd=0,md=class extends to{constructor(e){super(),this._core=this._register(new ad(e)),this._addonManager=this._register(new ld),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],i=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let s in this._core.options){let e={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,e)}}_checkReadonlyOptions(e){if(fd.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 ud(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _d(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 dd(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"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write("\r\n",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 Qr()},set promptLabel(e){en(e)},get tooMuchOutput(){return sn()},set tooMuchOutput(e){rn(e)}}}_verifyIntegers(...e){for(pd of e)if(pd===1/0||isNaN(pd)||pd%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(pd of e)if(pd&&(pd===1/0||isNaN(pd)||pd%1!=0||pd<0))throw new Error("This API only accepts positive integers")}},gd=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 e;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(0===t.css.cell.width||0===t.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:(null==(e=this._terminal.options.overviewRuler)?void 0:e.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a=r-(parseInt(o.getPropertyValue("padding-top"))+parseInt(o.getPropertyValue("padding-bottom"))),l=n-(parseInt(o.getPropertyValue("padding-right"))+parseInt(o.getPropertyValue("padding-left")))-i;return{cols:Math.max(2,Math.floor(l/t.css.cell.width)),rows:Math.max(1,Math.floor(a/t.css.cell.height))}}},vd=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?kd.isErrorNoTelemetry(e)?new kd(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+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)}};function Sd(e){(function(e){return e instanceof Cd||e instanceof Error&&e.name===bd&&e.message===bd})(e)||vd.onUnexpectedError(e)}var bd="Canceled";var wd,xd,yd,Cd=class extends Error{constructor(){super(bd),this.name=this.message}},kd=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function Ed(e,t){let i,s=this,r=!1;return function(){return r||(r=!0,t||(i=e.apply(s,arguments))),i}}function Md(e){if(yd.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(Oa){t.push(Oa)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Nd(...e){return Dd(()=>Md(e))}function Dd(e){return{dispose:Ed(()=>{e()})}}(xd=wd||(wd={})).isLessThan=function(e){return e<0},xd.isLessThanOrEqual=function(e){return e<=0},xd.isGreaterThan=function(e){return e>0},xd.isNeitherLessOrGreaterThan=function(e){return 0===e},xd.greaterThan=1,xd.lessThan=-1,xd.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*s(e){yield e}e.empty=function(){return i},e.single=s,e.wrap=function(e){return t(e)?e:s(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let s of e)if(t(s,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let s of e)yield t(s,i++)},e.flatMap=function*(e,t){let i=0;for(let s of e)yield*t(s,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let s=i;for(let r of e)s=t(s,r);return s},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let s=[];if(0===i)return[s,t];let r=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=r.next();if(t.done)return[s,e.empty()];s.push(t.value)}return[s,{[Symbol.iterator]:()=>r}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(yd||(yd={}));var Rd=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Md(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?e.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(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};Rd.DISABLE_DISPOSED_WARNING=!1;var Ld=Rd,Pd=class{constructor(){this._store=new Ld,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)}};Pd.None=Object.freeze({dispose(){}});var Bd,Td=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},jd=globalThis.performance&&"function"==typeof globalThis.performance.now,Od=class e{static create(t){return new e(t)}constructor(e){this._now=jd&&!1===e?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-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,s)=>{let r,n=!1;return r=e(e=>{if(!n)return r?r.dispose():n=!0,t.call(i,e)},null,s),n&&r.dispose(),r}}function i(e,t,i){return r((i,s=null,r)=>e(e=>i.call(s,t(e)),null,r),i)}function s(e,t,i){return r((i,s=null,r)=>e(e=>t(e)&&i.call(s,e),null,r),i)}function r(e,t){let i,s=new Vd({onWillAddFirstListener(){i=e(s.fire,s)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(s),s.event}function n(e,t,i=100,s=!1,r=!1,n,o){let a,l,h,c,d=0,u=new Vd({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{d++,l=t(l,e),s&&!h&&(u.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!s||d>1)&&u.fire(e),d=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){r&&d>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(u),u.event}e.None=()=>Pd.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return r((i,s=null,r)=>e(e=>{t(e),i.call(s,e)},null,r),i)},e.filter=s,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,s)=>{let r=Nd(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(r,s)}},e.reduce=function(e,t,s,r){let n=s;return i(e,e=>(n=t(n,e),n),r)},e.debounce=n,e.accumulate=function(t,i=0,s){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,s)},e.latch=function(e,t=(e,t)=>e===t,i){let r,n=!0;return s(e,e=>{let i=n||!t(e,r);return n=!1,r=e,i},i)},e.split=function(t,i,s){return[e.filter(t,i,s),e.filter(t,e=>!i(e),s)]},e.buffer=function(e,t=!1,i=[],s){let r=i.slice(),n=e(e=>{r?r.push(e):a.fire(e)});s&&s.add(n);let o=()=>{null==r||r.forEach(e=>a.fire(e)),r=null},a=new Vd({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),s&&s.add(n))},onDidAddFirstListener(){r&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return s&&s.add(a),a.event},e.chain=function(e,t){return(i,s,r)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(s,t)},void 0,r)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(s=>{let r=i||!e(s,t);return i=!1,t=s,r?s:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new Vd({onWillAddFirstListener:()=>e.on(t,s),onDidRemoveLastListener:()=>e.removeListener(t,s)});return r.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let s=(...e)=>r.fire(i(...e)),r=new Vd({onWillAddFirstListener:()=>e.addEventListener(t,s),onDidRemoveLastListener:()=>e.removeEventListener(t,s)});return r.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Vd;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Vd(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,s)=>{let r=0,n=!1,o={beginUpdate(){r++},endUpdate(){r--,0===r&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return s instanceof Ld?s.add(a):Array.isArray(s)&&s.push(a),a}}})(Bd||(Bd={}));var Ad=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Od,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Ad.all=new Set,Ad._idPool=0;var Id=Ad,zd=class e{constructor(t,i,s=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,s]=this.getMostFrequentStack(),r=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${s}):`;console.warn(r),console.warn(e);let n=new $d(r,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,s]of this._stacks)(!e||t<s)&&(e=[i,s],t=s);return e}};zd._idPool=1;var Wd,Hd=zd,Fd=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},$d=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Kd=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Ud=0,qd=class{constructor(e){this.value=e,this.id=Ud++}},Vd=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new Hd((null==e?void 0:e.onListenerError)??Sd,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(s=this._options)?void 0:s._profName)?new Id(this._options._profName):void 0,this._deliveryQueue=null==(r=this._options)?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(s=this._leakageMon)||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var s,r,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new Kd(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(s=this._options)?void 0:s.onListenerError)||Sd)(i),Pd.None}if(this._disposed)return Pd.None;t&&(e=e.bind(t));let l,h=new qd(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Fd.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof qd?(this._deliveryQueue??(this._deliveryQueue=new Yd),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(r=this._options)?void 0:r.onWillAddFirstListener)||n.call(r,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=Dd(()=>{null==l||l(),this._removeListener(h)});return i instanceof Ld?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,s,r;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(r=null==(s=this._options)?void 0:s.onDidRemoveLastListener)||r.call(s,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)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--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let s=(null==(i=this._options)?void 0:i.onListenerError)||Sd;if(s)try{e.value(t)}catch(Ho){s(Ho)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(s=this._perfMon)||s.start(this._size),this._listeners)if(this._listeners instanceof qd)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(r=this._perfMon)||r.stop()}hasListeners(){return this._size>0}},Yd=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gd=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Zd||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Bd.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gd})})(Wd||(Wd={}));var Xd,Jd,Zd=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?Gd:(this._emitter||(this._emitter=new Vd),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Qd="en",eu=Qd,tu=globalThis;typeof tu.vscode<"u"&&typeof tu.vscode.process<"u"?Jd=tu.vscode.process:typeof process<"u"&&"string"==typeof(null==(s=null==process?void 0:process.versions)?void 0:s.node)&&(Jd=process);var iu="string"==typeof(null==(r=null==Jd?void 0:Jd.versions)?void 0:r.electron)&&"renderer"===(null==Jd?void 0:Jd.type);if("object"==typeof Jd){Jd.platform,Jd.platform,"linux"===Jd.platform&&!!Jd.env.SNAP&&Jd.env.SNAP_REVISION,!!Jd.env.CI||Jd.env.BUILD_ARTIFACTSTAGINGDIRECTORY,eu=Qd;let e=Jd.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,eu=t.resolvedLanguage||Qd,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||iu?console.error("Unable to resolve platform."):((Xd=navigator.userAgent).indexOf("Windows"),Xd.indexOf("Macintosh"),(Xd.indexOf("Macintosh")>=0||Xd.indexOf("iPad")>=0||Xd.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Xd.indexOf("Linux")>=0,null==Xd||Xd.indexOf("Mobi"),eu=globalThis._VSCODE_NLS_LANGUAGE||Qd,navigator.language.toLowerCase());var su,ru=Xd,nu=eu;(e=>{e.value=function(){return nu},e.isDefaultVariant=function(){return 2===nu.length?"en"===nu:nu.length>=3&&("e"===nu[0]&&"n"===nu[1]&&"-"===nu[2])},e.isDefault=function(){return"en"===nu}})(su||(su={}));var ou="function"==typeof tu.postMessage&&!tu.importScripts;(()=>{if(ou){let e=[];tu.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let s=e[i];if(s.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void s.callback()}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),tu.postMessage({vscodeScheduleAsyncWork:s},"*")}}})();var au,lu,hu=!!(ru&&ru.indexOf("Chrome")>=0);function cu(e,t=0,i){let s=setTimeout(()=>{e()},t);return Dd(()=>{clearTimeout(s)})}ru&&ru.indexOf("Firefox"),!hu&&ru&&ru.indexOf("Safari"),ru&&ru.indexOf("Edg/"),ru&&ru.indexOf("Android"),(lu=au||(au={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},lu.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(s){i(s)}})};var du=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Vd,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(Ho){this.reject(Ho)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await Bd.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let s of t)e.emitOne(i(s))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let s of t)i(s)&&e.emitOne(s)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};du.EMPTY=du.fromArray([]);var uu=class extends Pd{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Td),this._linesCacheDisposables=this._register(new Td),this._register(Dd(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Nd(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=cu(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let s=[],r=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(s.push(l),!a)break;r.push(r[r.length-1]+l.length),e++,n=o}return[s.join(""),r]}},_u=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},fu=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:r,startCol:n};if(s&&(l.startRow=r=s.start.y,l.startCol=n=s.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=r=s.end.y,l.startCol=n=s.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=r-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(l.startRow=h,a=this._findInLine(e,l,t,o),!a);h--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){var r;let n=t.startRow,o=t.startCol;if(null==(r=this._terminal.buffer.active.getLine(n))?void 0:r.isWrapped)return s?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,h]=a,c=this._bufferColsToStringOffset(n,o),d=e,u=l;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),u=i.caseSensitive?l:l.toLowerCase());let _=-1;if(i.regex){let t,r=RegExp(d,i.caseSensitive?"g":"gi");if(s)for(;t=r.exec(u.slice(0,c));)_=r.lastIndex-t[0].length,e=t[0],r.lastIndex-=e.length-1;else t=r.exec(u.slice(c)),t&&t[0].length>0&&(_=c+(r.lastIndex-t[0].length),e=t[0])}else s?c-d.length>=0&&(_=u.lastIndexOf(d,c-d.length)):_=u.indexOf(d,c);if(_>=0){if(i.wholeWord&&!this._isWholeWord(_,u,e))return;let t=0;for(;t<h.length-1&&_>=h[t+1];)t++;let s=t;for(;s<h.length-1&&_+e.length>=h[s+1];)s++;let r=_-h[t],o=_+e.length-h[s],a=this._stringLengthToBufferSize(n+t,r);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+s,o)-a+this._terminal.cols*(s-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let e=i.getCell(s);if(!e)break;let r=e.getChars();r.length>1&&(t-=r.length-1);let n=i.getCell(s+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=r.getCell(e);if(!t)break;t.getWidth()&&(s+=0===t.getCode()?1:t.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},pu=class extends Pd{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Dd(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){Md(i)}}}clearHighlightDecorations(){Md(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],r=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-r,n);s.push([o,r,e]),r=0,n-=e,o++}let a=[];for(let l of s){let e=this._terminal.registerMarker(l[0]),s=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(s){let r=[];r.push(e),r.push(s.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),r.push(s.onDispose(()=>Md(r))),a.push(s)}}return 0===a.length?void 0:a}},mu=class extends Pd{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Vd)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},gu=class extends Pd{constructor(e){super(),this._highlightTimeout=this._register(new Td),this._lineCache=this._register(new Td),this._state=new _u,this._resultTracker=this._register(new mu),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new uu(e),this._engine=new fu(e,this._lineCache.value),this._decorationManager=new pu(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Dd(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=cu(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,s=[],r=this._engine.find(e,0,0,t);for(;r&&((null==i?void 0:i.row)!==r.row||(null==i?void 0:i.col)!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(s,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(s,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}};const vu={background:"#09090b",foreground:"#e4e4e7",cursor:"#a1a1aa",cursorAccent:"#09090b",selectionBackground:"#3f3f46",black:"#18181b",brightBlack:"#3f3f46",red:"#ef4444",brightRed:"#f87171",green:"#22c55e",brightGreen:"#4ade80",yellow:"#eab308",brightYellow:"#facc15",blue:"#3b82f6",brightBlue:"#60a5fa",magenta:"#a855f7",brightMagenta:"#c084fc",cyan:"#06b6d4",brightCyan:"#22d3ee",white:"#e4e4e7",brightWhite:"#f4f4f5"},Su={background:"#ffffff",foreground:"#1c1c1c",cursor:"#6b7280",cursorAccent:"#ffffff",selectionBackground:"#d1d5db",black:"#1c1c1c",brightBlack:"#6b7280",red:"#dc2626",brightRed:"#ef4444",green:"#16a34a",brightGreen:"#22c55e",yellow:"#ca8a04",brightYellow:"#eab308",blue:"#2563eb",brightBlue:"#3b82f6",magenta:"#9333ea",brightMagenta:"#a855f7",cyan:"#0891b2",brightCyan:"#06b6d4",white:"#e5e7eb",brightWhite:"#f9fafb"},bu=l.forwardRef(({onInput:e,onResize:t,onReady:i,cliTool:s="claude"},r)=>{const n=l.useRef(null),o=l.useRef(null),a=l.useRef(null),c=l.useRef(null),d=l.useRef(e),u=l.useRef(t),_=l.useRef(i),p=l.useRef(!1),m=l.useRef(null);d.current=e,u.current=t,_.current=i;const{resolved:g}=h();return l.useImperativeHandle(r,()=>({write:e=>{var t;null==(t=o.current)||t.write(e)},reset:()=>{const e=o.current;e&&(e.reset(),e.clear())},search:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findNext(e,t))??!1},searchNext:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findNext(e,t))??!1},searchPrevious:(e,t)=>{var i;return(null==(i=c.current)?void 0:i.findPrevious(e,t))??!1},clearSearch:()=>{var e;null==(e=c.current)||e.clearDecorations()}})),l.useEffect(()=>{if(!n.current)return;const e=new md({theme:"dark"===g?vu:Su,fontFamily:'"JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace',fontSize:13,lineHeight:1.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0}),t=new gd;e.loadAddon(t);const i=new gu;e.loadAddon(i),c.current=i,e.open(n.current),requestAnimationFrame(()=>{var i;t.fit();const{cols:s,rows:r}=e;p.current||(p.current=!0,null==(i=_.current)||i.call(_,s,r)),u.current(s,r)}),o.current=e,a.current=t,m.current=g,e.onData(e=>{d.current(e)});const s=new ResizeObserver(()=>{requestAnimationFrame(()=>{n.current&&null!==n.current.offsetParent&&(t.fit(),u.current(e.cols,e.rows))})});return s.observe(n.current),()=>{s.disconnect(),e.dispose(),o.current=null,a.current=null,c.current=null}},[]),l.useEffect(()=>{const e=o.current;if(e&&m.current!==g)if(m.current=g,e.options.theme="dark"===g?vu:Su,"claude"===s){const e="dark"===g?"dark":"light";d.current(`/theme ${e}\r`)}else if("gemini"===s){const e="dark"===g?"dark":"light";d.current(`/settings theme ${e}\r`)}else if("codex"===s){const e="dark"===g?"dark":"light";d.current(`/theme ${e}\r`)}},[g,s]),f.jsx("div",{ref:n,className:"h-full w-full bg-background",style:{overflow:"hidden",padding:"4px"}})});function wu({onSearch:e,onSearchNext:t,onSearchPrev:i,onClear:s,onClose:r}){const[n,o]=l.useState(""),[a,h]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{var e;null==(e=u.current)||e.focus()},[]);const _=l.useMemo(()=>({caseSensitive:a,regex:c}),[a,c]);return f.jsxs("div",{className:"absolute top-2 right-2 z-20 flex items-center gap-1 bg-background border border-border rounded-md shadow-sm px-2 py-1",children:[f.jsx($t,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),f.jsx(K,{ref:u,value:n,onChange:t=>{return i=t.target.value,o(i),void(i?e(i,_):s());var i},onKeyDown:e=>{if("Enter"===e.key){if(!n)return;e.shiftKey?i(n,_):t(n,_)}"Escape"===e.key&&(s(),r())},placeholder:"搜索...",className:"h-6 w-44 text-xs border-0 p-0 focus-visible:ring-0 bg-transparent"}),f.jsx("button",{title:"区分大小写",onClick:()=>{const t=!a;h(t),n&&e(n,{..._,caseSensitive:t})},className:p("text-[10px] px-1 rounded font-mono transition-colors",a?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground"),children:"Aa"}),f.jsx("button",{title:"正则表达式",onClick:()=>{const t=!c;d(t),n&&e(n,{..._,regex:t})},className:p("text-[10px] px-1 rounded font-mono transition-colors",c?"bg-accent text-foreground font-medium":"text-muted-foreground hover:text-foreground"),children:".*"}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{n&&i(n,_)},disabled:!n,children:f.jsx(Ft,{className:"h-3 w-3"})}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{n&&t(n,_)},disabled:!n,children:f.jsx(Wt,{className:"h-3 w-3"})}),f.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{s(),r()},children:f.jsx(b,{className:"h-3 w-3"})})]})}bu.displayName="WebTerminal";const xu=l.forwardRef(({projectId:e,project:t,onStatusChange:i,onChatMessage:s,onWsConnected:r,onWsDisconnected:n,onApprovalRequest:o,onApprovalResolved:a,onSemanticUpdate:h},c)=>{const d=l.useRef([]),[u,_]=l.useState(!1),[p,m]=l.useState(null),g=l.useRef(null),v=l.useRef(null),S=l.useRef(null),b=l.useRef(null),w=l.useCallback(e=>{var t;null==(t=g.current)||t.write(e)},[]),x=l.useCallback(()=>{var e;const t=v.current;t&&S.current&&S.current(t.cols,t.rows),null==(e=b.current)||e.call(b)},[]),y=l.useCallback(()=>{var e;null==(e=g.current)||e.reset()},[]),{subscribeTerminal:C,sendTerminalInput:k,sendTerminalResize:E,subscribeChatMessages:M}=ot(e,{onTerminalData:w,onTerminalReset:y,onStatus:i,onConnected:()=>{d.current=[],null==r||r(),x()},onDisconnected:()=>{null==n||n()},onChatMessage:e=>{d.current.push(e),null==s||s(e)},onApprovalRequest:e=>null==o?void 0:o(e),onApprovalResolved:e=>null==a?void 0:a(e),onContextUpdate:e=>m(e),onSemanticUpdate:e=>null==h?void 0:h(e)});l.useEffect(()=>{S.current=C},[C]),l.useEffect(()=>{b.current=M},[M]),l.useEffect(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key&&(e.preventDefault(),_(e=>!e))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);const N=l.useCallback((e,t)=>{v.current={cols:e,rows:t},x()},[x]);return l.useImperativeHandle(c,()=>({sendTerminalInput:k}),[k]),f.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex flex-col",children:[f.jsxs("div",{className:"relative flex-1 min-h-0",children:[f.jsx(bu,{ref:g,onInput:k,onResize:(e,t)=>{v.current={cols:e,rows:t},E(e,t)},onReady:N,cliTool:null==t?void 0:t.cliTool}),u&&f.jsx(wu,{onSearch:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.search(e,t))??!1},onSearchNext:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.searchNext(e,t))??!1},onSearchPrev:(e,t)=>{var i;return(null==(i=g.current)?void 0:i.searchPrevious(e,t))??!1},onClear:()=>{var e;return null==(e=g.current)?void 0:e.clearSearch()},onClose:()=>_(!1)})]}),f.jsxs("div",{className:"flex-shrink-0 flex items-center px-3 h-7 border-t border-border bg-muted/30 gap-3",children:[f.jsx(at,{}),p&&f.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[f.jsx("span",{className:"text-muted-foreground",children:"上下文"}),f.jsx("div",{className:"w-20 h-1.5 bg-muted rounded-full overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all "+(p.usedPercentage<50?"bg-green-500":p.usedPercentage<80?"bg-yellow-500":"bg-red-500"),style:{width:`${Math.min(p.usedPercentage,100)}%`}})}),f.jsxs("span",{className:"font-medium "+(p.usedPercentage<50?"text-green-500":p.usedPercentage<80?"text-yellow-500":"text-red-500"),children:[Math.round(p.usedPercentage),"%"]}),f.jsx("span",{className:"text-muted-foreground/50",children:p.contextWindowSize>=1e6?`${(p.contextWindowSize/1e6).toFixed(0)}M`:`${Math.round(p.contextWindowSize/1e3)}K`})]})]})]})});xu.displayName="TerminalView";const yu=200,Cu=520;const ku=Object.freeze(Object.defineProperty({__proto__:null,ProjectPage:function(){const{id:e}=lt(),t=Ve(),[i,s]=l.useState(null),[r,n]=l.useState(!0),[o,a]=Q(y.panelFileTree,"true"),[h,c]=Q(y.panelShortcuts,"true"),[d,u]=Q(y.chatOverlay(e??""),"true"),_=l.useCallback(()=>u(e=>"true"===e?"false":"true"),[u]),[m,g]=l.useState([]),[v,S]=l.useState(!1),[b,w]=l.useState([]),x=l.useRef(0),C=l.useCallback(e=>{x.current+=1;const t={...e,seq:x.current};w(e=>{const i=[...e,t];return i.length>500?i.slice(-500):i})},[]),[k,E]=l.useState(null),M=l.useCallback(e=>C(e),[C]),N=l.useCallback(e=>C(e),[C]),D=l.useCallback(e=>{g(t=>{const i=[...t,e];return i.length>200?i.slice(-200):i})},[]),R=l.useCallback(()=>{g([]),E(null),S(!0)},[]),L=l.useCallback(()=>{S(!1)},[]),B=l.useCallback(async e=>{var t,i;if(e.endsWith("\r")){const i=e.slice(0,-1);if(q.current){if("failed"===await q.current.sendCommand(i))throw new Error("chat send failed");return}const s=i.trimStart().startsWith("/")?i.replace(/\n/g,"\r")+"\r":ht(i);return void(null==(t=U.current)||t.sendTerminalInput(s))}null==(i=U.current)||i.sendTerminalInput(e)},[]),[T,j]=Q(y.panelLeftWidth,String(224)),[O,z]=Q(y.panelRightWidth,String(208)),W=parseInt(T,10)||224,F=parseInt(O,10)||208,$=l.useRef(null),K=l.useRef(null),U=l.useRef(null),q=l.useRef(null);l.useEffect(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"i"===e.key&&"terminal"!==(null==i?void 0:i.cliTool)&&(e.preventDefault(),_())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[_,null==i?void 0:i.cliTool]);const V=l.useRef(null);l.useEffect(()=>{const e=(null==i?void 0:i.cliTool)??null;e&&V.current&&e!==V.current&&(g([]),w([]),x.current=0,E(null)),V.current=e},[null==i?void 0:i.cliTool]);const[Y,G]=l.useState("terminal"),[X,J]=l.useState(()=>window.innerWidth<768);l.useEffect(()=>{const e=()=>J(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const{fetchProjects:Z,hasFetched:ee}=Ge();return l.useEffect(()=>{if(!e)return;(async()=>{ee||await Z();const t=Ge.getState().projects.find(t=>t.id===e)??null;s(t),n(!1)})()},[e,ee,Z]),r?f.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:f.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading…"})}):i&&e?f.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[f.jsx(Vr,{project:i,projectId:e,showFileTree:"true"===o,showShortcuts:"true"===h,showChatOverlay:"true"===d,onToggleFileTree:()=>a(e=>"true"===e?"false":"true"),onToggleShortcuts:()=>c(e=>"true"===e?"false":"true"),onToggleChatOverlay:_,onProjectUpdate:s}),X?f.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-h-0",children:[f.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:["files"===Y&&f.jsx(Pi,{projectPath:i.folderPath,projectId:e,cliTool:i.cliTool,onSend:B}),"terminal"===Y&&f.jsx(xu,{ref:U,projectId:e,project:i,onStatusChange:e=>s(t=>t?{...t,status:e}:t)}),"panel"===Y&&f.jsx(jr,{projectId:e,onSend:B})]}),f.jsx("div",{className:"flex-shrink-0 flex border-t border-border bg-background pb-[env(safe-area-inset-bottom)]",children:[{id:"files",icon:P,label:"文件"},{id:"terminal",icon:ct,label:"终端"},{id:"panel",icon:si,label:"快捷"}].map(({id:e,icon:t,label:i})=>f.jsxs("button",{onClick:()=>G(e),className:p("flex-1 flex flex-col items-center gap-0.5 py-2 text-[10px] transition-colors",Y===e?"text-blue-400":"text-muted-foreground hover:text-foreground"),children:[f.jsx(t,{className:"h-4 w-4"}),i]},e))})]}):f.jsxs("div",{className:"flex-1 overflow-hidden flex min-h-0",children:[f.jsx(A,{initial:!1,children:"true"===o&&f.jsx(I.div,{ref:$,initial:{width:0,opacity:0},animate:{width:W,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"flex-shrink-0 overflow-hidden",children:f.jsx(Pi,{projectPath:i.folderPath,projectId:e,cliTool:i.cliTool,onSend:B})})}),"true"===o&&f.jsx("div",{onMouseDown:e=>{var t;e.preventDefault();const i=e.clientX,s=(null==(t=$.current)?void 0:t.offsetWidth)??W;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const r=e=>{const t=Math.max(yu,Math.min(Cu,s+(e.clientX-i)));$.current&&($.current.style.width=t+"px")},n=e=>{const t=Math.max(yu,Math.min(Cu,s+(e.clientX-i)));j(String(t)),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)},className:"w-1 flex-shrink-0 bg-border hover:bg-blue-500/60 active:bg-blue-500/80 cursor-col-resize transition-colors"}),f.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 relative flex flex-col",children:[f.jsx(xu,{ref:U,projectId:e,project:i,onStatusChange:e=>s(t=>t?{...t,status:e}:t),onChatMessage:D,onWsConnected:R,onWsDisconnected:L,onApprovalRequest:M,onApprovalResolved:N,onSemanticUpdate:E}),f.jsx(A,{children:"true"===d&&"terminal"!==i.cliTool&&f.jsx(Ct,{ref:q,projectId:e,project:i,liveMessages:m,approvalEvents:b,semanticUpdate:k,wsConnected:v,onSend:e=>{var t;return null==(t=U.current)?void 0:t.sendTerminalInput(e)},onClose:_},"chat-overlay")})]}),"true"===h&&f.jsx("div",{onMouseDown:e=>{var t;e.preventDefault();const i=e.clientX,s=(null==(t=K.current)?void 0:t.offsetWidth)??F;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const r=e=>{const t=Math.max(yu,Math.min(Cu,s-(e.clientX-i)));K.current&&(K.current.style.width=t+"px")},n=e=>{const t=Math.max(yu,Math.min(Cu,s-(e.clientX-i)));z(String(t)),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",n)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",n)},className:"w-1 flex-shrink-0 bg-border hover:bg-blue-500/60 active:bg-blue-500/80 cursor-col-resize transition-colors"}),f.jsx(A,{initial:!1,children:"true"===h&&f.jsx(I.div,{ref:K,initial:{width:0,opacity:0},animate:{width:F,opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:"flex-shrink-0 overflow-hidden",children:f.jsx(jr,{projectId:e,onSend:B})})})]})]}):f.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center gap-4 bg-background",children:[f.jsx("p",{className:"text-muted-foreground",children:"Project not found."}),f.jsxs(H,{variant:"outline",onClick:()=>t("/"),children:[f.jsx(Xe,{className:"h-4 w-4 mr-2"}),"Back to Dashboard"]})]})}},Symbol.toStringTag,{value:"Module"}));export{ku as P,oi as Z,ai as a};
|