itwillsync 1.3.2 → 1.3.4

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.
@@ -1,25 +1,25 @@
1
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();var Bo=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,sh=(t,e)=>{for(var i in e)Bo(t,i,{get:e[i],enumerable:!0})},re=(t,e,i,s)=>{for(var r=s>1?void 0:s?ih(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&Bo(e,i,r),r},T=(t,e)=>(i,s)=>e(i,s,t),nn="Terminal input",Xs={get:()=>nn,set:t=>nn=t},on="Too much output to announce, navigate to rows manually to read",js={get:()=>on,set:t=>on=t};function rh(t){return t.replace(/\r?\n/g,"\r")}function nh(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function oh(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function ah(t,e,i,s){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Ro(r,e,i,s)}}function Ro(t,e,i,s){t=rh(t),t=nh(t,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function Do(t,e,i){let s=i.getBoundingClientRect(),r=t.clientX-s.left-10,n=t.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function an(t,e,i,s,r){Do(t,e,i),r&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function At(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function fs(t,e=0,i=t.length){let s="";for(let r=e;r<i;++r){let n=t[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var hh=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?i[r++]=(this._interim-55296)*1024+o-56320+65536:(i[r++]=this._interim,i[r++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?i[r++]=(a-55296)*1024+l-56320+65536:(i[r++]=a,i[r++]=l);continue}a!==65279&&(i[r++]=a)}return r}},lh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let _=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let S=0,k;for(;(k=this.interim[++S]&63)&&S<4;)f<<=6,f|=k;let A=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,D=A-S;for(;c<D;){if(c>=s)return 0;if(k=e[c++],(k&192)!==128){c--,_=!0;break}else this.interim[S++]=k,f<<=6,f|=k&63}_||(A===2?f<128?c--:i[r++]=f:A===3?f<2048||f>=55296&&f<=57343||f===65279||(i[r++]=f):f<65536||f>1114111||(i[r++]=f)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((n=e[u])&128)&&!((o=e[u+1])&128)&&!((a=e[u+2])&128)&&!((l=e[u+3])&128);)i[r++]=n,i[r++]=o,i[r++]=a,i[r++]=l,u+=4;if(n=e[u++],n<128)i[r++]=n;else if((n&224)===192){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(h=(n&31)<<6|o&63,h<128){u--;continue}i[r++]=h}else if((n&240)===224){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;i[r++]=h}else if((n&248)===240){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,r;if(l=e[u++],(l&192)!==128){u--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;i[r++]=h}}return r}},Ao="",Pt=" ",Pi=class To{constructor(){this.fg=0,this.bg=0,this.extended=new rs}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new To;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rs=class Po{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Po(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Je=class Oo extends Pi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rs,this.combinedData=""}static fromCharData(e){let i=new Oo;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?At(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hn="di$target",Zs="di$dependencies",Cs=new Map;function ch(t){return t[Zs]||[]}function Ce(t){if(Cs.has(t))return Cs.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");dh(e,i,r)};return e._id=t,Cs.set(t,e),e}function dh(t,e,i){e[hn]===e?e[Zs].push({id:t,index:i}):(e[Zs]=[{id:t,index:i}],e[hn]=e)}var Te=Ce("BufferService"),Io=Ce("CoreMouseService"),Gt=Ce("CoreService"),uh=Ce("CharsetService"),Hr=Ce("InstantiationService"),$o=Ce("LogService"),Pe=Ce("OptionsService"),Fo=Ce("OscLinkService"),_h=Ce("UnicodeService"),Oi=Ce("DecorationService"),Js=class{constructor(e,i,s){this._bufferService=e,this._optionsService=i,this._oscLinkService=s}provideLinks(e,i){let s=this._bufferService.buffer.lines.get(e-1);if(!s){i(void 0);return}let r=[],n=this._optionsService.rawOptions.linkHandler,o=new Je,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let _={start:{x:h+1,y:e},end:{x:d+(!c&&d===a-1?1:0),y:e}},f=!1;if(!n?.allowNonHttpProtocols)try{let S=new URL(u);["http:","https:"].includes(S.protocol)||(f=!0)}catch{f=!0}f||r.push({text:u,range:_,activate:(S,k)=>n?n.activate(S,k,_):fh(S,k),hover:(S,k)=>n?.hover?.(S,k,_),leave:(S,k)=>n?.leave?.(S,k,_)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}i(r)}};Js=re([T(0,Te),T(1,Pe),T(2,Fo)],Js);function fh(t,e){if(confirm(`Do you want to navigate to ${e}?
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();var To=Object.defineProperty,ah=Object.getOwnPropertyDescriptor,hh=(t,e)=>{for(var i in e)To(t,i,{get:e[i],enumerable:!0})},re=(t,e,i,s)=>{for(var r=s>1?void 0:s?ah(e,i):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=(s?o(e,i,r):o(r))||r);return s&&r&&To(e,i,r),r},T=(t,e)=>(i,s)=>e(i,s,t),ln="Terminal input",Js={get:()=>ln,set:t=>ln=t},cn="Too much output to announce, navigate to rows manually to read",Qs={get:()=>cn,set:t=>cn=t};function lh(t){return t.replace(/\r?\n/g,"\r")}function ch(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function dh(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function uh(t,e,i,s){if(t.stopPropagation(),t.clipboardData){let r=t.clipboardData.getData("text/plain");Po(r,e,i,s)}}function Po(t,e,i,s){t=lh(t),t=ch(t,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(t,!0),e.value=""}function Oo(t,e,i){let s=i.getBoundingClientRect(),r=t.clientX-s.left-10,n=t.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function dn(t,e,i,s,r){Oo(t,e,i),r&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function Tt(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function ps(t,e=0,i=t.length){let s="";for(let r=e;r<i;++r){let n=t[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var _h=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?i[r++]=(this._interim-55296)*1024+o-56320+65536:(i[r++]=this._interim,i[r++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,r;let l=e.charCodeAt(o);56320<=l&&l<=57343?i[r++]=(a-55296)*1024+l-56320+65536:(i[r++]=a,i[r++]=l);continue}a!==65279&&(i[r++]=a)}return r}},fh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let _=!1,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let S=0,k;for(;(k=this.interim[++S]&63)&&S<4;)f<<=6,f|=k;let D=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=D-S;for(;c<A;){if(c>=s)return 0;if(k=e[c++],(k&192)!==128){c--,_=!0;break}else this.interim[S++]=k,f<<=6,f|=k&63}_||(D===2?f<128?c--:i[r++]=f:D===3?f<2048||f>=55296&&f<=57343||f===65279||(i[r++]=f):f<65536||f>1114111||(i[r++]=f)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!((n=e[u])&128)&&!((o=e[u+1])&128)&&!((a=e[u+2])&128)&&!((l=e[u+3])&128);)i[r++]=n,i[r++]=o,i[r++]=a,i[r++]=l,u+=4;if(n=e[u++],n<128)i[r++]=n;else if((n&224)===192){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(h=(n&31)<<6|o&63,h<128){u--;continue}i[r++]=h}else if((n&240)===224){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;i[r++]=h}else if((n&248)===240){if(u>=s)return this.interim[0]=n,r;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if(a=e[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,r;if(l=e[u++],(l&192)!==128){u--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;i[r++]=h}}return r}},Io="",Pt=" ",Oi=class $o{constructor(){this.fg=0,this.bg=0,this.extended=new os}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new $o;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},os=class Fo{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Fo(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Je=class No extends Oi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new os,this.combinedData=""}static fromCharData(e){let i=new No;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Tt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},un="di$target",er="di$dependencies",xs=new Map;function gh(t){return t[er]||[]}function Ce(t){if(xs.has(t))return xs.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");ph(e,i,r)};return e._id=t,xs.set(t,e),e}function ph(t,e,i){e[un]===e?e[er].push({id:t,index:i}):(e[er]=[{id:t,index:i}],e[un]=e)}var Te=Ce("BufferService"),Wo=Ce("CoreMouseService"),Gt=Ce("CoreService"),vh=Ce("CharsetService"),Kr=Ce("InstantiationService"),zo=Ce("LogService"),Pe=Ce("OptionsService"),Ho=Ce("OscLinkService"),mh=Ce("UnicodeService"),Ii=Ce("DecorationService"),tr=class{constructor(e,i,s){this._bufferService=e,this._optionsService=i,this._oscLinkService=s}provideLinks(e,i){let s=this._bufferService.buffer.lines.get(e-1);if(!s){i(void 0);return}let r=[],n=this._optionsService.rawOptions.linkHandler,o=new Je,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let d=0;d<a;d++)if(!(h===-1&&!s.hasContent(d))){if(s.loadCell(d,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=d,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&d===a-1){let u=this._oscLinkService.getLinkData(l)?.uri;if(u){let _={start:{x:h+1,y:e},end:{x:d+(!c&&d===a-1?1:0),y:e}},f=!1;if(!n?.allowNonHttpProtocols)try{let S=new URL(u);["http:","https:"].includes(S.protocol)||(f=!0)}catch{f=!0}f||r.push({text:u,range:_,activate:(S,k)=>n?n.activate(S,k,_):Sh(S,k),hover:(S,k)=>n?.hover?.(S,k,_),leave:(S,k)=>n?.leave?.(S,k,_)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=d,l=o.extended.urlId):(h=-1,l=-1)}}i(r)}};tr=re([T(0,Te),T(1,Pe),T(2,Ho)],tr);function Sh(t,e){if(confirm(`Do you want to navigate to ${e}?
2
2
 
3
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var gs=Ce("CharSizeService"),xt=Ce("CoreBrowserService"),Ur=Ce("MouseService"),kt=Ce("RenderService"),gh=Ce("SelectionService"),No=Ce("CharacterJoinerService"),oi=Ce("ThemeService"),Wo=Ce("LinkProviderService"),ph=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ln.isErrorNoTelemetry(e)?new ln(e.message+`
3
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var vs=Ce("CharSizeService"),kt=Ce("CoreBrowserService"),Vr=Ce("MouseService"),Lt=Ce("RenderService"),wh=Ce("SelectionService"),Uo=Ce("CharacterJoinerService"),oi=Ce("ThemeService"),qo=Ce("LinkProviderService"),bh=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?_n.isErrorNoTelemetry(e)?new _n(e.message+`
4
4
 
5
5
  `+e.stack):new Error(e.message+`
6
6
 
7
- `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(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)}},vh=new ph;function Xi(t){mh(t)||vh.onUnexpectedError(t)}var Qs="Canceled";function mh(t){return t instanceof Sh?!0:t instanceof Error&&t.name===Qs&&t.message===Qs}var Sh=class extends Error{constructor(){super(Qs),this.name=this.message}};function wh(t){return new Error(`Illegal argument: ${t}`)}var ln=class er extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof er)return e;let i=new er;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},tr=class zo extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,zo.prototype)}};function Fe(t,e=0){return t[t.length-(1+e)]}var bh;(t=>{function e(n){return n<0}t.isLessThan=e;function i(n){return n<=0}t.isLessThanOrEqual=i;function s(n){return n>0}t.isGreaterThan=s;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(bh||={});function Ch(t,e){let i=this,s=!1,r;return function(){return s||(s=!0,e||(r=t.apply(i,arguments))),r}}var Ho;(t=>{function e(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function s(){return i}t.empty=s;function*r(w){yield w}t.single=r;function n(w){return e(w)?w:r(w)}t.wrap=n;function o(w){return w||i}t.from=o;function*a(w){for(let R=w.length-1;R>=0;R--)yield w[R]}t.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}t.isEmpty=l;function h(w){return w[Symbol.iterator]().next().value}t.first=h;function c(w,R){let P=0;for(let N of w)if(R(N,P++))return!0;return!1}t.some=c;function d(w,R){for(let P of w)if(R(P))return P}t.find=d;function*u(w,R){for(let P of w)R(P)&&(yield P)}t.filter=u;function*_(w,R){let P=0;for(let N of w)yield R(N,P++)}t.map=_;function*f(w,R){let P=0;for(let N of w)yield*R(N,P++)}t.flatMap=f;function*S(...w){for(let R of w)yield*R}t.concat=S;function k(w,R,P){let N=P;for(let G of w)N=R(N,G);return N}t.reduce=k;function*A(w,R,P=w.length){for(R<0&&(R+=w.length),P<0?P+=w.length:P>w.length&&(P=w.length);R<P;R++)yield w[R]}t.slice=A;function D(w,R=Number.POSITIVE_INFINITY){let P=[];if(R===0)return[P,w];let N=w[Symbol.iterator]();for(let G=0;G<R;G++){let ae=N.next();if(ae.done)return[P,t.empty()];P.push(ae.value)}return[P,{[Symbol.iterator](){return N}}]}t.consume=D;async function B(w){let R=[];for await(let P of w)R.push(P);return Promise.resolve(R)}t.asyncToArray=B})(Ho||={});function Kt(t){if(Ho.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function yh(...t){return J(()=>Kt(t))}function J(t){return{dispose:Ch(()=>{t()})}}var Uo=class qo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Kt(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?qo.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(e),e}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),void 0)}};Uo.DISABLE_DISPOSED_WARNING=!1;var Ot=Uo,F=class{constructor(){this._store=new Ot,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)}};F.None=Object.freeze({dispose(){}});var ni=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},bt=typeof window=="object"?window:globalThis,ir=class sr{constructor(e){this.element=e,this.next=sr.Undefined,this.prev=sr.Undefined}};ir.Undefined=new ir(void 0);var Q=ir,cn=class{constructor(){this._first=Q.Undefined,this._last=Q.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Q.Undefined}clear(){let e=this._first;for(;e!==Q.Undefined;){let i=e.next;e.prev=Q.Undefined,e.next=Q.Undefined,e=i}this._first=Q.Undefined,this._last=Q.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let s=new Q(e);if(this._first===Q.Undefined)this._first=s,this._last=s;else if(i){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Q.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Q.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Q.Undefined&&e.next!==Q.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===Q.Undefined&&e.next===Q.Undefined?(this._first=Q.Undefined,this._last=Q.Undefined):e.next===Q.Undefined?(this._last=this._last.prev,this._last.next=Q.Undefined):e.prev===Q.Undefined&&(this._first=this._first.next,this._first.prev=Q.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Q.Undefined;)yield e.element,e=e.next}},xh=globalThis.performance&&typeof globalThis.performance.now=="function",kh=class Ko{static create(e){return new Ko(e)}constructor(e){this._now=xh&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Le;(t=>{t.None=()=>F.None;function e(p,g){return d(p,()=>{},0,void 0,!0,void 0,g)}t.defer=e;function i(p){return(g,v=null,m)=>{let y=!1,b;return b=p(L=>{if(!y)return b?b.dispose():y=!0,g.call(v,L)},null,m),y&&b.dispose(),b}}t.once=i;function s(p,g,v){return h((m,y=null,b)=>p(L=>m.call(y,g(L)),null,b),v)}t.map=s;function r(p,g,v){return h((m,y=null,b)=>p(L=>{g(L),m.call(y,L)},null,b),v)}t.forEach=r;function n(p,g,v){return h((m,y=null,b)=>p(L=>g(L)&&m.call(y,L),null,b),v)}t.filter=n;function o(p){return p}t.signal=o;function a(...p){return(g,v=null,m)=>{let y=yh(...p.map(b=>b(L=>g.call(v,L))));return c(y,m)}}t.any=a;function l(p,g,v,m){let y=v;return s(p,b=>(y=g(y,b),y),m)}t.reduce=l;function h(p,g){let v,m={onWillAddFirstListener(){v=p(y.fire,y)},onDidRemoveLastListener(){v?.dispose()}},y=new E(m);return g?.add(y),y.event}function c(p,g){return g instanceof Array?g.push(p):g&&g.add(p),p}function d(p,g,v=100,m=!1,y=!1,b,L){let C,M,I,Y=0,z,Oe={leakWarningThreshold:b,onWillAddFirstListener(){C=p(ye=>{Y++,M=g(M,ye),m&&!I&&(U.fire(M),M=void 0),z=()=>{let K=M;M=void 0,I=void 0,(!m||Y>1)&&U.fire(K),Y=0},typeof v=="number"?(clearTimeout(I),I=setTimeout(z,v)):I===void 0&&(I=0,queueMicrotask(z))})},onWillRemoveListener(){y&&Y>0&&z?.()},onDidRemoveLastListener(){z=void 0,C.dispose()}},U=new E(Oe);return L?.add(U),U.event}t.debounce=d;function u(p,g=0,v){return t.debounce(p,(m,y)=>m?(m.push(y),m):[y],g,void 0,!0,void 0,v)}t.accumulate=u;function _(p,g=(m,y)=>m===y,v){let m=!0,y;return n(p,b=>{let L=m||!g(b,y);return m=!1,y=b,L},v)}t.latch=_;function f(p,g,v){return[t.filter(p,g,v),t.filter(p,m=>!g(m),v)]}t.split=f;function S(p,g=!1,v=[],m){let y=v.slice(),b=p(M=>{y?y.push(M):C.fire(M)});m&&m.add(b);let L=()=>{y?.forEach(M=>C.fire(M)),y=null},C=new E({onWillAddFirstListener(){b||(b=p(M=>C.fire(M)),m&&m.add(b))},onDidAddFirstListener(){y&&(g?setTimeout(L):L())},onDidRemoveLastListener(){b&&b.dispose(),b=null}});return m&&m.add(C),C.event}t.buffer=S;function k(p,g){return(v,m,y)=>{let b=g(new D);return p(function(L){let C=b.evaluate(L);C!==A&&v.call(m,C)},void 0,y)}}t.chain=k;let A=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(g){return this.steps.push(g),this}forEach(g){return this.steps.push(v=>(g(v),v)),this}filter(g){return this.steps.push(v=>g(v)?v:A),this}reduce(g,v){let m=v;return this.steps.push(y=>(m=g(m,y),m)),this}latch(g=(v,m)=>v===m){let v=!0,m;return this.steps.push(y=>{let b=v||!g(y,m);return v=!1,m=y,b?y:A}),this}evaluate(g){for(let v of this.steps)if(g=v(g),g===A)break;return g}}function B(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.on(g,m),b=()=>p.removeListener(g,m),L=new E({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromNodeEventEmitter=B;function w(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.addEventListener(g,m),b=()=>p.removeEventListener(g,m),L=new E({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromDOMEventEmitter=w;function R(p){return new Promise(g=>i(p)(g))}t.toPromise=R;function P(p){let g=new E;return p.then(v=>{g.fire(v)},()=>{g.fire(void 0)}).finally(()=>{g.dispose()}),g.event}t.fromPromise=P;function N(p,g){return p(v=>g.fire(v))}t.forward=N;function G(p,g,v){return g(v),p(m=>g(m))}t.runAndSubscribe=G;class ae{constructor(g,v){this._observable=g,this._counter=0,this._hasChanged=!1;let m={onWillAddFirstListener:()=>{g.addObserver(this)},onDidRemoveLastListener:()=>{g.removeObserver(this)}};this.emitter=new E(m),v&&v.add(this.emitter)}beginUpdate(g){this._counter++}handlePossibleChange(g){}handleChange(g,v){this._hasChanged=!0}endUpdate(g){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(p,g){return new ae(p,g).emitter.event}t.fromObservable=Ee;function W(p){return(g,v,m)=>{let y=0,b=!1,L={beginUpdate(){y++},endUpdate(){y--,y===0&&(p.reportChanges(),b&&(b=!1,g.call(v)))},handlePossibleChange(){},handleChange(){b=!0}};p.addObserver(L),p.reportChanges();let C={dispose(){p.removeObserver(L)}};return m instanceof Ot?m.add(C):Array.isArray(m)&&m.push(C),C}}t.fromObservableLight=W})(Le||={});var rr=class nr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${nr._idPool++}`,nr.all.add(this)}start(e){this._stopWatch=new kh,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}}};rr.all=new Set,rr._idPool=0;var Lh=rr,Eh=-1,Vo=class Go{constructor(e,i,s=(Go._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new Rh(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[s,r]of this._stacks)(!e||i<r)&&(e=[s,r],i=r);return e}};Vo._idPool=1;var Mh=Vo,Bh=class Yo{constructor(e){this.value=e}static create(){let e=new Error;return new Yo(e.stack??"")}print(){console.warn(this.value.split(`
7
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(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)}},Ch=new bh;function Zi(t){yh(t)||Ch.onUnexpectedError(t)}var ir="Canceled";function yh(t){return t instanceof xh?!0:t instanceof Error&&t.name===ir&&t.message===ir}var xh=class extends Error{constructor(){super(ir),this.name=this.message}};function kh(t){return new Error(`Illegal argument: ${t}`)}var _n=class sr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof sr)return e;let i=new sr;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},rr=class Ko extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,Ko.prototype)}};function Fe(t,e=0){return t[t.length-(1+e)]}var Lh;(t=>{function e(n){return n<0}t.isLessThan=e;function i(n){return n<=0}t.isLessThanOrEqual=i;function s(n){return n>0}t.isGreaterThan=s;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Lh||={});function Eh(t,e){let i=this,s=!1,r;return function(){return s||(s=!0,e||(r=t.apply(i,arguments))),r}}var Vo;(t=>{function e(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function s(){return i}t.empty=s;function*r(w){yield w}t.single=r;function n(w){return e(w)?w:r(w)}t.wrap=n;function o(w){return w||i}t.from=o;function*a(w){for(let R=w.length-1;R>=0;R--)yield w[R]}t.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}t.isEmpty=l;function h(w){return w[Symbol.iterator]().next().value}t.first=h;function c(w,R){let P=0;for(let N of w)if(R(N,P++))return!0;return!1}t.some=c;function d(w,R){for(let P of w)if(R(P))return P}t.find=d;function*u(w,R){for(let P of w)R(P)&&(yield P)}t.filter=u;function*_(w,R){let P=0;for(let N of w)yield R(N,P++)}t.map=_;function*f(w,R){let P=0;for(let N of w)yield*R(N,P++)}t.flatMap=f;function*S(...w){for(let R of w)yield*R}t.concat=S;function k(w,R,P){let N=P;for(let G of w)N=R(N,G);return N}t.reduce=k;function*D(w,R,P=w.length){for(R<0&&(R+=w.length),P<0?P+=w.length:P>w.length&&(P=w.length);R<P;R++)yield w[R]}t.slice=D;function A(w,R=Number.POSITIVE_INFINITY){let P=[];if(R===0)return[P,w];let N=w[Symbol.iterator]();for(let G=0;G<R;G++){let ae=N.next();if(ae.done)return[P,t.empty()];P.push(ae.value)}return[P,{[Symbol.iterator](){return N}}]}t.consume=A;async function B(w){let R=[];for await(let P of w)R.push(P);return Promise.resolve(R)}t.asyncToArray=B})(Vo||={});function Kt(t){if(Vo.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function Mh(...t){return J(()=>Kt(t))}function J(t){return{dispose:Eh(()=>{t()})}}var Go=class Yo{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Kt(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Yo.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(e),e}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),void 0)}};Go.DISABLE_DISPOSED_WARNING=!1;var Ot=Go,F=class{constructor(){this._store=new Ot,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)}};F.None=Object.freeze({dispose(){}});var ni=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Ct=typeof window=="object"?window:globalThis,nr=class or{constructor(e){this.element=e,this.next=or.Undefined,this.prev=or.Undefined}};nr.Undefined=new nr(void 0);var Q=nr,fn=class{constructor(){this._first=Q.Undefined,this._last=Q.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Q.Undefined}clear(){let e=this._first;for(;e!==Q.Undefined;){let i=e.next;e.prev=Q.Undefined,e.next=Q.Undefined,e=i}this._first=Q.Undefined,this._last=Q.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let s=new Q(e);if(this._first===Q.Undefined)this._first=s,this._last=s;else if(i){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Q.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Q.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Q.Undefined&&e.next!==Q.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===Q.Undefined&&e.next===Q.Undefined?(this._first=Q.Undefined,this._last=Q.Undefined):e.next===Q.Undefined?(this._last=this._last.prev,this._last.next=Q.Undefined):e.prev===Q.Undefined&&(this._first=this._first.next,this._first.prev=Q.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Q.Undefined;)yield e.element,e=e.next}},Bh=globalThis.performance&&typeof globalThis.performance.now=="function",Rh=class Xo{static create(e){return new Xo(e)}constructor(e){this._now=Bh&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Le;(t=>{t.None=()=>F.None;function e(p,g){return d(p,()=>{},0,void 0,!0,void 0,g)}t.defer=e;function i(p){return(g,v=null,m)=>{let y=!1,b;return b=p(L=>{if(!y)return b?b.dispose():y=!0,g.call(v,L)},null,m),y&&b.dispose(),b}}t.once=i;function s(p,g,v){return h((m,y=null,b)=>p(L=>m.call(y,g(L)),null,b),v)}t.map=s;function r(p,g,v){return h((m,y=null,b)=>p(L=>{g(L),m.call(y,L)},null,b),v)}t.forEach=r;function n(p,g,v){return h((m,y=null,b)=>p(L=>g(L)&&m.call(y,L),null,b),v)}t.filter=n;function o(p){return p}t.signal=o;function a(...p){return(g,v=null,m)=>{let y=Mh(...p.map(b=>b(L=>g.call(v,L))));return c(y,m)}}t.any=a;function l(p,g,v,m){let y=v;return s(p,b=>(y=g(y,b),y),m)}t.reduce=l;function h(p,g){let v,m={onWillAddFirstListener(){v=p(y.fire,y)},onDidRemoveLastListener(){v?.dispose()}},y=new E(m);return g?.add(y),y.event}function c(p,g){return g instanceof Array?g.push(p):g&&g.add(p),p}function d(p,g,v=100,m=!1,y=!1,b,L){let C,M,I,Y=0,z,Oe={leakWarningThreshold:b,onWillAddFirstListener(){C=p(ye=>{Y++,M=g(M,ye),m&&!I&&(U.fire(M),M=void 0),z=()=>{let K=M;M=void 0,I=void 0,(!m||Y>1)&&U.fire(K),Y=0},typeof v=="number"?(clearTimeout(I),I=setTimeout(z,v)):I===void 0&&(I=0,queueMicrotask(z))})},onWillRemoveListener(){y&&Y>0&&z?.()},onDidRemoveLastListener(){z=void 0,C.dispose()}},U=new E(Oe);return L?.add(U),U.event}t.debounce=d;function u(p,g=0,v){return t.debounce(p,(m,y)=>m?(m.push(y),m):[y],g,void 0,!0,void 0,v)}t.accumulate=u;function _(p,g=(m,y)=>m===y,v){let m=!0,y;return n(p,b=>{let L=m||!g(b,y);return m=!1,y=b,L},v)}t.latch=_;function f(p,g,v){return[t.filter(p,g,v),t.filter(p,m=>!g(m),v)]}t.split=f;function S(p,g=!1,v=[],m){let y=v.slice(),b=p(M=>{y?y.push(M):C.fire(M)});m&&m.add(b);let L=()=>{y?.forEach(M=>C.fire(M)),y=null},C=new E({onWillAddFirstListener(){b||(b=p(M=>C.fire(M)),m&&m.add(b))},onDidAddFirstListener(){y&&(g?setTimeout(L):L())},onDidRemoveLastListener(){b&&b.dispose(),b=null}});return m&&m.add(C),C.event}t.buffer=S;function k(p,g){return(v,m,y)=>{let b=g(new A);return p(function(L){let C=b.evaluate(L);C!==D&&v.call(m,C)},void 0,y)}}t.chain=k;let D=Symbol("HaltChainable");class A{constructor(){this.steps=[]}map(g){return this.steps.push(g),this}forEach(g){return this.steps.push(v=>(g(v),v)),this}filter(g){return this.steps.push(v=>g(v)?v:D),this}reduce(g,v){let m=v;return this.steps.push(y=>(m=g(m,y),m)),this}latch(g=(v,m)=>v===m){let v=!0,m;return this.steps.push(y=>{let b=v||!g(y,m);return v=!1,m=y,b?y:D}),this}evaluate(g){for(let v of this.steps)if(g=v(g),g===D)break;return g}}function B(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.on(g,m),b=()=>p.removeListener(g,m),L=new E({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromNodeEventEmitter=B;function w(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.addEventListener(g,m),b=()=>p.removeEventListener(g,m),L=new E({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromDOMEventEmitter=w;function R(p){return new Promise(g=>i(p)(g))}t.toPromise=R;function P(p){let g=new E;return p.then(v=>{g.fire(v)},()=>{g.fire(void 0)}).finally(()=>{g.dispose()}),g.event}t.fromPromise=P;function N(p,g){return p(v=>g.fire(v))}t.forward=N;function G(p,g,v){return g(v),p(m=>g(m))}t.runAndSubscribe=G;class ae{constructor(g,v){this._observable=g,this._counter=0,this._hasChanged=!1;let m={onWillAddFirstListener:()=>{g.addObserver(this)},onDidRemoveLastListener:()=>{g.removeObserver(this)}};this.emitter=new E(m),v&&v.add(this.emitter)}beginUpdate(g){this._counter++}handlePossibleChange(g){}handleChange(g,v){this._hasChanged=!0}endUpdate(g){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(p,g){return new ae(p,g).emitter.event}t.fromObservable=Ee;function W(p){return(g,v,m)=>{let y=0,b=!1,L={beginUpdate(){y++},endUpdate(){y--,y===0&&(p.reportChanges(),b&&(b=!1,g.call(v)))},handlePossibleChange(){},handleChange(){b=!0}};p.addObserver(L),p.reportChanges();let C={dispose(){p.removeObserver(L)}};return m instanceof Ot?m.add(C):Array.isArray(m)&&m.push(C),C}}t.fromObservableLight=W})(Le||={});var ar=class hr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${hr._idPool++}`,hr.all.add(this)}start(e){this._stopWatch=new Rh,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}}};ar.all=new Set,ar._idPool=0;var Ah=ar,Dh=-1,jo=class Zo{constructor(e,i,s=(Zo._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new Oh(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[s,r]of this._stacks)(!e||i<r)&&(e=[s,r],i=r);return e}};jo._idPool=1;var Th=jo,Ph=class Jo{constructor(e){this.value=e}static create(){let e=new Error;return new Jo(e.stack??"")}print(){console.warn(this.value.split(`
8
8
  `).slice(2).join(`
9
- `))}},Rh=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Dh=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Ah=0,ys=class{constructor(e){this.value=e,this.id=Ah++}},Th=2,Ph,E=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Mh(t?.onListenerError??Xi,this._options?.leakWarningThreshold??Eh):void 0,this._perfMon=this._options?._profName?new Lh(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Dh(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||Xi)(l),F.None}if(this._disposed)return F.None;e&&(t=t.bind(e));let s=new ys(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Bh.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof ys?(this._deliveryQueue??=new Oh,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=J(()=>{r?.(),this._removeListener(s)});return i instanceof Ot?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Th<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||Xi;if(!i){t.value(e);return}try{t.value(e)}catch(s){i(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof ys)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Oh=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,s){this.i=0,this.end=s,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},or=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new E,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new E,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};or.INSTANCE=new or;var qr=or;function Ih(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}qr.INSTANCE.onDidChangeZoomLevel;function $h(t){return qr.INSTANCE.getZoomFactor(t)}qr.INSTANCE.onDidChangeFullscreen;var ai=typeof navigator=="object"?navigator.userAgent:"",ar=ai.indexOf("Firefox")>=0,Fh=ai.indexOf("AppleWebKit")>=0,Kr=ai.indexOf("Chrome")>=0,Nh=!Kr&&ai.indexOf("Safari")>=0;ai.indexOf("Electron/")>=0;ai.indexOf("Android")>=0;var xs=!1;if(typeof bt.matchMedia=="function"){let t=bt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=bt.matchMedia("(display-mode: fullscreen)");xs=t.matches,Ih(bt,t,({matches:i})=>{xs&&e.matches||(xs=i)})}var ei="en",hr=!1,lr=!1,ji=!1,Xo=!1,Ni,Zi=ei,dn=ei,Wh,vt,Ht=globalThis,ze;typeof Ht.vscode<"u"&&typeof Ht.vscode.process<"u"?ze=Ht.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ze=process);var zh=typeof ze?.versions?.electron=="string",Hh=zh&&ze?.type==="renderer";if(typeof ze=="object"){hr=ze.platform==="win32",lr=ze.platform==="darwin",ji=ze.platform==="linux",ji&&ze.env.SNAP&&ze.env.SNAP_REVISION,ze.env.CI||ze.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ni=ei,Zi=ei;let t=ze.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Ni=e.userLocale,dn=e.osLocale,Zi=e.resolvedLanguage||ei,Wh=e.languagePack?.translationsConfigFile}catch{}Xo=!0}else typeof navigator=="object"&&!Hh?(vt=navigator.userAgent,hr=vt.indexOf("Windows")>=0,lr=vt.indexOf("Macintosh")>=0,(vt.indexOf("Macintosh")>=0||vt.indexOf("iPad")>=0||vt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ji=vt.indexOf("Linux")>=0,vt?.indexOf("Mobi")>=0,Zi=globalThis._VSCODE_NLS_LANGUAGE||ei,Ni=navigator.language.toLowerCase(),dn=Ni):console.error("Unable to resolve platform.");var jo=hr,ht=lr,Uh=ji,un=Xo,lt=vt,Lt=Zi,qh;(t=>{function e(){return Lt}t.value=e;function i(){return Lt.length===2?Lt==="en":Lt.length>=3?Lt[0]==="e"&&Lt[1]==="n"&&Lt[2]==="-":!1}t.isDefaultVariant=i;function s(){return Lt==="en"}t.isDefault=s})(qh||={});var Kh=typeof Ht.postMessage=="function"&&!Ht.importScripts;(()=>{if(Kh){let t=[];Ht.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=t.length;s<r;s++){let n=t[s];if(n.id===i.data.vscodeScheduleAsyncWork){t.splice(s,1),n.callback();return}}});let e=0;return i=>{let s=++e;t.push({id:s,callback:i}),Ht.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var Vh=!!(lt&&lt.indexOf("Chrome")>=0);lt&&lt.indexOf("Firefox")>=0;!Vh&&lt&&lt.indexOf("Safari")>=0;lt&&lt.indexOf("Edg/")>=0;lt&&lt.indexOf("Android")>=0;var Yt=typeof navigator=="object"?navigator:{};un||document.queryCommandSupported&&document.queryCommandSupported("copy")||Yt&&Yt.clipboard&&Yt.clipboard.writeText,un||Yt&&Yt.clipboard&&Yt.clipboard.readText;var Vr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ks=new Vr,_n=new Vr,fn=new Vr,Gh=new Array(230),Zo;(t=>{function e(a){return ks.keyCodeToStr(a)}t.toString=e;function i(a){return ks.strToKeyCode(a)}t.fromString=i;function s(a){return _n.keyCodeToStr(a)}t.toUserSettingsUS=s;function r(a){return fn.keyCodeToStr(a)}t.toUserSettingsGeneral=r;function n(a){return _n.strToKeyCode(a)||fn.strToKeyCode(a)}t.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ks.keyCodeToStr(a)}t.toElectronAccelerator=o})(Zo||={});var Yh=class Jo{constructor(e,i,s,r,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof Jo&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Xh([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Xh=class{constructor(t){if(t.length===0)throw wh("chords");this.chords=t}getHashCode(){let t="";for(let e=0,i=this.chords.length;e<i;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function jh(t){if(t.charCode){let i=String.fromCharCode(t.charCode).toUpperCase();return Zo.fromString(i)}let e=t.keyCode;if(e===3)return 7;if(ar)switch(e){case 59:return 85;case 60:if(Uh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ht)return 57;break}else if(Fh&&(ht&&e===93||!ht&&e===92))return 57;return Gh[e]||0}var Zh=ht?256:2048,Jh=512,Qh=1024,el=ht?2048:256,gn=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=jh(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=Zh),this.altKey&&(e|=Jh),this.shiftKey&&(e|=Qh),this.metaKey&&(e|=el),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Yh(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},pn=new WeakMap;function tl(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,i=t.parent.location;if(e.origin!=="null"&&i.origin!=="null"&&e.origin!==i.origin)return null}catch{return null}return t.parent}var il=class{static getSameOriginWindowChain(t){let e=pn.get(t);if(!e){e=[],pn.set(t,e);let i=t,s;do s=tl(i),s?e.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):e.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(t);for(let n of r){let o=n.window.deref();if(i+=o?.scrollY??0,s+=o?.scrollX??0,o===e||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Wi=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=i.button===0,this.middleButton=i.button===1,this.rightButton=i.button===2,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,i.type==="dblclick"&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,typeof i.pageX=="number"?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=il.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},vn=class{constructor(e,i=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=i;let r=!1;if(Kr){let n=navigator.userAgent.match(/Chrome\/(\d+)/);r=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=e.view?.devicePixelRatio||1;if(typeof n.wheelDeltaY<"u")r?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ar&&!ht?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Nh&&jo?this.deltaX=-(n.wheelDeltaX/120):r?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?ar&&!ht?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Qo=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),sl;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof rl?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Le.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Qo})})(sl||={});var rl=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?Qo:(this._emitter||(this._emitter=new E),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Gr=class{constructor(e,i){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof i=="number"&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new tr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new tr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},nl=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,s=globalThis){if(this.isDisposed)throw new tr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},i);this.disposable=J(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ol;(t=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}t.withAsyncBody=i})(ol||={});var mn=class Ve{static fromArray(e){return new Ve(i=>{i.emitMany(e)})}static fromPromise(e){return new Ve(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Ve(async i=>{await Promise.all(e.map(async s=>i.emitOne(await s)))})}static merge(e){return new Ve(async i=>{await Promise.all(e.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new E,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Le.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Ve(async s=>{for await(let r of e)s.emitOne(i(r))})}map(e){return Ve.map(this,e)}static filter(e,i){return new Ve(async s=>{for await(let r of e)i(r)&&s.emitOne(r)})}filter(e){return Ve.filter(this,e)}static coalesce(e){return Ve.filter(e,i=>!!i)}coalesce(){return Ve.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return Ve.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};mn.EMPTY=mn.fromArray([]);var{getWindow:at,getWindowId:al,onDidRegisterWindow:hl}=(function(){let t=new Map,e={window:bt,disposables:new Ot};t.set(bt.vscodeWindowId,e);let i=new E,s=new E,r=new E;function n(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(t.has(o.vscodeWindowId))return F.None;let a=new Ot,l={window:o,disposables:a.add(new Ot)};return t.set(o.vscodeWindowId,l),a.add(J(()=>{t.delete(o.vscodeWindowId),s.fire(o)})),a.add(O(o,ge.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(l),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:bt},getDocument(o){return at(o).document}}})(),ll=class{constructor(e,i,s,r){this._node=e,this._type=i,this._handler=s,this._options=r||!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 O(t,e,i,s){return new ll(t,e,i,s)}var Sn=function(t,e,i,s){return O(t,e,i,s)},Yr,cl=class extends nl{constructor(t){super(),this.defaultTarget=t&&at(t)}cancelAndSet(t,e,i){return super.cancelAndSet(t,e,i??this.defaultTarget)}},wn=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Xi(e)}}static sort(e,i){return i.priority-e.priority}};(function(){let t=new Map,e=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=t.get(n)??[];for(e.set(n,o),t.set(n,[]),s.set(n,!0);o.length>0;)o.sort(wn.sort),o.shift().execute();s.set(n,!1)};Yr=(n,o,a=0)=>{let l=al(n),h=new wn(o,a),c=t.get(l);return c||(c=[],t.set(l,c)),c.push(h),i.get(l)||(i.set(l,!0),n.requestAnimationFrame(()=>r(l))),h}})();function dl(t){let e=t.getBoundingClientRect(),i=at(t);return{left:e.left+i.scrollX,top:e.top+i.scrollY,width:e.width,height:e.height}}var ge={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"},ul=class{constructor(t){this.domNode=t,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(t){let e=Ie(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Ie(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Ie(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Ie(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Ie(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Ie(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Ie(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Ie(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Ie(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Ie(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Ie(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Ie(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Ie(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Ie(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Ie(t){return typeof t=="number"?`${t}px`:t}function Li(t){return new ul(t)}var ea=class{constructor(){this._hooks=new Ot,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,s,r,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=n;let o=e;try{e.setPointerCapture(i),this._hooks.add(J(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=at(e)}this._hooks.add(O(o,ge.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(O(o,ge.POINTER_UP,a=>this.stopMonitoring(!0)))}};function _l(t,e,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${e}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var ot;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(ot||={});var wi=class Me extends F{constructor(){super(),this.dispatched=!1,this.targets=new cn,this.ignoreTargets=new cn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Le.runAndSubscribe(hl,({window:e,disposables:i})=>{i.add(O(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(O(e.document,"touchend",s=>this.onTouchEnd(e,s))),i.add(O(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:bt,disposables:this._store}))}static addTarget(e){if(!Me.isTouchDevice())return F.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.targets.push(e);return J(i)}static ignoreTarget(e){if(!Me.isTouchDevice())return F.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.ignoreTargets.push(e);return J(i)}static isTouchDevice(){return"ontouchstart"in bt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=e.targetTouches.length;s<r;s++){let n=e.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(ot.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<Me.HOLD_DELAY&&Math.abs(l.initialPageX-Fe(l.rollingPageX))<30&&Math.abs(l.initialPageY-Fe(l.rollingPageY))<30){let c=this.newGestureEvent(ot.Tap,l.initialTarget);c.pageX=Fe(l.rollingPageX),c.pageY=Fe(l.rollingPageY),this.dispatchEvent(c)}else if(h>=Me.HOLD_DELAY&&Math.abs(l.initialPageX-Fe(l.rollingPageX))<30&&Math.abs(l.initialPageY-Fe(l.rollingPageY))<30){let c=this.newGestureEvent(ot.Contextmenu,l.initialTarget);c.pageX=Fe(l.rollingPageX),c.pageY=Fe(l.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=Fe(l.rollingPageX),d=Fe(l.rollingPageY),u=Fe(l.rollingTimestamps)-l.rollingTimestamps[0],_=c-l.rollingPageX[0],f=d-l.rollingPageY[0],S=[...this.targets].filter(k=>l.initialTarget instanceof Node&&k.contains(l.initialTarget));this.inertia(e,S,s,Math.abs(_)/u,_>0?1:-1,c,Math.abs(f)/u,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(ot.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(e){if(e.type===ot.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Me.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,e.tapCount=s}else(e.type===ot.Change||e.type===ot.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let r=0,n=e.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,i,s,r,n,o,a,l,h){this.handle=Yr(e,()=>{let c=Date.now(),d=c-s,u=0,_=0,f=!0;r+=Me.SCROLL_FRICTION*d,a+=Me.SCROLL_FRICTION*d,r>0&&(f=!1,u=n*r*d),a>0&&(f=!1,_=l*a*d);let S=this.newGestureEvent(ot.Change);S.translationX=u,S.translationY=_,i.forEach(k=>k.dispatchEvent(S)),f||this.inertia(e,i,c,r,n,o+u,a,l,h+_)})}onTouchMove(e){let i=Date.now();for(let s=0,r=e.changedTouches.length;s<r;s++){let n=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(ot.Change,o.initialTarget);a.translationX=n.pageX-Fe(o.rollingPageX),a.translationY=n.pageY-Fe(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};wi.SCROLL_FRICTION=-.005,wi.HOLD_DELAY=700,wi.CLEAR_TAP_COUNT_TIME=400,re([_l],wi,"isTouchDevice",1);var fl=wi,Xr=class extends F{onclick(e,i){this._register(O(e,ge.CLICK,s=>i(new Wi(at(e),s))))}onmousedown(e,i){this._register(O(e,ge.MOUSE_DOWN,s=>i(new Wi(at(e),s))))}onmouseover(e,i){this._register(O(e,ge.MOUSE_OVER,s=>i(new Wi(at(e),s))))}onmouseleave(e,i){this._register(O(e,ge.MOUSE_LEAVE,s=>i(new Wi(at(e),s))))}onkeydown(e,i){this._register(O(e,ge.KEY_DOWN,s=>i(new gn(s))))}onkeyup(e,i){this._register(O(e,ge.KEY_UP,s=>i(new gn(s))))}oninput(e,i){this._register(O(e,ge.INPUT,i))}onblur(e,i){this._register(O(e,ge.BLUR,i))}onfocus(e,i){this._register(O(e,ge.FOCUS,i))}onchange(e,i){this._register(O(e,ge.CHANGE,i))}ignoreGesture(e){return fl.ignoreTarget(e)}},bn=11,gl=class extends Xr{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=bn+"px",this.domNode.style.height=bn+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new ea),this._register(Sn(this.bgDomNode,ge.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(Sn(this.domNode,ge.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new cl),this._pointerdownScheduleRepeatTimer=this._register(new Gr)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,at(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},pl=class cr{constructor(e,i,s,r,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(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(e,i){return new cr(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new cr(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let s=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},vl=class extends F{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new pl(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let i=this._state.withScrollDimensions(t,e);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let i=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;e?s=new yn(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=yn.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let i=this._state;i.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(i,e)))}},Cn=class{constructor(e,i,s){this.scrollLeft=e,this.scrollTop=i,this.isDone=s}};function Ls(t,e){let i=e-t;return function(s){return t+i*wl(s)}}function ml(t,e,i){return function(s){return s<i?t(s/i):e((s-i)/(1-i))}}var yn=class dr{constructor(e,i,s,r){this.from=e,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,i,s){if(Math.abs(e-i)>2.5*s){let r,n;return e<i?(r=e+.75*s,n=i-.75*s):(r=e-.75*s,n=i+.75*s),ml(Ls(e,r),Ls(n,i),.33)}return Ls(e,i)}dispose(){this.animationFrameDisposable!==null&&(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 i=(e-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new Cn(s,r,!1)}return new Cn(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,i,s){return dr.start(e,i,s)}static start(e,i,s){s=s+10;let r=Date.now()-10;return new dr(e,i,r,s)}};function Sl(t){return Math.pow(t,3)}function wl(t){return 1-Sl(1-t)}var bl=class extends F{constructor(e,i,s){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Gr)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},Cl=140,ta=class extends Xr{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 bl(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ea),this._shouldRender=!0,this.domNode=Li(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(O(this.domNode.domNode,ge.POINTER_DOWN,i=>this._domNodePointerDown(i)))}_createArrow(e){let i=this._register(new gl(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,s,r){this.slider=Li(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(O(this.slider.domNode,ge.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,s=i+this._scrollbarState.getSliderPosition(),r=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")i=e.offsetX,s=e.offsetY;else{let n=dl(this.domNode.domNode);i=e.pageX-n.left,s=e.pageY-n.top}let r=this._pointerDownRelativePosition(i,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(jo&&a>Cl){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(n)-i;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ia=class ur{constructor(e,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new ur(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,s,r,n){let o=Math.max(0,s-e),a=Math.max(0,o-2*i),l=r>0&&r>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-h)/(r-s),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let e=ur._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.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 i=e-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+e;return Math.round(i/this._computedSliderRatio)}},yl=class extends ta{constructor(e,i,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new ia(i.horizontalHasArrows?i.arrowSize:0,i.horizontal===2?0:i.horizontalScrollbarSize,i.vertical===2?0:i.verticalScrollbarSize,r.width,r.scrollWidth,n.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),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,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},xl=class extends ta{constructor(t,e,i){let s=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:i,scrollbarState:new ia(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},kl=500,xn=50,Ll=class{constructor(e,i,s){this.timestamp=e,this.deltaX=i,this.deltaY=s,this.score=0}},_r=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,i=0,s=1,r=this._rear;do{let n=r===this._front?e:Math.pow(2,-s);if(e-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(e){if(Kr){let i=at(e.browserEvent),s=$h(i);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,s){let r=null,n=new Ll(e,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),i){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%l===0&&d%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};_r.INSTANCE=new _r;var El=_r,Ml=class extends Xr{constructor(t,e,i){super(),this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new E),this.onWillScroll=this._onWillScroll.event,this._options=Rl(e),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new xl(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new yl(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(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Li(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Li(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Li(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Gr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Kt(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,ht&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new vn(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Kt(this._mouseWheelToDispose),t)){let e=i=>{this._onMouseWheel(new vn(i))};this._mouseWheelToDispose.push(O(this._listenOnDomNode,ge.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=El.INSTANCE;e.acceptStandardWheelEvent(t);let i=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,n=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let o=!ht&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(n=n*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(r){let h=xn*r,c=a.scrollTop-(h<0?Math.floor(h):Math.ceil(h));this._verticalScrollbar.writeScrollPosition(l,c)}if(n){let h=xn*n,c=a.scrollLeft-(h<0?Math.floor(h):Math.ceil(h));this._horizontalScrollbar.writeScrollPosition(l,c)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||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 t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,i=t.scrollLeft>0,s=i?" left":"",r=e?" top":"",n=i||e?" 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(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){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(),kl)}},Bl=class extends Ml{constructor(e,i,s){super(e,i,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Rl(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,ht&&(e.className+=" mac"),e}var fr=class extends F{constructor(e,i,s,r,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new E),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new vl({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>Yr(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Bl(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Le.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(J(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(J(()=>this._styleElement.remove())),this._register(Le.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
10
- `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=i-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=i,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};fr=re([T(2,Te),T(3,xt),T(4,Io),T(5,oi),T(6,Pe),T(7,kt)],fr);var gr=class extends F{constructor(e,i,s,r,n){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=s,this._decorationService=r,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(J(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),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 i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,i=e.element){if(!i)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?i.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};gr=re([T(1,Te),T(2,xt),T(3,Oi),T(4,kt)],gr);var Dl=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 i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(i,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,s){return i>=e.startBufferLine-this._linePadding[s||"full"]&&i<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},st={full:0,left:0,center:0,right:0},Et={full:0,left:0,center:0,right:0},ci={full:0,left:0,center:0,right:0},ns=class extends F{constructor(e,i,s,r,n,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=s,this._decorationService=r,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Dl,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(J(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);Et.full=this._canvas.width,Et.left=e,Et.center=i,Et.right=e,this._refreshDrawHeightConstants(),ci.full=1,ci.left=1,ci.center=1+Et.left,ci.right=1+Et.left+Et.center}_refreshDrawHeightConstants(){st.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,i=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);st.left=i,st.center=i,st.right=i}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*st.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*st.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*st.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*st.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 i of this._decorationService.decorations)this._colorZoneStore.addDecoration(i);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)i.position!=="full"&&this._renderColorZone(i);for(let i of e)i.position==="full"&&this._renderColorZone(i);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(ci[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-st[e.position||"full"]/2),Et[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+st[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ns=re([T(2,Te),T(3,Oi),T(4,kt),T(5,Pe),T(6,oi),T(7,xt)],ns);var x;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
11
- `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(x||={});var Ji;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(Ji||={});var sa;(t=>t.ST=`${x.ESC}\\`)(sa||={});var pr=class{constructor(e,i,s,r,n,o){this._textarea=e,this._compositionView=i,this._bufferService=s,this._optionsService=r,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;i.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(i.start,this._compositionPosition.start):s=this._textarea.value.substring(i.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,s=i.replace(e,"");this._dataAlreadySent=s,i.length>e.length?this._coreService.triggerDataEvent(s,!0):i.length<e.length?this._coreService.triggerDataEvent(`${x.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};pr=re([T(2,Te),T(3,Pe),T(4,Gt),T(5,kt)],pr);var pe=0,ve=0,me=0,ie=0,kn={css:"#00000000",rgba:0},ce;(t=>{function e(r,n,o,a){return a!==void 0?`#${It(r)}${It(n)}${It(o)}${It(a)}`:`#${It(r)}${It(n)}${It(o)}`}t.toCss=e;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}t.toRgba=i;function s(r,n,o,a){return{css:t.toCss(r,n,o,a),rgba:t.toRgba(r,n,o,a)}}t.toColor=s})(ce||={});var j;(t=>{function e(l,h){if(ie=(h.rgba&255)/255,ie===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,_=l.rgba>>24&255,f=l.rgba>>16&255,S=l.rgba>>8&255;pe=_+Math.round((c-_)*ie),ve=f+Math.round((d-f)*ie),me=S+Math.round((u-S)*ie);let k=ce.toCss(pe,ve,me),A=ce.toRgba(pe,ve,me);return{css:k,rgba:A}}t.blend=e;function i(l){return(l.rgba&255)===255}t.isOpaque=i;function s(l,h,c){let d=Qi.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return ce.toColor(d>>24&255,d>>16&255,d>>8&255)}t.ensureContrastRatio=s;function r(l){let h=(l.rgba|255)>>>0;return[pe,ve,me]=Qi.toChannels(h),{css:ce.toCss(pe,ve,me),rgba:h}}t.opaque=r;function n(l,h){return ie=Math.round(h*255),[pe,ve,me]=Qi.toChannels(l.rgba),{css:ce.toCss(pe,ve,me,ie),rgba:ce.toRgba(pe,ve,me,ie)}}t.opacity=n;function o(l,h){return ie=l.rgba&255,n(l,ie*h/255)}t.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}t.toColorRGB=a})(j||={});var ee;(t=>{let e,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return pe=parseInt(r.slice(1,2).repeat(2),16),ve=parseInt(r.slice(2,3).repeat(2),16),me=parseInt(r.slice(3,4).repeat(2),16),ce.toColor(pe,ve,me);case 5:return pe=parseInt(r.slice(1,2).repeat(2),16),ve=parseInt(r.slice(2,3).repeat(2),16),me=parseInt(r.slice(3,4).repeat(2),16),ie=parseInt(r.slice(4,5).repeat(2),16),ce.toColor(pe,ve,me,ie);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return pe=parseInt(n[1]),ve=parseInt(n[2]),me=parseInt(n[3]),ie=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ce.toColor(pe,ve,me,ie);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[pe,ve,me,ie]=e.getImageData(0,0,1,1).data,ie!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ce.toRgba(pe,ve,me,ie),css:r}}t.toColor=s})(ee||={});var Re;(t=>{function e(s){return i(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function i(s,r,n){let o=s/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}t.relativeLuminance2=i})(Re||={});var Qi;(t=>{function e(o,a){if(ie=(a&255)/255,ie===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,_=o>>8&255;return pe=d+Math.round((l-d)*ie),ve=u+Math.round((h-u)*ie),me=_+Math.round((c-_)*ie),ce.toRgba(pe,ve,me)}t.blend=e;function i(o,a,l){let h=Re.relativeLuminance(o>>8),c=Re.relativeLuminance(a>>8);if(_t(h,c)<l){if(c<h){let _=s(o,a,l),f=_t(h,Re.relativeLuminance(_>>8));if(f<l){let S=r(o,a,l),k=_t(h,Re.relativeLuminance(S>>8));return f>k?_:S}return _}let d=r(o,a,l),u=_t(h,Re.relativeLuminance(d>>8));if(u<l){let _=s(o,a,l),f=_t(h,Re.relativeLuminance(_>>8));return u>f?d:_}return d}}t.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=_t(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));for(;S<l&&(u>0||_>0||f>0);)u-=Math.max(0,Math.ceil(u*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),S=_t(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=s;function r(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=_t(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));for(;S<l&&(u<255||_<255||f<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),S=_t(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(Qi||={});function It(t){let e=t.toString(16);return e.length<2?"0"+e:e}function _t(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var Al=class extends Pi{constructor(e,i,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},os=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Je}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let i=[],s=e.translateToString(!0),r=0,n=0,o=0,a=e.getFg(0),l=e.getBg(0);for(let h=0;h<e.getTrimmedLength();h++)if(e.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let c=this._getJoinedRanges(s,o,n,e,r);for(let d=0;d<c.length;d++)i.push(c[d])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||Pt.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,e,r);for(let c=0;c<h.length;c++)i.push(h[c])}return i}_getJoinedRanges(t,e,i,s,r){let n=t.substring(e,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(n);for(let h=0;h<l.length;h++)os._mergeRanges(o,l[h])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(t,e,i){let s=0,r=!1,n=0,o=t[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let l=e.getWidth(a),h=e.getString(a).length||Pt.length;if(l!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=t[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let i=!1;for(let s=0;s<t.length;s++){let r=t[s];if(i){if(e[1]<=r[0])return t[s-1][1]=e[1],t;if(e[1]<=r[1])return t[s-1][1]=Math.max(e[1],r[1]),t.splice(s,1),t;t.splice(s,1),s--}else{if(e[1]<=r[0])return t.splice(s,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),i=!0);continue}}return i?t[t.length-1][1]=e[1]:t.push(e),t}};os=re([T(0,Te)],os);function Tl(t){return 57508<=t&&t<=57558}function Pl(t){return 9472<=t&&t<=9631}function Ol(t){return Tl(t)||Pl(t)}function Il(){return{css:{canvas:zi(),cell:zi()},device:{canvas:zi(),cell:zi(),char:{width:0,height:0,left:0,top:0}}}}function zi(){return{width:0,height:0}}var vr=class{constructor(e,i,s,r,n,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=s,this._coreBrowserService=r,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new Je,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,s){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=s}createRow(e,i,s,r,n,o,a,l,h,c,d){let u=[],_=this._characterJoinerService.getJoinedCharacters(i),f=this._themeService.colors,S=e.getNoBgTrimmedLength();s&&S<o+1&&(S=o+1);let k,A=0,D="",B=0,w=0,R=0,P=0,N=!1,G=0,ae=!1,Ee=0,W=0,p=[],g=c!==-1&&d!==-1;for(let v=0;v<S;v++){e.loadCell(v,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let y=!1,b=v>=W,L=v,C=this._workCell;if(_.length>0&&v===_[0][0]&&b){let H=_.shift(),li=this._isCellInSelection(H[0],i);for(B=H[0]+1;B<H[1];B++)b&&=li===this._isCellInSelection(B,i);b&&=!s||o<H[0]||o>=H[1],b?(y=!0,C=new Al(this._workCell,e.translateToString(!0,H[0],H[1]),H[1]-H[0]),L=H[1]-1,m=C.getWidth()):W=H[1]}let M=this._isCellInSelection(v,i),I=s&&v===o,Y=g&&v>=c&&v<=d,z=!1;this._decorationService.forEachDecorationAtCell(v,i,void 0,H=>{z=!0});let Oe=C.getChars()||Pt;if(Oe===" "&&(C.isUnderline()||C.isOverline())&&(Oe=" "),Ee=m*l-h.get(Oe,C.isBold(),C.isItalic()),!k)k=this._document.createElement("span");else if(A&&(M&&ae||!M&&!ae&&C.bg===w)&&(M&&ae&&f.selectionForeground||C.fg===R)&&C.extended.ext===P&&Y===N&&Ee===G&&!I&&!y&&!z&&b){C.isInvisible()?D+=Pt:D+=Oe,A++;continue}else A&&(k.textContent=D),k=this._document.createElement("span"),A=0,D="";if(w=C.bg,R=C.fg,P=C.extended.ext,N=Y,G=Ee,ae=M,y&&o>=v&&o<=L&&(o=v),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(p.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&p.push("xterm-cursor-blink"),p.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":p.push("xterm-cursor-outline");break;case"block":p.push("xterm-cursor-block");break;case"bar":p.push("xterm-cursor-bar");break;case"underline":p.push("xterm-cursor-underline");break}}if(C.isBold()&&p.push("xterm-bold"),C.isItalic()&&p.push("xterm-italic"),C.isDim()&&p.push("xterm-dim"),C.isInvisible()?D=Pt:D=C.getChars()||Pt,C.isUnderline()&&(p.push(`xterm-underline-${C.extended.underlineStyle}`),D===" "&&(D=" "),!C.isUnderlineColorDefault()))if(C.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Pi.toColorRGB(C.getUnderlineColor()).join(",")})`;else{let H=C.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&C.isBold()&&H<8&&(H+=8),k.style.textDecorationColor=f.ansi[H].css}C.isOverline()&&(p.push("xterm-overline"),D===" "&&(D=" ")),C.isStrikethrough()&&p.push("xterm-strikethrough"),Y&&(k.style.textDecoration="underline");let U=C.getFgColor(),ye=C.getFgColorMode(),K=C.getBgColor(),V=C.getBgColorMode(),xe=!!C.isInverse();if(xe){let H=U;U=K,K=H;let li=ye;ye=V,V=li}let qe,ut,it=!1;this._decorationService.forEachDecorationAtCell(v,i,void 0,H=>{H.options.layer!=="top"&&it||(H.backgroundColorRGB&&(V=50331648,K=H.backgroundColorRGB.rgba>>8&16777215,qe=H.backgroundColorRGB),H.foregroundColorRGB&&(ye=50331648,U=H.foregroundColorRGB.rgba>>8&16777215,ut=H.foregroundColorRGB),it=H.options.layer==="top")}),!it&&M&&(qe=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,K=qe.rgba>>8&16777215,V=50331648,it=!0,f.selectionForeground&&(ye=50331648,U=f.selectionForeground.rgba>>8&16777215,ut=f.selectionForeground)),it&&p.push("xterm-decoration-top");let Qe;switch(V){case 16777216:case 33554432:Qe=f.ansi[K],p.push(`xterm-bg-${K}`);break;case 50331648:Qe=ce.toColor(K>>16,K>>8&255,K&255),this._addStyle(k,`background-color:#${Ln((K>>>0).toString(16),"0",6)}`);break;default:xe?(Qe=f.foreground,p.push("xterm-bg-257")):Qe=f.background}switch(qe||C.isDim()&&(qe=j.multiplyOpacity(Qe,.5)),ye){case 16777216:case 33554432:C.isBold()&&U<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(U+=8),this._applyMinimumContrast(k,Qe,f.ansi[U],C,qe,void 0)||p.push(`xterm-fg-${U}`);break;case 50331648:let H=ce.toColor(U>>16&255,U>>8&255,U&255);this._applyMinimumContrast(k,Qe,H,C,qe,ut)||this._addStyle(k,`color:#${Ln(U.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(k,Qe,f.foreground,C,qe,ut)||xe&&p.push("xterm-fg-257")}p.length&&(k.className=p.join(" "),p.length=0),!I&&!y&&!z&&b?A++:k.textContent=D,Ee!==this.defaultSpacing&&(k.style.letterSpacing=`${Ee}px`),u.push(k),v=L}return k&&A&&(k.textContent=D),u}_applyMinimumContrast(e,i,s,r,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ol(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!n&&!o&&(l=a.getColor(i.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=j.ensureContrastRatio(n||i,o||s,h),a.setColor((n||i).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&i>=s[1]&&e<r[0]&&i<=r[1]:e<s[0]&&i>=s[1]&&e>=r[0]&&i<=r[1]:i>s[1]&&i<r[1]||s[1]===r[1]&&i===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&i===r[1]&&e<r[0]||s[1]<r[1]&&i===s[1]&&e>=s[0]}};vr=re([T(1,No),T(2,Pe),T(3,xt),T(4,Gt),T(5,Oi),T(6,oi)],vr);function Ln(t,e,i){for(;t.length<i;)t=e+t;return t}var $l=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,r,n,o],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(o),i.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,i,s,r){e===this._font&&i===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=i,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,i,s){let r=0;if(!i&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let a=this._measure(e,0);return a>0&&(this._flat[r]=a),a}let n=e;i&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;i&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,i){let s=this._measureElements[i];return s.textContent=e.repeat(32),s.offsetWidth/32}},Fl=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,i,s,r=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=i[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=s[0]}isCellSelected(e,i,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&s>=this.viewportCappedStartRow&&i<this.endCol&&s<=this.viewportCappedEndRow:i<this.startCol&&s>=this.viewportCappedStartRow&&i>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol):!1}};function Nl(){return new Fl}var Es="xterm-dom-renderer-owner-",Ke="xterm-rows",Hi="xterm-fg-",En="xterm-bg-",di="xterm-focus",Ui="xterm-selection",Wl=1,mr=class extends F{constructor(e,i,s,r,n,o,a,l,h,c,d,u,_,f){super(),this._terminal=e,this._document=i,this._element=s,this._screenElement=r,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=_,this._themeService=f,this._terminalClass=Wl++,this._rowElements=[],this._selectionRenderModel=Nl(),this.onRequestRedraw=this._register(new E).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ke),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(Ui),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Il(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(vr,document),this._element.classList.add(Es+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(J(()=>{this._element.classList.remove(Es+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new $l(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${Ke} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,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 i=`${this._terminalSelector} .${Ke} { 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}`;i+=`${this._terminalSelector} .${Ke} .xterm-dim { color: ${j.multiplyOpacity(e.foreground,.5).css};}`,i+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;i+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,i+=`@keyframes ${r} { 50% { box-shadow: none; }}`,i+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,i+=`${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${Ui} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ui} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ui} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())i+=`${this._terminalSelector} .${Hi}${o} { color: ${a.css}; }${this._terminalSelector} .${Hi}${o}.xterm-dim { color: ${j.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${En}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${Hi}257 { color: ${j.opaque(e.background).css}; }${this._terminalSelector} .${Hi}257.xterm-dim { color: ${j.multiplyOpacity(j.opaque(e.background),.5).css}; }${this._terminalSelector} .${En}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_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,i){for(let s=this._rowElements.length;s<=i;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),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(di),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(di),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,s),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>i[0];l.appendChild(this._createSelectionElement(o,h?i[0]:e[0],h?e[0]:i[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===n?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let d=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,d)),o!==a){let u=n===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,s,r=1){let n=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${r*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let s=this._bufferService.buffer,r=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===r,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Es}${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,i,s,r,n,o){s<0&&(e=0),r<0&&(i=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=r;++f){let S=f+l.ydisp,k=this._rowElements[f],A=l.lines.get(S);if(!k||!A)break;k.replaceChildren(...this._rowFactory.createRow(A,S,S===h,u,_,c,d,this.dimensions.css.cell.width,this._widthCache,o?f===s?e:0:-1,o?(f===r?i:n)-1:-1))}}};mr=re([T(7,Hr),T(8,gs),T(9,Pe),T(10,Te),T(11,Gt),T(12,xt),T(13,oi)],mr);var Sr=class extends F{constructor(e,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new E),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Hl(this._optionsService))}catch{this._measureStrategy=this._register(new zl(e,i,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())}};Sr=re([T(2,Pe)],Sr);var ra=class extends F{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},zl=class extends ra{constructor(t,e,i){super(),this._document=t,this._parentElement=e,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}},Hl=class extends ra{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))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}},Ul=class extends F{constructor(e,i,s){super(),this._textarea=e,this._window=i,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new ql(this._window)),this._onDprChange=this._register(new E),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new E),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Le.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(O(this._textarea,"focus",()=>this._isFocused=!0)),this._register(O(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},ql=class extends F{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ni),this._onDprChange=this._register(new E),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(J(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=O(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}},Kl=class extends F{constructor(){super(),this.linkProviders=[],this._register(J(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function jr(t,e,i){let s=i.getBoundingClientRect(),r=t.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-s.left-n,e.clientY-s.top-o]}function Vl(t,e,i,s,r,n,o,a,l){if(!n)return;let h=jr(t,e,i);if(h)return 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}var wr=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,s,r,n){return Vl(window,e,i,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,i){let s=jr(window,e,i);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};wr=re([T(0,kt),T(1,gs)],wr);var Gl=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,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,i,s){this._rowCount=s,e=e!==void 0?e:0,i=i!==void 0?i:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,i):i,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},na={};sh(na,{getSafariVersion:()=>Xl,isChromeOS:()=>la,isFirefox:()=>oa,isIpad:()=>jl,isIphone:()=>Zl,isLegacyEdge:()=>Yl,isLinux:()=>Zr,isMac:()=>as,isNode:()=>ps,isSafari:()=>aa,isWindows:()=>ha});var ps=typeof process<"u"&&"title"in process,Ii=ps?"node":navigator.userAgent,$i=ps?"node":navigator.platform,oa=Ii.includes("Firefox"),Yl=Ii.includes("Edge"),aa=/^((?!chrome|android).)*safari/i.test(Ii);function Xl(){if(!aa)return 0;let t=Ii.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var as=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($i),jl=$i==="iPad",Zl=$i==="iPhone",ha=["Windows","Win16","Win32","WinCE"].includes($i),Zr=$i.indexOf("Linux")>=0,la=/\bCrOS\b/.test(Ii),ca=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,s=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),r=t.timeRemaining(),i*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},Jl=class extends ca{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},Ql=class extends ca{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},hs=!ps&&"requestIdleCallback"in window?Ql:Jl,ec=class{constructor(){this._queue=new hs}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},br=class extends F{constructor(e,i,s,r,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new ni),this._pausedResizeTask=new ec,this._observerDisposable=this._register(new ni),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 E),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new E),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new E),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new E),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Gl((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new tc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(J(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(i),this._observerDisposable.value=J(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),i=Math.max(i,r.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),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:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,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(i=>this.refreshRows(i.start,i.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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,s){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,i,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};br=re([T(2,Pe),T(3,gs),T(4,Gt),T(5,Oi),T(6,Te),T(7,xt),T(8,oi)],br);var tc=class{constructor(t,e,i){this._coreBrowserService=t,this._coreService=e,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function ic(t,e,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return nc(r,n,t,e,i,s)+vs(n,e,i,s)+oc(r,n,t,e,i,s);let o;if(n===e)return o=r>t?"D":"C",Mi(Math.abs(r-t),Ei(o,s));o=n>e?"D":"C";let a=Math.abs(n-e),l=rc(n>e?t:r,i)+(a-1)*i.cols+1+sc(n>e?r:t);return Mi(l,Ei(o,s))}function sc(t,e){return t-1}function rc(t,e){return e.cols-t}function nc(t,e,i,s,r,n){return vs(e,s,r,n).length===0?"":Mi(ua(t,e,t,e-Vt(e,r),!1,r).length,Ei("D",n))}function vs(t,e,i,s){let r=t-Vt(t,i),n=e-Vt(e,i),o=Math.abs(r-n)-ac(t,e,i);return Mi(o,Ei(da(t,e),s))}function oc(t,e,i,s,r,n){let o;vs(e,s,r,n).length>0?o=s-Vt(s,r):o=e;let a=s,l=hc(t,e,i,s,r,n);return Mi(ua(t,o,i,a,l==="C",r).length,Ei(l,n))}function ac(t,e,i){let s=0,r=t-Vt(t,i),n=e-Vt(e,i);for(let o=0;o<Math.abs(r-n);o++){let a=da(t,e)==="A"?-1:1;i.buffer.lines.get(r+a*o)?.isWrapped&&s++}return s}function Vt(t,e){let i=0,s=e.buffer.lines.get(t),r=s?.isWrapped;for(;r&&t>=0&&t<e.rows;)i++,s=e.buffer.lines.get(--t),r=s?.isWrapped;return i}function hc(t,e,i,s,r,n){let o;return vs(i,s,r,n).length>0?o=s-Vt(s,r):o=e,t<i&&o<=s||t>=i&&o<s?"C":"D"}function da(t,e){return t>e?"A":"B"}function ua(t,e,i,s,r,n){let o=t,a=e,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,t,o),o=0,t=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,t+1),o=n.cols-1,t=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,t,o)}function Ei(t,e){let i=e?"O":"[";return x.ESC+i+t}function Mi(t,e){t=Math.floor(t);let i="";for(let s=0;s<t;s++)i+=e;return i}var lc=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Mn(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Ms=50,cc=15,dc=50,uc=500,_c=" ",fc=new RegExp(_c,"g"),Cr=class extends F{constructor(e,i,s,r,n,o,a,l,h){super(),this._element=e,this._screenElement=i,this._linkifier=s,this._bufferService=r,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Je,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new E),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new E),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new E),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new E),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new lc(this._bufferService),this._activeSelectionMode=0,this._register(J(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!e||!i?!1:e[0]!==i[0]||e[1]!==i[1]}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===i[0])return"";let n=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);r.push(l)}}else{let n=e[1]===i[1]?i[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=i[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?r[r.length-1]+=l:r.push(l)}if(e[1]!==i[1]){let o=s.lines.get(i[1]),a=s.translateBufferLineToString(i[1],!0,0,i[0]);o&&o.isWrapped?r[r.length-1]+=a:r.push(a)}}return r.map(n=>n.replace(fc," ")).join(ha?`\r
9
+ `))}},Oh=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Ih=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},$h=0,ks=class{constructor(e){this.value=e,this.id=$h++}},Fh=2,Nh,E=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Th(t?.onListenerError??Zi,this._options?.leakWarningThreshold??Dh):void 0,this._perfMon=this._options?._profName?new Ah(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Ih(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||Zi)(l),F.None}if(this._disposed)return F.None;e&&(t=t.bind(e));let s=new ks(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Ph.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof ks?(this._deliveryQueue??=new Wh,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=J(()=>{r?.(),this._removeListener(s)});return i instanceof Ot?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Fh<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||Zi;if(!i){t.value(e);return}try{t.value(e)}catch(s){i(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof ks)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Wh=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,s){this.i=0,this.end=s,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},lr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new E,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new E,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};lr.INSTANCE=new lr;var Gr=lr;function zh(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}Gr.INSTANCE.onDidChangeZoomLevel;function Hh(t){return Gr.INSTANCE.getZoomFactor(t)}Gr.INSTANCE.onDidChangeFullscreen;var ai=typeof navigator=="object"?navigator.userAgent:"",cr=ai.indexOf("Firefox")>=0,Uh=ai.indexOf("AppleWebKit")>=0,Yr=ai.indexOf("Chrome")>=0,qh=!Yr&&ai.indexOf("Safari")>=0;ai.indexOf("Electron/")>=0;ai.indexOf("Android")>=0;var Ls=!1;if(typeof Ct.matchMedia=="function"){let t=Ct.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Ct.matchMedia("(display-mode: fullscreen)");Ls=t.matches,zh(Ct,t,({matches:i})=>{Ls&&e.matches||(Ls=i)})}var ei="en",dr=!1,ur=!1,Ji=!1,Qo=!1,Wi,Qi=ei,gn=ei,Kh,mt,Ht=globalThis,ze;typeof Ht.vscode<"u"&&typeof Ht.vscode.process<"u"?ze=Ht.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(ze=process);var Vh=typeof ze?.versions?.electron=="string",Gh=Vh&&ze?.type==="renderer";if(typeof ze=="object"){dr=ze.platform==="win32",ur=ze.platform==="darwin",Ji=ze.platform==="linux",Ji&&ze.env.SNAP&&ze.env.SNAP_REVISION,ze.env.CI||ze.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Wi=ei,Qi=ei;let t=ze.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Wi=e.userLocale,gn=e.osLocale,Qi=e.resolvedLanguage||ei,Kh=e.languagePack?.translationsConfigFile}catch{}Qo=!0}else typeof navigator=="object"&&!Gh?(mt=navigator.userAgent,dr=mt.indexOf("Windows")>=0,ur=mt.indexOf("Macintosh")>=0,(mt.indexOf("Macintosh")>=0||mt.indexOf("iPad")>=0||mt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ji=mt.indexOf("Linux")>=0,mt?.indexOf("Mobi")>=0,Qi=globalThis._VSCODE_NLS_LANGUAGE||ei,Wi=navigator.language.toLowerCase(),gn=Wi):console.error("Unable to resolve platform.");var ea=dr,lt=ur,Yh=Ji,pn=Qo,ct=mt,Et=Qi,Xh;(t=>{function e(){return Et}t.value=e;function i(){return Et.length===2?Et==="en":Et.length>=3?Et[0]==="e"&&Et[1]==="n"&&Et[2]==="-":!1}t.isDefaultVariant=i;function s(){return Et==="en"}t.isDefault=s})(Xh||={});var jh=typeof Ht.postMessage=="function"&&!Ht.importScripts;(()=>{if(jh){let t=[];Ht.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=t.length;s<r;s++){let n=t[s];if(n.id===i.data.vscodeScheduleAsyncWork){t.splice(s,1),n.callback();return}}});let e=0;return i=>{let s=++e;t.push({id:s,callback:i}),Ht.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var Zh=!!(ct&&ct.indexOf("Chrome")>=0);ct&&ct.indexOf("Firefox")>=0;!Zh&&ct&&ct.indexOf("Safari")>=0;ct&&ct.indexOf("Edg/")>=0;ct&&ct.indexOf("Android")>=0;var Yt=typeof navigator=="object"?navigator:{};pn||document.queryCommandSupported&&document.queryCommandSupported("copy")||Yt&&Yt.clipboard&&Yt.clipboard.writeText,pn||Yt&&Yt.clipboard&&Yt.clipboard.readText;var Xr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Es=new Xr,vn=new Xr,mn=new Xr,Jh=new Array(230),ta;(t=>{function e(a){return Es.keyCodeToStr(a)}t.toString=e;function i(a){return Es.strToKeyCode(a)}t.fromString=i;function s(a){return vn.keyCodeToStr(a)}t.toUserSettingsUS=s;function r(a){return mn.keyCodeToStr(a)}t.toUserSettingsGeneral=r;function n(a){return vn.strToKeyCode(a)||mn.strToKeyCode(a)}t.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Es.keyCodeToStr(a)}t.toElectronAccelerator=o})(ta||={});var Qh=class ia{constructor(e,i,s,r,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof ia&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new el([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},el=class{constructor(t){if(t.length===0)throw kh("chords");this.chords=t}getHashCode(){let t="";for(let e=0,i=this.chords.length;e<i;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function tl(t){if(t.charCode){let i=String.fromCharCode(t.charCode).toUpperCase();return ta.fromString(i)}let e=t.keyCode;if(e===3)return 7;if(cr)switch(e){case 59:return 85;case 60:if(Yh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(lt)return 57;break}else if(Uh&&(lt&&e===93||!lt&&e===92))return 57;return Jh[e]||0}var il=lt?256:2048,sl=512,rl=1024,nl=lt?2048:256,Sn=class{constructor(t){this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=tl(e),this.code=e.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=il),this.altKey&&(e|=sl),this.shiftKey&&(e|=rl),this.metaKey&&(e|=nl),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new Qh(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},wn=new WeakMap;function ol(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,i=t.parent.location;if(e.origin!=="null"&&i.origin!=="null"&&e.origin!==i.origin)return null}catch{return null}return t.parent}var al=class{static getSameOriginWindowChain(t){let e=wn.get(t);if(!e){e=[],wn.set(t,e);let i=t,s;do s=ol(i),s?e.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):e.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(t);for(let n of r){let o=n.window.deref();if(i+=o?.scrollY??0,s+=o?.scrollX??0,o===e||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},zi=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=i.button===0,this.middleButton=i.button===1,this.rightButton=i.button===2,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,i.type==="dblclick"&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,typeof i.pageX=="number"?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=al.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},bn=class{constructor(e,i=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=i;let r=!1;if(Yr){let n=navigator.userAgent.match(/Chrome\/(\d+)/);r=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=e.view?.devicePixelRatio||1;if(typeof n.wheelDeltaY<"u")r?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?cr&&!lt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")qh&&ea?this.deltaX=-(n.wheelDeltaX/120):r?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?cr&&!lt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},sa=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),hl;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof ll?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Le.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sa})})(hl||={});var ll=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?sa:(this._emitter||(this._emitter=new E),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},jr=class{constructor(e,i){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof i=="number"&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new rr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new rr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},cl=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,s=globalThis){if(this.isDisposed)throw new rr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},i);this.disposable=J(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},dl;(t=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}t.withAsyncBody=i})(dl||={});var Cn=class Ve{static fromArray(e){return new Ve(i=>{i.emitMany(e)})}static fromPromise(e){return new Ve(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Ve(async i=>{await Promise.all(e.map(async s=>i.emitOne(await s)))})}static merge(e){return new Ve(async i=>{await Promise.all(e.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new E,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Le.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Ve(async s=>{for await(let r of e)s.emitOne(i(r))})}map(e){return Ve.map(this,e)}static filter(e,i){return new Ve(async s=>{for await(let r of e)i(r)&&s.emitOne(r)})}filter(e){return Ve.filter(this,e)}static coalesce(e){return Ve.filter(e,i=>!!i)}coalesce(){return Ve.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return Ve.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Cn.EMPTY=Cn.fromArray([]);var{getWindow:ht,getWindowId:ul,onDidRegisterWindow:_l}=(function(){let t=new Map,e={window:Ct,disposables:new Ot};t.set(Ct.vscodeWindowId,e);let i=new E,s=new E,r=new E;function n(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(t.has(o.vscodeWindowId))return F.None;let a=new Ot,l={window:o,disposables:a.add(new Ot)};return t.set(o.vscodeWindowId,l),a.add(J(()=>{t.delete(o.vscodeWindowId),s.fire(o)})),a.add(O(o,ge.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(l),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:Ct},getDocument(o){return ht(o).document}}})(),fl=class{constructor(e,i,s,r){this._node=e,this._type=i,this._handler=s,this._options=r||!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 O(t,e,i,s){return new fl(t,e,i,s)}var yn=function(t,e,i,s){return O(t,e,i,s)},Zr,gl=class extends cl{constructor(t){super(),this.defaultTarget=t&&ht(t)}cancelAndSet(t,e,i){return super.cancelAndSet(t,e,i??this.defaultTarget)}},xn=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Zi(e)}}static sort(e,i){return i.priority-e.priority}};(function(){let t=new Map,e=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=t.get(n)??[];for(e.set(n,o),t.set(n,[]),s.set(n,!0);o.length>0;)o.sort(xn.sort),o.shift().execute();s.set(n,!1)};Zr=(n,o,a=0)=>{let l=ul(n),h=new xn(o,a),c=t.get(l);return c||(c=[],t.set(l,c)),c.push(h),i.get(l)||(i.set(l,!0),n.requestAnimationFrame(()=>r(l))),h}})();function pl(t){let e=t.getBoundingClientRect(),i=ht(t);return{left:e.left+i.scrollX,top:e.top+i.scrollY,width:e.width,height:e.height}}var ge={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"},vl=class{constructor(t){this.domNode=t,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(t){let e=Ie(t);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let e=Ie(t);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(t){let e=Ie(t);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(t){let e=Ie(t);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(t){let e=Ie(t);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(t){let e=Ie(t);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(t){let e=Ie(t);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(t){let e=Ie(t);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let e=Ie(t);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let e=Ie(t);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let e=Ie(t);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let e=Ie(t);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let e=Ie(t);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let e=Ie(t);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,e){this.domNode.classList.toggle(t,e),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,e){this.domNode.setAttribute(t,e)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Ie(t){return typeof t=="number"?`${t}px`:t}function Li(t){return new vl(t)}var ra=class{constructor(){this._hooks=new Ot,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,s,r,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=n;let o=e;try{e.setPointerCapture(i),this._hooks.add(J(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=ht(e)}this._hooks.add(O(o,ge.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(O(o,ge.POINTER_UP,a=>this.stopMonitoring(!0)))}};function ml(t,e,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${e}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var at;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(at||={});var wi=class Me extends F{constructor(){super(),this.dispatched=!1,this.targets=new fn,this.ignoreTargets=new fn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Le.runAndSubscribe(_l,({window:e,disposables:i})=>{i.add(O(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(O(e.document,"touchend",s=>this.onTouchEnd(e,s))),i.add(O(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Ct,disposables:this._store}))}static addTarget(e){if(!Me.isTouchDevice())return F.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.targets.push(e);return J(i)}static ignoreTarget(e){if(!Me.isTouchDevice())return F.None;Me.INSTANCE||(Me.INSTANCE=new Me);let i=Me.INSTANCE.ignoreTargets.push(e);return J(i)}static isTouchDevice(){return"ontouchstart"in Ct||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=e.targetTouches.length;s<r;s++){let n=e.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(at.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<Me.HOLD_DELAY&&Math.abs(l.initialPageX-Fe(l.rollingPageX))<30&&Math.abs(l.initialPageY-Fe(l.rollingPageY))<30){let c=this.newGestureEvent(at.Tap,l.initialTarget);c.pageX=Fe(l.rollingPageX),c.pageY=Fe(l.rollingPageY),this.dispatchEvent(c)}else if(h>=Me.HOLD_DELAY&&Math.abs(l.initialPageX-Fe(l.rollingPageX))<30&&Math.abs(l.initialPageY-Fe(l.rollingPageY))<30){let c=this.newGestureEvent(at.Contextmenu,l.initialTarget);c.pageX=Fe(l.rollingPageX),c.pageY=Fe(l.rollingPageY),this.dispatchEvent(c)}else if(r===1){let c=Fe(l.rollingPageX),d=Fe(l.rollingPageY),u=Fe(l.rollingTimestamps)-l.rollingTimestamps[0],_=c-l.rollingPageX[0],f=d-l.rollingPageY[0],S=[...this.targets].filter(k=>l.initialTarget instanceof Node&&k.contains(l.initialTarget));this.inertia(e,S,s,Math.abs(_)/u,_>0?1:-1,c,Math.abs(f)/u,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(at.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(e){if(e.type===at.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Me.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,e.tapCount=s}else(e.type===at.Change||e.type===at.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let r=0,n=e.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,i,s,r,n,o,a,l,h){this.handle=Zr(e,()=>{let c=Date.now(),d=c-s,u=0,_=0,f=!0;r+=Me.SCROLL_FRICTION*d,a+=Me.SCROLL_FRICTION*d,r>0&&(f=!1,u=n*r*d),a>0&&(f=!1,_=l*a*d);let S=this.newGestureEvent(at.Change);S.translationX=u,S.translationY=_,i.forEach(k=>k.dispatchEvent(S)),f||this.inertia(e,i,c,r,n,o+u,a,l,h+_)})}onTouchMove(e){let i=Date.now();for(let s=0,r=e.changedTouches.length;s<r;s++){let n=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(at.Change,o.initialTarget);a.translationX=n.pageX-Fe(o.rollingPageX),a.translationY=n.pageY-Fe(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};wi.SCROLL_FRICTION=-.005,wi.HOLD_DELAY=700,wi.CLEAR_TAP_COUNT_TIME=400,re([ml],wi,"isTouchDevice",1);var Sl=wi,Jr=class extends F{onclick(e,i){this._register(O(e,ge.CLICK,s=>i(new zi(ht(e),s))))}onmousedown(e,i){this._register(O(e,ge.MOUSE_DOWN,s=>i(new zi(ht(e),s))))}onmouseover(e,i){this._register(O(e,ge.MOUSE_OVER,s=>i(new zi(ht(e),s))))}onmouseleave(e,i){this._register(O(e,ge.MOUSE_LEAVE,s=>i(new zi(ht(e),s))))}onkeydown(e,i){this._register(O(e,ge.KEY_DOWN,s=>i(new Sn(s))))}onkeyup(e,i){this._register(O(e,ge.KEY_UP,s=>i(new Sn(s))))}oninput(e,i){this._register(O(e,ge.INPUT,i))}onblur(e,i){this._register(O(e,ge.BLUR,i))}onfocus(e,i){this._register(O(e,ge.FOCUS,i))}onchange(e,i){this._register(O(e,ge.CHANGE,i))}ignoreGesture(e){return Sl.ignoreTarget(e)}},kn=11,wl=class extends Jr{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=kn+"px",this.domNode.style.height=kn+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new ra),this._register(yn(this.bgDomNode,ge.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(yn(this.domNode,ge.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new gl),this._pointerdownScheduleRepeatTimer=this._register(new jr)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ht(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},bl=class _r{constructor(e,i,s,r,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(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(e,i){return new _r(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new _r(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let s=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},Cl=class extends F{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new bl(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){let i=this._state.withScrollDimensions(t,e);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let i=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;e?s=new En(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=En.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let i=this._state;i.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(i,e)))}},Ln=class{constructor(e,i,s){this.scrollLeft=e,this.scrollTop=i,this.isDone=s}};function Ms(t,e){let i=e-t;return function(s){return t+i*kl(s)}}function yl(t,e,i){return function(s){return s<i?t(s/i):e((s-i)/(1-i))}}var En=class fr{constructor(e,i,s,r){this.from=e,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,i,s){if(Math.abs(e-i)>2.5*s){let r,n;return e<i?(r=e+.75*s,n=i-.75*s):(r=e-.75*s,n=i+.75*s),yl(Ms(e,r),Ms(n,i),.33)}return Ms(e,i)}dispose(){this.animationFrameDisposable!==null&&(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 i=(e-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new Ln(s,r,!1)}return new Ln(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,i,s){return fr.start(e,i,s)}static start(e,i,s){s=s+10;let r=Date.now()-10;return new fr(e,i,r,s)}};function xl(t){return Math.pow(t,3)}function kl(t){return 1-xl(1-t)}var Ll=class extends F{constructor(e,i,s){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new jr)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},El=140,na=class extends Jr{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 Ll(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ra),this._shouldRender=!0,this.domNode=Li(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(O(this.domNode.domNode,ge.POINTER_DOWN,i=>this._domNodePointerDown(i)))}_createArrow(e){let i=this._register(new wl(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,s,r){this.slider=Li(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(O(this.slider.domNode,ge.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,s=i+this._scrollbarState.getSliderPosition(),r=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")i=e.offsetX,s=e.offsetY;else{let n=pl(this.domNode.domNode);i=e.pageX-n.left,s=e.pageY-n.top}let r=this._pointerDownRelativePosition(i,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(ea&&a>El){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let l=this._sliderPointerPosition(n)-i;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},oa=class gr{constructor(e,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new gr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,s,r,n){let o=Math.max(0,s-e),a=Math.max(0,o-2*i),l=r>0&&r>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-h)/(r-s),d=n*c;return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let e=gr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.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 i=e-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+e;return Math.round(i/this._computedSliderRatio)}},Ml=class extends na{constructor(e,i,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new oa(i.horizontalHasArrows?i.arrowSize:0,i.horizontal===2?0:i.horizontalScrollbarSize,i.vertical===2?0:i.verticalScrollbarSize,r.width,r.scrollWidth,n.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),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,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Bl=class extends na{constructor(t,e,i){let s=t.getScrollDimensions(),r=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:i,scrollbarState:new oa(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},Rl=500,Mn=50,Al=class{constructor(e,i,s){this.timestamp=e,this.deltaX=i,this.deltaY=s,this.score=0}},pr=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,i=0,s=1,r=this._rear;do{let n=r===this._front?e:Math.pow(2,-s);if(e-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(e){if(Yr){let i=ht(e.browserEvent),s=Hh(i);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,s){let r=null,n=new Al(e,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),i){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(r,o),d=Math.max(n,a);c%l===0&&d%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};pr.INSTANCE=new pr;var Dl=pr,Tl=class extends Jr{constructor(t,e,i){super(),this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new E),this.onWillScroll=this._onWillScroll.event,this._options=Ol(e),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Bl(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Ml(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(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Li(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Li(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Li(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new jr),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Kt(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,lt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new bn(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Kt(this._mouseWheelToDispose),t)){let e=i=>{this._onMouseWheel(new bn(i))};this._mouseWheelToDispose.push(O(this._listenOnDomNode,ge.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let e=Dl.INSTANCE;e.acceptStandardWheelEvent(t);let i=!1;if(t.deltaY||t.deltaX){let r=t.deltaY*this._options.mouseWheelScrollSensitivity,n=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let o=!lt&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=r,r=0),t.browserEvent&&t.browserEvent.altKey&&(n=n*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(r){let h=Mn*r,c=a.scrollTop-(h<0?Math.floor(h):Math.ceil(h));this._verticalScrollbar.writeScrollPosition(l,c)}if(n){let h=Mn*n,c=a.scrollLeft-(h<0?Math.floor(h):Math.ceil(h));this._horizontalScrollbar.writeScrollPosition(l,c)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||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 t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,i=t.scrollLeft>0,s=i?" left":"",r=e?" top":"",n=i||e?" 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(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){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(),Rl)}},Pl=class extends Tl{constructor(e,i,s){super(e,i,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Ol(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,lt&&(e.className+=" mac"),e}var vr=class extends F{constructor(e,i,s,r,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new E),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Cl({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>Zr(r.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Pl(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Le.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(J(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(J(()=>this._styleElement.remove())),this._register(Le.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
10
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=i-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=i,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};vr=re([T(2,Te),T(3,kt),T(4,Wo),T(5,oi),T(6,Pe),T(7,Lt)],vr);var mr=class extends F{constructor(e,i,s,r,n){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=s,this._decorationService=r,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(J(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),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 i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,i=e.element){if(!i)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?i.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};mr=re([T(1,Te),T(2,kt),T(3,Ii),T(4,Lt)],mr);var Il=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 i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(i,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,s){return i>=e.startBufferLine-this._linePadding[s||"full"]&&i<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},rt={full:0,left:0,center:0,right:0},Mt={full:0,left:0,center:0,right:0},ci={full:0,left:0,center:0,right:0},as=class extends F{constructor(e,i,s,r,n,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=s,this._decorationService=r,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Il,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(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(J(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);Mt.full=this._canvas.width,Mt.left=e,Mt.center=i,Mt.right=e,this._refreshDrawHeightConstants(),ci.full=1,ci.left=1,ci.center=1+Mt.left,ci.right=1+Mt.left+Mt.center}_refreshDrawHeightConstants(){rt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,i=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);rt.left=i,rt.center=i,rt.right=i}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let i of this._decorationService.decorations)this._colorZoneStore.addDecoration(i);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)i.position!=="full"&&this._renderColorZone(i);for(let i of e)i.position==="full"&&this._renderColorZone(i);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(ci[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-rt[e.position||"full"]/2),Mt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+rt[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};as=re([T(2,Te),T(3,Ii),T(4,Lt),T(5,Pe),T(6,oi),T(7,kt)],as);var x;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
11
+ `,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(x||={});var es;(t=>(t.PAD="€",t.HOP="",t.BPH="‚",t.NBH="ƒ",t.IND="„",t.NEL="…",t.SSA="†",t.ESA="‡",t.HTS="ˆ",t.HTJ="‰",t.VTS="Š",t.PLD="‹",t.PLU="Œ",t.RI="",t.SS2="Ž",t.SS3="",t.DCS="",t.PU1="‘",t.PU2="’",t.STS="“",t.CCH="”",t.MW="•",t.SPA="–",t.EPA="—",t.SOS="˜",t.SGCI="™",t.SCI="š",t.CSI="›",t.ST="œ",t.OSC="",t.PM="ž",t.APC="Ÿ"))(es||={});var aa;(t=>t.ST=`${x.ESC}\\`)(aa||={});var Sr=class{constructor(e,i,s,r,n,o){this._textarea=e,this._compositionView=i,this._bufferService=s,this._optionsService=r,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let i={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;i.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(i.start,this._compositionPosition.start):s=this._textarea.value.substring(i.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let i=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(i,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,s=i.replace(e,"");this._dataAlreadySent=s,i.length>e.length?this._coreService.triggerDataEvent(s,!0):i.length<e.length?this._coreService.triggerDataEvent(`${x.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let i=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=i*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Sr=re([T(2,Te),T(3,Pe),T(4,Gt),T(5,Lt)],Sr);var pe=0,ve=0,me=0,ie=0,Bn={css:"#00000000",rgba:0},ce;(t=>{function e(r,n,o,a){return a!==void 0?`#${It(r)}${It(n)}${It(o)}${It(a)}`:`#${It(r)}${It(n)}${It(o)}`}t.toCss=e;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}t.toRgba=i;function s(r,n,o,a){return{css:t.toCss(r,n,o,a),rgba:t.toRgba(r,n,o,a)}}t.toColor=s})(ce||={});var j;(t=>{function e(l,h){if(ie=(h.rgba&255)/255,ie===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,_=l.rgba>>24&255,f=l.rgba>>16&255,S=l.rgba>>8&255;pe=_+Math.round((c-_)*ie),ve=f+Math.round((d-f)*ie),me=S+Math.round((u-S)*ie);let k=ce.toCss(pe,ve,me),D=ce.toRgba(pe,ve,me);return{css:k,rgba:D}}t.blend=e;function i(l){return(l.rgba&255)===255}t.isOpaque=i;function s(l,h,c){let d=ts.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return ce.toColor(d>>24&255,d>>16&255,d>>8&255)}t.ensureContrastRatio=s;function r(l){let h=(l.rgba|255)>>>0;return[pe,ve,me]=ts.toChannels(h),{css:ce.toCss(pe,ve,me),rgba:h}}t.opaque=r;function n(l,h){return ie=Math.round(h*255),[pe,ve,me]=ts.toChannels(l.rgba),{css:ce.toCss(pe,ve,me,ie),rgba:ce.toRgba(pe,ve,me,ie)}}t.opacity=n;function o(l,h){return ie=l.rgba&255,n(l,ie*h/255)}t.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}t.toColorRGB=a})(j||={});var ee;(t=>{let e,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return pe=parseInt(r.slice(1,2).repeat(2),16),ve=parseInt(r.slice(2,3).repeat(2),16),me=parseInt(r.slice(3,4).repeat(2),16),ce.toColor(pe,ve,me);case 5:return pe=parseInt(r.slice(1,2).repeat(2),16),ve=parseInt(r.slice(2,3).repeat(2),16),me=parseInt(r.slice(3,4).repeat(2),16),ie=parseInt(r.slice(4,5).repeat(2),16),ce.toColor(pe,ve,me,ie);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return pe=parseInt(n[1]),ve=parseInt(n[2]),me=parseInt(n[3]),ie=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ce.toColor(pe,ve,me,ie);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[pe,ve,me,ie]=e.getImageData(0,0,1,1).data,ie!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ce.toRgba(pe,ve,me,ie),css:r}}t.toColor=s})(ee||={});var Re;(t=>{function e(s){return i(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function i(s,r,n){let o=s/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}t.relativeLuminance2=i})(Re||={});var ts;(t=>{function e(o,a){if(ie=(a&255)/255,ie===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,_=o>>8&255;return pe=d+Math.round((l-d)*ie),ve=u+Math.round((h-u)*ie),me=_+Math.round((c-_)*ie),ce.toRgba(pe,ve,me)}t.blend=e;function i(o,a,l){let h=Re.relativeLuminance(o>>8),c=Re.relativeLuminance(a>>8);if(ft(h,c)<l){if(c<h){let _=s(o,a,l),f=ft(h,Re.relativeLuminance(_>>8));if(f<l){let S=r(o,a,l),k=ft(h,Re.relativeLuminance(S>>8));return f>k?_:S}return _}let d=r(o,a,l),u=ft(h,Re.relativeLuminance(d>>8));if(u<l){let _=s(o,a,l),f=ft(h,Re.relativeLuminance(_>>8));return u>f?d:_}return d}}t.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=ft(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));for(;S<l&&(u>0||_>0||f>0);)u-=Math.max(0,Math.ceil(u*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),S=ft(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=s;function r(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=ft(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));for(;S<l&&(u<255||_<255||f<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),S=ft(Re.relativeLuminance2(u,_,f),Re.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(ts||={});function It(t){let e=t.toString(16);return e.length<2?"0"+e:e}function ft(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var $l=class extends Oi{constructor(e,i,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hs=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Je}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let i=[],s=e.translateToString(!0),r=0,n=0,o=0,a=e.getFg(0),l=e.getBg(0);for(let h=0;h<e.getTrimmedLength();h++)if(e.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==l){if(h-r>1){let c=this._getJoinedRanges(s,o,n,e,r);for(let d=0;d<c.length;d++)i.push(c[d])}r=h,o=n,a=this._workCell.fg,l=this._workCell.bg}n+=this._workCell.getChars().length||Pt.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,e,r);for(let c=0;c<h.length;c++)i.push(h[c])}return i}_getJoinedRanges(t,e,i,s,r){let n=t.substring(e,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let l=this._characterJoiners[a].handler(n);for(let h=0;h<l.length;h++)hs._mergeRanges(o,l[h])}catch(l){console.error(l)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(t,e,i){let s=0,r=!1,n=0,o=t[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let l=e.getWidth(a),h=e.getString(a).length||Pt.length;if(l!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=t[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let i=!1;for(let s=0;s<t.length;s++){let r=t[s];if(i){if(e[1]<=r[0])return t[s-1][1]=e[1],t;if(e[1]<=r[1])return t[s-1][1]=Math.max(e[1],r[1]),t.splice(s,1),t;t.splice(s,1),s--}else{if(e[1]<=r[0])return t.splice(s,0,e),t;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),t;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),i=!0);continue}}return i?t[t.length-1][1]=e[1]:t.push(e),t}};hs=re([T(0,Te)],hs);function Fl(t){return 57508<=t&&t<=57558}function Nl(t){return 9472<=t&&t<=9631}function Wl(t){return Fl(t)||Nl(t)}function zl(){return{css:{canvas:Hi(),cell:Hi()},device:{canvas:Hi(),cell:Hi(),char:{width:0,height:0,left:0,top:0}}}}function Hi(){return{width:0,height:0}}var wr=class{constructor(e,i,s,r,n,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=s,this._coreBrowserService=r,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new Je,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,s){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=s}createRow(e,i,s,r,n,o,a,l,h,c,d){let u=[],_=this._characterJoinerService.getJoinedCharacters(i),f=this._themeService.colors,S=e.getNoBgTrimmedLength();s&&S<o+1&&(S=o+1);let k,D=0,A="",B=0,w=0,R=0,P=0,N=!1,G=0,ae=!1,Ee=0,W=0,p=[],g=c!==-1&&d!==-1;for(let v=0;v<S;v++){e.loadCell(v,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let y=!1,b=v>=W,L=v,C=this._workCell;if(_.length>0&&v===_[0][0]&&b){let H=_.shift(),li=this._isCellInSelection(H[0],i);for(B=H[0]+1;B<H[1];B++)b&&=li===this._isCellInSelection(B,i);b&&=!s||o<H[0]||o>=H[1],b?(y=!0,C=new $l(this._workCell,e.translateToString(!0,H[0],H[1]),H[1]-H[0]),L=H[1]-1,m=C.getWidth()):W=H[1]}let M=this._isCellInSelection(v,i),I=s&&v===o,Y=g&&v>=c&&v<=d,z=!1;this._decorationService.forEachDecorationAtCell(v,i,void 0,H=>{z=!0});let Oe=C.getChars()||Pt;if(Oe===" "&&(C.isUnderline()||C.isOverline())&&(Oe=" "),Ee=m*l-h.get(Oe,C.isBold(),C.isItalic()),!k)k=this._document.createElement("span");else if(D&&(M&&ae||!M&&!ae&&C.bg===w)&&(M&&ae&&f.selectionForeground||C.fg===R)&&C.extended.ext===P&&Y===N&&Ee===G&&!I&&!y&&!z&&b){C.isInvisible()?A+=Pt:A+=Oe,D++;continue}else D&&(k.textContent=A),k=this._document.createElement("span"),D=0,A="";if(w=C.bg,R=C.fg,P=C.extended.ext,N=Y,G=Ee,ae=M,y&&o>=v&&o<=L&&(o=v),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(p.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&p.push("xterm-cursor-blink"),p.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":p.push("xterm-cursor-outline");break;case"block":p.push("xterm-cursor-block");break;case"bar":p.push("xterm-cursor-bar");break;case"underline":p.push("xterm-cursor-underline");break}}if(C.isBold()&&p.push("xterm-bold"),C.isItalic()&&p.push("xterm-italic"),C.isDim()&&p.push("xterm-dim"),C.isInvisible()?A=Pt:A=C.getChars()||Pt,C.isUnderline()&&(p.push(`xterm-underline-${C.extended.underlineStyle}`),A===" "&&(A=" "),!C.isUnderlineColorDefault()))if(C.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Oi.toColorRGB(C.getUnderlineColor()).join(",")})`;else{let H=C.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&C.isBold()&&H<8&&(H+=8),k.style.textDecorationColor=f.ansi[H].css}C.isOverline()&&(p.push("xterm-overline"),A===" "&&(A=" ")),C.isStrikethrough()&&p.push("xterm-strikethrough"),Y&&(k.style.textDecoration="underline");let U=C.getFgColor(),ye=C.getFgColorMode(),K=C.getBgColor(),V=C.getBgColorMode(),xe=!!C.isInverse();if(xe){let H=U;U=K,K=H;let li=ye;ye=V,V=li}let qe,_t,st=!1;this._decorationService.forEachDecorationAtCell(v,i,void 0,H=>{H.options.layer!=="top"&&st||(H.backgroundColorRGB&&(V=50331648,K=H.backgroundColorRGB.rgba>>8&16777215,qe=H.backgroundColorRGB),H.foregroundColorRGB&&(ye=50331648,U=H.foregroundColorRGB.rgba>>8&16777215,_t=H.foregroundColorRGB),st=H.options.layer==="top")}),!st&&M&&(qe=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,K=qe.rgba>>8&16777215,V=50331648,st=!0,f.selectionForeground&&(ye=50331648,U=f.selectionForeground.rgba>>8&16777215,_t=f.selectionForeground)),st&&p.push("xterm-decoration-top");let Qe;switch(V){case 16777216:case 33554432:Qe=f.ansi[K],p.push(`xterm-bg-${K}`);break;case 50331648:Qe=ce.toColor(K>>16,K>>8&255,K&255),this._addStyle(k,`background-color:#${Rn((K>>>0).toString(16),"0",6)}`);break;default:xe?(Qe=f.foreground,p.push("xterm-bg-257")):Qe=f.background}switch(qe||C.isDim()&&(qe=j.multiplyOpacity(Qe,.5)),ye){case 16777216:case 33554432:C.isBold()&&U<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(U+=8),this._applyMinimumContrast(k,Qe,f.ansi[U],C,qe,void 0)||p.push(`xterm-fg-${U}`);break;case 50331648:let H=ce.toColor(U>>16&255,U>>8&255,U&255);this._applyMinimumContrast(k,Qe,H,C,qe,_t)||this._addStyle(k,`color:#${Rn(U.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(k,Qe,f.foreground,C,qe,_t)||xe&&p.push("xterm-fg-257")}p.length&&(k.className=p.join(" "),p.length=0),!I&&!y&&!z&&b?D++:k.textContent=A,Ee!==this.defaultSpacing&&(k.style.letterSpacing=`${Ee}px`),u.push(k),v=L}return k&&D&&(k.textContent=A),u}_applyMinimumContrast(e,i,s,r,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Wl(r.getCode()))return!1;let a=this._getContrastCache(r),l;if(!n&&!o&&(l=a.getColor(i.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);l=j.ensureContrastRatio(n||i,o||s,h),a.setColor((n||i).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&i>=s[1]&&e<r[0]&&i<=r[1]:e<s[0]&&i>=s[1]&&e>=r[0]&&i<=r[1]:i>s[1]&&i<r[1]||s[1]===r[1]&&i===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&i===r[1]&&e<r[0]||s[1]<r[1]&&i===s[1]&&e>=s[0]}};wr=re([T(1,Uo),T(2,Pe),T(3,kt),T(4,Gt),T(5,Ii),T(6,oi)],wr);function Rn(t,e,i){for(;t.length<i;)t=e+t;return t}var Hl=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,r,n,o],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(o),i.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,i,s,r){e===this._font&&i===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=i,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,i,s){let r=0;if(!i&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let a=this._measure(e,0);return a>0&&(this._flat[r]=a),a}let n=e;i&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;i&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,i){let s=this._measureElements[i];return s.textContent=e.repeat(32),s.offsetWidth/32}},Ul=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,i,s,r=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=i[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=s[0]}isCellSelected(e,i,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&s>=this.viewportCappedStartRow&&i<this.endCol&&s<=this.viewportCappedEndRow:i<this.startCol&&s>=this.viewportCappedStartRow&&i>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol):!1}};function ql(){return new Ul}var Bs="xterm-dom-renderer-owner-",Ke="xterm-rows",Ui="xterm-fg-",An="xterm-bg-",di="xterm-focus",qi="xterm-selection",Kl=1,br=class extends F{constructor(e,i,s,r,n,o,a,l,h,c,d,u,_,f){super(),this._terminal=e,this._document=i,this._element=s,this._screenElement=r,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=_,this._themeService=f,this._terminalClass=Kl++,this._rowElements=[],this._selectionRenderModel=ql(),this.onRequestRedraw=this._register(new E).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ke),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(qi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=zl(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(S=>this._injectCss(S))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(wr,document),this._element.classList.add(Bs+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(S=>this._handleLinkHover(S))),this._register(this._linkifier2.onHideLinkUnderline(S=>this._handleLinkLeave(S))),this._register(J(()=>{this._element.classList.remove(Bs+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Hl(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${Ke} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,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 i=`${this._terminalSelector} .${Ke} { 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}`;i+=`${this._terminalSelector} .${Ke} .xterm-dim { color: ${j.multiplyOpacity(e.foreground,.5).css};}`,i+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;i+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,i+=`@keyframes ${r} { 50% { box-shadow: none; }}`,i+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,i+=`${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ke}.${di} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ke} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${qi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${qi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${qi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())i+=`${this._terminalSelector} .${Ui}${o} { color: ${a.css}; }${this._terminalSelector} .${Ui}${o}.xterm-dim { color: ${j.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${An}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${Ui}257 { color: ${j.opaque(e.background).css}; }${this._terminalSelector} .${Ui}257.xterm-dim { color: ${j.multiplyOpacity(j.opaque(e.background),.5).css}; }${this._terminalSelector} .${An}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_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,i){for(let s=this._rowElements.length;s<=i;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),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(di),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(di),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,s),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>i[0];l.appendChild(this._createSelectionElement(o,h?i[0]:e[0],h?e[0]:i[0],a-o+1))}else{let h=r===o?e[0]:0,c=o===n?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let d=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,d)),o!==a){let u=n===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,s,r=1){let n=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${r*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let s=this._bufferService.buffer,r=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let c=h+s.ydisp,d=this._rowElements[h],u=s.lines.get(c);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,c,c===r,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Bs}${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,i,s,r,n,o){s<0&&(e=0),r<0&&(i=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=s;f<=r;++f){let S=f+l.ydisp,k=this._rowElements[f],D=l.lines.get(S);if(!k||!D)break;k.replaceChildren(...this._rowFactory.createRow(D,S,S===h,u,_,c,d,this.dimensions.css.cell.width,this._widthCache,o?f===s?e:0:-1,o?(f===r?i:n)-1:-1))}}};br=re([T(7,Kr),T(8,vs),T(9,Pe),T(10,Te),T(11,Gt),T(12,kt),T(13,oi)],br);var Cr=class extends F{constructor(e,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new E),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Gl(this._optionsService))}catch{this._measureStrategy=this._register(new Vl(e,i,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())}};Cr=re([T(2,Pe)],Cr);var ha=class extends F{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},Vl=class extends ha{constructor(t,e,i){super(),this._document=t,this._parentElement=e,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}},Gl=class extends ha{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))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}},Yl=class extends F{constructor(e,i,s){super(),this._textarea=e,this._window=i,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Xl(this._window)),this._onDprChange=this._register(new E),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new E),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Le.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(O(this._textarea,"focus",()=>this._isFocused=!0)),this._register(O(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Xl=class extends F{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ni),this._onDprChange=this._register(new E),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(J(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=O(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.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)}},jl=class extends F{constructor(){super(),this.linkProviders=[],this._register(J(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function Qr(t,e,i){let s=i.getBoundingClientRect(),r=t.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-s.left-n,e.clientY-s.top-o]}function Zl(t,e,i,s,r,n,o,a,l){if(!n)return;let h=Qr(t,e,i);if(h)return 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}var yr=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,s,r,n){return Zl(window,e,i,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,i){let s=Qr(window,e,i);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};yr=re([T(0,Lt),T(1,vs)],yr);var Jl=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,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,i,s){this._rowCount=s,e=e!==void 0?e:0,i=i!==void 0?i:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,i):i,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},la={};hh(la,{getSafariVersion:()=>ec,isChromeOS:()=>_a,isFirefox:()=>ca,isIpad:()=>tc,isIphone:()=>ic,isLegacyEdge:()=>Ql,isLinux:()=>en,isMac:()=>ls,isNode:()=>ms,isSafari:()=>da,isWindows:()=>ua});var ms=typeof process<"u"&&"title"in process,$i=ms?"node":navigator.userAgent,Fi=ms?"node":navigator.platform,ca=$i.includes("Firefox"),Ql=$i.includes("Edge"),da=/^((?!chrome|android).)*safari/i.test($i);function ec(){if(!da)return 0;let t=$i.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var ls=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Fi),tc=Fi==="iPad",ic=Fi==="iPhone",ua=["Windows","Win16","Win32","WinCE"].includes(Fi),en=Fi.indexOf("Linux")>=0,_a=/\bCrOS\b/.test($i),fa=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,s=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),r=t.timeRemaining(),i*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},sc=class extends fa{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},rc=class extends fa{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},cs=!ms&&"requestIdleCallback"in window?rc:sc,nc=class{constructor(){this._queue=new cs}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},xr=class extends F{constructor(e,i,s,r,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new ni),this._pausedResizeTask=new nc,this._observerDisposable=this._register(new ni),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 E),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new E),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new E),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new E),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Jl((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new oc(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(J(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(i),this._observerDisposable.value=J(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),i=Math.max(i,r.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,i);return}e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),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:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,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(i=>this.refreshRows(i.start,i.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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,s){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,i,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};xr=re([T(2,Pe),T(3,vs),T(4,Gt),T(5,Ii),T(6,Te),T(7,kt),T(8,oi)],xr);var oc=class{constructor(t,e,i){this._coreBrowserService=t,this._coreService=e,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function ac(t,e,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return cc(r,n,t,e,i,s)+Ss(n,e,i,s)+dc(r,n,t,e,i,s);let o;if(n===e)return o=r>t?"D":"C",Bi(Math.abs(r-t),Mi(o,s));o=n>e?"D":"C";let a=Math.abs(n-e),l=lc(n>e?t:r,i)+(a-1)*i.cols+1+hc(n>e?r:t);return Bi(l,Mi(o,s))}function hc(t,e){return t-1}function lc(t,e){return e.cols-t}function cc(t,e,i,s,r,n){return Ss(e,s,r,n).length===0?"":Bi(pa(t,e,t,e-Vt(e,r),!1,r).length,Mi("D",n))}function Ss(t,e,i,s){let r=t-Vt(t,i),n=e-Vt(e,i),o=Math.abs(r-n)-uc(t,e,i);return Bi(o,Mi(ga(t,e),s))}function dc(t,e,i,s,r,n){let o;Ss(e,s,r,n).length>0?o=s-Vt(s,r):o=e;let a=s,l=_c(t,e,i,s,r,n);return Bi(pa(t,o,i,a,l==="C",r).length,Mi(l,n))}function uc(t,e,i){let s=0,r=t-Vt(t,i),n=e-Vt(e,i);for(let o=0;o<Math.abs(r-n);o++){let a=ga(t,e)==="A"?-1:1;i.buffer.lines.get(r+a*o)?.isWrapped&&s++}return s}function Vt(t,e){let i=0,s=e.buffer.lines.get(t),r=s?.isWrapped;for(;r&&t>=0&&t<e.rows;)i++,s=e.buffer.lines.get(--t),r=s?.isWrapped;return i}function _c(t,e,i,s,r,n){let o;return Ss(i,s,r,n).length>0?o=s-Vt(s,r):o=e,t<i&&o<=s||t>=i&&o<s?"C":"D"}function ga(t,e){return t>e?"A":"B"}function pa(t,e,i,s,r,n){let o=t,a=e,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,t,o),o=0,t=0,a++):!r&&o<0&&(l+=n.buffer.translateBufferLineToString(a,!1,0,t+1),o=n.cols-1,t=o,a--);return l+n.buffer.translateBufferLineToString(a,!1,t,o)}function Mi(t,e){let i=e?"O":"[";return x.ESC+i+t}function Bi(t,e){t=Math.floor(t);let i="";for(let s=0;s<t;s++)i+=e;return i}var fc=class{constructor(t){this._bufferService=t,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Dn(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Rs=50,gc=15,pc=50,vc=500,mc=" ",Sc=new RegExp(mc,"g"),kr=class extends F{constructor(e,i,s,r,n,o,a,l,h){super(),this._element=e,this._screenElement=i,this._linkifier=s,this._bufferService=r,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Je,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new E),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new E),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new E),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new E),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new fc(this._bufferService),this._activeSelectionMode=0,this._register(J(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!e||!i?!1:e[0]!==i[0]||e[1]!==i[1]}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===i[0])return"";let n=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);r.push(l)}}else{let n=e[1]===i[1]?i[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=i[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a?.isWrapped?r[r.length-1]+=l:r.push(l)}if(e[1]!==i[1]){let o=s.lines.get(i[1]),a=s.translateBufferLineToString(i[1],!0,0,i[0]);o&&o.isWrapped?r[r.length-1]+=a:r.push(a)}}return r.map(n=>n.replace(Sc," ")).join(ua?`\r
12
12
  `:`
13
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Zr&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!i?!1:this._areCoordsInSelection(i,s,r)}isCellInSelection(e,i){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,i],s,r)}_areCoordsInSelection(e,i,s){return e[1]>i[1]&&e[1]<s[1]||i[1]===s[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<s[0]||i[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||i[1]<s[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Mn(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,i),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=jr(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=s?0:(i>s&&(i-=s),i=Math.min(Math.max(i,-Ms),Ms),i/=Ms,i/Math.abs(i)+Math.round(i*(cc-1)))}shouldForceSelection(e){return as?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),dc)}_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 i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&i.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(as&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let r=s.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!i||i[0]!==this._model.selectionEnd[0]||i[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<uc&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let r=ic(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,s=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,i,s);return}!e||!i||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||i[0]!==this._oldSelectionEnd[0]||i[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,i,s)}_fireOnSelectionChange(e,i,s){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(i=>this._handleTrim(i))}_convertViewportColToCharacterIndex(e,i){let s=i;for(let r=0;i>=r;r++){let n=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&i!==r&&(s+=n-1)}return s}setSelection(e,i,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,d=0,u=0,_=0,f=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let A=e[0],D=e[0];o.getWidth(A)===0&&(d++,A--),o.getWidth(D)===2&&(u++,D++);let B=o.getString(D).length;for(B>1&&(f+=B-1,h+=B-1);A>0&&l>0&&!this._isCharWordSeparator(o.loadCell(A-1,this._workCell));){o.loadCell(A-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,A--):w>1&&(_+=w-1,l-=w-1),l--,A--}for(;D<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(D+1,this._workCell));){o.loadCell(D+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,D++):w>1&&(f+=w-1,h+=w-1),h++,D++}}h++;let S=l+c-d+_,k=Math.min(this._bufferService.cols,h-l+d+u-_-f);if(!(!i&&a.slice(l,h).trim()==="")){if(s&&S===0&&o.getCodePoint(0)!==32){let A=n.lines.get(e[1]-1);if(A&&o.isWrapped&&A.getCodePoint(this._bufferService.cols-1)!==32){let D=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(D){let B=this._bufferService.cols-D.start;S-=B,k+=B}}}if(r&&S+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let A=n.lines.get(e[1]+1);if(A?.isWrapped&&A.getCodePoint(0)!==32){let D=this._getWordAt([0,e[1]+1],!1,!1,!0);D&&(k+=D.length)}}return{start:S,length:k}}}_selectWordAt(e,i){let s=this._getWordAt(e,i);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let s=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Mn(s,this._bufferService.cols)}};Cr=re([T(3,Te),T(4,Gt),T(5,Ur),T(6,Pe),T(7,kt),T(8,xt)],Cr);var Bn=class{constructor(){this._data={}}set(e,i,s){this._data[e]||(this._data[e]={}),this._data[e][i]=s}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},Rn=class{constructor(){this._color=new Bn,this._css=new Bn}setCss(e,i,s){this._css.set(e,i,s)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,s){this._color.set(e,i,s)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},de=Object.freeze((()=>{let t=[ee.toColor("#2e3436"),ee.toColor("#cc0000"),ee.toColor("#4e9a06"),ee.toColor("#c4a000"),ee.toColor("#3465a4"),ee.toColor("#75507b"),ee.toColor("#06989a"),ee.toColor("#d3d7cf"),ee.toColor("#555753"),ee.toColor("#ef2929"),ee.toColor("#8ae234"),ee.toColor("#fce94f"),ee.toColor("#729fcf"),ee.toColor("#ad7fa8"),ee.toColor("#34e2e2"),ee.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=e[i/36%6|0],r=e[i/6%6|0],n=e[i%6];t.push({css:ce.toCss(s,r,n),rgba:ce.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;t.push({css:ce.toCss(s,s,s),rgba:ce.toRgba(s,s,s)})}return t})()),Ft=ee.toColor("#ffffff"),bi=ee.toColor("#000000"),Dn=ee.toColor("#ffffff"),An=bi,ui={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},gc=Ft,yr=class extends F{constructor(e){super(),this._optionsService=e,this._contrastCache=new Rn,this._halfContrastCache=new Rn,this._onChangeColors=this._register(new E),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ft,background:bi,cursor:Dn,cursorAccent:An,selectionForeground:void 0,selectionBackgroundTransparent:ui,selectionBackgroundOpaque:j.blend(bi,ui),selectionInactiveBackgroundTransparent:ui,selectionInactiveBackgroundOpaque:j.blend(bi,ui),scrollbarSliderBackground:j.opacity(Ft,.2),scrollbarSliderHoverBackground:j.opacity(Ft,.4),scrollbarSliderActiveBackground:j.opacity(Ft,.5),overviewRulerBorder:Ft,ansi:de.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 i=this._colors;if(i.foreground=q(e.foreground,Ft),i.background=q(e.background,bi),i.cursor=j.blend(i.background,q(e.cursor,Dn)),i.cursorAccent=j.blend(i.background,q(e.cursorAccent,An)),i.selectionBackgroundTransparent=q(e.selectionBackground,ui),i.selectionBackgroundOpaque=j.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=q(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=j.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?q(e.selectionForeground,kn):void 0,i.selectionForeground===kn&&(i.selectionForeground=void 0),j.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=j.opacity(i.selectionBackgroundTransparent,.3)),j.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=j.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=q(e.scrollbarSliderBackground,j.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=q(e.scrollbarSliderHoverBackground,j.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=q(e.scrollbarSliderActiveBackground,j.opacity(i.foreground,.5)),i.overviewRulerBorder=q(e.overviewRulerBorder,gc),i.ansi=de.slice(),i.ansi[0]=q(e.black,de[0]),i.ansi[1]=q(e.red,de[1]),i.ansi[2]=q(e.green,de[2]),i.ansi[3]=q(e.yellow,de[3]),i.ansi[4]=q(e.blue,de[4]),i.ansi[5]=q(e.magenta,de[5]),i.ansi[6]=q(e.cyan,de[6]),i.ansi[7]=q(e.white,de[7]),i.ansi[8]=q(e.brightBlack,de[8]),i.ansi[9]=q(e.brightRed,de[9]),i.ansi[10]=q(e.brightGreen,de[10]),i.ansi[11]=q(e.brightYellow,de[11]),i.ansi[12]=q(e.brightBlue,de[12]),i.ansi[13]=q(e.brightMagenta,de[13]),i.ansi[14]=q(e.brightCyan,de[14]),i.ansi[15]=q(e.brightWhite,de[15]),e.extendedAnsi){let s=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)i.ansi[r+16]=q(e.extendedAnsi[r],de[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let i=0;i<this._restoreColors.ansi.length;++i)this._colors.ansi[i]=this._restoreColors.ansi[i];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};yr=re([T(0,Pe)],yr);function q(t,e){if(t!==void 0)try{return ee.toColor(t)}catch{}return e}var pc=class{constructor(...e){this._entries=new Map;for(let[i,s]of e)this.set(i,s)}set(e,i){let s=this._entries.get(e);return this._entries.set(e,i),s}forEach(e){for(let[i,s]of this._entries.entries())e(i,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},vc=class{constructor(){this._services=new pc,this._services.set(Hr,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let i=ch(t).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...s)}},mc={trace:0,debug:1,info:2,warn:3,error:4,off:5},Sc="xterm.js: ",xr=class extends F{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=mc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)typeof e[i]=="function"&&(e[i]=e[i]())}_log(e,i,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Sc)+i,...s)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};xr=re([T(0,Pe)],xr);var Tn=class extends F{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new E),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new E),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new E),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 i=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)i[s]=this._array[this._getCyclicIndex(s)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}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,i,...s){if(i){for(let r=e;r<this._length-i;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,s){if(!(i<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=i-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let r=e+i+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<i;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},$=3,he=Object.freeze(new Pi),qi=0,Bs=2,Ci=class _a{constructor(e,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*$);let r=i||Je.fromCharData([0,Ao,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let i=this._data[e*$+0],s=i&2097151;return[this._data[e*$+1],i&2097152?this._combined[e]:s?At(s):"",i>>22,i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,i){this._data[e*$+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[e*$+0]=e|2097152|i[2]<<22):this._data[e*$+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[e*$+0]>>22}hasWidth(e){return this._data[e*$+0]&12582912}getFg(e){return this._data[e*$+1]}getBg(e){return this._data[e*$+2]}hasContent(e){return this._data[e*$+0]&4194303}getCodePoint(e){let i=this._data[e*$+0];return i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i&2097151}isCombined(e){return this._data[e*$+0]&2097152}getString(e){let i=this._data[e*$+0];return i&2097152?this._combined[e]:i&2097151?At(i&2097151):""}isProtected(e){return this._data[e*$+2]&536870912}loadCell(e,i){return qi=e*$,i.content=this._data[qi+0],i.fg=this._data[qi+1],i.bg=this._data[qi+2],i.content&2097152&&(i.combinedData=this._combined[e]),i.bg&268435456&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){i.content&2097152&&(this._combined[e]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*$+0]=i.content,this._data[e*$+1]=i.fg,this._data[e*$+2]=i.bg}setCellFromCodepoint(e,i,s,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*$+0]=i|s<<22,this._data[e*$+1]=r.fg,this._data[e*$+2]=r.bg}addCodepointToCell(e,i,s){let r=this._data[e*$+0];r&2097152?this._combined[e]+=At(i):r&2097151?(this._combined[e]=At(r&2097151)+At(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[e*$+0]=r}insertCells(e,i,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length-e){let r=new Je;for(let n=this.length-e-i-1;n>=0;--n)this.setCell(e+i+n,this.loadCell(e+n,r));for(let n=0;n<i;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,i,s){if(e%=this.length,i<this.length-e){let r=new Je;for(let n=0;n<this.length-e-i;++n)this.setCell(e+n,this.loadCell(e+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,i,s,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.setCell(e++,s)}resize(e,i){if(e===this.length)return this._data.length*4*Bs<this._data.buffer.byteLength;let s=e*$;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=e&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=e&&delete this._extendedAttrs[a]}}return this.length=e,s*4*Bs<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Bs<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in e._combined)this._combined[i]=e._combined[i];this._extendedAttrs={};for(let i in e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let e=new _a(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let i in this._combined)e._combined[i]=this._combined[i];for(let i in this._extendedAttrs)e._extendedAttrs[i]=this._extendedAttrs[i];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$+0]&4194303)return e+(this._data[e*$+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$+0]&4194303||this._data[e*$+2]&50331648)return e+(this._data[e*$+0]>>22);return 0}copyCellsFrom(e,i,s,r,n){let o=e._data;if(n)for(let l=r-1;l>=0;l--){for(let h=0;h<$;h++)this._data[(s+l)*$+h]=o[(i+l)*$+h];o[(i+l)*$+2]&268435456&&(this._extendedAttrs[s+l]=e._extendedAttrs[i+l])}else for(let l=0;l<r;l++){for(let h=0;h<$;h++)this._data[(s+l)*$+h]=o[(i+l)*$+h];o[(i+l)*$+2]&268435456&&(this._extendedAttrs[s+l]=e._extendedAttrs[i+l])}let a=Object.keys(e._combined);for(let l=0;l<a.length;l++){let h=parseInt(a[l],10);h>=i&&(this._combined[h-i+s]=e._combined[h])}}translateToString(e,i,s,r){i=i??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*$+0],a=o&2097151,l=o&2097152?this._combined[i]:a?At(a):Pt;if(n+=l,r)for(let h=0;h<l.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function wc(t,e,i,s,r,n){let o=[];for(let a=0;a<t.length-1;a++){let l=a,h=t.get(++l);if(!h.isWrapped)continue;let c=[t.get(a)];for(;l<t.length&&h.isWrapped;)c.push(h),h=t.get(++l);if(!n&&s>=a&&s<l){a+=c.length-1;continue}let d=0,u=Bi(c,d,e),_=1,f=0;for(;_<c.length;){let k=Bi(c,_,e),A=k-f,D=i-u,B=Math.min(A,D);c[d].copyCellsFrom(c[_],f,u,B,!1),u+=B,u===i&&(d++,u=0),f+=B,f===k&&(_++,f=0),u===0&&d!==0&&c[d-1].getWidth(i-1)===2&&(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 S=0;for(let k=c.length-1;k>0&&(k>d||c[k].getTrimmedLength()===0);k--)S++;S>0&&(o.push(a+c.length-S),o.push(S)),a+=c.length-1}return o}function bc(t,e){let i=[],s=0,r=e[s],n=0;for(let o=0;o<t.length;o++)if(r===o){let a=e[++s];t.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=e[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Cc(t,e){let i=[];for(let s=0;s<e.length;s++)i.push(t.get(e[s]));for(let s=0;s<i.length;s++)t.set(s,i[s]);t.length=e.length}function yc(t,e,i){let s=[],r=t.map((l,h)=>Bi(t,h,e)).reduce((l,h)=>l+h),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let l=Bi(t,o,e);n>l&&(n-=l,o++);let h=t[o].getWidth(n-1)===2;h&&n--;let c=h?i-1:i;s.push(c),a+=c}return s}function Bi(t,e,i){if(e===t.length-1)return t[e].getTrimmedLength();let s=!t[e].hasContent(i-1)&&t[e].getWidth(i-1)===1,r=t[e+1].getWidth(0)===2;return s&&r?i-1:i}var fa=class ga{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=ga._nextId++,this._onDispose=this.register(new E),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Kt(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};fa._nextId=1;var xc=fa,_e={},Nt=_e.B;_e[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:"≥","{":"π","|":"≠","}":"£","~":"·"};_e.A={"#":"£"};_e.B=void 0;_e[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};_e.C=_e[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_e.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};_e.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};_e.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};_e.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};_e.E=_e[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};_e.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};_e.H=_e[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_e["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Pn=4294967295,On=class{constructor(t,e,i){this._hasScrollback=t,this._optionsService=e,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=he.clone(),this.savedCharset=Nt,this.markers=[],this._nullCell=Je.fromCharData([0,Ao,1,0]),this._whitespaceCell=Je.fromCharData([0,Pt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new hs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Tn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rs),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rs),this._whitespaceCell}getBlankLine(t,e){return new Ci(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>Pn?Pn:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=he);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Tn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let i=this.getNullCell(he),s=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(t,i);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ci(t,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 Ci(t,i)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(t,i);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,s=wc(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(he),i);if(s.length>0){let r=bc(this.lines,s);Cc(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,i){let s=this.getNullCell(he),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Ci(t,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(he),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()<=t)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let B=this.ybase+this.y;if(B>=o&&B<o+l.length)continue}let h=l[l.length-1].getTrimmedLength(),c=yc(l,this._cols,t),d=c.length-l.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+d):u=Math.max(0,this.lines.length-this.lines.maxLength+d);let _=[];for(let B=0;B<d;B++){let w=this.getBlankLine(he,!0);_.push(w)}_.length>0&&(r.push({start:o+l.length+n,newLines:_}),n+=_.length),l.push(..._);let f=c.length-1,S=c[f];S===0&&(f--,S=c[f]);let k=l.length-d-1,A=h;for(;k>=0;){let B=Math.min(A,S);if(l[f]===void 0)break;if(l[f].copyCellsFrom(l[k],A-B,S-B,B,!0),S-=B,S===0&&(f--,S=c[f]),A-=B,A===0){k--;let w=Math.max(k,0);A=Bi(l,w,this._cols)}}for(let B=0;B<l.length;B++)c[B]<t&&l[B].setCell(c[B],s);let D=d-u;for(;D-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(r.length>0){let o=[],a=[];for(let S=0;S<this.lines.length;S++)a.push(this.lines.get(S));let l=this.lines.length,h=l-1,c=0,d=r[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let u=0;for(let S=Math.min(this.lines.maxLength-1,l+n-1);S>=0;S--)if(d&&d.start>h+u){for(let k=d.newLines.length-1;k>=0;k--)this.lines.set(S--,d.newLines[k]);S++,o.push({index:h+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(S,a[h--]);let _=0;for(let S=o.length-1;S>=0;S--)o[S].index+=_,this.lines.onInsertEmitter.fire(o[S]),_+=o[S].amount;let f=Math.max(0,l+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(t,e,i=0,s){let r=this.lines.get(t);return r?r.translateToString(e,i,s):""}getWrappedRangeForLine(t){let e=t,i=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:e,last:i}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new xc(t);return this.markers.push(e),e.register(this.lines.onTrim(i=>{e.line-=i,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(i=>{e.line>=i.index&&(e.line+=i.amount)})),e.register(this.lines.onDelete(i=>{e.line>=i.index&&e.line<i.index+i.amount&&e.dispose(),e.line>i.index&&(e.line-=i.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},kc=class extends F{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new E),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 On(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new On(!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,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},pa=2,va=1,kr=class extends F{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new E),this.onResize=this._onResize.event,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,pa),this.rows=Math.max(t.rawOptions.rows||0,va),this.buffers=this._register(new kc(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let i=this.cols!==t,s=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=i.getBlankLine(t,e),this._cachedBlankLine=s),s.isWrapped=e;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(t,e){let i=this.buffer;if(t<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else t+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+t,i.ybase),0),s!==i.ydisp&&(e||this._onScroll.fire(i.ydisp))}};kr=re([T(0,Pe)],kr);var Xt={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:as,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Lc=["normal","bold","100","200","300","400","500","600","700","800","900"],Ec=class extends F{constructor(e){super(),this._onOptionChange=this._register(new E),this.onOptionChange=this._onOptionChange.event;let i={...Xt};for(let s in e)if(s in i)try{let r=e[s];i[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(J(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(s=>{s===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&i()})}_setupOptions(){let e=s=>{if(!(s in Xt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},i=(s,r)=>{if(!(s in Xt))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":if(i||(i=Xt[e]),!Mc(i))throw new Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=Xt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=Lc.includes(i)?i:Xt[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(i*10)/10));break;case"scrollback":if(i=Math.min(i,4294967295),i<0)throw new Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{};break}return i}};function Mc(t){return t==="block"||t==="underline"||t==="bar"}function yi(t,e=5){if(typeof t!="object")return t;let i=Array.isArray(t)?[]:{};for(let s in t)i[s]=e<=1?t[s]:t[s]&&yi(t[s],e-1);return i}var In=Object.freeze({insertMode:!1}),$n=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Lr=class extends F{constructor(e,i,s){super(),this._bufferService=e,this._logService=i,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new E),this.onData=this._onData.event,this._onUserInput=this._register(new E),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new E),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new E),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=yi(In),this.decPrivateModes=yi($n)}reset(){this.modes=yi(In),this.decPrivateModes=yi($n)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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(i=>i.charCodeAt(0))),this._onBinary.fire(e))}};Lr=re([T(0,Te),T(1,$o),T(2,Pe)],Lr);var Fn={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Rs(t,e){let i=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(i|=64,i|=t.action):(i|=t.button&3,t.button&4&&(i|=64),t.button&8&&(i|=128),t.action===32?i|=32:t.action===0&&!e&&(i|=3)),i}var Ds=String.fromCharCode,Nn={DEFAULT:t=>{let e=[Rs(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Ds(e[0])}${Ds(e[1])}${Ds(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Rs(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Rs(t,!0)};${t.x};${t.y}${e}`}},Er=class extends F{constructor(t,e,i){super(),this._bufferService=t,this._coreService=e,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new E),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Fn))this.addProtocol(s,Fn[s]);for(let s of Object.keys(Nn))this.addEncoding(s,Nn[s]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,i){if(t.deltaY===0||t.shiftKey||e===void 0||i===void 0)return 0;let s=e/i,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,i){if(i){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Er=re([T(0,Te),T(1,Gt),T(2,Pe)],Er);var As=[[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]],Bc=[[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]],ue;function Rc(t,e){let i=0,s=e.length-1,r;if(t<e[0][0]||t>e[s][1])return!1;for(;s>=i;)if(r=i+s>>1,t>e[r][1])i=r+1;else if(t<e[r][0])s=r-1;else return!0;return!1}var Dc=class{constructor(){if(this.version="6",!ue){ue=new Uint8Array(65536),ue.fill(1),ue[0]=0,ue.fill(0,1,32),ue.fill(0,127,160),ue.fill(2,4352,4448),ue[9001]=2,ue[9002]=2,ue.fill(2,11904,42192),ue[12351]=1,ue.fill(2,44032,55204),ue.fill(2,63744,64256),ue.fill(2,65040,65050),ue.fill(2,65072,65136),ue.fill(2,65280,65377),ue.fill(2,65504,65511);for(let e=0;e<As.length;++e)ue.fill(0,As[e][0],As[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ue[e]:Rc(e,Bc)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,i){let s=this.wcwidth(e),r=s===0&&i!==0;if(r){let n=Wt.extractWidth(i);n===0?r=!1:n>s&&(s=n)}return Wt.createPropertyValue(0,s,r)}},Wt=class es{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new E,this.onChange=this._onChange.event;let e=new Dc;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,s=!1){return(e&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(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(e){let i=0,s=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let h=e.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=es.extractWidth(a);es.extractShouldJoin(a)&&(l-=es.extractWidth(s)),i+=l,s=a}return i}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},Ac=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,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function Wn(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);i&&e&&(i.isWrapped=e[3]!==0&&e[3]!==32)}var _i=2147483647,Tc=256,ma=class Mr{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>Tc)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let i=new Mr;if(!e.length)return i;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let r=e[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let e=new Mr(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,r))}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;return}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>_i?_i:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>_i?_i:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(e[i]=this._subParams.slice(s,r))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+e,_i):e}},fi=[],Pc=class{constructor(){this._state=0,this._active=fi,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fi}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=fi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fi,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,i,s){if(!this._active.length)this._handlerFb(this._id,"PUT",fs(e,i,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s)}start(){this.reset(),this._state=1}put(e,i,s){if(this._state!==3){if(this._state===1)for(;i<s;){let r=e[i++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&s-i>0&&this._put(e,i,s)}}end(e,i=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=fi,this._id=-1,this._state=0}}},Ne=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,s){this._hitLimit||(this._data+=fs(e,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data),i instanceof Promise))return i.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,i}},gi=[],Oc=class{constructor(){this._handlers=Object.create(null),this._active=gi,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gi}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,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=gi,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gi,!this._active.length)this._handlerFb(this._ident,"HOOK",i);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(i)}put(e,i,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",fs(e,i,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s)}unhook(e,i=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=gi,this._ident=0}},xi=new ma;xi.addParam(0);var zn=class{constructor(t){this._handler=t,this._data="",this._params=xi,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():xi,this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=fs(t,e,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(i=>(this._params=xi,this._data="",this._hitLimit=!1,i));return this._params=xi,this._data="",this._hitLimit=!1,e}},Ic=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,s,r){this.table[i<<8|e]=s<<4|r}addMany(e,i,s,r){for(let n=0;n<e.length;n++)this.table[i<<8|e[n]]=s<<4|r}},Xe=160,$c=(function(){let t=new Ic(4095),e=Array.apply(null,Array(256)).map((a,l)=>l),i=(a,l)=>e.slice(a,l),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;t.setDefault(1,0),t.addMany(s,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(i(128,144),o,3,0),t.addMany(i(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(s,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(i(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(s,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(i(64,127),3,7,0),t.addMany(i(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(i(48,60),4,8,4),t.addMany(i(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(i(32,64),6,0,6),t.add(127,6,0,6),t.addMany(i(64,127),6,0,0),t.addMany(i(32,48),3,9,5),t.addMany(i(32,48),5,9,5),t.addMany(i(48,64),5,0,6),t.addMany(i(64,127),5,7,0),t.addMany(i(32,48),4,9,5),t.addMany(i(32,48),1,9,2),t.addMany(i(32,48),2,9,2),t.addMany(i(48,127),2,10,0),t.addMany(i(48,80),1,10,0),t.addMany(i(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(i(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(i(28,32),9,0,9),t.addMany(i(32,48),9,9,12),t.addMany(i(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(i(32,128),11,0,11),t.addMany(i(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(i(28,32),10,0,10),t.addMany(i(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(i(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(i(28,32),12,0,12),t.addMany(i(32,48),12,9,12),t.addMany(i(48,64),12,0,11),t.addMany(i(64,127),12,12,13),t.addMany(i(64,127),10,12,13),t.addMany(i(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(s,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Xe,0,2,0),t.add(Xe,8,5,8),t.add(Xe,6,0,6),t.add(Xe,11,0,11),t.add(Xe,13,13,13),t})(),Fc=class extends F{constructor(e=$c){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 ma,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(i,s,r)=>{},this._executeHandlerFb=i=>{},this._csiHandlerFb=(i,s)=>{},this._escHandlerFb=i=>{},this._errorHandlerFb=i=>i,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(J(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Pc),this._dcsParser=this._register(new Oc),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(i[0]>r||r>i[1])throw new Error(`final must be in range ${i[0]} .. ${i[1]}`);return s<<=8,s|=r,s}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(e&255)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(i),{dispose:()=>{let n=r.indexOf(i);n!==-1&&r.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(i),{dispose:()=>{let n=r.indexOf(i);n!==-1&&r.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,s,r,n){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=n}parse(e,i,s){let r=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<i;++l){switch(r=e[l],n=this._transitions.table[this.currentState<<8|(r<160?r:Xe)],n>>4){case 2:for(let _=l+1;;++_){if(_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-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:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|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(++l<i&&(r=e[l])>47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let d=this._escHandlers[this._collect<<8|r],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,u,n,l),a;u<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 _=l+1;;++_)if(_>=i||(r=e[_])===24||r===26||r===27||r>127&&r<Xe){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,n,l),a;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=i||(r=e[_])<32||r>127&&r<Xe){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,n,l),a;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},Nc=/^([\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})$/,Wc=/^[\da-f]+$/;function Hn(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let i=Nc.exec(e);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Wc.exec(e)&&[3,6,9,12].includes(e.length))){let i=e.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Ts(t,e){let i=t.toString(16),s=i.length<2?"0"+i:i;switch(e){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function zc(t,e=16){let[i,s,r]=t;return`rgb:${Ts(i,e)}/${Ts(s,e)}/${Ts(r,e)}`}var Hc={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Mt=131072,Un=10;function qn(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var Kn=5e3,Vn=0,Uc=class extends F{constructor(t,e,i,s,r,n,o,a,l=new Fc){super(),this._bufferService=t,this._charsetService=e,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 hh,this._utf8Decoder=new lh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=he.clone(),this._eraseAttrDataInternal=he.clone(),this._onRequestBell=this._register(new E),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new E),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new E),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new E),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new E),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new E),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new E),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new E),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new E),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new E),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new E),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new E),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 Br(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:d})}),this._parser.setDcsHandlerFallback((h,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:d})}),this._parser.setPrintHandler((h,c,d)=>this.print(h,c,d)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(x.BEL,()=>this.bell()),this._parser.setExecuteHandler(x.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(x.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(x.BS,()=>this.backspace()),this._parser.setExecuteHandler(x.HT,()=>this.tab()),this._parser.setExecuteHandler(x.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(x.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ji.IND,()=>this.index()),this._parser.setExecuteHandler(Ji.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ji.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ne(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ne(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ne(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ne(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ne(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ne(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ne(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ne(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ne(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ne(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ne(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ne(h=>this.restoreCursorColor(h))),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 _e)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(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new zn((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Kn))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Kn} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){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,e))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Mt&&(n=this._parseStack.position+Mt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(h=>h.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Mt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Mt))),o||this._dirtyRowTracker.clearRange(),t.length>Mt)for(let h=n;h<t.length;h+=Mt){let c=h+Mt<t.length?h+Mt:t.length,d=typeof t=="string"?this._stringDecoder.decode(t.substring(h,c),this._parseBuffer):this._utf8Decoder.decode(t.subarray(h,c),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(s,r,h,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(t,e,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-e>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let _=e;_<i;++_){if(s=t[_],s<127&&n){let A=n[String.fromCharCode(s)];A&&(s=A.charCodeAt(0))}let f=this._unicodeService.charProperties(s,u);r=Wt.extractWidth(f);let S=Wt.extractShouldJoin(f),k=S?Wt.extractWidth(u):0;if(u=f,o&&this._onA11yChar.fire(At(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-k>a){if(l){let A=d,D=this._activeBuffer.x-k;for(this._activeBuffer.x=k,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),k>0&&d instanceof Ci&&d.copyCellsFrom(A,D,0,k,!1);D<a;)A.setCellFromCodepoint(D++,0,1,c)}else if(this._activeBuffer.x=a-1,r===2)continue}if(S&&this._activeBuffer.x){let A=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-A,s,r);for(let D=r-k;--D>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(d.insertCells(this._activeBuffer.x,r-k,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&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-e>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,i=>qn(i.params[0],this._optionsService.rawOptions.windowOptions)?e(i):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new zn(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ne(e))}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(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(t,e=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),i.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let i;switch(t.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);i<this._bufferService.rows;i++)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.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(;e--;)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(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;e--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(he));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let i=t.params[0]||1,s=Wt.extractWidth(e),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 c=n.codePointAt(h)||0;o[a++]=c,h+=c>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(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(x.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(x.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(x.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(x.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(x.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Nt),this._charsetService.setgCharset(1,Nt),this._charsetService.setgCharset(2,Nt),this._charsetService.setgCharset(3,Nt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let i;(S=>(S[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"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:h,alt:c}=a,d=this._optionsService.rawOptions,u=(S,k)=>(o.triggerDataEvent(`${x.ESC}[${e?"":"?"}${S};${k}$y`),!0),_=S=>S?1:2,f=t.params[0];return e?f===2?u(f,4):f===4?u(f,_(o.modes.insertMode)):f===12?u(f,3):f===20?u(f,_(d.convertEol)):u(f,0):f===1?u(f,_(s.applicationCursorKeys)):f===3?u(f,d.windowOptions.setWinLines?l===80?2:l===132?1:0:0):f===6?u(f,_(s.origin)):f===7?u(f,_(s.wraparound)):f===8?u(f,3):f===9?u(f,_(r==="X10")):f===12?u(f,_(d.cursorBlink)):f===25?u(f,_(!o.isCursorHidden)):f===45?u(f,_(s.reverseWraparound)):f===66?u(f,_(s.applicationKeypad)):f===67?u(f,4):f===1e3?u(f,_(r==="VT200")):f===1002?u(f,_(r==="DRAG")):f===1003?u(f,_(r==="ANY")):f===1004?u(f,_(s.sendFocus)):f===1005?u(f,4):f===1006?u(f,_(n==="SGR")):f===1015?u(f,4):f===1016?u(f,_(n==="SGR_PIXELS")):f===1048?u(f,1):f===47||f===1047||f===1049?u(f,_(h===c)):f===2004?u(f,_(s.bracketedPasteMode)):f===2026?u(f,_(s.synchronizedOutput)):u(f,0)}_updateAttrColor(t,e,i,s,r){return e===2?(t|=50331648,t&=-16777216,t|=Pi.fromColorRGB([i,s,r])):e===5&&(t&=-50331904,t|=33554432|i&255),t}_extractColor(t,e,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+e<t.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=he.fg,t.bg=he.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,i,s=this._curAttrData;for(let r=0;r<e;r++)i=t.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=he.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=he.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(t,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=he.fg&16777215,s.bg&=-67108864,s.bg|=he.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${x.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[${e};${i}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[?${e};${i}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=he.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=e%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(t){let e=t.params[0]||1,i;return(t.length<2||(i=t.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!qn(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${x.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Un&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Un&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],i=t.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Gn(n))if(r==="?")e.push({type:0,index:n});else{let o=Hn(r);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let i=t.slice(0,e).trim(),s=t.slice(e+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let i=t.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let i=t.split(";");for(let s=0;s<i.length&&!(e>=this._specialColors.length);++s,++e)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=Hn(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],i=t.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Gn(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,Nt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(Hc[t[0]],_e[t[1]]||Nt),!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 t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=he.clone(),this._eraseAttrDataInternal=he.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Je;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let i=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(i);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let i=o=>(this._coreService.triggerDataEvent(`${x.ESC}${o}${x.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Br=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Vn=t,t=e,e=Vn),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Br=re([T(0,Te)],Br);function Gn(t){return 0<=t&&t<256}var qc=5e7,Yn=12,Kc=50,Vc=class extends F{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 E),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){if(i!==void 0&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,i){if(this._pendingData>qc)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],n=this._action(r,i);if(n){let a=l=>performance.now()-s>=Yn?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Yn)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Kc&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Rr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(e.id===void 0){let l=i.addMarker(i.ybase+i.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),n=this._entriesWithId.get(r);if(n)return this.addLineToLink(n.id,i.ybase+i.y),n.id;let o=i.addMarker(i.ybase+i.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,i){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==i)){let r=this._bufferService.buffer.addMarker(i);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let s=e.lines.indexOf(i);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Rr=re([T(0,Te)],Rr);var Xn=!1,Gc=class extends F{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ni),this._onBinary=this._register(new E),this.onBinary=this._onBinary.event,this._onData=this._register(new E),this.onData=this._onData.event,this._onLineFeed=this._register(new E),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new E),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new E),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new E),this._instantiationService=new vc,this.optionsService=this._register(new Ec(e)),this._instantiationService.setService(Pe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(kr)),this._instantiationService.setService(Te,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(xr)),this._instantiationService.setService($o,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Lr)),this._instantiationService.setService(Gt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Er)),this._instantiationService.setService(Io,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Wt)),this._instantiationService.setService(_h,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Ac),this._instantiationService.setService(uh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Rr),this._instantiationService.setService(Fo,this._oscLinkService),this._inputHandler=this._register(new Uc(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Le.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Le.forward(this._bufferService.onResize,this._onResize)),this._register(Le.forward(this.coreService.onData,this._onData)),this._register(Le.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((i,s)=>this._inputHandler.parse(i,s))),this._register(Le.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new E),this._onScroll.event(e=>{this._onScrollApi?.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 i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!Xn&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Xn=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,pa),i=Math.max(i,va),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&i.buildNumber!==void 0&&i.buildNumber!==void 0?e=i.backend==="conpty"&&i.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(Wn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Wn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=J(()=>{for(let i of e)i.dispose()})}}},Yc={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Xc(t,e,i,s){let r={type:0,cancel:!1,key:void 0},n=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=x.ESC+"OA":r.key=x.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=x.ESC+"OD":r.key=x.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=x.ESC+"OC":r.key=x.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=x.ESC+"OB":r.key=x.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":x.DEL,t.altKey&&(r.key=x.ESC+r.key);break;case 9:if(t.shiftKey){r.key=x.ESC+"[Z";break}r.key=x.HT,r.cancel=!0;break;case 13:r.key=t.altKey?x.ESC+x.CR:x.CR,r.cancel=!0;break;case 27:r.key=x.ESC,t.altKey&&(r.key=x.ESC+x.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"D":e?r.key=x.ESC+"OD":r.key=x.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"C":e?r.key=x.ESC+"OC":r.key=x.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"A":e?r.key=x.ESC+"OA":r.key=x.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"B":e?r.key=x.ESC+"OB":r.key=x.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=x.ESC+"[2~");break;case 46:n?r.key=x.ESC+"[3;"+(n+1)+"~":r.key=x.ESC+"[3~";break;case 36:n?r.key=x.ESC+"[1;"+(n+1)+"H":e?r.key=x.ESC+"OH":r.key=x.ESC+"[H";break;case 35:n?r.key=x.ESC+"[1;"+(n+1)+"F":e?r.key=x.ESC+"OF":r.key=x.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=x.ESC+"[5;"+(n+1)+"~":r.key=x.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=x.ESC+"[6;"+(n+1)+"~":r.key=x.ESC+"[6~";break;case 112:n?r.key=x.ESC+"[1;"+(n+1)+"P":r.key=x.ESC+"OP";break;case 113:n?r.key=x.ESC+"[1;"+(n+1)+"Q":r.key=x.ESC+"OQ";break;case 114:n?r.key=x.ESC+"[1;"+(n+1)+"R":r.key=x.ESC+"OR";break;case 115:n?r.key=x.ESC+"[1;"+(n+1)+"S":r.key=x.ESC+"OS";break;case 116:n?r.key=x.ESC+"[15;"+(n+1)+"~":r.key=x.ESC+"[15~";break;case 117:n?r.key=x.ESC+"[17;"+(n+1)+"~":r.key=x.ESC+"[17~";break;case 118:n?r.key=x.ESC+"[18;"+(n+1)+"~":r.key=x.ESC+"[18~";break;case 119:n?r.key=x.ESC+"[19;"+(n+1)+"~":r.key=x.ESC+"[19~";break;case 120:n?r.key=x.ESC+"[20;"+(n+1)+"~":r.key=x.ESC+"[20~";break;case 121:n?r.key=x.ESC+"[21;"+(n+1)+"~":r.key=x.ESC+"[21~";break;case 122:n?r.key=x.ESC+"[23;"+(n+1)+"~":r.key=x.ESC+"[23~";break;case 123:n?r.key=x.ESC+"[24;"+(n+1)+"~":r.key=x.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=x.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=x.DEL:t.keyCode===219?r.key=x.ESC:t.keyCode===220?r.key=x.FS:t.keyCode===221&&(r.key=x.GS);else if((!i||s)&&t.altKey&&!t.metaKey){let o=Yc[t.keyCode]?.[t.shiftKey?1:0];if(o)r.key=x.ESC+o;else if(t.keyCode>=65&&t.keyCode<=90){let a=t.ctrlKey?t.keyCode-64:t.keyCode+32,l=String.fromCharCode(a);t.shiftKey&&(l=l.toUpperCase()),r.key=x.ESC+l}else if(t.keyCode===32)r.key=x.ESC+(t.ctrlKey?x.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),r.key=x.ESC+a,r.cancel=!0}}else i&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=x.US),t.key==="@"&&(r.key=x.NUL));break}return r}var ne=0,jc=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new hs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new hs,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),i=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<r.length;n++)s>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[s])?(r[n]=e[i],i++):r[n]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let i=this._getKey(e);if(i===void 0||(ne=this._search(i),ne===-1)||this._getKey(this._array[ne])!==i)return!1;do if(this._array[ne]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ne),!0;while(++ne<this._array.length&&this._getKey(this._array[ne])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),i=0,s=new Array(this._array.length-e.length),r=0;for(let n=0;n<this._array.length;n++)e[i]===n?i++:s[r++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ne=this._search(e),!(ne<0||ne>=this._array.length)&&this._getKey(this._array[ne])===e))do yield this._array[ne];while(++ne<this._array.length&&this._getKey(this._array[ne])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ne=this._search(e),!(ne<0||ne>=this._array.length)&&this._getKey(this._array[ne])===e))do i(this._array[ne]);while(++ne<this._array.length&&this._getKey(this._array[ne])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,s=this._array.length-1;for(;s>=i;){let r=i+s>>1,n=this._getKey(this._array[r]);if(n>e)s=r-1;else if(n<e)i=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return i}},Ps=0,jn=0,Zc=class extends F{constructor(){super(),this._decorations=new jc(t=>t?.marker.line),this._onDecorationRegistered=this._register(new E),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new E),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(J(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new Jc(t);if(e){let i=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),i.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(e))s=n.options.x??0,r=s+(n.options.width??1),t>=s&&t<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(t,e,i,s){this._decorations.forEachByKey(e,r=>{Ps=r.options.x??0,jn=Ps+(r.options.width??1),t>=Ps&&t<jn&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},Jc=class extends Ot{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new E),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new E),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ee.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ee.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Qc=1e3,ed=class{constructor(e,i=Qc){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,s){this._rowCount=s,e=e!==void 0?e:0,i=i!==void 0?i:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,i):i;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=r-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},Zn=20,ls=class extends F{constructor(t,e,i,s){super(),this._terminal=t,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new ed(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
14
- `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(O(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(J(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Zn+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
15
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Zn+1&&(this._liveRegion.textContent+=js.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=t;r<=e;r++){let n=i.lines.get(i.ydisp+r),o=[],a=n?.translateToString(!0,void 0,void 0,o)||"",l=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",l),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let i=t.target,s=this._rowElements[e===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||t.relatedTarget!==s)return;let o,a;if(e===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},i={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===i.node&&e.offset>i.offset)&&([e,i]=[i,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let r=({node:a,offset:l})=>{let h=a instanceof Text?a.parentNode:a,c=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(h);if(!d)return console.warn("columns is null. Race condition?"),null;let u=l<d.length?d[l]:d.slice(-1)[0]+1;return u>=this._terminal.cols&&(++c,u=0),{row:c,column:u}},n=r(e),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_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 t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,i=this._rowColumns.get(t)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${s/e})`}};ls=re([T(1,Hr),T(2,xt),T(3,kt)],ls);var Dr=class extends F{constructor(t,e,i,s,r){super(),this._element=t,this._mouseService=e,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 E),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new E),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(J(()=>{Kt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(O(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(O(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(O(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(O(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let i=t.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let i=!1;for(let[s,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,t,i)):r.provideLinks(t.y,n=>{if(this._isMouseOut)return;let o=n?.map(a=>({link:a}));this._activeProviderReplies?.set(s,o),i=this._checkLinkProviderResult(s,t,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let i=new Set;for(let s=0;s<e.size;s++){let r=e.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<t?0:o.link.range.start.x,l=o.link.range.end.y>t?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=l;h++){if(i.has(h)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(t,e,i){if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&s){let n=s.find(o=>this._linkAtPosition(o.link,e));n&&(i=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let n=0;n<this._activeProviderReplies.size;n++){let o=this._activeProviderReplies.get(n)?.find(a=>this._linkAtPosition(a.link,e));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&td(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Kt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(i,e.text)}_fireUnderlineEvent(t,e){let i=t.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);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(i,e.text)}_linkAtPosition(t,e){let i=t.range.start.y*this._bufferService.cols+t.range.start.x,s=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return i<=r&&r<=s}_positionFromMouseEvent(t,e,i){let s=i.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,i,s,r){return{x1:t,y1:e,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Dr=re([T(1,Ur),T(2,kt),T(3,Te),T(4,Wo)],Dr);function td(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var id=class extends Gc{constructor(e={}){super(e),this._linkifier=this._register(new ni),this.browser=na,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ni),this._onCursorMove=this._register(new E),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new E),this.onKey=this._onKey.event,this._onRender=this._register(new E),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new E),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new E),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new E),this.onBell=this._onBell.event,this._onFocus=this._register(new E),this._onBlur=this._register(new E),this._onA11yCharEmitter=this._register(new E),this._onA11yTabEmitter=this._register(new E),this._onWillOpen=this._register(new E),this._setup(),this._decorationService=this._instantiationService.createInstance(Zc),this._instantiationService.setService(Oi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Kl),this._instantiationService.setService(Wo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Js)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(i=>this.refresh(i?.start??0,i?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(i=>this._reportWindowsOptions(i))),this._register(this._inputHandler.onColor(i=>this._handleColorEvent(i))),this._register(Le.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Le.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Le.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Le.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(i=>this._afterResize(i.cols,i.rows))),this._register(J(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.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 i of e){let s,r="";switch(i.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+i.index}switch(i.type){case 0:let n=j.toColorRGB(s==="ansi"?this._themeService.colors.ansi[i.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${x.ESC}]${r};${zc(n)}${sa.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[i.index]=ce.toColor(...i.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=ce.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ls,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.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,i=this.buffer.lines.get(e);if(!i)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,n=i.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(O(this.element,"copy",i=>{this.hasSelection()&&oh(i,this._selectionService)}));let e=i=>ah(i,this.textarea,this.coreService,this.optionsService);this._register(O(this.textarea,"paste",e)),this._register(O(this.element,"paste",e)),oa?this._register(O(this.element,"mousedown",i=>{i.button===2&&an(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(O(this.element,"contextmenu",i=>{an(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Zr&&this._register(O(this.element,"auxclick",i=>{i.button===1&&Do(i,this.textarea,this.screenElement)}))}_bindKeys(){this._register(O(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(O(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(O(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(O(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(O(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(O(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(O(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){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"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let 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(O(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),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",Xs.get()),la||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(Ul,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xt,this._coreBrowserService),this._register(O(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(O(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Sr,this._document,this._helperContainer),this._instantiationService.setService(gs,this._charSizeService),this._themeService=this._instantiationService.createInstance(yr),this._instantiationService.setService(oi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(os),this._instantiationService.setService(No,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(br,this.rows,this.screenElement)),this._instantiationService.setService(kt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(pr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(wr),this._instantiationService.setService(Ur,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Dr,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(fr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Cr,this.element,this.screenElement,r)),this._instantiationService.setService(gh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Le.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(gr,this.screenElement)),this._register(O(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ls,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ns,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ns,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(mr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function s(o){let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let c=o.deltaY;if(c===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?r.mousemove||(i.addEventListener("mousemove",n.mousemove),r.mousemove=n.mousemove):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(i.addEventListener("wheel",n.wheel,{passive:!1}),r.wheel=n.wheel):(i.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(O(i,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(O(i,"wheel",o=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=x.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.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,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}paste(e){Ro(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 i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,i,s){this._selectionService.setSelection(e,i,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!i&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=Xc(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===x.ETX||s.key===x.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,i){let s=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return i.type==="keypress"?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(sd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(e.which===null||e.which===void 0)i=e.keyCode;else if(e.which!==0&&e.charCode!==0)i=e.which;else return!1;return!i||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(he));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(x.ESC+"[I"):this.coreService.triggerDataEvent(x.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[4;${s};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[6;${n};${r}t`);break}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}};function sd(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var rd=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){i=s;break}if(i===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},nd=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new Je)}translateToString(e,i,s){return this._line.translateToString(e,i,s)}},Jn=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new nd(e)}getNullCell(){return new Je}},od=class extends F{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new E),this.onBufferChange=this._onBufferChange.event,this._normal=new Jn(this._core.buffers.normal,"normal"),this._alternate=new Jn(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)}},ad=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,s)=>e(i,s.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},hd=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}},ld=["cols","rows"],rt=0,cd=class extends F{constructor(t){super(),this._core=this._register(new id(t)),this._addonManager=this._register(new rd),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(t){if(ld.includes(t))throw new Error(`Option "${t}" 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 ad(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new hd(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 od(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
16
- `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Xs.get()},set promptLabel(t){Xs.set(t)},get tooMuchOutput(){return js.get()},set tooMuchOutput(t){js.set(t)}}}_verifyIntegers(...t){for(rt of t)if(rt===1/0||isNaN(rt)||rt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(rt of t)if(rt&&(rt===1/0||isNaN(rt)||rt%1!==0||rt<0))throw new Error("This API only accepts positive integers")}};var dd=2,ud=1,_d=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,h=s-a,c=r-l-e;return{cols:Math.max(dd,Math.floor(c/t.css.cell.width)),rows:Math.max(ud,Math.floor(h/t.css.cell.height))}}};var fd=(t,e,i,s)=>{for(var r=e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=o(r)||r);return r},gd=(t,e)=>(i,s)=>e(i,s,t),pd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Qn.isErrorNoTelemetry(t)?new Qn(t.message+`
13
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),en&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!i?!1:this._areCoordsInSelection(i,s,r)}isCellInSelection(e,i){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,i],s,r)}_areCoordsInSelection(e,i,s){return e[1]>i[1]&&e[1]<s[1]||i[1]===s[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<s[0]||i[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||i[1]<s[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Dn(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,i),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=Qr(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=s?0:(i>s&&(i-=s),i=Math.min(Math.max(i,-Rs),Rs),i/=Rs,i/Math.abs(i)+Math.round(i*(gc-1)))}shouldForceSelection(e){return ls?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),pc)}_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 i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&i.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(ls&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let r=s.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!i||i[0]!==this._model.selectionEnd[0]||i[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<vc&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let r=ac(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,s=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,i,s);return}!e||!i||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||i[0]!==this._oldSelectionEnd[0]||i[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,i,s)}_fireOnSelectionChange(e,i,s){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(i=>this._handleTrim(i))}_convertViewportColToCharacterIndex(e,i){let s=i;for(let r=0;i>=r;r++){let n=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&i!==r&&(s+=n-1)}return s}setSelection(e,i,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,d=0,u=0,_=0,f=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let D=e[0],A=e[0];o.getWidth(D)===0&&(d++,D--),o.getWidth(A)===2&&(u++,A++);let B=o.getString(A).length;for(B>1&&(f+=B-1,h+=B-1);D>0&&l>0&&!this._isCharWordSeparator(o.loadCell(D-1,this._workCell));){o.loadCell(D-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,D--):w>1&&(_+=w-1,l-=w-1),l--,D--}for(;A<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(A+1,this._workCell));){o.loadCell(A+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,A++):w>1&&(f+=w-1,h+=w-1),h++,A++}}h++;let S=l+c-d+_,k=Math.min(this._bufferService.cols,h-l+d+u-_-f);if(!(!i&&a.slice(l,h).trim()==="")){if(s&&S===0&&o.getCodePoint(0)!==32){let D=n.lines.get(e[1]-1);if(D&&o.isWrapped&&D.getCodePoint(this._bufferService.cols-1)!==32){let A=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(A){let B=this._bufferService.cols-A.start;S-=B,k+=B}}}if(r&&S+k===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let D=n.lines.get(e[1]+1);if(D?.isWrapped&&D.getCodePoint(0)!==32){let A=this._getWordAt([0,e[1]+1],!1,!1,!0);A&&(k+=A.length)}}return{start:S,length:k}}}_selectWordAt(e,i){let s=this._getWordAt(e,i);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let s=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Dn(s,this._bufferService.cols)}};kr=re([T(3,Te),T(4,Gt),T(5,Vr),T(6,Pe),T(7,Lt),T(8,kt)],kr);var Tn=class{constructor(){this._data={}}set(e,i,s){this._data[e]||(this._data[e]={}),this._data[e][i]=s}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},Pn=class{constructor(){this._color=new Tn,this._css=new Tn}setCss(e,i,s){this._css.set(e,i,s)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,s){this._color.set(e,i,s)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},de=Object.freeze((()=>{let t=[ee.toColor("#2e3436"),ee.toColor("#cc0000"),ee.toColor("#4e9a06"),ee.toColor("#c4a000"),ee.toColor("#3465a4"),ee.toColor("#75507b"),ee.toColor("#06989a"),ee.toColor("#d3d7cf"),ee.toColor("#555753"),ee.toColor("#ef2929"),ee.toColor("#8ae234"),ee.toColor("#fce94f"),ee.toColor("#729fcf"),ee.toColor("#ad7fa8"),ee.toColor("#34e2e2"),ee.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=e[i/36%6|0],r=e[i/6%6|0],n=e[i%6];t.push({css:ce.toCss(s,r,n),rgba:ce.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;t.push({css:ce.toCss(s,s,s),rgba:ce.toRgba(s,s,s)})}return t})()),Ft=ee.toColor("#ffffff"),bi=ee.toColor("#000000"),On=ee.toColor("#ffffff"),In=bi,ui={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},wc=Ft,Lr=class extends F{constructor(e){super(),this._optionsService=e,this._contrastCache=new Pn,this._halfContrastCache=new Pn,this._onChangeColors=this._register(new E),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ft,background:bi,cursor:On,cursorAccent:In,selectionForeground:void 0,selectionBackgroundTransparent:ui,selectionBackgroundOpaque:j.blend(bi,ui),selectionInactiveBackgroundTransparent:ui,selectionInactiveBackgroundOpaque:j.blend(bi,ui),scrollbarSliderBackground:j.opacity(Ft,.2),scrollbarSliderHoverBackground:j.opacity(Ft,.4),scrollbarSliderActiveBackground:j.opacity(Ft,.5),overviewRulerBorder:Ft,ansi:de.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 i=this._colors;if(i.foreground=q(e.foreground,Ft),i.background=q(e.background,bi),i.cursor=j.blend(i.background,q(e.cursor,On)),i.cursorAccent=j.blend(i.background,q(e.cursorAccent,In)),i.selectionBackgroundTransparent=q(e.selectionBackground,ui),i.selectionBackgroundOpaque=j.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=q(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=j.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?q(e.selectionForeground,Bn):void 0,i.selectionForeground===Bn&&(i.selectionForeground=void 0),j.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=j.opacity(i.selectionBackgroundTransparent,.3)),j.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=j.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=q(e.scrollbarSliderBackground,j.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=q(e.scrollbarSliderHoverBackground,j.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=q(e.scrollbarSliderActiveBackground,j.opacity(i.foreground,.5)),i.overviewRulerBorder=q(e.overviewRulerBorder,wc),i.ansi=de.slice(),i.ansi[0]=q(e.black,de[0]),i.ansi[1]=q(e.red,de[1]),i.ansi[2]=q(e.green,de[2]),i.ansi[3]=q(e.yellow,de[3]),i.ansi[4]=q(e.blue,de[4]),i.ansi[5]=q(e.magenta,de[5]),i.ansi[6]=q(e.cyan,de[6]),i.ansi[7]=q(e.white,de[7]),i.ansi[8]=q(e.brightBlack,de[8]),i.ansi[9]=q(e.brightRed,de[9]),i.ansi[10]=q(e.brightGreen,de[10]),i.ansi[11]=q(e.brightYellow,de[11]),i.ansi[12]=q(e.brightBlue,de[12]),i.ansi[13]=q(e.brightMagenta,de[13]),i.ansi[14]=q(e.brightCyan,de[14]),i.ansi[15]=q(e.brightWhite,de[15]),e.extendedAnsi){let s=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)i.ansi[r+16]=q(e.extendedAnsi[r],de[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let i=0;i<this._restoreColors.ansi.length;++i)this._colors.ansi[i]=this._restoreColors.ansi[i];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Lr=re([T(0,Pe)],Lr);function q(t,e){if(t!==void 0)try{return ee.toColor(t)}catch{}return e}var bc=class{constructor(...e){this._entries=new Map;for(let[i,s]of e)this.set(i,s)}set(e,i){let s=this._entries.get(e);return this._entries.set(e,i),s}forEach(e){for(let[i,s]of this._entries.entries())e(i,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Cc=class{constructor(){this._services=new bc,this._services.set(Kr,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let i=gh(t).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new t(...e,...s)}},yc={trace:0,debug:1,info:2,warn:3,error:4,off:5},xc="xterm.js: ",Er=class extends F{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=yc[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)typeof e[i]=="function"&&(e[i]=e[i]())}_log(e,i,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":xc)+i,...s)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};Er=re([T(0,Pe)],Er);var $n=class extends F{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new E),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new E),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new E),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 i=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)i[s]=this._array[this._getCyclicIndex(s)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}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,i,...s){if(i){for(let r=e;r<this._length-i;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,s){if(!(i<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=i-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let r=e+i+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<i;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},$=3,he=Object.freeze(new Oi),Ki=0,As=2,Ci=class va{constructor(e,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*$);let r=i||Je.fromCharData([0,Io,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let i=this._data[e*$+0],s=i&2097151;return[this._data[e*$+1],i&2097152?this._combined[e]:s?Tt(s):"",i>>22,i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,i){this._data[e*$+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[e*$+0]=e|2097152|i[2]<<22):this._data[e*$+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[e*$+0]>>22}hasWidth(e){return this._data[e*$+0]&12582912}getFg(e){return this._data[e*$+1]}getBg(e){return this._data[e*$+2]}hasContent(e){return this._data[e*$+0]&4194303}getCodePoint(e){let i=this._data[e*$+0];return i&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):i&2097151}isCombined(e){return this._data[e*$+0]&2097152}getString(e){let i=this._data[e*$+0];return i&2097152?this._combined[e]:i&2097151?Tt(i&2097151):""}isProtected(e){return this._data[e*$+2]&536870912}loadCell(e,i){return Ki=e*$,i.content=this._data[Ki+0],i.fg=this._data[Ki+1],i.bg=this._data[Ki+2],i.content&2097152&&(i.combinedData=this._combined[e]),i.bg&268435456&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){i.content&2097152&&(this._combined[e]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*$+0]=i.content,this._data[e*$+1]=i.fg,this._data[e*$+2]=i.bg}setCellFromCodepoint(e,i,s,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*$+0]=i|s<<22,this._data[e*$+1]=r.fg,this._data[e*$+2]=r.bg}addCodepointToCell(e,i,s){let r=this._data[e*$+0];r&2097152?this._combined[e]+=Tt(i):r&2097151?(this._combined[e]=Tt(r&2097151)+Tt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[e*$+0]=r}insertCells(e,i,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length-e){let r=new Je;for(let n=this.length-e-i-1;n>=0;--n)this.setCell(e+i+n,this.loadCell(e+n,r));for(let n=0;n<i;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,i,s){if(e%=this.length,i<this.length-e){let r=new Je;for(let n=0;n<this.length-e-i;++n)this.setCell(e+n,this.loadCell(e+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,i,s,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.setCell(e++,s)}resize(e,i){if(e===this.length)return this._data.length*4*As<this._data.buffer.byteLength;let s=e*$;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=e&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=e&&delete this._extendedAttrs[a]}}return this.length=e,s*4*As<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*As<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in e._combined)this._combined[i]=e._combined[i];this._extendedAttrs={};for(let i in e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let e=new va(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let i in this._combined)e._combined[i]=this._combined[i];for(let i in this._extendedAttrs)e._extendedAttrs[i]=this._extendedAttrs[i];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$+0]&4194303)return e+(this._data[e*$+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$+0]&4194303||this._data[e*$+2]&50331648)return e+(this._data[e*$+0]>>22);return 0}copyCellsFrom(e,i,s,r,n){let o=e._data;if(n)for(let l=r-1;l>=0;l--){for(let h=0;h<$;h++)this._data[(s+l)*$+h]=o[(i+l)*$+h];o[(i+l)*$+2]&268435456&&(this._extendedAttrs[s+l]=e._extendedAttrs[i+l])}else for(let l=0;l<r;l++){for(let h=0;h<$;h++)this._data[(s+l)*$+h]=o[(i+l)*$+h];o[(i+l)*$+2]&268435456&&(this._extendedAttrs[s+l]=e._extendedAttrs[i+l])}let a=Object.keys(e._combined);for(let l=0;l<a.length;l++){let h=parseInt(a[l],10);h>=i&&(this._combined[h-i+s]=e._combined[h])}}translateToString(e,i,s,r){i=i??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*$+0],a=o&2097151,l=o&2097152?this._combined[i]:a?Tt(a):Pt;if(n+=l,r)for(let h=0;h<l.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function kc(t,e,i,s,r,n){let o=[];for(let a=0;a<t.length-1;a++){let l=a,h=t.get(++l);if(!h.isWrapped)continue;let c=[t.get(a)];for(;l<t.length&&h.isWrapped;)c.push(h),h=t.get(++l);if(!n&&s>=a&&s<l){a+=c.length-1;continue}let d=0,u=Ri(c,d,e),_=1,f=0;for(;_<c.length;){let k=Ri(c,_,e),D=k-f,A=i-u,B=Math.min(D,A);c[d].copyCellsFrom(c[_],f,u,B,!1),u+=B,u===i&&(d++,u=0),f+=B,f===k&&(_++,f=0),u===0&&d!==0&&c[d-1].getWidth(i-1)===2&&(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 S=0;for(let k=c.length-1;k>0&&(k>d||c[k].getTrimmedLength()===0);k--)S++;S>0&&(o.push(a+c.length-S),o.push(S)),a+=c.length-1}return o}function Lc(t,e){let i=[],s=0,r=e[s],n=0;for(let o=0;o<t.length;o++)if(r===o){let a=e[++s];t.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=e[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Ec(t,e){let i=[];for(let s=0;s<e.length;s++)i.push(t.get(e[s]));for(let s=0;s<i.length;s++)t.set(s,i[s]);t.length=e.length}function Mc(t,e,i){let s=[],r=t.map((l,h)=>Ri(t,h,e)).reduce((l,h)=>l+h),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let l=Ri(t,o,e);n>l&&(n-=l,o++);let h=t[o].getWidth(n-1)===2;h&&n--;let c=h?i-1:i;s.push(c),a+=c}return s}function Ri(t,e,i){if(e===t.length-1)return t[e].getTrimmedLength();let s=!t[e].hasContent(i-1)&&t[e].getWidth(i-1)===1,r=t[e+1].getWidth(0)===2;return s&&r?i-1:i}var ma=class Sa{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Sa._nextId++,this._onDispose=this.register(new E),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Kt(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ma._nextId=1;var Bc=ma,_e={},Nt=_e.B;_e[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:"≥","{":"π","|":"≠","}":"£","~":"·"};_e.A={"#":"£"};_e.B=void 0;_e[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};_e.C=_e[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_e.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};_e.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};_e.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};_e.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};_e.E=_e[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};_e.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};_e.H=_e[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};_e["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Fn=4294967295,Nn=class{constructor(t,e,i){this._hasScrollback=t,this._optionsService=e,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=he.clone(),this.savedCharset=Nt,this.markers=[],this._nullCell=Je.fromCharData([0,Io,1,0]),this._whitespaceCell=Je.fromCharData([0,Pt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new cs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new $n(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new os),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new os),this._whitespaceCell}getBlankLine(t,e){return new Ci(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>Fn?Fn:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=he);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new $n(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let i=this.getNullCell(he),s=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<t)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(t,i);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Ci(t,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 Ci(t,i)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(t,i);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,s=kc(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(he),i);if(s.length>0){let r=Lc(this.lines,s);Ec(this.lines,r.layout),this._reflowLargerAdjustViewport(t,e,r.countRemoved)}}_reflowLargerAdjustViewport(t,e,i){let s=this.getNullCell(he),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new Ci(t,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(t,e){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(he),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()<=t)continue;let l=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),l.unshift(a);if(!i){let B=this.ybase+this.y;if(B>=o&&B<o+l.length)continue}let h=l[l.length-1].getTrimmedLength(),c=Mc(l,this._cols,t),d=c.length-l.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+d):u=Math.max(0,this.lines.length-this.lines.maxLength+d);let _=[];for(let B=0;B<d;B++){let w=this.getBlankLine(he,!0);_.push(w)}_.length>0&&(r.push({start:o+l.length+n,newLines:_}),n+=_.length),l.push(..._);let f=c.length-1,S=c[f];S===0&&(f--,S=c[f]);let k=l.length-d-1,D=h;for(;k>=0;){let B=Math.min(D,S);if(l[f]===void 0)break;if(l[f].copyCellsFrom(l[k],D-B,S-B,B,!0),S-=B,S===0&&(f--,S=c[f]),D-=B,D===0){k--;let w=Math.max(k,0);D=Ri(l,w,this._cols)}}for(let B=0;B<l.length;B++)c[B]<t&&l[B].setCell(c[B],s);let A=d-u;for(;A-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(r.length>0){let o=[],a=[];for(let S=0;S<this.lines.length;S++)a.push(this.lines.get(S));let l=this.lines.length,h=l-1,c=0,d=r[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let u=0;for(let S=Math.min(this.lines.maxLength-1,l+n-1);S>=0;S--)if(d&&d.start>h+u){for(let k=d.newLines.length-1;k>=0;k--)this.lines.set(S--,d.newLines[k]);S++,o.push({index:h+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c]}else this.lines.set(S,a[h--]);let _=0;for(let S=o.length-1;S>=0;S--)o[S].index+=_,this.lines.onInsertEmitter.fire(o[S]),_+=o[S].amount;let f=Math.max(0,l+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(t,e,i=0,s){let r=this.lines.get(t);return r?r.translateToString(e,i,s):""}getWrappedRangeForLine(t){let e=t,i=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:e,last:i}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new Bc(t);return this.markers.push(e),e.register(this.lines.onTrim(i=>{e.line-=i,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(i=>{e.line>=i.index&&(e.line+=i.amount)})),e.register(this.lines.onDelete(i=>{e.line>=i.index&&e.line<i.index+i.amount&&e.dispose(),e.line>i.index&&(e.line-=i.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},Rc=class extends F{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new E),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 Nn(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Nn(!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,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},wa=2,ba=1,Mr=class extends F{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new E),this.onResize=this._onResize.event,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,wa),this.rows=Math.max(t.rawOptions.rows||0,ba),this.buffers=this._register(new Rc(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let i=this.cols!==t,s=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=i.getBlankLine(t,e),this._cachedBlankLine=s),s.isWrapped=e;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(t,e){let i=this.buffer;if(t<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else t+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+t,i.ybase),0),s!==i.ydisp&&(e||this._onScroll.fire(i.ydisp))}};Mr=re([T(0,Pe)],Mr);var Xt={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:ls,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Ac=["normal","bold","100","200","300","400","500","600","700","800","900"],Dc=class extends F{constructor(e){super(),this._onOptionChange=this._register(new E),this.onOptionChange=this._onOptionChange.event;let i={...Xt};for(let s in e)if(s in i)try{let r=e[s];i[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(J(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(s=>{s===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&i()})}_setupOptions(){let e=s=>{if(!(s in Xt))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},i=(s,r)=>{if(!(s in Xt))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":if(i||(i=Xt[e]),!Tc(i))throw new Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=Xt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof i=="number"&&1<=i&&i<=1e3)break;i=Ac.includes(i)?i:Xt[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(i*10)/10));break;case"scrollback":if(i=Math.min(i,4294967295),i<0)throw new Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&i!==0)throw new Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{};break}return i}};function Tc(t){return t==="block"||t==="underline"||t==="bar"}function yi(t,e=5){if(typeof t!="object")return t;let i=Array.isArray(t)?[]:{};for(let s in t)i[s]=e<=1?t[s]:t[s]&&yi(t[s],e-1);return i}var Wn=Object.freeze({insertMode:!1}),zn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Br=class extends F{constructor(e,i,s){super(),this._bufferService=e,this._logService=i,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new E),this.onData=this._onData.event,this._onUserInput=this._register(new E),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new E),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new E),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=yi(Wn),this.decPrivateModes=yi(zn)}reset(){this.modes=yi(Wn),this.decPrivateModes=yi(zn)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.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(i=>i.charCodeAt(0))),this._onBinary.fire(e))}};Br=re([T(0,Te),T(1,zo),T(2,Pe)],Br);var Hn={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function Ds(t,e){let i=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(i|=64,i|=t.action):(i|=t.button&3,t.button&4&&(i|=64),t.button&8&&(i|=128),t.action===32?i|=32:t.action===0&&!e&&(i|=3)),i}var Ts=String.fromCharCode,Un={DEFAULT:t=>{let e=[Ds(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Ts(e[0])}${Ts(e[1])}${Ts(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Ds(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${Ds(t,!0)};${t.x};${t.y}${e}`}},Rr=class extends F{constructor(t,e,i){super(),this._bufferService=t,this._coreService=e,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new E),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Hn))this.addProtocol(s,Hn[s]);for(let s of Object.keys(Un))this.addEncoding(s,Un[s]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,i){if(t.deltaY===0||t.shiftKey||e===void 0||i===void 0)return 0;let s=e/i,r=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(t.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,i){if(i){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Rr=re([T(0,Te),T(1,Gt),T(2,Pe)],Rr);var Ps=[[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]],ue;function Oc(t,e){let i=0,s=e.length-1,r;if(t<e[0][0]||t>e[s][1])return!1;for(;s>=i;)if(r=i+s>>1,t>e[r][1])i=r+1;else if(t<e[r][0])s=r-1;else return!0;return!1}var Ic=class{constructor(){if(this.version="6",!ue){ue=new Uint8Array(65536),ue.fill(1),ue[0]=0,ue.fill(0,1,32),ue.fill(0,127,160),ue.fill(2,4352,4448),ue[9001]=2,ue[9002]=2,ue.fill(2,11904,42192),ue[12351]=1,ue.fill(2,44032,55204),ue.fill(2,63744,64256),ue.fill(2,65040,65050),ue.fill(2,65072,65136),ue.fill(2,65280,65377),ue.fill(2,65504,65511);for(let e=0;e<Ps.length;++e)ue.fill(0,Ps[e][0],Ps[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ue[e]:Oc(e,Pc)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,i){let s=this.wcwidth(e),r=s===0&&i!==0;if(r){let n=Wt.extractWidth(i);n===0?r=!1:n>s&&(s=n)}return Wt.createPropertyValue(0,s,r)}},Wt=class is{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new E,this.onChange=this._onChange.event;let e=new Ic;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,s=!1){return(e&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(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(e){let i=0,s=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let h=e.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let a=this.charProperties(o,s),l=is.extractWidth(a);is.extractShouldJoin(a)&&(l-=is.extractWidth(s)),i+=l,s=a}return i}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},$c=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,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function qn(t){let e=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);i&&e&&(i.isWrapped=e[3]!==0&&e[3]!==32)}var _i=2147483647,Fc=256,Ca=class Ar{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>Fc)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let i=new Ar;if(!e.length)return i;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let r=e[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let e=new Ar(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,r))}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;return}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>_i?_i:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>_i?_i:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(e[i]=this._subParams.slice(s,r))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+e,_i):e}},fi=[],Nc=class{constructor(){this._state=0,this._active=fi,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fi}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=fi,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fi,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,i,s){if(!this._active.length)this._handlerFb(this._id,"PUT",ps(e,i,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s)}start(){this.reset(),this._state=1}put(e,i,s){if(this._state!==3){if(this._state===1)for(;i<s;){let r=e[i++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&s-i>0&&this._put(e,i,s)}}end(e,i=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=fi,this._id=-1,this._state=0}}},Ne=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,s){this._hitLimit||(this._data+=ps(e,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data),i instanceof Promise))return i.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,i}},gi=[],Wc=class{constructor(){this._handlers=Object.create(null),this._active=gi,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=gi}registerHandler(e,i){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let r=s.indexOf(i);r!==-1&&s.splice(r,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=gi,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||gi,!this._active.length)this._handlerFb(this._ident,"HOOK",i);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(i)}put(e,i,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",ps(e,i,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s)}unhook(e,i=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=gi,this._ident=0}},xi=new Ca;xi.addParam(0);var Kn=class{constructor(t){this._handler=t,this._data="",this._params=xi,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():xi,this._data="",this._hitLimit=!1}put(t,e,i){this._hitLimit||(this._data+=ps(t,e,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(i=>(this._params=xi,this._data="",this._hitLimit=!1,i));return this._params=xi,this._data="",this._hitLimit=!1,e}},zc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,s,r){this.table[i<<8|e]=s<<4|r}addMany(e,i,s,r){for(let n=0;n<e.length;n++)this.table[i<<8|e[n]]=s<<4|r}},Xe=160,Hc=(function(){let t=new zc(4095),e=Array.apply(null,Array(256)).map((a,l)=>l),i=(a,l)=>e.slice(a,l),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;t.setDefault(1,0),t.addMany(s,0,2,0);for(o in n)t.addMany([24,26,153,154],o,3,0),t.addMany(i(128,144),o,3,0),t.addMany(i(144,152),o,3,0),t.add(156,o,0,0),t.add(27,o,11,1),t.add(157,o,4,8),t.addMany([152,158,159],o,0,7),t.add(155,o,11,3),t.add(144,o,11,9);return t.addMany(r,0,3,0),t.addMany(r,1,3,1),t.add(127,1,0,1),t.addMany(r,8,0,8),t.addMany(r,3,3,3),t.add(127,3,0,3),t.addMany(r,4,3,4),t.add(127,4,0,4),t.addMany(r,6,3,6),t.addMany(r,5,3,5),t.add(127,5,0,5),t.addMany(r,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(s,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(i(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(s,7,0,7),t.addMany(r,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(i(64,127),3,7,0),t.addMany(i(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(i(48,60),4,8,4),t.addMany(i(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(i(32,64),6,0,6),t.add(127,6,0,6),t.addMany(i(64,127),6,0,0),t.addMany(i(32,48),3,9,5),t.addMany(i(32,48),5,9,5),t.addMany(i(48,64),5,0,6),t.addMany(i(64,127),5,7,0),t.addMany(i(32,48),4,9,5),t.addMany(i(32,48),1,9,2),t.addMany(i(32,48),2,9,2),t.addMany(i(48,127),2,10,0),t.addMany(i(48,80),1,10,0),t.addMany(i(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(i(96,127),1,10,0),t.add(80,1,11,9),t.addMany(r,9,0,9),t.add(127,9,0,9),t.addMany(i(28,32),9,0,9),t.addMany(i(32,48),9,9,12),t.addMany(i(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(r,11,0,11),t.addMany(i(32,128),11,0,11),t.addMany(i(28,32),11,0,11),t.addMany(r,10,0,10),t.add(127,10,0,10),t.addMany(i(28,32),10,0,10),t.addMany(i(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(i(32,48),10,9,12),t.addMany(r,12,0,12),t.add(127,12,0,12),t.addMany(i(28,32),12,0,12),t.addMany(i(32,48),12,9,12),t.addMany(i(48,64),12,0,11),t.addMany(i(64,127),12,12,13),t.addMany(i(64,127),10,12,13),t.addMany(i(64,127),9,12,13),t.addMany(r,13,13,13),t.addMany(s,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Xe,0,2,0),t.add(Xe,8,5,8),t.add(Xe,6,0,6),t.add(Xe,11,0,11),t.add(Xe,13,13,13),t})(),Uc=class extends F{constructor(e=Hc){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 Ca,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(i,s,r)=>{},this._executeHandlerFb=i=>{},this._csiHandlerFb=(i,s)=>{},this._escHandlerFb=i=>{},this._errorHandlerFb=i=>i,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(J(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Nc),this._dcsParser=this._register(new Wc),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(i[0]>r||r>i[1])throw new Error(`final must be in range ${i[0]} .. ${i[1]}`);return s<<=8,s|=r,s}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(e&255)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(i),{dispose:()=>{let n=r.indexOf(i);n!==-1&&r.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(i),{dispose:()=>{let n=r.indexOf(i);n!==-1&&r.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,s,r,n){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=n}parse(e,i,s){let r=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(r!==24&&r!==26,s),a)return a;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<i;++l){switch(r=e[l],n=this._transitions.table[this.currentState<<8|(r<160?r:Xe)],n>>4){case 2:for(let _=l+1;;++_){if(_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-1;break}if(++_>=i||(r=e[_])<32||r>126&&r<Xe){this._printHandler(e,l,_),l=_-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:l,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|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(++l<i&&(r=e[l])>47&&r<60);l--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let d=this._escHandlers[this._collect<<8|r],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,u,n,l),a;u<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 _=l+1;;++_)if(_>=i||(r=e[_])===24||r===26||r===27||r>127&&r<Xe){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(r!==24&&r!==26),a)return this._preserveStack(6,[],0,n,l),a;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=i||(r=e[_])<32||r>127&&r<Xe){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(r!==24&&r!==26),a)return this._preserveStack(5,[],0,n,l),a;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},qc=/^([\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})$/,Kc=/^[\da-f]+$/;function Vn(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let i=qc.exec(e);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Kc.exec(e)&&[3,6,9,12].includes(e.length))){let i=e.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Os(t,e){let i=t.toString(16),s=i.length<2?"0"+i:i;switch(e){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Vc(t,e=16){let[i,s,r]=t;return`rgb:${Os(i,e)}/${Os(s,e)}/${Os(r,e)}`}var Gc={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bt=131072,Gn=10;function Yn(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var Xn=5e3,jn=0,Yc=class extends F{constructor(t,e,i,s,r,n,o,a,l=new Uc){super(),this._bufferService=t,this._charsetService=e,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 _h,this._utf8Decoder=new fh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=he.clone(),this._eraseAttrDataInternal=he.clone(),this._onRequestBell=this._register(new E),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new E),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new E),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new E),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new E),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new E),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new E),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new E),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new E),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new E),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new E),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new E),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new E),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Dr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:c.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:c,data:d})}),this._parser.setDcsHandlerFallback((h,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:c,payload:d})}),this._parser.setPrintHandler((h,c,d)=>this.print(h,c,d)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(x.BEL,()=>this.bell()),this._parser.setExecuteHandler(x.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(x.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(x.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(x.BS,()=>this.backspace()),this._parser.setExecuteHandler(x.HT,()=>this.tab()),this._parser.setExecuteHandler(x.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(x.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(es.IND,()=>this.index()),this._parser.setExecuteHandler(es.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(es.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ne(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ne(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ne(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ne(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ne(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ne(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ne(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ne(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ne(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ne(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ne(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ne(h=>this.restoreCursorColor(h))),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 _e)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(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Kn((h,c)=>this.requestStatusString(h,c)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Xn))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Xn} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){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,e))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Bt&&(n=this._parseStack.position+Bt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(h=>h.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Bt&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Bt))),o||this._dirtyRowTracker.clearRange(),t.length>Bt)for(let h=n;h<t.length;h+=Bt){let c=h+Bt<t.length?h+Bt:t.length,d=typeof t=="string"?this._stringDecoder.decode(t.substring(h,c),this._parseBuffer):this._utf8Decoder.decode(t.subarray(h,c),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(s,r,h,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(t,e,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-e>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let _=e;_<i;++_){if(s=t[_],s<127&&n){let D=n[String.fromCharCode(s)];D&&(s=D.charCodeAt(0))}let f=this._unicodeService.charProperties(s,u);r=Wt.extractWidth(f);let S=Wt.extractShouldJoin(f),k=S?Wt.extractWidth(u):0;if(u=f,o&&this._onA11yChar.fire(Tt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-k>a){if(l){let D=d,A=this._activeBuffer.x-k;for(this._activeBuffer.x=k,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),k>0&&d instanceof Ci&&d.copyCellsFrom(D,A,0,k,!1);A<a;)D.setCellFromCodepoint(A++,0,1,c)}else if(this._activeBuffer.x=a-1,r===2)continue}if(S&&this._activeBuffer.x){let D=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-D,s,r);for(let A=r-k;--A>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(h&&(d.insertCells(this._activeBuffer.x,r-k,this._activeBuffer.getNullCell(c)),d.getWidth(a-1)===2&&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-e>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,i=>Yn(i.params[0],this._optionsService.rawOptions.windowOptions)?e(i):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Kn(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new Ne(e))}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(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n.replaceCells(e,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(t,e=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),i.isWrapped=!1)}eraseInDisplay(t,e=!1){this._restrictCursor(this._bufferService.cols);let i;switch(t.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);i<this._bufferService.rows;i++)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.getTrimmedLength(););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.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(;e--;)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(t){this._restrictCursor();let e=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;e--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(he));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let i=t.params[0]||1,s=Wt.extractWidth(e),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 c=n.codePointAt(h)||0;o[a++]=c,h+=c>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(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(x.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(x.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(x.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(x.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(x.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Nt),this._charsetService.setgCharset(1,Nt),this._charsetService.setgCharset(2,Nt),this._charsetService.setgCharset(3,Nt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),t.params[e]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(t,e){let i;(S=>(S[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"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:h,alt:c}=a,d=this._optionsService.rawOptions,u=(S,k)=>(o.triggerDataEvent(`${x.ESC}[${e?"":"?"}${S};${k}$y`),!0),_=S=>S?1:2,f=t.params[0];return e?f===2?u(f,4):f===4?u(f,_(o.modes.insertMode)):f===12?u(f,3):f===20?u(f,_(d.convertEol)):u(f,0):f===1?u(f,_(s.applicationCursorKeys)):f===3?u(f,d.windowOptions.setWinLines?l===80?2:l===132?1:0:0):f===6?u(f,_(s.origin)):f===7?u(f,_(s.wraparound)):f===8?u(f,3):f===9?u(f,_(r==="X10")):f===12?u(f,_(d.cursorBlink)):f===25?u(f,_(!o.isCursorHidden)):f===45?u(f,_(s.reverseWraparound)):f===66?u(f,_(s.applicationKeypad)):f===67?u(f,4):f===1e3?u(f,_(r==="VT200")):f===1002?u(f,_(r==="DRAG")):f===1003?u(f,_(r==="ANY")):f===1004?u(f,_(s.sendFocus)):f===1005?u(f,4):f===1006?u(f,_(n==="SGR")):f===1015?u(f,4):f===1016?u(f,_(n==="SGR_PIXELS")):f===1048?u(f,1):f===47||f===1047||f===1049?u(f,_(h===c)):f===2004?u(f,_(s.bracketedPasteMode)):f===2026?u(f,_(s.synchronizedOutput)):u(f,0)}_updateAttrColor(t,e,i,s,r){return e===2?(t|=50331648,t&=-16777216,t|=Oi.fromColorRGB([i,s,r])):e===5&&(t&=-50331904,t|=33554432|i&255),t}_extractColor(t,e,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=t.params[e+n],t.hasSubParams(e+n)){let o=t.getSubParams(e+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+e<t.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=he.fg,t.bg=he.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,i,s=this._curAttrData;for(let r=0;r<e;r++)i=t.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(t.hasSubParams(r)?t.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=he.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=he.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(t,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=he.fg&16777215,s.bg&=-67108864,s.bg|=he.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${x.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[${e};${i}R`);break}return!0}deviceStatusPrivate(t){if(t.params[0]===6){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${x.ESC}[?${e};${i}R`)}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=he.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=e%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(t){let e=t.params[0]||1,i;return(t.length<2||(i=t.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Yn(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${x.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Gn&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Gn&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],i=t.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Zn(n))if(r==="?")e.push({type:0,index:n});else{let o=Vn(r);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let i=t.slice(0,e).trim(),s=t.slice(e+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let i=t.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let i=t.split(";");for(let s=0;s<i.length&&!(e>=this._specialColors.length);++s,++e)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=Vn(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],i=t.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Zn(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,Nt),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(Gc[t[0]],_e[t[1]]||Nt),!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 t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=he.clone(),this._eraseAttrDataInternal=he.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new Je;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let i=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(i);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let i=o=>(this._coreService.triggerDataEvent(`${x.ESC}${o}${x.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Dr=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(jn=t,t=e,e=jn),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Dr=re([T(0,Te)],Dr);function Zn(t){return 0<=t&&t<256}var Xc=5e7,Jn=12,jc=50,Zc=class extends F{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 E),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){if(i!==void 0&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,i){if(this._pendingData>Xc)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],n=this._action(r,i);if(n){let a=l=>performance.now()-s>=Jn?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=Jn)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>jc&&(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()}},Tr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(e.id===void 0){let l=i.addMarker(i.ybase+i.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,r=this._getEntryIdKey(s),n=this._entriesWithId.get(r);if(n)return this.addLineToLink(n.id,i.ybase+i.y),n.id;let o=i.addMarker(i.ybase+i.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,i){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==i)){let r=this._bufferService.buffer.addMarker(i);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let s=e.lines.indexOf(i);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Tr=re([T(0,Te)],Tr);var Qn=!1,Jc=class extends F{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ni),this._onBinary=this._register(new E),this.onBinary=this._onBinary.event,this._onData=this._register(new E),this.onData=this._onData.event,this._onLineFeed=this._register(new E),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new E),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new E),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new E),this._instantiationService=new Cc,this.optionsService=this._register(new Dc(e)),this._instantiationService.setService(Pe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Mr)),this._instantiationService.setService(Te,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Er)),this._instantiationService.setService(zo,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Br)),this._instantiationService.setService(Gt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Rr)),this._instantiationService.setService(Wo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Wt)),this._instantiationService.setService(mh,this.unicodeService),this._charsetService=this._instantiationService.createInstance($c),this._instantiationService.setService(vh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Tr),this._instantiationService.setService(Ho,this._oscLinkService),this._inputHandler=this._register(new Yc(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Le.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Le.forward(this._bufferService.onResize,this._onResize)),this._register(Le.forward(this.coreService.onData,this._onData)),this._register(Le.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 Zc((i,s)=>this._inputHandler.parse(i,s))),this._register(Le.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new E),this._onScroll.event(e=>{this._onScrollApi?.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 i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!Qn&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Qn=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,wa),i=Math.max(i,ba),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&i.buildNumber!==void 0&&i.buildNumber!==void 0?e=i.backend==="conpty"&&i.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(qn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(qn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=J(()=>{for(let i of e)i.dispose()})}}},Qc={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function ed(t,e,i,s){let r={type:0,cancel:!1,key:void 0},n=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?r.key=x.ESC+"OA":r.key=x.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?r.key=x.ESC+"OD":r.key=x.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?r.key=x.ESC+"OC":r.key=x.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?r.key=x.ESC+"OB":r.key=x.ESC+"[B");break;case 8:r.key=t.ctrlKey?"\b":x.DEL,t.altKey&&(r.key=x.ESC+r.key);break;case 9:if(t.shiftKey){r.key=x.ESC+"[Z";break}r.key=x.HT,r.cancel=!0;break;case 13:r.key=t.altKey?x.ESC+x.CR:x.CR,r.cancel=!0;break;case 27:r.key=x.ESC,t.altKey&&(r.key=x.ESC+x.ESC),r.cancel=!0;break;case 37:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"D":e?r.key=x.ESC+"OD":r.key=x.ESC+"[D";break;case 39:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"C":e?r.key=x.ESC+"OC":r.key=x.ESC+"[C";break;case 38:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"A":e?r.key=x.ESC+"OA":r.key=x.ESC+"[A";break;case 40:if(t.metaKey)break;n?r.key=x.ESC+"[1;"+(n+1)+"B":e?r.key=x.ESC+"OB":r.key=x.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(r.key=x.ESC+"[2~");break;case 46:n?r.key=x.ESC+"[3;"+(n+1)+"~":r.key=x.ESC+"[3~";break;case 36:n?r.key=x.ESC+"[1;"+(n+1)+"H":e?r.key=x.ESC+"OH":r.key=x.ESC+"[H";break;case 35:n?r.key=x.ESC+"[1;"+(n+1)+"F":e?r.key=x.ESC+"OF":r.key=x.ESC+"[F";break;case 33:t.shiftKey?r.type=2:t.ctrlKey?r.key=x.ESC+"[5;"+(n+1)+"~":r.key=x.ESC+"[5~";break;case 34:t.shiftKey?r.type=3:t.ctrlKey?r.key=x.ESC+"[6;"+(n+1)+"~":r.key=x.ESC+"[6~";break;case 112:n?r.key=x.ESC+"[1;"+(n+1)+"P":r.key=x.ESC+"OP";break;case 113:n?r.key=x.ESC+"[1;"+(n+1)+"Q":r.key=x.ESC+"OQ";break;case 114:n?r.key=x.ESC+"[1;"+(n+1)+"R":r.key=x.ESC+"OR";break;case 115:n?r.key=x.ESC+"[1;"+(n+1)+"S":r.key=x.ESC+"OS";break;case 116:n?r.key=x.ESC+"[15;"+(n+1)+"~":r.key=x.ESC+"[15~";break;case 117:n?r.key=x.ESC+"[17;"+(n+1)+"~":r.key=x.ESC+"[17~";break;case 118:n?r.key=x.ESC+"[18;"+(n+1)+"~":r.key=x.ESC+"[18~";break;case 119:n?r.key=x.ESC+"[19;"+(n+1)+"~":r.key=x.ESC+"[19~";break;case 120:n?r.key=x.ESC+"[20;"+(n+1)+"~":r.key=x.ESC+"[20~";break;case 121:n?r.key=x.ESC+"[21;"+(n+1)+"~":r.key=x.ESC+"[21~";break;case 122:n?r.key=x.ESC+"[23;"+(n+1)+"~":r.key=x.ESC+"[23~";break;case 123:n?r.key=x.ESC+"[24;"+(n+1)+"~":r.key=x.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?r.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?r.key=x.NUL:t.keyCode>=51&&t.keyCode<=55?r.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?r.key=x.DEL:t.keyCode===219?r.key=x.ESC:t.keyCode===220?r.key=x.FS:t.keyCode===221&&(r.key=x.GS);else if((!i||s)&&t.altKey&&!t.metaKey){let o=Qc[t.keyCode]?.[t.shiftKey?1:0];if(o)r.key=x.ESC+o;else if(t.keyCode>=65&&t.keyCode<=90){let a=t.ctrlKey?t.keyCode-64:t.keyCode+32,l=String.fromCharCode(a);t.shiftKey&&(l=l.toUpperCase()),r.key=x.ESC+l}else if(t.keyCode===32)r.key=x.ESC+(t.ctrlKey?x.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let a=t.code.slice(3,4);t.shiftKey||(a=a.toLowerCase()),r.key=x.ESC+a,r.cancel=!0}}else i&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(r.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?r.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(r.key=x.US),t.key==="@"&&(r.key=x.NUL));break}return r}var ne=0,td=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new cs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new cs,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),i=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<r.length;n++)s>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[s])?(r[n]=e[i],i++):r[n]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let i=this._getKey(e);if(i===void 0||(ne=this._search(i),ne===-1)||this._getKey(this._array[ne])!==i)return!1;do if(this._array[ne]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ne),!0;while(++ne<this._array.length&&this._getKey(this._array[ne])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),i=0,s=new Array(this._array.length-e.length),r=0;for(let n=0;n<this._array.length;n++)e[i]===n?i++:s[r++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ne=this._search(e),!(ne<0||ne>=this._array.length)&&this._getKey(this._array[ne])===e))do yield this._array[ne];while(++ne<this._array.length&&this._getKey(this._array[ne])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ne=this._search(e),!(ne<0||ne>=this._array.length)&&this._getKey(this._array[ne])===e))do i(this._array[ne]);while(++ne<this._array.length&&this._getKey(this._array[ne])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,s=this._array.length-1;for(;s>=i;){let r=i+s>>1,n=this._getKey(this._array[r]);if(n>e)s=r-1;else if(n<e)i=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return i}},Is=0,eo=0,id=class extends F{constructor(){super(),this._decorations=new td(t=>t?.marker.line),this._onDecorationRegistered=this._register(new E),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new E),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(J(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new sd(t);if(e){let i=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),i.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(e))s=n.options.x??0,r=s+(n.options.width??1),t>=s&&t<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(t,e,i,s){this._decorations.forEachByKey(e,r=>{Is=r.options.x??0,eo=Is+(r.options.width??1),t>=Is&&t<eo&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},sd=class extends Ot{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new E),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new E),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ee.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ee.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},rd=1e3,nd=class{constructor(e,i=rd){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,s){this._rowCount=s,e=e!==void 0?e:0,i=i!==void 0?i:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,i):i;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=r-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},to=20,ds=class extends F{constructor(t,e,i,s){super(),this._terminal=t,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new nd(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
14
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(O(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(J(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<to+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
15
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===to+1&&(this._liveRegion.textContent+=Qs.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=t;r<=e;r++){let n=i.lines.get(i.ydisp+r),o=[],a=n?.translateToString(!0,void 0,void 0,o)||"",l=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(a.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=a,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",l),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let i=t.target,s=this._rowElements[e===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||t.relatedTarget!==s)return;let o,a;if(e===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},i={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===i.node&&e.offset>i.offset)&&([e,i]=[i,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let r=({node:a,offset:l})=>{let h=a instanceof Text?a.parentNode:a,c=parseInt(h?.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(h);if(!d)return console.warn("columns is null. Race condition?"),null;let u=l<d.length?d[l]:d.slice(-1)[0]+1;return u>=this._terminal.cols&&(++c,u=0),{row:c,column:u}},n=r(e),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_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 t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){t.style.transform="";let e=t.getBoundingClientRect().width,i=this._rowColumns.get(t)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${s/e})`}};ds=re([T(1,Kr),T(2,kt),T(3,Lt)],ds);var Pr=class extends F{constructor(t,e,i,s,r){super(),this._element=t,this._mouseService=e,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 E),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new E),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(J(()=>{Kt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(O(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(O(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(O(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(O(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let i=t.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){(!this._activeProviderReplies||!e)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let i=!1;for(let[s,r]of this._linkProviderService.linkProviders.entries())e?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,t,i)):r.provideLinks(t.y,n=>{if(this._isMouseOut)return;let o=n?.map(a=>({link:a}));this._activeProviderReplies?.set(s,o),i=this._checkLinkProviderResult(s,t,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let i=new Set;for(let s=0;s<e.size;s++){let r=e.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<t?0:o.link.range.start.x,l=o.link.range.end.y>t?this._bufferService.cols:o.link.range.end.x;for(let h=a;h<=l;h++){if(i.has(h)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(t,e,i){if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(t),r=!1;for(let n=0;n<t;n++)(!this._activeProviderReplies.has(n)||this._activeProviderReplies.get(n))&&(r=!0);if(!r&&s){let n=s.find(o=>this._linkAtPosition(o.link,e));n&&(i=!0,this._handleNewLink(n))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let n=0;n<this._activeProviderReplies.size;n++){let o=this._activeProviderReplies.get(n)?.find(a=>this._linkAtPosition(a.link,e));if(o){i=!0,this._handleNewLink(o);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&od(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Kt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(i,e.text)}_fireUnderlineEvent(t,e){let i=t.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);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(t,e,i){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(i,e.text)}_linkAtPosition(t,e){let i=t.range.start.y*this._bufferService.cols+t.range.start.x,s=t.range.end.y*this._bufferService.cols+t.range.end.x,r=e.y*this._bufferService.cols+e.x;return i<=r&&r<=s}_positionFromMouseEvent(t,e,i){let s=i.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,i,s,r){return{x1:t,y1:e,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};Pr=re([T(1,Vr),T(2,Lt),T(3,Te),T(4,qo)],Pr);function od(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var ad=class extends Jc{constructor(e={}){super(e),this._linkifier=this._register(new ni),this.browser=la,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ni),this._onCursorMove=this._register(new E),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new E),this.onKey=this._onKey.event,this._onRender=this._register(new E),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new E),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new E),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new E),this.onBell=this._onBell.event,this._onFocus=this._register(new E),this._onBlur=this._register(new E),this._onA11yCharEmitter=this._register(new E),this._onA11yTabEmitter=this._register(new E),this._onWillOpen=this._register(new E),this._setup(),this._decorationService=this._instantiationService.createInstance(id),this._instantiationService.setService(Ii,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(jl),this._instantiationService.setService(qo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(tr)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(i=>this.refresh(i?.start??0,i?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(i=>this._reportWindowsOptions(i))),this._register(this._inputHandler.onColor(i=>this._handleColorEvent(i))),this._register(Le.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Le.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Le.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Le.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(i=>this._afterResize(i.cols,i.rows))),this._register(J(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.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 i of e){let s,r="";switch(i.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+i.index}switch(i.type){case 0:let n=j.toColorRGB(s==="ansi"?this._themeService.colors.ansi[i.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${x.ESC}]${r};${Vc(n)}${aa.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[i.index]=ce.toColor(...i.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=ce.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ds,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(x.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,i=this.buffer.lines.get(e);if(!i)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,n=i.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(O(this.element,"copy",i=>{this.hasSelection()&&dh(i,this._selectionService)}));let e=i=>uh(i,this.textarea,this.coreService,this.optionsService);this._register(O(this.textarea,"paste",e)),this._register(O(this.element,"paste",e)),ca?this._register(O(this.element,"mousedown",i=>{i.button===2&&dn(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(O(this.element,"contextmenu",i=>{dn(i,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),en&&this._register(O(this.element,"auxclick",i=>{i.button===1&&Oo(i,this.textarea,this.screenElement)}))}_bindKeys(){this._register(O(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(O(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(O(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(O(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(O(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(O(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(O(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){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"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let 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(O(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),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",Js.get()),_a||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(Yl,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(kt,this._coreBrowserService),this._register(O(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(O(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Cr,this._document,this._helperContainer),this._instantiationService.setService(vs,this._charSizeService),this._themeService=this._instantiationService.createInstance(Lr),this._instantiationService.setService(oi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(hs),this._instantiationService.setService(Uo,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(xr,this.rows,this.screenElement)),this._instantiationService.setService(Lt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Sr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(yr),this._instantiationService.setService(Vr,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Pr,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(vr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(kr,this.element,this.screenElement,r)),this._instantiationService.setService(wh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Le.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(mr,this.screenElement)),this._register(O(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ds,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(as,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(as,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(br,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function s(o){let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let c=o.deltaY;if(c===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;h=c<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?r.mousemove||(i.addEventListener("mousemove",n.mousemove),r.mousemove=n.mousemove):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(i.addEventListener("wheel",n.wheel,{passive:!1}),r.wheel=n.wheel):(i.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(O(i,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(O(i,"wheel",o=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let a=x.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(a,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.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,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),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 i=e-this._bufferService.buffer.ydisp;i!==0&&this.scrollLines(i)}paste(e){Po(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 i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,i,s){this._selectionService.setSelection(e,i,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!i&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=ed(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===x.ETX||s.key===x.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,i){let s=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return i.type==="keypress"?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(hd(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(e.which===null||e.which===void 0)i=e.keyCode;else if(e.which!==0&&e.charCode!==0)i=e.which;else return!1;return!i||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(he));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(x.ESC+"[I"):this.coreService.triggerDataEvent(x.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[4;${s};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${x.ESC}[6;${n};${r}t`);break}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}};function hd(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var ld=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){i=s;break}if(i===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},cd=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new Je)}translateToString(e,i,s){return this._line.translateToString(e,i,s)}},io=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new cd(e)}getNullCell(){return new Je}},dd=class extends F{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new E),this.onBufferChange=this._onBufferChange.event,this._normal=new io(this._core.buffers.normal,"normal"),this._alternate=new io(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(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,i=>e(i.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(i,s)=>e(i,s.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},_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"],nt=0,gd=class extends F{constructor(t){super(),this._core=this._register(new ad(t)),this._addonManager=this._register(new ld),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(t){if(fd.includes(t))throw new Error(`Option "${t}" 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 t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,i){this._verifyIntegers(t,e,i),this._core.select(t,e,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
16
+ `,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return Js.get()},set promptLabel(t){Js.set(t)},get tooMuchOutput(){return Qs.get()},set tooMuchOutput(t){Qs.set(t)}}}_verifyIntegers(...t){for(nt of t)if(nt===1/0||isNaN(nt)||nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(nt of t)if(nt&&(nt===1/0||isNaN(nt)||nt%1!==0||nt<0))throw new Error("This API only accepts positive integers")}};var pd=2,vd=1,md=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,h=s-a,c=r-l-e;return{cols:Math.max(pd,Math.floor(c/t.css.cell.width)),rows:Math.max(vd,Math.floor(h/t.css.cell.height))}}};var Sd=(t,e,i,s)=>{for(var r=e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(r=o(r)||r);return r},wd=(t,e)=>(i,s)=>e(i,s,t),bd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?so.isErrorNoTelemetry(t)?new so(t.message+`
17
17
 
18
18
  `+t.stack):new Error(t.message+`
19
19
 
20
- `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},vd=new pd;function Os(t){md(t)||vd.onUnexpectedError(t)}var Ar="Canceled";function md(t){return t instanceof Sd?!0:t instanceof Error&&t.name===Ar&&t.message===Ar}var Sd=class extends Error{constructor(){super(Ar),this.name=this.message}},Qn=class Tr extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Tr)return e;let i=new Tr;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},wd;(t=>{function e(n){return n<0}t.isLessThan=e;function i(n){return n<=0}t.isLessThanOrEqual=i;function s(n){return n>0}t.isGreaterThan=s;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(wd||={});function bd(t,e){let i=this,s=!1,r;return function(){return s||(s=!0,e||(r=t.apply(i,arguments))),r}}var Sa;(t=>{function e(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function s(){return i}t.empty=s;function*r(w){yield w}t.single=r;function n(w){return e(w)?w:r(w)}t.wrap=n;function o(w){return w||i}t.from=o;function*a(w){for(let R=w.length-1;R>=0;R--)yield w[R]}t.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}t.isEmpty=l;function h(w){return w[Symbol.iterator]().next().value}t.first=h;function c(w,R){let P=0;for(let N of w)if(R(N,P++))return!0;return!1}t.some=c;function d(w,R){for(let P of w)if(R(P))return P}t.find=d;function*u(w,R){for(let P of w)R(P)&&(yield P)}t.filter=u;function*_(w,R){let P=0;for(let N of w)yield R(N,P++)}t.map=_;function*f(w,R){let P=0;for(let N of w)yield*R(N,P++)}t.flatMap=f;function*S(...w){for(let R of w)yield*R}t.concat=S;function k(w,R,P){let N=P;for(let G of w)N=R(N,G);return N}t.reduce=k;function*A(w,R,P=w.length){for(R<0&&(R+=w.length),P<0?P+=w.length:P>w.length&&(P=w.length);R<P;R++)yield w[R]}t.slice=A;function D(w,R=Number.POSITIVE_INFINITY){let P=[];if(R===0)return[P,w];let N=w[Symbol.iterator]();for(let G=0;G<R;G++){let ae=N.next();if(ae.done)return[P,t.empty()];P.push(ae.value)}return[P,{[Symbol.iterator](){return N}}]}t.consume=D;async function B(w){let R=[];for await(let P of w)R.push(P);return Promise.resolve(R)}t.asyncToArray=B})(Sa||={});function wa(t){if(Sa.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function ba(...t){return Be(()=>wa(t))}function Be(t){return{dispose:bd(()=>{t()})}}var Ca=class ya{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{wa(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?ya.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(e),e}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),void 0)}};Ca.DISABLE_DISPOSED_WARNING=!1;var si=Ca,tt=class{constructor(){this._store=new si,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};tt.None=Object.freeze({dispose(){}});var pi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},Jr=typeof process<"u"&&"title"in process,ms=Jr?"node":navigator.userAgent,Cd=Jr?"node":navigator.platform,yd=ms.includes("Firefox"),xd=ms.includes("Edge"),xa=/^((?!chrome|android).)*safari/i.test(ms);function kd(){if(!xa)return 0;let t=ms.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}Cd.indexOf("Linux")>=0;var Ld="",Se=0,we=0,be=0,se=0,Ge={css:"#00000000",rgba:0},Ae;(t=>{function e(r,n,o,a){return a!==void 0?`#${$t(r)}${$t(n)}${$t(o)}${$t(a)}`:`#${$t(r)}${$t(n)}${$t(o)}`}t.toCss=e;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}t.toRgba=i;function s(r,n,o,a){return{css:t.toCss(r,n,o,a),rgba:t.toRgba(r,n,o,a)}}t.toColor=s})(Ae||={});var ki;(t=>{function e(l,h){if(se=(h.rgba&255)/255,se===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,_=l.rgba>>24&255,f=l.rgba>>16&255,S=l.rgba>>8&255;Se=_+Math.round((c-_)*se),we=f+Math.round((d-f)*se),be=S+Math.round((u-S)*se);let k=Ae.toCss(Se,we,be),A=Ae.toRgba(Se,we,be);return{css:k,rgba:A}}t.blend=e;function i(l){return(l.rgba&255)===255}t.isOpaque=i;function s(l,h,c){let d=Ut.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return Ae.toColor(d>>24&255,d>>16&255,d>>8&255)}t.ensureContrastRatio=s;function r(l){let h=(l.rgba|255)>>>0;return[Se,we,be]=Ut.toChannels(h),{css:Ae.toCss(Se,we,be),rgba:h}}t.opaque=r;function n(l,h){return se=Math.round(h*255),[Se,we,be]=Ut.toChannels(l.rgba),{css:Ae.toCss(Se,we,be,se),rgba:Ae.toRgba(Se,we,be,se)}}t.opacity=n;function o(l,h){return se=l.rgba&255,n(l,se*h/255)}t.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}t.toColorRGB=a})(ki||={});var Ed;(t=>{let e,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Se=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),be=parseInt(r.slice(3,4).repeat(2),16),Ae.toColor(Se,we,be);case 5:return Se=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),be=parseInt(r.slice(3,4).repeat(2),16),se=parseInt(r.slice(4,5).repeat(2),16),Ae.toColor(Se,we,be,se);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Se=parseInt(n[1]),we=parseInt(n[2]),be=parseInt(n[3]),se=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ae.toColor(Se,we,be,se);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Se,we,be,se]=e.getImageData(0,0,1,1).data,se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ae.toRgba(Se,we,be,se),css:r}}t.toColor=s})(Ed||={});var De;(t=>{function e(s){return i(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function i(s,r,n){let o=s/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}t.relativeLuminance2=i})(De||={});var Ut;(t=>{function e(o,a){if(se=(a&255)/255,se===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,_=o>>8&255;return Se=d+Math.round((l-d)*se),we=u+Math.round((h-u)*se),be=_+Math.round((c-_)*se),Ae.toRgba(Se,we,be)}t.blend=e;function i(o,a,l){let h=De.relativeLuminance(o>>8),c=De.relativeLuminance(a>>8);if(ft(h,c)<l){if(c<h){let _=s(o,a,l),f=ft(h,De.relativeLuminance(_>>8));if(f<l){let S=r(o,a,l),k=ft(h,De.relativeLuminance(S>>8));return f>k?_:S}return _}let d=r(o,a,l),u=ft(h,De.relativeLuminance(d>>8));if(u<l){let _=s(o,a,l),f=ft(h,De.relativeLuminance(_>>8));return u>f?d:_}return d}}t.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=ft(De.relativeLuminance2(u,_,f),De.relativeLuminance2(h,c,d));for(;S<l&&(u>0||_>0||f>0);)u-=Math.max(0,Math.ceil(u*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),S=ft(De.relativeLuminance2(u,_,f),De.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=s;function r(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=ft(De.relativeLuminance2(u,_,f),De.relativeLuminance2(h,c,d));for(;S<l&&(u<255||_<255||f<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),S=ft(De.relativeLuminance2(u,_,f),De.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(Ut||={});function $t(t){let e=t.toString(16);return e.length<2?"0"+e:e}function ft(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function le(t){if(!t)throw new Error("value must not be falsy");return t}function Qr(t){return 57508<=t&&t<=57558}function Md(t){return 57520<=t&&t<=57527}function Bd(t){return 57344<=t&&t<=63743}function Rd(t){return 9472<=t&&t<=9631}function Dd(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function Ad(t,e,i,s){return e===1&&i>Math.ceil(s*1.5)&&t!==void 0&&t>255&&!Dd(t)&&!Qr(t)&&!Bd(t)}function ka(t){return Qr(t)||Rd(t)}function Td(){return{css:{canvas:Ki(),cell:Ki()},device:{canvas:Ki(),cell:Ki(),char:{width:0,height:0,left:0,top:0}}}}function Ki(){return{width:0,height:0}}function Pd(t,e,i=0){return(t-(Math.round(e)*2-i))%(Math.round(e)*2)}var ke=0,fe=0,nt=!1,gt=!1,Vi=!1,$e,Is=0,Od=class{constructor(t,e,i,s,r,n){this._terminal=t,this._optionService=e,this._selectionRenderModel=i,this._decorationService=s,this._coreBrowserService=r,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(t,e,i,s){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,fe=0,ke=0,gt=!1,nt=!1,Vi=!1,$e=this._themeService.colors,Is=0,t.getCode()!==0&&t.extended.underlineStyle===4){let r=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Is=e*s%(Math.round(r)*2)}if(this._decorationService.forEachDecorationAtCell(e,i,"bottom",r=>{r.backgroundColorRGB&&(fe=r.backgroundColorRGB.rgba>>8&16777215,gt=!0),r.foregroundColorRGB&&(ke=r.foregroundColorRGB.rgba>>8&16777215,nt=!0)}),Vi=this._selectionRenderModel.isCellSelected(this._terminal,e,i),Vi){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:fe=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:fe=(this.result.fg&16777215)<<8|255;break;default:fe=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:fe=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:fe=(this.result.bg&16777215)<<8|255;break}fe=Ut.blend(fe,(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else fe=(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(gt=!0,$e.selectionForeground&&(ke=$e.selectionForeground.rgba>>8&16777215,nt=!0),ka(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)ke=(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:ke=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ke=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:ke=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ke=(this.result.fg&16777215)<<8|255;break;default:ke=this._themeService.colors.foreground.rgba}ke=Ut.blend(ke,(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}nt=!0}}this._decorationService.forEachDecorationAtCell(e,i,"top",r=>{r.backgroundColorRGB&&(fe=r.backgroundColorRGB.rgba>>8&16777215,gt=!0),r.foregroundColorRGB&&(ke=r.foregroundColorRGB.rgba>>8&16777215,nt=!0)}),gt&&(Vi?fe=t.bg&-16777216&-134217729|fe|50331648:fe=t.bg&-16777216|fe|50331648),nt&&(ke=t.fg&-16777216&-67108865|ke|50331648),this.result.fg&67108864&&(gt&&!nt&&((this.result.bg&50331648)===0?ke=this.result.fg&-134217728|$e.background.rgba>>8&16777215&16777215|50331648:ke=this.result.fg&-134217728|this.result.bg&67108863,nt=!0),!gt&&nt&&((this.result.fg&50331648)===0?fe=this.result.bg&-67108864|$e.foreground.rgba>>8&16777215&16777215|50331648:fe=this.result.bg&-67108864|this.result.fg&67108863,gt=!0)),$e=void 0,this.result.bg=gt?fe:this.result.bg,this.result.fg=nt?ke:this.result.fg,this.result.ext&=536870911,this.result.ext|=Is<<29&3758096384}},Id=.5,La=yd||xd?"bottom":"ideographic",$d={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Fd={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Nd={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},Ri={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};Ri[""]=Ri[""];Ri[""]=Ri[""];function Wd(t,e,i,s,r,n,o,a){let l=$d[e];if(l)return zd(t,l,i,s,r,n),!0;let h=Fd[e];if(h)return Hd(t,h,i,s,r,n),!0;let c=Nd[e];if(c)return Ud(t,c,i,s,r,n,a),!0;let d=Ri[e];return d?(qd(t,d,i,s,r,n,o,a),!0):!1}function zd(t,e,i,s,r,n){for(let o=0;o<e.length;o++){let a=e[o],l=r/8,h=n/8;t.fillRect(i+a.x*l,s+a.y*h,a.w*l,a.h*h)}}var eo=new Map;function Hd(t,e,i,s,r,n){let o=eo.get(e);o||(o=new Map,eo.set(e,o));let a=t.fillStyle;if(typeof a!="string")throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let h=e[0].length,c=e.length,d=t.canvas.ownerDocument.createElement("canvas");d.width=h,d.height=c;let u=le(d.getContext("2d")),_=new ImageData(h,c),f,S,k,A;if(a.startsWith("#"))f=parseInt(a.slice(1,3),16),S=parseInt(a.slice(3,5),16),k=parseInt(a.slice(5,7),16),A=a.length>7&&parseInt(a.slice(7,9),16)||1;else if(a.startsWith("rgba"))[f,S,k,A]=a.substring(5,a.length-1).split(",").map(D=>parseFloat(D));else throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);for(let D=0;D<c;D++)for(let B=0;B<h;B++)_.data[(D*h+B)*4]=f,_.data[(D*h+B)*4+1]=S,_.data[(D*h+B)*4+2]=k,_.data[(D*h+B)*4+3]=e[D][B]*(A*255);u.putImageData(_,0,0),l=le(t.createPattern(d,null)),o.set(a,l)}t.fillStyle=l,t.fillRect(i,s,r,n)}function Ud(t,e,i,s,r,n,o){t.strokeStyle=t.fillStyle;for(let[a,l]of Object.entries(e)){t.beginPath(),t.lineWidth=o*Number.parseInt(a);let h;if(typeof l=="function"){let c=.15/n*r;h=l(.15,c)}else h=l;for(let c of h.split(" ")){let d=c[0],u=Ea[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let _=c.substring(1).split(",");!_[0]||!_[1]||u(t,Ma(_,r,n,i,s,!0,o))}t.stroke(),t.closePath()}}function qd(t,e,i,s,r,n,o,a){let l=new Path2D;l.rect(i,s,r,n),t.clip(l),t.beginPath();let h=o/12;t.lineWidth=a*h;for(let c of e.d.split(" ")){let d=c[0],u=Ea[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let _=c.substring(1).split(",");!_[0]||!_[1]||u(t,Ma(_,r,n,i,s,!1,a,(e.leftPadding??0)*(h/2),(e.rightPadding??0)*(h/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function to(t,e,i=0){return Math.max(Math.min(t,e),i)}var Ea={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function Ma(t,e,i,s,r,n,o,a=0,l=0){let h=t.map(c=>parseFloat(c)||parseInt(c));if(h.length<2)throw new Error("Too few arguments for instruction");for(let c=0;c<h.length;c+=2)h[c]*=e-a*o-l*o,n&&h[c]!==0&&(h[c]=to(Math.round(h[c]+.5)-.5,e,0)),h[c]+=s+a*o;for(let c=1;c<h.length;c+=2)h[c]*=i,n&&h[c]!==0&&(h[c]=to(Math.round(h[c]+.5)-.5,i,0)),h[c]+=r;return h}var io=class{constructor(){this._data={}}set(t,e,i){this._data[t]||(this._data[t]={}),this._data[t][e]=i}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},so=class{constructor(){this._data=new io}set(t,e,i,s,r){this._data.get(t,e)||this._data.set(t,e,new io),this._data.get(t,e).set(i,s,r)}get(t,e,i,s){return this._data.get(t,e)?.get(i,s)}clear(){this._data.clear()}},Ba=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,s=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),r=t.timeRemaining(),i*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},Kd=class extends Ba{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Vd=class extends Ba{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Gd=!Jr&&"requestIdleCallback"in window?Vd:Kd,ti=class Ra{constructor(){this.fg=0,this.bg=0,this.extended=new Da}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Ra;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Da=class Aa{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Aa(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Yd=globalThis.performance&&typeof globalThis.performance.now=="function",Xd=class Ta{static create(e){return new Ta(e)}constructor(e){this._now=Yd&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ct;(t=>{t.None=()=>tt.None;function e(p,g){return d(p,()=>{},0,void 0,!0,void 0,g)}t.defer=e;function i(p){return(g,v=null,m)=>{let y=!1,b;return b=p(L=>{if(!y)return b?b.dispose():y=!0,g.call(v,L)},null,m),y&&b.dispose(),b}}t.once=i;function s(p,g,v){return h((m,y=null,b)=>p(L=>m.call(y,g(L)),null,b),v)}t.map=s;function r(p,g,v){return h((m,y=null,b)=>p(L=>{g(L),m.call(y,L)},null,b),v)}t.forEach=r;function n(p,g,v){return h((m,y=null,b)=>p(L=>g(L)&&m.call(y,L),null,b),v)}t.filter=n;function o(p){return p}t.signal=o;function a(...p){return(g,v=null,m)=>{let y=ba(...p.map(b=>b(L=>g.call(v,L))));return c(y,m)}}t.any=a;function l(p,g,v,m){let y=v;return s(p,b=>(y=g(y,b),y),m)}t.reduce=l;function h(p,g){let v,m={onWillAddFirstListener(){v=p(y.fire,y)},onDidRemoveLastListener(){v?.dispose()}},y=new Z(m);return g?.add(y),y.event}function c(p,g){return g instanceof Array?g.push(p):g&&g.add(p),p}function d(p,g,v=100,m=!1,y=!1,b,L){let C,M,I,Y=0,z,Oe={leakWarningThreshold:b,onWillAddFirstListener(){C=p(ye=>{Y++,M=g(M,ye),m&&!I&&(U.fire(M),M=void 0),z=()=>{let K=M;M=void 0,I=void 0,(!m||Y>1)&&U.fire(K),Y=0},typeof v=="number"?(clearTimeout(I),I=setTimeout(z,v)):I===void 0&&(I=0,queueMicrotask(z))})},onWillRemoveListener(){y&&Y>0&&z?.()},onDidRemoveLastListener(){z=void 0,C.dispose()}},U=new Z(Oe);return L?.add(U),U.event}t.debounce=d;function u(p,g=0,v){return t.debounce(p,(m,y)=>m?(m.push(y),m):[y],g,void 0,!0,void 0,v)}t.accumulate=u;function _(p,g=(m,y)=>m===y,v){let m=!0,y;return n(p,b=>{let L=m||!g(b,y);return m=!1,y=b,L},v)}t.latch=_;function f(p,g,v){return[t.filter(p,g,v),t.filter(p,m=>!g(m),v)]}t.split=f;function S(p,g=!1,v=[],m){let y=v.slice(),b=p(M=>{y?y.push(M):C.fire(M)});m&&m.add(b);let L=()=>{y?.forEach(M=>C.fire(M)),y=null},C=new Z({onWillAddFirstListener(){b||(b=p(M=>C.fire(M)),m&&m.add(b))},onDidAddFirstListener(){y&&(g?setTimeout(L):L())},onDidRemoveLastListener(){b&&b.dispose(),b=null}});return m&&m.add(C),C.event}t.buffer=S;function k(p,g){return(v,m,y)=>{let b=g(new D);return p(function(L){let C=b.evaluate(L);C!==A&&v.call(m,C)},void 0,y)}}t.chain=k;let A=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(g){return this.steps.push(g),this}forEach(g){return this.steps.push(v=>(g(v),v)),this}filter(g){return this.steps.push(v=>g(v)?v:A),this}reduce(g,v){let m=v;return this.steps.push(y=>(m=g(m,y),m)),this}latch(g=(v,m)=>v===m){let v=!0,m;return this.steps.push(y=>{let b=v||!g(y,m);return v=!1,m=y,b?y:A}),this}evaluate(g){for(let v of this.steps)if(g=v(g),g===A)break;return g}}function B(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.on(g,m),b=()=>p.removeListener(g,m),L=new Z({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromNodeEventEmitter=B;function w(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.addEventListener(g,m),b=()=>p.removeEventListener(g,m),L=new Z({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromDOMEventEmitter=w;function R(p){return new Promise(g=>i(p)(g))}t.toPromise=R;function P(p){let g=new Z;return p.then(v=>{g.fire(v)},()=>{g.fire(void 0)}).finally(()=>{g.dispose()}),g.event}t.fromPromise=P;function N(p,g){return p(v=>g.fire(v))}t.forward=N;function G(p,g,v){return g(v),p(m=>g(m))}t.runAndSubscribe=G;class ae{constructor(g,v){this._observable=g,this._counter=0,this._hasChanged=!1;let m={onWillAddFirstListener:()=>{g.addObserver(this)},onDidRemoveLastListener:()=>{g.removeObserver(this)}};this.emitter=new Z(m),v&&v.add(this.emitter)}beginUpdate(g){this._counter++}handlePossibleChange(g){}handleChange(g,v){this._hasChanged=!0}endUpdate(g){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(p,g){return new ae(p,g).emitter.event}t.fromObservable=Ee;function W(p){return(g,v,m)=>{let y=0,b=!1,L={beginUpdate(){y++},endUpdate(){y--,y===0&&(p.reportChanges(),b&&(b=!1,g.call(v)))},handlePossibleChange(){},handleChange(){b=!0}};p.addObserver(L),p.reportChanges();let C={dispose(){p.removeObserver(L)}};return m instanceof si?m.add(C):Array.isArray(m)&&m.push(C),C}}t.fromObservableLight=W})(Ct||={});var Pr=class Or{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Or._idPool++}`,Or.all.add(this)}start(e){this._stopWatch=new Xd,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}}};Pr.all=new Set,Pr._idPool=0;var jd=Pr,Zd=-1,Pa=class Oa{constructor(e,i,s=(Oa._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new eu(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[s,r]of this._stacks)(!e||i<r)&&(e=[s,r],i=r);return e}};Pa._idPool=1;var Jd=Pa,Qd=class Ia{constructor(e){this.value=e}static create(){let e=new Error;return new Ia(e.stack??"")}print(){console.warn(this.value.split(`
20
+ `+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},Cd=new bd;function $s(t){yd(t)||Cd.onUnexpectedError(t)}var Or="Canceled";function yd(t){return t instanceof xd?!0:t instanceof Error&&t.name===Or&&t.message===Or}var xd=class extends Error{constructor(){super(Or),this.name=this.message}},so=class Ir extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Ir)return e;let i=new Ir;return i.message=e.message,i.stack=e.stack,i}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},kd;(t=>{function e(n){return n<0}t.isLessThan=e;function i(n){return n<=0}t.isLessThanOrEqual=i;function s(n){return n>0}t.isGreaterThan=s;function r(n){return n===0}t.isNeitherLessOrGreaterThan=r,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(kd||={});function Ld(t,e){let i=this,s=!1,r;return function(){return s||(s=!0,e||(r=t.apply(i,arguments))),r}}var ya;(t=>{function e(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}t.is=e;let i=Object.freeze([]);function s(){return i}t.empty=s;function*r(w){yield w}t.single=r;function n(w){return e(w)?w:r(w)}t.wrap=n;function o(w){return w||i}t.from=o;function*a(w){for(let R=w.length-1;R>=0;R--)yield w[R]}t.reverse=a;function l(w){return!w||w[Symbol.iterator]().next().done===!0}t.isEmpty=l;function h(w){return w[Symbol.iterator]().next().value}t.first=h;function c(w,R){let P=0;for(let N of w)if(R(N,P++))return!0;return!1}t.some=c;function d(w,R){for(let P of w)if(R(P))return P}t.find=d;function*u(w,R){for(let P of w)R(P)&&(yield P)}t.filter=u;function*_(w,R){let P=0;for(let N of w)yield R(N,P++)}t.map=_;function*f(w,R){let P=0;for(let N of w)yield*R(N,P++)}t.flatMap=f;function*S(...w){for(let R of w)yield*R}t.concat=S;function k(w,R,P){let N=P;for(let G of w)N=R(N,G);return N}t.reduce=k;function*D(w,R,P=w.length){for(R<0&&(R+=w.length),P<0?P+=w.length:P>w.length&&(P=w.length);R<P;R++)yield w[R]}t.slice=D;function A(w,R=Number.POSITIVE_INFINITY){let P=[];if(R===0)return[P,w];let N=w[Symbol.iterator]();for(let G=0;G<R;G++){let ae=N.next();if(ae.done)return[P,t.empty()];P.push(ae.value)}return[P,{[Symbol.iterator](){return N}}]}t.consume=A;async function B(w){let R=[];for await(let P of w)R.push(P);return Promise.resolve(R)}t.asyncToArray=B})(ya||={});function xa(t){if(ya.is(t)){let e=[];for(let i of t)if(i)try{i.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function ka(...t){return Be(()=>xa(t))}function Be(t){return{dispose:Ld(()=>{t()})}}var La=class Ea{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xa(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ea.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(e),e}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),void 0)}};La.DISABLE_DISPOSED_WARNING=!1;var si=La,it=class{constructor(){this._store=new si,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};it.None=Object.freeze({dispose(){}});var pi=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},tn=typeof process<"u"&&"title"in process,ws=tn?"node":navigator.userAgent,Ed=tn?"node":navigator.platform,Md=ws.includes("Firefox"),Bd=ws.includes("Edge"),Ma=/^((?!chrome|android).)*safari/i.test(ws);function Rd(){if(!Ma)return 0;let t=ws.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}Ed.indexOf("Linux")>=0;var Ad="",Se=0,we=0,be=0,se=0,Ge={css:"#00000000",rgba:0},De;(t=>{function e(r,n,o,a){return a!==void 0?`#${$t(r)}${$t(n)}${$t(o)}${$t(a)}`:`#${$t(r)}${$t(n)}${$t(o)}`}t.toCss=e;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}t.toRgba=i;function s(r,n,o,a){return{css:t.toCss(r,n,o,a),rgba:t.toRgba(r,n,o,a)}}t.toColor=s})(De||={});var ki;(t=>{function e(l,h){if(se=(h.rgba&255)/255,se===1)return{css:h.css,rgba:h.rgba};let c=h.rgba>>24&255,d=h.rgba>>16&255,u=h.rgba>>8&255,_=l.rgba>>24&255,f=l.rgba>>16&255,S=l.rgba>>8&255;Se=_+Math.round((c-_)*se),we=f+Math.round((d-f)*se),be=S+Math.round((u-S)*se);let k=De.toCss(Se,we,be),D=De.toRgba(Se,we,be);return{css:k,rgba:D}}t.blend=e;function i(l){return(l.rgba&255)===255}t.isOpaque=i;function s(l,h,c){let d=Ut.ensureContrastRatio(l.rgba,h.rgba,c);if(d)return De.toColor(d>>24&255,d>>16&255,d>>8&255)}t.ensureContrastRatio=s;function r(l){let h=(l.rgba|255)>>>0;return[Se,we,be]=Ut.toChannels(h),{css:De.toCss(Se,we,be),rgba:h}}t.opaque=r;function n(l,h){return se=Math.round(h*255),[Se,we,be]=Ut.toChannels(l.rgba),{css:De.toCss(Se,we,be,se),rgba:De.toRgba(Se,we,be,se)}}t.opacity=n;function o(l,h){return se=l.rgba&255,n(l,se*h/255)}t.multiplyOpacity=o;function a(l){return[l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}t.toColorRGB=a})(ki||={});var Dd;(t=>{let e,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",i=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Se=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),be=parseInt(r.slice(3,4).repeat(2),16),De.toColor(Se,we,be);case 5:return Se=parseInt(r.slice(1,2).repeat(2),16),we=parseInt(r.slice(2,3).repeat(2),16),be=parseInt(r.slice(3,4).repeat(2),16),se=parseInt(r.slice(4,5).repeat(2),16),De.toColor(Se,we,be,se);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Se=parseInt(n[1]),we=parseInt(n[2]),be=parseInt(n[3]),se=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),De.toColor(Se,we,be,se);if(!e||!i)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=i,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Se,we,be,se]=e.getImageData(0,0,1,1).data,se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:De.toRgba(Se,we,be,se),css:r}}t.toColor=s})(Dd||={});var Ae;(t=>{function e(s){return i(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function i(s,r,n){let o=s/255,a=r/255,l=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return h*.2126+c*.7152+d*.0722}t.relativeLuminance2=i})(Ae||={});var Ut;(t=>{function e(o,a){if(se=(a&255)/255,se===1)return a;let l=a>>24&255,h=a>>16&255,c=a>>8&255,d=o>>24&255,u=o>>16&255,_=o>>8&255;return Se=d+Math.round((l-d)*se),we=u+Math.round((h-u)*se),be=_+Math.round((c-_)*se),De.toRgba(Se,we,be)}t.blend=e;function i(o,a,l){let h=Ae.relativeLuminance(o>>8),c=Ae.relativeLuminance(a>>8);if(gt(h,c)<l){if(c<h){let _=s(o,a,l),f=gt(h,Ae.relativeLuminance(_>>8));if(f<l){let S=r(o,a,l),k=gt(h,Ae.relativeLuminance(S>>8));return f>k?_:S}return _}let d=r(o,a,l),u=gt(h,Ae.relativeLuminance(d>>8));if(u<l){let _=s(o,a,l),f=gt(h,Ae.relativeLuminance(_>>8));return u>f?d:_}return d}}t.ensureContrastRatio=i;function s(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=gt(Ae.relativeLuminance2(u,_,f),Ae.relativeLuminance2(h,c,d));for(;S<l&&(u>0||_>0||f>0);)u-=Math.max(0,Math.ceil(u*.1)),_-=Math.max(0,Math.ceil(_*.1)),f-=Math.max(0,Math.ceil(f*.1)),S=gt(Ae.relativeLuminance2(u,_,f),Ae.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.reduceLuminance=s;function r(o,a,l){let h=o>>24&255,c=o>>16&255,d=o>>8&255,u=a>>24&255,_=a>>16&255,f=a>>8&255,S=gt(Ae.relativeLuminance2(u,_,f),Ae.relativeLuminance2(h,c,d));for(;S<l&&(u<255||_<255||f<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),S=gt(Ae.relativeLuminance2(u,_,f),Ae.relativeLuminance2(h,c,d));return(u<<24|_<<16|f<<8|255)>>>0}t.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}t.toChannels=n})(Ut||={});function $t(t){let e=t.toString(16);return e.length<2?"0"+e:e}function gt(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function le(t){if(!t)throw new Error("value must not be falsy");return t}function sn(t){return 57508<=t&&t<=57558}function Td(t){return 57520<=t&&t<=57527}function Pd(t){return 57344<=t&&t<=63743}function Od(t){return 9472<=t&&t<=9631}function Id(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function $d(t,e,i,s){return e===1&&i>Math.ceil(s*1.5)&&t!==void 0&&t>255&&!Id(t)&&!sn(t)&&!Pd(t)}function Ba(t){return sn(t)||Od(t)}function Fd(){return{css:{canvas:Vi(),cell:Vi()},device:{canvas:Vi(),cell:Vi(),char:{width:0,height:0,left:0,top:0}}}}function Vi(){return{width:0,height:0}}function Nd(t,e,i=0){return(t-(Math.round(e)*2-i))%(Math.round(e)*2)}var ke=0,fe=0,ot=!1,pt=!1,Gi=!1,$e,Fs=0,Wd=class{constructor(t,e,i,s,r,n){this._terminal=t,this._optionService=e,this._selectionRenderModel=i,this._decorationService=s,this._coreBrowserService=r,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(t,e,i,s){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,fe=0,ke=0,pt=!1,ot=!1,Gi=!1,$e=this._themeService.colors,Fs=0,t.getCode()!==0&&t.extended.underlineStyle===4){let r=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Fs=e*s%(Math.round(r)*2)}if(this._decorationService.forEachDecorationAtCell(e,i,"bottom",r=>{r.backgroundColorRGB&&(fe=r.backgroundColorRGB.rgba>>8&16777215,pt=!0),r.foregroundColorRGB&&(ke=r.foregroundColorRGB.rgba>>8&16777215,ot=!0)}),Gi=this._selectionRenderModel.isCellSelected(this._terminal,e,i),Gi){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:fe=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:fe=(this.result.fg&16777215)<<8|255;break;default:fe=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:fe=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:fe=(this.result.bg&16777215)<<8|255;break}fe=Ut.blend(fe,(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else fe=(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(pt=!0,$e.selectionForeground&&(ke=$e.selectionForeground.rgba>>8&16777215,ot=!0),Ba(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)ke=(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:ke=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ke=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:ke=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ke=(this.result.fg&16777215)<<8|255;break;default:ke=this._themeService.colors.foreground.rgba}ke=Ut.blend(ke,(this._coreBrowserService.isFocused?$e.selectionBackgroundOpaque:$e.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}ot=!0}}this._decorationService.forEachDecorationAtCell(e,i,"top",r=>{r.backgroundColorRGB&&(fe=r.backgroundColorRGB.rgba>>8&16777215,pt=!0),r.foregroundColorRGB&&(ke=r.foregroundColorRGB.rgba>>8&16777215,ot=!0)}),pt&&(Gi?fe=t.bg&-16777216&-134217729|fe|50331648:fe=t.bg&-16777216|fe|50331648),ot&&(ke=t.fg&-16777216&-67108865|ke|50331648),this.result.fg&67108864&&(pt&&!ot&&((this.result.bg&50331648)===0?ke=this.result.fg&-134217728|$e.background.rgba>>8&16777215&16777215|50331648:ke=this.result.fg&-134217728|this.result.bg&67108863,ot=!0),!pt&&ot&&((this.result.fg&50331648)===0?fe=this.result.bg&-67108864|$e.foreground.rgba>>8&16777215&16777215|50331648:fe=this.result.bg&-67108864|this.result.fg&67108863,pt=!0)),$e=void 0,this.result.bg=pt?fe:this.result.bg,this.result.fg=ot?ke:this.result.fg,this.result.ext&=536870911,this.result.ext|=Fs<<29&3758096384}},zd=.5,Ra=Md||Bd?"bottom":"ideographic",Hd={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Ud={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},qd={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},Ai={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};Ai[""]=Ai[""];Ai[""]=Ai[""];function Kd(t,e,i,s,r,n,o,a){let l=Hd[e];if(l)return Vd(t,l,i,s,r,n),!0;let h=Ud[e];if(h)return Gd(t,h,i,s,r,n),!0;let c=qd[e];if(c)return Yd(t,c,i,s,r,n,a),!0;let d=Ai[e];return d?(Xd(t,d,i,s,r,n,o,a),!0):!1}function Vd(t,e,i,s,r,n){for(let o=0;o<e.length;o++){let a=e[o],l=r/8,h=n/8;t.fillRect(i+a.x*l,s+a.y*h,a.w*l,a.h*h)}}var ro=new Map;function Gd(t,e,i,s,r,n){let o=ro.get(e);o||(o=new Map,ro.set(e,o));let a=t.fillStyle;if(typeof a!="string")throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let h=e[0].length,c=e.length,d=t.canvas.ownerDocument.createElement("canvas");d.width=h,d.height=c;let u=le(d.getContext("2d")),_=new ImageData(h,c),f,S,k,D;if(a.startsWith("#"))f=parseInt(a.slice(1,3),16),S=parseInt(a.slice(3,5),16),k=parseInt(a.slice(5,7),16),D=a.length>7&&parseInt(a.slice(7,9),16)||1;else if(a.startsWith("rgba"))[f,S,k,D]=a.substring(5,a.length-1).split(",").map(A=>parseFloat(A));else throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);for(let A=0;A<c;A++)for(let B=0;B<h;B++)_.data[(A*h+B)*4]=f,_.data[(A*h+B)*4+1]=S,_.data[(A*h+B)*4+2]=k,_.data[(A*h+B)*4+3]=e[A][B]*(D*255);u.putImageData(_,0,0),l=le(t.createPattern(d,null)),o.set(a,l)}t.fillStyle=l,t.fillRect(i,s,r,n)}function Yd(t,e,i,s,r,n,o){t.strokeStyle=t.fillStyle;for(let[a,l]of Object.entries(e)){t.beginPath(),t.lineWidth=o*Number.parseInt(a);let h;if(typeof l=="function"){let c=.15/n*r;h=l(.15,c)}else h=l;for(let c of h.split(" ")){let d=c[0],u=Aa[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let _=c.substring(1).split(",");!_[0]||!_[1]||u(t,Da(_,r,n,i,s,!0,o))}t.stroke(),t.closePath()}}function Xd(t,e,i,s,r,n,o,a){let l=new Path2D;l.rect(i,s,r,n),t.clip(l),t.beginPath();let h=o/12;t.lineWidth=a*h;for(let c of e.d.split(" ")){let d=c[0],u=Aa[d];if(!u){console.error(`Could not find drawing instructions for "${d}"`);continue}let _=c.substring(1).split(",");!_[0]||!_[1]||u(t,Da(_,r,n,i,s,!1,a,(e.leftPadding??0)*(h/2),(e.rightPadding??0)*(h/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function no(t,e,i=0){return Math.max(Math.min(t,e),i)}var Aa={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function Da(t,e,i,s,r,n,o,a=0,l=0){let h=t.map(c=>parseFloat(c)||parseInt(c));if(h.length<2)throw new Error("Too few arguments for instruction");for(let c=0;c<h.length;c+=2)h[c]*=e-a*o-l*o,n&&h[c]!==0&&(h[c]=no(Math.round(h[c]+.5)-.5,e,0)),h[c]+=s+a*o;for(let c=1;c<h.length;c+=2)h[c]*=i,n&&h[c]!==0&&(h[c]=no(Math.round(h[c]+.5)-.5,i,0)),h[c]+=r;return h}var oo=class{constructor(){this._data={}}set(t,e,i){this._data[t]||(this._data[t]={}),this._data[t][e]=i}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},ao=class{constructor(){this._data=new oo}set(t,e,i,s,r){this._data.get(t,e)||this._data.set(t,e,new oo),this._data.get(t,e).set(i,s,r)}get(t,e,i,s){return this._data.get(t,e)?.get(i,s)}clear(){this._data.clear()}},Ta=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,i=0,s=t.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),i=Math.max(e,i),r=t.timeRemaining(),i*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},jd=class extends Ta{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Zd=class extends Ta{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Jd=!tn&&"requestIdleCallback"in window?Zd:jd,ti=class Pa{constructor(){this.fg=0,this.bg=0,this.extended=new Oa}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Pa;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Oa=class Ia{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Ia(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qd=globalThis.performance&&typeof globalThis.performance.now=="function",eu=class $a{static create(e){return new $a(e)}constructor(e){this._now=Qd&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},yt;(t=>{t.None=()=>it.None;function e(p,g){return d(p,()=>{},0,void 0,!0,void 0,g)}t.defer=e;function i(p){return(g,v=null,m)=>{let y=!1,b;return b=p(L=>{if(!y)return b?b.dispose():y=!0,g.call(v,L)},null,m),y&&b.dispose(),b}}t.once=i;function s(p,g,v){return h((m,y=null,b)=>p(L=>m.call(y,g(L)),null,b),v)}t.map=s;function r(p,g,v){return h((m,y=null,b)=>p(L=>{g(L),m.call(y,L)},null,b),v)}t.forEach=r;function n(p,g,v){return h((m,y=null,b)=>p(L=>g(L)&&m.call(y,L),null,b),v)}t.filter=n;function o(p){return p}t.signal=o;function a(...p){return(g,v=null,m)=>{let y=ka(...p.map(b=>b(L=>g.call(v,L))));return c(y,m)}}t.any=a;function l(p,g,v,m){let y=v;return s(p,b=>(y=g(y,b),y),m)}t.reduce=l;function h(p,g){let v,m={onWillAddFirstListener(){v=p(y.fire,y)},onDidRemoveLastListener(){v?.dispose()}},y=new Z(m);return g?.add(y),y.event}function c(p,g){return g instanceof Array?g.push(p):g&&g.add(p),p}function d(p,g,v=100,m=!1,y=!1,b,L){let C,M,I,Y=0,z,Oe={leakWarningThreshold:b,onWillAddFirstListener(){C=p(ye=>{Y++,M=g(M,ye),m&&!I&&(U.fire(M),M=void 0),z=()=>{let K=M;M=void 0,I=void 0,(!m||Y>1)&&U.fire(K),Y=0},typeof v=="number"?(clearTimeout(I),I=setTimeout(z,v)):I===void 0&&(I=0,queueMicrotask(z))})},onWillRemoveListener(){y&&Y>0&&z?.()},onDidRemoveLastListener(){z=void 0,C.dispose()}},U=new Z(Oe);return L?.add(U),U.event}t.debounce=d;function u(p,g=0,v){return t.debounce(p,(m,y)=>m?(m.push(y),m):[y],g,void 0,!0,void 0,v)}t.accumulate=u;function _(p,g=(m,y)=>m===y,v){let m=!0,y;return n(p,b=>{let L=m||!g(b,y);return m=!1,y=b,L},v)}t.latch=_;function f(p,g,v){return[t.filter(p,g,v),t.filter(p,m=>!g(m),v)]}t.split=f;function S(p,g=!1,v=[],m){let y=v.slice(),b=p(M=>{y?y.push(M):C.fire(M)});m&&m.add(b);let L=()=>{y?.forEach(M=>C.fire(M)),y=null},C=new Z({onWillAddFirstListener(){b||(b=p(M=>C.fire(M)),m&&m.add(b))},onDidAddFirstListener(){y&&(g?setTimeout(L):L())},onDidRemoveLastListener(){b&&b.dispose(),b=null}});return m&&m.add(C),C.event}t.buffer=S;function k(p,g){return(v,m,y)=>{let b=g(new A);return p(function(L){let C=b.evaluate(L);C!==D&&v.call(m,C)},void 0,y)}}t.chain=k;let D=Symbol("HaltChainable");class A{constructor(){this.steps=[]}map(g){return this.steps.push(g),this}forEach(g){return this.steps.push(v=>(g(v),v)),this}filter(g){return this.steps.push(v=>g(v)?v:D),this}reduce(g,v){let m=v;return this.steps.push(y=>(m=g(m,y),m)),this}latch(g=(v,m)=>v===m){let v=!0,m;return this.steps.push(y=>{let b=v||!g(y,m);return v=!1,m=y,b?y:D}),this}evaluate(g){for(let v of this.steps)if(g=v(g),g===D)break;return g}}function B(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.on(g,m),b=()=>p.removeListener(g,m),L=new Z({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromNodeEventEmitter=B;function w(p,g,v=m=>m){let m=(...C)=>L.fire(v(...C)),y=()=>p.addEventListener(g,m),b=()=>p.removeEventListener(g,m),L=new Z({onWillAddFirstListener:y,onDidRemoveLastListener:b});return L.event}t.fromDOMEventEmitter=w;function R(p){return new Promise(g=>i(p)(g))}t.toPromise=R;function P(p){let g=new Z;return p.then(v=>{g.fire(v)},()=>{g.fire(void 0)}).finally(()=>{g.dispose()}),g.event}t.fromPromise=P;function N(p,g){return p(v=>g.fire(v))}t.forward=N;function G(p,g,v){return g(v),p(m=>g(m))}t.runAndSubscribe=G;class ae{constructor(g,v){this._observable=g,this._counter=0,this._hasChanged=!1;let m={onWillAddFirstListener:()=>{g.addObserver(this)},onDidRemoveLastListener:()=>{g.removeObserver(this)}};this.emitter=new Z(m),v&&v.add(this.emitter)}beginUpdate(g){this._counter++}handlePossibleChange(g){}handleChange(g,v){this._hasChanged=!0}endUpdate(g){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Ee(p,g){return new ae(p,g).emitter.event}t.fromObservable=Ee;function W(p){return(g,v,m)=>{let y=0,b=!1,L={beginUpdate(){y++},endUpdate(){y--,y===0&&(p.reportChanges(),b&&(b=!1,g.call(v)))},handlePossibleChange(){},handleChange(){b=!0}};p.addObserver(L),p.reportChanges();let C={dispose(){p.removeObserver(L)}};return m instanceof si?m.add(C):Array.isArray(m)&&m.push(C),C}}t.fromObservableLight=W})(yt||={});var $r=class Fr{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Fr._idPool++}`,Fr.all.add(this)}start(e){this._stopWatch=new eu,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}}};$r.all=new Set,$r._idPool=0;var tu=$r,iu=-1,Fa=class Na{constructor(e,i,s=(Na._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let l=new nu(a,n);this._errorHandler(l)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[s,r]of this._stacks)(!e||i<r)&&(e=[s,r],i=r);return e}};Fa._idPool=1;var su=Fa,ru=class Wa{constructor(e){this.value=e}static create(){let e=new Error;return new Wa(e.stack??"")}print(){console.warn(this.value.split(`
21
21
  `).slice(2).join(`
22
- `))}},eu=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},tu=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},iu=0,$s=class{constructor(t){this.value=t,this.id=iu++}},su=2,ru,Z=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Jd(t?.onListenerError??Os,this._options?.leakWarningThreshold??Zd):void 0,this._perfMon=this._options?._profName?new jd(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new tu(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||Os)(l),tt.None}if(this._disposed)return tt.None;e&&(t=t.bind(e));let s=new $s(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Qd.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof $s?(this._deliveryQueue??=new nu,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Be(()=>{r?.(),this._removeListener(s)});return i instanceof si?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*su<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||Os;if(!i){t.value(e);return}try{t.value(e)}catch(s){i(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof $s)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},nu=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,i){this.i=0,this.end=i,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ro={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},vi=2,mi,Rt=class Qt{constructor(e,i,s){this._document=e,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new so,this._cacheMapCombined=new so,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ti,this._textureSize=512,this._onAddTextureAtlasCanvas=new Z,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Z,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=$a(e,this._config.deviceCellWidth*4+vi*2,this._config.deviceCellHeight+vi*2),this._tmpCtx=le(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Gd;for(let i=33;i<126;i++)e.enqueue(()=>{if(!this._cacheMap.get(i,0,0,0)){let s=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Qt.maxAtlasPages&&this._pages.length>=Math.max(4,Qt.maxAtlasPages)){let i=this._pages.filter(h=>h.canvas.width*2<=(Qt.maxTextureSize||4096)).sort((h,c)=>c.canvas.width!==h.canvas.width?c.canvas.width-h.canvas.width:c.percentageUsed-h.percentageUsed),s=-1,r=0;for(let h=0;h<i.length;h++)if(i[h].canvas.width!==r)s=h,r=i[h].canvas.width;else if(h-s===3)break;let n=i.slice(s,s+4),o=n.map(h=>h.glyphs[0].texturePage).sort((h,c)=>h>c?1:-1),a=this.pages.length-n.length,l=this._mergePages(n,a);l.version++;for(let h=o.length-1;h>=0;h--)this._deletePage(o[h]);this.pages.push(l),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(l.canvas)}let e=new Fs(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,i){let s=e[0].canvas.width*2,r=new Fs(this._document,s,e);for(let[n,o]of e.entries()){let a=n*o.canvas.width%s,l=Math.floor(n/2)*o.canvas.height;r.ctx.drawImage(o.canvas,a,l);for(let c of o.glyphs)c.texturePage=i,c.sizeClipSpace.x=c.size.x/s,c.sizeClipSpace.y=c.size.y/s,c.texturePosition.x+=a,c.texturePosition.y+=l,c.texturePositionClipSpace.x=c.texturePosition.x/s,c.texturePositionClipSpace.y=c.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(o.canvas);let h=this._activePages.indexOf(o);h!==-1&&this._activePages.splice(h,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let i=e;i<this._pages.length;i++){let s=this._pages[i];for(let r of s.glyphs)r.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,i,s,r,n,o){return this._getFromCacheMap(this._cacheMapCombined,e,i,s,r,n,o)}getRasterizedGlyph(e,i,s,r,n,o){return this._getFromCacheMap(this._cacheMap,e,i,s,r,n,o)}_getFromCacheMap(e,i,s,r,n,o,a){return mi=e.get(i,s,r,n),mi||(mi=this._drawToCache(i,s,r,n,o,a),e.set(i,s,r,n,mi)),mi}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,i,s,r){if(this._config.allowTransparency)return Ge;let n;switch(e){case 16777216:case 33554432:n=this._getColorFromAnsiIndex(i);break;case 50331648:let o=ti.toColorRGB(i);n=Ae.toColor(o[0],o[1],o[2]);break;default:s?n=ki.opaque(this._config.colors.foreground):n=this._config.colors.background;break}return this._config.allowTransparency||(n=ki.opaque(n)),n}_getForegroundColor(e,i,s,r,n,o,a,l,h,c){let d=this._getMinimumContrastColor(e,i,s,r,n,o,a,h,l,c);if(d)return d;let u;switch(n){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&h&&o<8&&(o+=8),u=this._getColorFromAnsiIndex(o);break;case 50331648:let _=ti.toColorRGB(o);u=Ae.toColor(_[0],_[1],_[2]);break;default:a?u=this._config.colors.background:u=this._config.colors.foreground}return this._config.allowTransparency&&(u=ki.opaque(u)),l&&(u=ki.multiplyOpacity(u,Id)),u}_resolveBackgroundRgba(e,i,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,i,s,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&i<8&&(i+=8),this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,i,s,r,n,o,a,l,h,c){if(this._config.minimumContrastRatio===1||c)return;let d=this._getContrastCache(h),u=d.getColor(e,r);if(u!==void 0)return u||void 0;let _=this._resolveBackgroundRgba(i,s,a),f=this._resolveForegroundRgba(n,o,a,l),S=Ut.ensureContrastRatio(_,f,this._config.minimumContrastRatio/(h?2:1));if(!S){d.setColor(e,r,null);return}let k=Ae.toColor(S>>24&255,S>>16&255,S>>8&255);return d.setColor(e,r,k),k}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,i,s,r,n,o){let a=typeof e=="number"?String.fromCharCode(e):e;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+vi*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let h=Math.min(this._config.deviceCellHeight+vi*4,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=r,!!this._workAttributeData.isInvisible())return ro;let c=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),u=!!this._workAttributeData.isDim(),_=!!this._workAttributeData.isItalic(),f=!!this._workAttributeData.isUnderline(),S=!!this._workAttributeData.isStrikethrough(),k=!!this._workAttributeData.isOverline(),A=this._workAttributeData.getFgColor(),D=this._workAttributeData.getFgColorMode(),B=this._workAttributeData.getBgColor(),w=this._workAttributeData.getBgColorMode();if(d){let M=A;A=B,B=M;let I=D;D=w,w=I}let R=this._getBackgroundColor(w,B,d,u);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=R.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let P=c?this._config.fontWeightBold:this._config.fontWeight,N=_?"italic":"";this._tmpCtx.font=`${N} ${P} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=La;let G=a.length===1&&Qr(a.charCodeAt(0)),ae=a.length===1&&Md(a.charCodeAt(0)),Ee=this._getForegroundColor(i,w,B,s,D,A,d,u,c,ka(a.charCodeAt(0)));this._tmpCtx.fillStyle=Ee.css;let W=ae?0:vi*2,p=!1;this._config.customGlyphs!==!1&&(p=Wd(this._tmpCtx,a,W,W,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let g=!G,v;if(typeof e=="number"?v=this._unicodeService.wcwidth(e):v=this._unicodeService.getStringCellWidth(e),f){this._tmpCtx.save();let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=M%2===1?.5:0;if(this._tmpCtx.lineWidth=M,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())g=!1,this._tmpCtx.strokeStyle=`rgb(${ti.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{g=!1;let K=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&K<8&&(K+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(K).css}this._tmpCtx.beginPath();let Y=W,z=Math.ceil(W+this._config.deviceCharHeight)-I-(n?M*2:0),Oe=z+M,U=z+M*2,ye=this._workAttributeData.getUnderlineVariantOffset();for(let K=0;K<v;K++){this._tmpCtx.save();let V=Y+K*this._config.deviceCellWidth,xe=Y+(K+1)*this._config.deviceCellWidth,qe=V+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z),this._tmpCtx.moveTo(V,U),this._tmpCtx.lineTo(xe,U);break;case 3:let ut=M<=1?U:Math.ceil(W+this._config.deviceCharHeight-M/2)-I,it=M<=1?z:Math.ceil(W+this._config.deviceCharHeight+M/2)-I,Qe=new Path2D;Qe.rect(V,z,this._config.deviceCellWidth,U-z),this._tmpCtx.clip(Qe),this._tmpCtx.moveTo(V-this._config.deviceCellWidth/2,Oe),this._tmpCtx.bezierCurveTo(V-this._config.deviceCellWidth/2,it,V,it,V,Oe),this._tmpCtx.bezierCurveTo(V,ut,qe,ut,qe,Oe),this._tmpCtx.bezierCurveTo(qe,it,xe,it,xe,Oe),this._tmpCtx.bezierCurveTo(xe,ut,xe+this._config.deviceCellWidth/2,ut,xe+this._config.deviceCellWidth/2,Oe);break;case 4:let H=ye===0?0:ye>=M?M*2-ye:M-ye;ye>=M||H===0?(this._tmpCtx.setLineDash([Math.round(M),Math.round(M)]),this._tmpCtx.moveTo(V+H,z),this._tmpCtx.lineTo(xe,z)):(this._tmpCtx.setLineDash([Math.round(M),Math.round(M)]),this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(V+H,z),this._tmpCtx.moveTo(V+H+M,z),this._tmpCtx.lineTo(xe,z)),ye=Pd(xe-V,M,ye);break;case 5:let li=.6,eh=.3,bs=xe-V,sn=Math.floor(li*bs),rn=Math.floor(eh*bs),th=bs-sn-rn;this._tmpCtx.setLineDash([sn,rn,th]),this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z);break;default:this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!p&&this._config.fontSize>=12&&!this._config.allowTransparency&&a!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let K=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in K&&K.actualBoundingBoxDescent>0){this._tmpCtx.save();let V=new Path2D;V.rect(Y,z-Math.ceil(M/2),this._config.deviceCellWidth*v,U-z+Math.ceil(M/2)),this._tmpCtx.clip(V),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=R.css,this._tmpCtx.strokeText(a,W,W+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(k){let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=M%2===1?.5:0;this._tmpCtx.lineWidth=M,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(W,W+I),this._tmpCtx.lineTo(W+this._config.deviceCharWidth*v,W+I),this._tmpCtx.stroke()}if(p||this._tmpCtx.fillText(a,W,W+this._config.deviceCharHeight),a==="_"&&!this._config.allowTransparency){let M=Ns(this._tmpCtx.getImageData(W,W,this._config.deviceCellWidth,this._config.deviceCellHeight),R,Ee,g);if(M)for(let I=1;I<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=R.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,W,W+this._config.deviceCharHeight-I),M=Ns(this._tmpCtx.getImageData(W,W,this._config.deviceCellWidth,this._config.deviceCellHeight),R,Ee,g),!!M);I++);}if(S){let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),I=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=M,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(W,W+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.lineTo(W+this._config.deviceCharWidth*v,W+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.stroke()}this._tmpCtx.restore();let m=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),y;if(this._config.allowTransparency?y=ou(m):y=Ns(m,R,Ee,g),y)return ro;let b=this._findGlyphBoundingBox(m,this._workBoundingBox,l,ae,p,W),L,C;for(;;){if(this._activePages.length===0){let M=this._createNewPage();L=M,C=M.currentRow,C.height=b.size.y;break}L=this._activePages[this._activePages.length-1],C=L.currentRow;for(let M of this._activePages)b.size.y<=M.currentRow.height&&(L=M,C=M.currentRow);for(let M=this._activePages.length-1;M>=0;M--)for(let I of this._activePages[M].fixedRows)I.height<=C.height&&b.size.y<=I.height&&(L=this._activePages[M],C=I);if(b.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Fs(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),L=this._overflowSizePage,C=this._overflowSizePage.currentRow,C.x+b.size.x>=L.canvas.width&&(C.x=0,C.y+=C.height,C.height=0);break}if(C.y+b.size.y>=L.canvas.height||C.height>b.size.y+2){let M=!1;if(L.currentRow.y+L.currentRow.height+b.size.y>=L.canvas.height){let I;for(let Y of this._activePages)if(Y.currentRow.y+Y.currentRow.height+b.size.y<Y.canvas.height){I=Y;break}if(I)L=I;else if(Qt.maxAtlasPages&&this._pages.length>=Qt.maxAtlasPages&&C.y+b.size.y<=L.canvas.height&&C.height>=b.size.y&&C.x+b.size.x<=L.canvas.width)M=!0;else{let Y=this._createNewPage();L=Y,C=Y.currentRow,C.height=b.size.y,M=!0}}M||(L.currentRow.height>0&&L.fixedRows.push(L.currentRow),C={x:0,y:L.currentRow.y+L.currentRow.height,height:b.size.y},L.fixedRows.push(C),L.currentRow={x:0,y:C.y+C.height,height:0})}if(C.x+b.size.x<=L.canvas.width)break;C===L.currentRow?(C.x=0,C.y+=C.height,C.height=0):L.fixedRows.splice(L.fixedRows.indexOf(C),1)}return b.texturePage=this._pages.indexOf(L),b.texturePosition.x=C.x,b.texturePosition.y=C.y,b.texturePositionClipSpace.x=C.x/L.canvas.width,b.texturePositionClipSpace.y=C.y/L.canvas.height,b.sizeClipSpace.x/=L.canvas.width,b.sizeClipSpace.y/=L.canvas.height,C.height=Math.max(C.height,b.size.y),C.x+=b.size.x,L.ctx.putImageData(m,b.texturePosition.x-this._workBoundingBox.left,b.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,b.size.x,b.size.y),L.addGlyph(b),L.version++,b}_findGlyphBoundingBox(e,i,s,r,n,o){i.top=0;let a=r?this._config.deviceCellHeight:this._tmpCanvas.height,l=r?this._config.deviceCellWidth:s,h=!1;for(let c=0;c<a;c++){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(e.data[u]!==0){i.top=c,h=!0;break}}if(h)break}i.left=0,h=!1;for(let c=0;c<o+l;c++){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(e.data[u]!==0){i.left=c,h=!0;break}}if(h)break}i.right=l,h=!1;for(let c=o+l-1;c>=o;c--){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(e.data[u]!==0){i.right=c,h=!0;break}}if(h)break}i.bottom=a,h=!1;for(let c=a-1;c>=0;c--){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(e.data[u]!==0){i.bottom=c,h=!0;break}}if(h)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:i.right-i.left+1,y:i.bottom-i.top+1},sizeClipSpace:{x:i.right-i.left+1,y:i.bottom-i.top+1},offset:{x:-i.left+o+(r||n?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+o+(r||n?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Fs=class{constructor(t,e,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let s of i)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=$a(t,e,e),this.ctx=le(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function Ns(t,e,i,s){let r=e.rgba>>>24,n=e.rgba>>>16&255,o=e.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,h=i.rgba>>>8&255,c=Math.floor((Math.abs(r-a)+Math.abs(n-l)+Math.abs(o-h))/12),d=!0;for(let u=0;u<t.data.length;u+=4)t.data[u]===r&&t.data[u+1]===n&&t.data[u+2]===o||s&&Math.abs(t.data[u]-r)+Math.abs(t.data[u+1]-n)+Math.abs(t.data[u+2]-o)<c?t.data[u+3]=0:d=!1;return d}function ou(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function $a(t,e,i){let s=t.createElement("canvas");return s.width=e,s.height=i,s}function au(t,e,i,s,r,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:Ge,cursorAccent:Ge,selectionForeground:Ge,selectionBackgroundTransparent:Ge,selectionBackgroundOpaque:Ge,selectionInactiveBackgroundTransparent:Ge,selectionInactiveBackgroundOpaque:Ge,overviewRulerBorder:Ge,scrollbarSliderBackground:Ge,scrollbarSliderHoverBackground:Ge,scrollbarSliderActiveBackground:Ge,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:r.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:a,letterSpacing:r.letterSpacing,lineHeight:r.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:i,deviceCharHeight:s,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,drawBoldTextInBrightColors:r.drawBoldTextInBrightColors,minimumContrastRatio:r.minimumContrastRatio,colors:l}}function no(t,e){for(let i=0;i<t.colors.ansi.length;i++)if(t.colors.ansi[i].rgba!==e.colors.ansi[i].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function hu(t){return(t&50331648)===16777216||(t&50331648)===33554432}var je=[];function Fa(t,e,i,s,r,n,o,a,l){let h=au(s,r,n,o,e,i,a,l);for(let u=0;u<je.length;u++){let _=je[u],f=_.ownedBy.indexOf(t);if(f>=0){if(no(_.config,h))return _.atlas;_.ownedBy.length===1?(_.atlas.dispose(),je.splice(u,1)):_.ownedBy.splice(f,1);break}}for(let u=0;u<je.length;u++){let _=je[u];if(no(_.config,h))return _.ownedBy.push(t),_.atlas}let c=t._core,d={atlas:new Rt(document,h,c.unicodeService),config:h,ownedBy:[t]};return je.push(d),d.atlas}function oo(t){for(let e=0;e<je.length;e++){let i=je[e].ownedBy.indexOf(t);if(i!==-1){je[e].ownedBy.length===1?(je[e].atlas.dispose(),je.splice(e,1)):je[e].ownedBy.splice(i,1);break}}}var Gi=600,lu=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=Gi){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Gi-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Gi-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Gi)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function ao(t,e,i){let s=new e.ResizeObserver(r=>{let n=r.find(l=>l.target===t);if(!n)return;if(!("devicePixelContentBoxSize"in n)){s?.disconnect(),s=void 0;return}let o=n.devicePixelContentBoxSize[0].inlineSize,a=n.devicePixelContentBoxSize[0].blockSize;o>0&&a>0&&i(o,a)});try{s.observe(t,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return Be(()=>s?.disconnect())}function cu(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var ho=class Na extends ti{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Da,this.combinedData=""}static fromCharData(e){let i=new Na;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?cu(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wa=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function za(t,e,i){let s=le(t.createProgram());if(t.attachShader(s,le(lo(t,t.VERTEX_SHADER,e))),t.attachShader(s,le(lo(t,t.FRAGMENT_SHADER,i))),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS))return s;console.error(t.getProgramInfoLog(s)),t.deleteProgram(s)}function lo(t,e,i){let s=le(t.createShader(e));if(t.shaderSource(s,i),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))return s;console.error(t.getShaderInfoLog(s)),t.deleteShader(s)}function du(t,e){let i=Math.min(t.length*2,e),s=new Float32Array(i);for(let r=0;r<t.length;r++)s[r]=t[r];return s}var uu=class{constructor(t){this.texture=t,this.version=-1}},_u=`#version 300 es
22
+ `))}},nu=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},ou=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},au=0,Ns=class{constructor(t){this.value=t,this.id=au++}},hu=2,lu,Z=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new su(t?.onListenerError??$s,this._options?.leakWarningThreshold??iu):void 0,this._perfMon=this._options?._profName?new tu(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(t,e,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let a=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new ou(`${o}. HINT: Stack shows most frequent listener (${a[1]}-times)`,a[0]);return(this._options?.onListenerError||$s)(l),it.None}if(this._disposed)return it.None;e&&(t=t.bind(e));let s=new Ns(t),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=ru.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ns?(this._deliveryQueue??=new cu,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Be(()=>{r?.(),this._removeListener(s)});return i instanceof si?i.add(n):Array.isArray(i)&&i.push(n),n},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let e=this._listeners,i=e.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,e[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*hu<=e.length){let r=0;for(let n=0;n<e.length;n++)e[n]?e[r++]=e[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=r}}_deliver(t,e){if(!t)return;let i=this._options?.onListenerError||$s;if(!i){t.value(e);return}try{t.value(e)}catch(s){i(s)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Ns)this._deliver(this._listeners,t);else{let e=this._deliveryQueue;e.enqueue(this,t,this._listeners.length),this._deliverQueue(e)}this._perfMon?.stop()}hasListeners(){return this._size>0}},cu=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,i){this.i=0,this.end=i,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ho={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},vi=2,mi,At=class Qt{constructor(e,i,s){this._document=e,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new ao,this._cacheMapCombined=new ao,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new ti,this._textureSize=512,this._onAddTextureAtlasCanvas=new Z,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Z,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=za(e,this._config.deviceCellWidth*4+vi*2,this._config.deviceCellHeight+vi*2),this._tmpCtx=le(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Jd;for(let i=33;i<126;i++)e.enqueue(()=>{if(!this._cacheMap.get(i,0,0,0)){let s=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Qt.maxAtlasPages&&this._pages.length>=Math.max(4,Qt.maxAtlasPages)){let i=this._pages.filter(h=>h.canvas.width*2<=(Qt.maxTextureSize||4096)).sort((h,c)=>c.canvas.width!==h.canvas.width?c.canvas.width-h.canvas.width:c.percentageUsed-h.percentageUsed),s=-1,r=0;for(let h=0;h<i.length;h++)if(i[h].canvas.width!==r)s=h,r=i[h].canvas.width;else if(h-s===3)break;let n=i.slice(s,s+4),o=n.map(h=>h.glyphs[0].texturePage).sort((h,c)=>h>c?1:-1),a=this.pages.length-n.length,l=this._mergePages(n,a);l.version++;for(let h=o.length-1;h>=0;h--)this._deletePage(o[h]);this.pages.push(l),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(l.canvas)}let e=new Ws(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,i){let s=e[0].canvas.width*2,r=new Ws(this._document,s,e);for(let[n,o]of e.entries()){let a=n*o.canvas.width%s,l=Math.floor(n/2)*o.canvas.height;r.ctx.drawImage(o.canvas,a,l);for(let c of o.glyphs)c.texturePage=i,c.sizeClipSpace.x=c.size.x/s,c.sizeClipSpace.y=c.size.y/s,c.texturePosition.x+=a,c.texturePosition.y+=l,c.texturePositionClipSpace.x=c.texturePosition.x/s,c.texturePositionClipSpace.y=c.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(o.canvas);let h=this._activePages.indexOf(o);h!==-1&&this._activePages.splice(h,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let i=e;i<this._pages.length;i++){let s=this._pages[i];for(let r of s.glyphs)r.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,i,s,r,n,o){return this._getFromCacheMap(this._cacheMapCombined,e,i,s,r,n,o)}getRasterizedGlyph(e,i,s,r,n,o){return this._getFromCacheMap(this._cacheMap,e,i,s,r,n,o)}_getFromCacheMap(e,i,s,r,n,o,a){return mi=e.get(i,s,r,n),mi||(mi=this._drawToCache(i,s,r,n,o,a),e.set(i,s,r,n,mi)),mi}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,i,s,r){if(this._config.allowTransparency)return Ge;let n;switch(e){case 16777216:case 33554432:n=this._getColorFromAnsiIndex(i);break;case 50331648:let o=ti.toColorRGB(i);n=De.toColor(o[0],o[1],o[2]);break;default:s?n=ki.opaque(this._config.colors.foreground):n=this._config.colors.background;break}return this._config.allowTransparency||(n=ki.opaque(n)),n}_getForegroundColor(e,i,s,r,n,o,a,l,h,c){let d=this._getMinimumContrastColor(e,i,s,r,n,o,a,h,l,c);if(d)return d;let u;switch(n){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&h&&o<8&&(o+=8),u=this._getColorFromAnsiIndex(o);break;case 50331648:let _=ti.toColorRGB(o);u=De.toColor(_[0],_[1],_[2]);break;default:a?u=this._config.colors.background:u=this._config.colors.foreground}return this._config.allowTransparency&&(u=ki.opaque(u)),l&&(u=ki.multiplyOpacity(u,zd)),u}_resolveBackgroundRgba(e,i,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,i,s,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&i<8&&(i+=8),this._getColorFromAnsiIndex(i).rgba;case 50331648:return i<<8;default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,i,s,r,n,o,a,l,h,c){if(this._config.minimumContrastRatio===1||c)return;let d=this._getContrastCache(h),u=d.getColor(e,r);if(u!==void 0)return u||void 0;let _=this._resolveBackgroundRgba(i,s,a),f=this._resolveForegroundRgba(n,o,a,l),S=Ut.ensureContrastRatio(_,f,this._config.minimumContrastRatio/(h?2:1));if(!S){d.setColor(e,r,null);return}let k=De.toColor(S>>24&255,S>>16&255,S>>8&255);return d.setColor(e,r,k),k}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,i,s,r,n,o){let a=typeof e=="number"?String.fromCharCode(e):e;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+vi*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let h=Math.min(this._config.deviceCellHeight+vi*4,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=r,!!this._workAttributeData.isInvisible())return ho;let c=!!this._workAttributeData.isBold(),d=!!this._workAttributeData.isInverse(),u=!!this._workAttributeData.isDim(),_=!!this._workAttributeData.isItalic(),f=!!this._workAttributeData.isUnderline(),S=!!this._workAttributeData.isStrikethrough(),k=!!this._workAttributeData.isOverline(),D=this._workAttributeData.getFgColor(),A=this._workAttributeData.getFgColorMode(),B=this._workAttributeData.getBgColor(),w=this._workAttributeData.getBgColorMode();if(d){let M=D;D=B,B=M;let I=A;A=w,w=I}let R=this._getBackgroundColor(w,B,d,u);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=R.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let P=c?this._config.fontWeightBold:this._config.fontWeight,N=_?"italic":"";this._tmpCtx.font=`${N} ${P} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=Ra;let G=a.length===1&&sn(a.charCodeAt(0)),ae=a.length===1&&Td(a.charCodeAt(0)),Ee=this._getForegroundColor(i,w,B,s,A,D,d,u,c,Ba(a.charCodeAt(0)));this._tmpCtx.fillStyle=Ee.css;let W=ae?0:vi*2,p=!1;this._config.customGlyphs!==!1&&(p=Kd(this._tmpCtx,a,W,W,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let g=!G,v;if(typeof e=="number"?v=this._unicodeService.wcwidth(e):v=this._unicodeService.getStringCellWidth(e),f){this._tmpCtx.save();let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=M%2===1?.5:0;if(this._tmpCtx.lineWidth=M,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())g=!1,this._tmpCtx.strokeStyle=`rgb(${ti.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{g=!1;let K=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&K<8&&(K+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(K).css}this._tmpCtx.beginPath();let Y=W,z=Math.ceil(W+this._config.deviceCharHeight)-I-(n?M*2:0),Oe=z+M,U=z+M*2,ye=this._workAttributeData.getUnderlineVariantOffset();for(let K=0;K<v;K++){this._tmpCtx.save();let V=Y+K*this._config.deviceCellWidth,xe=Y+(K+1)*this._config.deviceCellWidth,qe=V+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z),this._tmpCtx.moveTo(V,U),this._tmpCtx.lineTo(xe,U);break;case 3:let _t=M<=1?U:Math.ceil(W+this._config.deviceCharHeight-M/2)-I,st=M<=1?z:Math.ceil(W+this._config.deviceCharHeight+M/2)-I,Qe=new Path2D;Qe.rect(V,z,this._config.deviceCellWidth,U-z),this._tmpCtx.clip(Qe),this._tmpCtx.moveTo(V-this._config.deviceCellWidth/2,Oe),this._tmpCtx.bezierCurveTo(V-this._config.deviceCellWidth/2,st,V,st,V,Oe),this._tmpCtx.bezierCurveTo(V,_t,qe,_t,qe,Oe),this._tmpCtx.bezierCurveTo(qe,st,xe,st,xe,Oe),this._tmpCtx.bezierCurveTo(xe,_t,xe+this._config.deviceCellWidth/2,_t,xe+this._config.deviceCellWidth/2,Oe);break;case 4:let H=ye===0?0:ye>=M?M*2-ye:M-ye;ye>=M||H===0?(this._tmpCtx.setLineDash([Math.round(M),Math.round(M)]),this._tmpCtx.moveTo(V+H,z),this._tmpCtx.lineTo(xe,z)):(this._tmpCtx.setLineDash([Math.round(M),Math.round(M)]),this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(V+H,z),this._tmpCtx.moveTo(V+H+M,z),this._tmpCtx.lineTo(xe,z)),ye=Nd(xe-V,M,ye);break;case 5:let li=.6,nh=.3,ys=xe-V,an=Math.floor(li*ys),hn=Math.floor(nh*ys),oh=ys-an-hn;this._tmpCtx.setLineDash([an,hn,oh]),this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z);break;default:this._tmpCtx.moveTo(V,z),this._tmpCtx.lineTo(xe,z);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!p&&this._config.fontSize>=12&&!this._config.allowTransparency&&a!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let K=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in K&&K.actualBoundingBoxDescent>0){this._tmpCtx.save();let V=new Path2D;V.rect(Y,z-Math.ceil(M/2),this._config.deviceCellWidth*v,U-z+Math.ceil(M/2)),this._tmpCtx.clip(V),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=R.css,this._tmpCtx.strokeText(a,W,W+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(k){let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=M%2===1?.5:0;this._tmpCtx.lineWidth=M,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(W,W+I),this._tmpCtx.lineTo(W+this._config.deviceCharWidth*v,W+I),this._tmpCtx.stroke()}if(p||this._tmpCtx.fillText(a,W,W+this._config.deviceCharHeight),a==="_"&&!this._config.allowTransparency){let M=zs(this._tmpCtx.getImageData(W,W,this._config.deviceCellWidth,this._config.deviceCellHeight),R,Ee,g);if(M)for(let I=1;I<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=R.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,W,W+this._config.deviceCharHeight-I),M=zs(this._tmpCtx.getImageData(W,W,this._config.deviceCellWidth,this._config.deviceCellHeight),R,Ee,g),!!M);I++);}if(S){let M=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),I=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=M,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(W,W+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.lineTo(W+this._config.deviceCharWidth*v,W+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.stroke()}this._tmpCtx.restore();let m=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),y;if(this._config.allowTransparency?y=du(m):y=zs(m,R,Ee,g),y)return ho;let b=this._findGlyphBoundingBox(m,this._workBoundingBox,l,ae,p,W),L,C;for(;;){if(this._activePages.length===0){let M=this._createNewPage();L=M,C=M.currentRow,C.height=b.size.y;break}L=this._activePages[this._activePages.length-1],C=L.currentRow;for(let M of this._activePages)b.size.y<=M.currentRow.height&&(L=M,C=M.currentRow);for(let M=this._activePages.length-1;M>=0;M--)for(let I of this._activePages[M].fixedRows)I.height<=C.height&&b.size.y<=I.height&&(L=this._activePages[M],C=I);if(b.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Ws(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),L=this._overflowSizePage,C=this._overflowSizePage.currentRow,C.x+b.size.x>=L.canvas.width&&(C.x=0,C.y+=C.height,C.height=0);break}if(C.y+b.size.y>=L.canvas.height||C.height>b.size.y+2){let M=!1;if(L.currentRow.y+L.currentRow.height+b.size.y>=L.canvas.height){let I;for(let Y of this._activePages)if(Y.currentRow.y+Y.currentRow.height+b.size.y<Y.canvas.height){I=Y;break}if(I)L=I;else if(Qt.maxAtlasPages&&this._pages.length>=Qt.maxAtlasPages&&C.y+b.size.y<=L.canvas.height&&C.height>=b.size.y&&C.x+b.size.x<=L.canvas.width)M=!0;else{let Y=this._createNewPage();L=Y,C=Y.currentRow,C.height=b.size.y,M=!0}}M||(L.currentRow.height>0&&L.fixedRows.push(L.currentRow),C={x:0,y:L.currentRow.y+L.currentRow.height,height:b.size.y},L.fixedRows.push(C),L.currentRow={x:0,y:C.y+C.height,height:0})}if(C.x+b.size.x<=L.canvas.width)break;C===L.currentRow?(C.x=0,C.y+=C.height,C.height=0):L.fixedRows.splice(L.fixedRows.indexOf(C),1)}return b.texturePage=this._pages.indexOf(L),b.texturePosition.x=C.x,b.texturePosition.y=C.y,b.texturePositionClipSpace.x=C.x/L.canvas.width,b.texturePositionClipSpace.y=C.y/L.canvas.height,b.sizeClipSpace.x/=L.canvas.width,b.sizeClipSpace.y/=L.canvas.height,C.height=Math.max(C.height,b.size.y),C.x+=b.size.x,L.ctx.putImageData(m,b.texturePosition.x-this._workBoundingBox.left,b.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,b.size.x,b.size.y),L.addGlyph(b),L.version++,b}_findGlyphBoundingBox(e,i,s,r,n,o){i.top=0;let a=r?this._config.deviceCellHeight:this._tmpCanvas.height,l=r?this._config.deviceCellWidth:s,h=!1;for(let c=0;c<a;c++){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(e.data[u]!==0){i.top=c,h=!0;break}}if(h)break}i.left=0,h=!1;for(let c=0;c<o+l;c++){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(e.data[u]!==0){i.left=c,h=!0;break}}if(h)break}i.right=l,h=!1;for(let c=o+l-1;c>=o;c--){for(let d=0;d<a;d++){let u=d*this._tmpCanvas.width*4+c*4+3;if(e.data[u]!==0){i.right=c,h=!0;break}}if(h)break}i.bottom=a,h=!1;for(let c=a-1;c>=0;c--){for(let d=0;d<l;d++){let u=c*this._tmpCanvas.width*4+d*4+3;if(e.data[u]!==0){i.bottom=c,h=!0;break}}if(h)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:i.right-i.left+1,y:i.bottom-i.top+1},sizeClipSpace:{x:i.right-i.left+1,y:i.bottom-i.top+1},offset:{x:-i.left+o+(r||n?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+o+(r||n?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Ws=class{constructor(t,e,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let s of i)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=za(t,e,e),this.ctx=le(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function zs(t,e,i,s){let r=e.rgba>>>24,n=e.rgba>>>16&255,o=e.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,h=i.rgba>>>8&255,c=Math.floor((Math.abs(r-a)+Math.abs(n-l)+Math.abs(o-h))/12),d=!0;for(let u=0;u<t.data.length;u+=4)t.data[u]===r&&t.data[u+1]===n&&t.data[u+2]===o||s&&Math.abs(t.data[u]-r)+Math.abs(t.data[u+1]-n)+Math.abs(t.data[u+2]-o)<c?t.data[u+3]=0:d=!1;return d}function du(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function za(t,e,i){let s=t.createElement("canvas");return s.width=e,s.height=i,s}function uu(t,e,i,s,r,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:Ge,cursorAccent:Ge,selectionForeground:Ge,selectionBackgroundTransparent:Ge,selectionBackgroundOpaque:Ge,selectionInactiveBackgroundTransparent:Ge,selectionInactiveBackgroundOpaque:Ge,overviewRulerBorder:Ge,scrollbarSliderBackground:Ge,scrollbarSliderHoverBackground:Ge,scrollbarSliderActiveBackground:Ge,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:r.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:a,letterSpacing:r.letterSpacing,lineHeight:r.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:i,deviceCharHeight:s,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,drawBoldTextInBrightColors:r.drawBoldTextInBrightColors,minimumContrastRatio:r.minimumContrastRatio,colors:l}}function lo(t,e){for(let i=0;i<t.colors.ansi.length;i++)if(t.colors.ansi[i].rgba!==e.colors.ansi[i].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function _u(t){return(t&50331648)===16777216||(t&50331648)===33554432}var je=[];function Ha(t,e,i,s,r,n,o,a,l){let h=uu(s,r,n,o,e,i,a,l);for(let u=0;u<je.length;u++){let _=je[u],f=_.ownedBy.indexOf(t);if(f>=0){if(lo(_.config,h))return _.atlas;_.ownedBy.length===1?(_.atlas.dispose(),je.splice(u,1)):_.ownedBy.splice(f,1);break}}for(let u=0;u<je.length;u++){let _=je[u];if(lo(_.config,h))return _.ownedBy.push(t),_.atlas}let c=t._core,d={atlas:new At(document,h,c.unicodeService),config:h,ownedBy:[t]};return je.push(d),d.atlas}function co(t){for(let e=0;e<je.length;e++){let i=je[e].ownedBy.indexOf(t);if(i!==-1){je[e].ownedBy.length===1?(je[e].atlas.dispose(),je.splice(e,1)):je[e].ownedBy.splice(i,1);break}}}var Yi=600,fu=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=Yi){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Yi-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Yi-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Yi)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function uo(t,e,i){let s=new e.ResizeObserver(r=>{let n=r.find(l=>l.target===t);if(!n)return;if(!("devicePixelContentBoxSize"in n)){s?.disconnect(),s=void 0;return}let o=n.devicePixelContentBoxSize[0].inlineSize,a=n.devicePixelContentBoxSize[0].blockSize;o>0&&a>0&&i(o,a)});try{s.observe(t,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return Be(()=>s?.disconnect())}function gu(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var _o=class Ua extends ti{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Oa,this.combinedData=""}static fromCharData(e){let i=new Ua;return i.setFromCharData(e),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?gu(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},qa=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Ka(t,e,i){let s=le(t.createProgram());if(t.attachShader(s,le(fo(t,t.VERTEX_SHADER,e))),t.attachShader(s,le(fo(t,t.FRAGMENT_SHADER,i))),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS))return s;console.error(t.getProgramInfoLog(s)),t.deleteProgram(s)}function fo(t,e,i){let s=le(t.createShader(e));if(t.shaderSource(s,i),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))return s;console.error(t.getShaderInfoLog(s)),t.deleteShader(s)}function pu(t,e){let i=Math.min(t.length*2,e),s=new Float32Array(i);for(let r=0;r<t.length;r++)s[r]=t[r];return s}var vu=class{constructor(t){this.texture=t,this.version=-1}},mu=`#version 300 es
23
23
  layout (location = 0) in vec2 a_unitquad;
24
24
  layout (location = 1) in vec2 a_cellpos;
25
25
  layout (location = 2) in vec2 a_offset;
@@ -39,7 +39,7 @@ void main() {
39
39
  gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
40
40
  v_texpage = int(a_texpage);
41
41
  v_texcoord = a_texcoord + a_unitquad * a_texsize;
42
- }`;function fu(t){let e="";for(let i=1;i<t;i++)e+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es
42
+ }`;function Su(t){let e="";for(let i=1;i<t;i++)e+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es
43
43
  precision lowp float;
44
44
 
45
45
  in vec2 v_texcoord;
@@ -53,7 +53,7 @@ void main() {
53
53
  if (v_texpage == 0) {
54
54
  outColor = texture(u_texture[0], v_texcoord);
55
55
  } ${e}
56
- }`}var Dt=11,jt=Dt*Float32Array.BYTES_PER_ELEMENT,gu=2,te=0,X,Ws=0,Si=0,pu=class extends tt{constructor(t,e,i,s){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let r=this._gl;Rt.maxAtlasPages===void 0&&(Rt.maxAtlasPages=Math.min(32,le(r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS))),Rt.maxTextureSize=le(r.getParameter(r.MAX_TEXTURE_SIZE))),this._program=le(za(r,_u,fu(Rt.maxAtlasPages))),this._register(Be(()=>r.deleteProgram(this._program))),this._projectionLocation=le(r.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=le(r.getUniformLocation(this._program,"u_resolution")),this._textureLocation=le(r.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(Be(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=r.createBuffer();this._register(Be(()=>r.deleteBuffer(l))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,l),r.bufferData(r.ELEMENT_ARRAY_BUFFER,a,r.STATIC_DRAW),this._attributesBuffer=le(r.createBuffer()),this._register(Be(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,2,r.FLOAT,!1,jt,0),r.vertexAttribDivisor(2,1),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,r.FLOAT,!1,jt,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(3,1),r.enableVertexAttribArray(4),r.vertexAttribPointer(4,1,r.FLOAT,!1,jt,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(4,1),r.enableVertexAttribArray(5),r.vertexAttribPointer(5,2,r.FLOAT,!1,jt,5*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(5,1),r.enableVertexAttribArray(6),r.vertexAttribPointer(6,2,r.FLOAT,!1,jt,7*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(6,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,jt,9*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.useProgram(this._program);let h=new Int32Array(Rt.maxAtlasPages);for(let c=0;c<Rt.maxAtlasPages;c++)h[c]=c;r.uniform1iv(this._textureLocation,h),r.uniformMatrix4fv(this._projectionLocation,!1,Wa),this._atlasTextures=[];for(let c=0;c<Rt.maxAtlasPages;c++){let d=new uu(le(r.createTexture()));this._register(Be(()=>r.deleteTexture(d.texture))),r.activeTexture(r.TEXTURE0+c),r.bindTexture(r.TEXTURE_2D,d.texture),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[c]=d}r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,i,s,r,n,o,a,l){this._updateCell(this._vertices.attributes,t,e,i,s,r,n,o,a,l)}_updateCell(t,e,i,s,r,n,o,a,l,h){if(te=(i*this._terminal.cols+e)*Dt,s===0||s===void 0){t.fill(0,te,te+Dt-1-gu);return}this._atlas&&(a&&a.length>1?X=this._atlas.getRasterizedGlyphCombinedChar(a,r,n,o,!1,this._terminal.element):X=this._atlas.getRasterizedGlyph(s,r,n,o,!1,this._terminal.element),Ws=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),r!==h&&X.offset.x>Ws?(Si=X.offset.x-Ws,t[te]=-(X.offset.x-Si)+this._dimensions.device.char.left,t[te+1]=-X.offset.y+this._dimensions.device.char.top,t[te+2]=(X.size.x-Si)/this._dimensions.device.canvas.width,t[te+3]=X.size.y/this._dimensions.device.canvas.height,t[te+4]=X.texturePage,t[te+5]=X.texturePositionClipSpace.x+Si/this._atlas.pages[X.texturePage].canvas.width,t[te+6]=X.texturePositionClipSpace.y,t[te+7]=X.sizeClipSpace.x-Si/this._atlas.pages[X.texturePage].canvas.width,t[te+8]=X.sizeClipSpace.y):(t[te]=-X.offset.x+this._dimensions.device.char.left,t[te+1]=-X.offset.y+this._dimensions.device.char.top,t[te+2]=X.size.x/this._dimensions.device.canvas.width,t[te+3]=X.size.y/this._dimensions.device.canvas.height,t[te+4]=X.texturePage,t[te+5]=X.texturePositionClipSpace.x,t[te+6]=X.texturePositionClipSpace.y,t[te+7]=X.sizeClipSpace.x,t[te+8]=X.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Ad(s,l,X.size.x,this._dimensions.device.cell.width)&&(t[te+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*Dt;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==e?this._vertices.attributesBuffers[i]=new Float32Array(e):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=e,i=0;for(let s=0;s<t.rows;s++)for(let r=0;r<t.cols;r++)this._vertices.attributes[i+9]=r/t.cols,this._vertices.attributes[i+10]=s/t.rows,i+=Dt}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let r=0;r<t.lineLengths.length;r++){let n=r*this._terminal.cols*Dt,o=this._vertices.attributes.subarray(n,n+t.lineLengths[r]*Dt);i.set(o,s),s+=o.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,i.subarray(0,s),e.STREAM_DRAW);for(let r=0;r<this._atlas.pages.length;r++)this._atlas.pages[r].version!==this._atlasTextures[r].version&&this._bindAtlasPageTexture(e,this._atlas,r);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/Dt)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,i){t.activeTexture(t.TEXTURE0+i),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[i].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[i].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[i].version=e.pages[i].version}setDimensions(t){this._dimensions=t}},vu=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(t,e,i,s=!1){if(this.selectionStart=e,this.selectionEnd=i,!e||!i||e[0]===i[0]&&e[1]===i[1]){this.clear();return}let r=t.buffers.active.ydisp,n=e[1]-r,o=i[1]-r,a=Math.max(n,0),l=Math.min(o,t.rows-1);if(a>=t.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=e[0],this.endCol=i[0]}isCellSelected(t,e,i){return this.hasSelection?(i-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&i>=this.viewportCappedStartRow&&e<this.endCol&&i<=this.viewportCappedEndRow:e<this.startCol&&i>=this.viewportCappedStartRow&&e>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol):!1}};function mu(){return new vu}var cs=4,ts=1,is=2,zs=3,Su=2147483648,wu=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=mu()}resize(t,e){let i=t*e*cs;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},bu=`#version 300 es
56
+ }`}var Dt=11,jt=Dt*Float32Array.BYTES_PER_ELEMENT,wu=2,te=0,X,Hs=0,Si=0,bu=class extends it{constructor(t,e,i,s){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let r=this._gl;At.maxAtlasPages===void 0&&(At.maxAtlasPages=Math.min(32,le(r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS))),At.maxTextureSize=le(r.getParameter(r.MAX_TEXTURE_SIZE))),this._program=le(Ka(r,mu,Su(At.maxAtlasPages))),this._register(Be(()=>r.deleteProgram(this._program))),this._projectionLocation=le(r.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=le(r.getUniformLocation(this._program,"u_resolution")),this._textureLocation=le(r.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(Be(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=r.createBuffer();this._register(Be(()=>r.deleteBuffer(l))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,l),r.bufferData(r.ELEMENT_ARRAY_BUFFER,a,r.STATIC_DRAW),this._attributesBuffer=le(r.createBuffer()),this._register(Be(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,2,r.FLOAT,!1,jt,0),r.vertexAttribDivisor(2,1),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,r.FLOAT,!1,jt,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(3,1),r.enableVertexAttribArray(4),r.vertexAttribPointer(4,1,r.FLOAT,!1,jt,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(4,1),r.enableVertexAttribArray(5),r.vertexAttribPointer(5,2,r.FLOAT,!1,jt,5*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(5,1),r.enableVertexAttribArray(6),r.vertexAttribPointer(6,2,r.FLOAT,!1,jt,7*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(6,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,jt,9*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.useProgram(this._program);let h=new Int32Array(At.maxAtlasPages);for(let c=0;c<At.maxAtlasPages;c++)h[c]=c;r.uniform1iv(this._textureLocation,h),r.uniformMatrix4fv(this._projectionLocation,!1,qa),this._atlasTextures=[];for(let c=0;c<At.maxAtlasPages;c++){let d=new vu(le(r.createTexture()));this._register(Be(()=>r.deleteTexture(d.texture))),r.activeTexture(r.TEXTURE0+c),r.bindTexture(r.TEXTURE_2D,d.texture),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[c]=d}r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,i,s,r,n,o,a,l){this._updateCell(this._vertices.attributes,t,e,i,s,r,n,o,a,l)}_updateCell(t,e,i,s,r,n,o,a,l,h){if(te=(i*this._terminal.cols+e)*Dt,s===0||s===void 0){t.fill(0,te,te+Dt-1-wu);return}this._atlas&&(a&&a.length>1?X=this._atlas.getRasterizedGlyphCombinedChar(a,r,n,o,!1,this._terminal.element):X=this._atlas.getRasterizedGlyph(s,r,n,o,!1,this._terminal.element),Hs=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),r!==h&&X.offset.x>Hs?(Si=X.offset.x-Hs,t[te]=-(X.offset.x-Si)+this._dimensions.device.char.left,t[te+1]=-X.offset.y+this._dimensions.device.char.top,t[te+2]=(X.size.x-Si)/this._dimensions.device.canvas.width,t[te+3]=X.size.y/this._dimensions.device.canvas.height,t[te+4]=X.texturePage,t[te+5]=X.texturePositionClipSpace.x+Si/this._atlas.pages[X.texturePage].canvas.width,t[te+6]=X.texturePositionClipSpace.y,t[te+7]=X.sizeClipSpace.x-Si/this._atlas.pages[X.texturePage].canvas.width,t[te+8]=X.sizeClipSpace.y):(t[te]=-X.offset.x+this._dimensions.device.char.left,t[te+1]=-X.offset.y+this._dimensions.device.char.top,t[te+2]=X.size.x/this._dimensions.device.canvas.width,t[te+3]=X.size.y/this._dimensions.device.canvas.height,t[te+4]=X.texturePage,t[te+5]=X.texturePositionClipSpace.x,t[te+6]=X.texturePositionClipSpace.y,t[te+7]=X.sizeClipSpace.x,t[te+8]=X.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&$d(s,l,X.size.x,this._dimensions.device.cell.width)&&(t[te+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*Dt;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==e?this._vertices.attributesBuffers[i]=new Float32Array(e):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=e,i=0;for(let s=0;s<t.rows;s++)for(let r=0;r<t.cols;r++)this._vertices.attributes[i+9]=r/t.cols,this._vertices.attributes[i+10]=s/t.rows,i+=Dt}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let r=0;r<t.lineLengths.length;r++){let n=r*this._terminal.cols*Dt,o=this._vertices.attributes.subarray(n,n+t.lineLengths[r]*Dt);i.set(o,s),s+=o.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,i.subarray(0,s),e.STREAM_DRAW);for(let r=0;r<this._atlas.pages.length;r++)this._atlas.pages[r].version!==this._atlasTextures[r].version&&this._bindAtlasPageTexture(e,this._atlas,r);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/Dt)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,i){t.activeTexture(t.TEXTURE0+i),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[i].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[i].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[i].version=e.pages[i].version}setDimensions(t){this._dimensions=t}},Cu=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(t,e,i,s=!1){if(this.selectionStart=e,this.selectionEnd=i,!e||!i||e[0]===i[0]&&e[1]===i[1]){this.clear();return}let r=t.buffers.active.ydisp,n=e[1]-r,o=i[1]-r,a=Math.max(n,0),l=Math.min(o,t.rows-1);if(a>=t.rows||l<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=e[0],this.endCol=i[0]}isCellSelected(t,e,i){return this.hasSelection?(i-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&i>=this.viewportCappedStartRow&&e<this.endCol&&i<=this.viewportCappedEndRow:e<this.startCol&&i>=this.viewportCappedStartRow&&e>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&e>=this.startCol):!1}};function yu(){return new Cu}var us=4,ss=1,rs=2,Us=3,xu=2147483648,ku=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=yu()}resize(t,e){let i=t*e*us;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Lu=`#version 300 es
57
57
  layout (location = 0) in vec2 a_position;
58
58
  layout (location = 1) in vec2 a_size;
59
59
  layout (location = 2) in vec4 a_color;
@@ -67,7 +67,7 @@ void main() {
67
67
  vec2 zeroToOne = a_position + (a_unitquad * a_size);
68
68
  gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
69
69
  v_color = a_color;
70
- }`,Cu=`#version 300 es
70
+ }`,Eu=`#version 300 es
71
71
  precision lowp float;
72
72
 
73
73
  in vec4 v_color;
@@ -76,5 +76,5 @@ out vec4 outColor;
76
76
 
77
77
  void main() {
78
78
  outColor = v_color;
79
- }`,St=8,Hs=St*Float32Array.BYTES_PER_ELEMENT,yu=20*St,co=class{constructor(){this.attributes=new Float32Array(yu),this.count=0}},pt=0,uo=0,_o=0,fo=0,go=0,po=0,vo=0,xu=class extends tt{constructor(t,e,i,s){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._themeService=s,this._vertices=new co,this._verticesCursor=new co;let r=this._gl;this._program=le(za(r,bu,Cu)),this._register(Be(()=>r.deleteProgram(this._program))),this._projectionLocation=le(r.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(Be(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=r.createBuffer();this._register(Be(()=>r.deleteBuffer(l))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,l),r.bufferData(r.ELEMENT_ARRAY_BUFFER,a,r.STATIC_DRAW),this._attributesBuffer=le(r.createBuffer()),this._register(Be(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,r.FLOAT,!1,Hs,0),r.vertexAttribDivisor(0,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,Hs,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,4,r.FLOAT,!1,Hs,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(h=>{this._updateCachedColors(h),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,Wa),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,i=this._vertices,s=1,r,n,o,a,l,h,c,d,u,_,f;for(r=0;r<e.rows;r++){for(o=-1,a=0,l=0,h=!1,n=0;n<e.cols;n++)c=(r*e.cols+n)*cs,d=t.cells[c+ts],u=t.cells[c+is],_=!!(u&67108864),(d!==a||u!==l&&(h||_))&&((a!==0||h&&l!==0)&&(f=s++*St,this._updateRectangle(i,f,l,a,o,n,r)),o=n,a=d,l=u,h=_);(a!==0||h&&l!==0)&&(f=s++*St,this._updateRectangle(i,f,l,a,o,e.cols,r))}i.count=s}updateCursor(t){let e=this._verticesCursor,i=t.cursor;if(!i||i.style==="block"){e.count=0;return}let s,r=0;(i.style==="bar"||i.style==="outline")&&(s=r++*St,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.style==="bar"?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(i.style==="underline"||i.style==="outline")&&(s=r++*St,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),i.style==="outline"&&(s=r++*St,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),s=r++*St,this._addRectangleFloat(e.attributes,s,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=r}_updateRectangle(t,e,i,s,r,n,o){if(i&67108864)switch(i&50331648){case 16777216:case 33554432:pt=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:pt=(i&16777215)<<8;break;default:pt=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:pt=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:pt=(s&16777215)<<8;break;default:pt=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=du(t.attributes,this._terminal.rows*this._terminal.cols*St)),uo=r*this._dimensions.device.cell.width,_o=o*this._dimensions.device.cell.height,fo=(pt>>24&255)/255,go=(pt>>16&255)/255,po=(pt>>8&255)/255,vo=1,this._addRectangle(t.attributes,e,uo,_o,(n-r)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,fo,go,po,vo)}_addRectangle(t,e,i,s,r,n,o,a,l,h){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=r/this._dimensions.device.canvas.width,t[e+3]=n/this._dimensions.device.canvas.height,t[e+4]=o,t[e+5]=a,t[e+6]=l,t[e+7]=h}_addRectangleFloat(t,e,i,s,r,n,o){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=r/this._dimensions.device.canvas.width,t[e+3]=n/this._dimensions.device.canvas.height,t[e+4]=o[0],t[e+5]=o[1],t[e+6]=o[2],t[e+7]=o[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},ku=class extends tt{constructor(t,e,i,s,r,n,o,a){super(),this._container=e,this._alpha=r,this._coreBrowserService=n,this._optionsService=o,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(l=>{this._refreshCharAtlas(t,l),this.reset(t)})),this._register(Be(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=le(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,i){}handleSelectionChanged(t,e,i,s=!1){}_setTransparency(t,e){if(e===this._alpha)return;let i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=Fa(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,i=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,i,s){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(t,e,i,s){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=La,this._clipCell(i,s,e.getWidth()),this._ctx.fillText(e.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,i){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,i){let s=e?t.options.fontWeightBold:t.options.fontWeight;return`${i?"italic":""} ${s} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},Lu=class extends ku{constructor(t,e,i,s,r,n,o){super(i,t,"link",e,!0,r,n,o),this._register(s.onShowLinkUnderline(a=>this._handleShowLinkUnderline(a))),this._register(s.onHideLinkUnderline(a=>this._handleHideLinkUnderline(a)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&hu(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},zt=typeof window=="object"?window:globalThis,Ir=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Ir.INSTANCE=new Ir;var Ha=Ir;function Eu(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}Ha.INSTANCE.onDidChangeZoomLevel;Ha.INSTANCE.onDidChangeFullscreen;var hi=typeof navigator=="object"?navigator.userAgent:"";hi.indexOf("Firefox")>=0;hi.indexOf("AppleWebKit")>=0;var Mu=hi.indexOf("Chrome")>=0;!Mu&&hi.indexOf("Safari")>=0;hi.indexOf("Electron/")>=0;hi.indexOf("Android")>=0;var Us=!1;if(typeof zt.matchMedia=="function"){let t=zt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=zt.matchMedia("(display-mode: fullscreen)");Us=t.matches,Eu(zt,t,({matches:i})=>{Us&&e.matches||(Us=i)})}var ii="en",qs=!1,Ua=!1,Yi,ss=ii,mo=ii,Bu,mt,qt=globalThis,He;typeof qt.vscode<"u"&&typeof qt.vscode.process<"u"?He=qt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(He=process);var Ru=typeof He?.versions?.electron=="string",Du=Ru&&He?.type==="renderer";if(typeof He=="object"){He.platform,He.platform,qs=He.platform==="linux",qs&&He.env.SNAP&&He.env.SNAP_REVISION,He.env.CI||He.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Yi=ii,ss=ii;let t=He.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Yi=e.userLocale,mo=e.osLocale,ss=e.resolvedLanguage||ii,Bu=e.languagePack?.translationsConfigFile}catch{}Ua=!0}else typeof navigator=="object"&&!Du?(mt=navigator.userAgent,mt.indexOf("Windows")>=0,mt.indexOf("Macintosh")>=0,(mt.indexOf("Macintosh")>=0||mt.indexOf("iPad")>=0||mt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qs=mt.indexOf("Linux")>=0,mt?.indexOf("Mobi")>=0,ss=globalThis._VSCODE_NLS_LANGUAGE||ii,Yi=navigator.language.toLowerCase(),mo=Yi):console.error("Unable to resolve platform.");var So=Ua,ct=mt,Bt=ss,Au;(t=>{function e(){return Bt}t.value=e;function i(){return Bt.length===2?Bt==="en":Bt.length>=3?Bt[0]==="e"&&Bt[1]==="n"&&Bt[2]==="-":!1}t.isDefaultVariant=i;function s(){return Bt==="en"}t.isDefault=s})(Au||={});var Tu=typeof qt.postMessage=="function"&&!qt.importScripts;(()=>{if(Tu){let t=[];qt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=t.length;s<r;s++){let n=t[s];if(n.id===i.data.vscodeScheduleAsyncWork){t.splice(s,1),n.callback();return}}});let e=0;return i=>{let s=++e;t.push({id:s,callback:i}),qt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var Pu=!!(ct&&ct.indexOf("Chrome")>=0);ct&&ct.indexOf("Firefox")>=0;!Pu&&ct&&ct.indexOf("Safari")>=0;ct&&ct.indexOf("Edg/")>=0;ct&&ct.indexOf("Android")>=0;var Zt=typeof navigator=="object"?navigator:{};So||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zt&&Zt.clipboard&&Zt.clipboard.writeText,So||Zt&&Zt.clipboard&&Zt.clipboard.readText;var en=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Ks=new en,wo=new en,bo=new en;new Array(230);var Ou;(t=>{function e(a){return Ks.keyCodeToStr(a)}t.toString=e;function i(a){return Ks.strToKeyCode(a)}t.fromString=i;function s(a){return wo.keyCodeToStr(a)}t.toUserSettingsUS=s;function r(a){return bo.keyCodeToStr(a)}t.toUserSettingsGeneral=r;function n(a){return wo.strToKeyCode(a)||bo.strToKeyCode(a)}t.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ks.keyCodeToStr(a)}t.toElectronAccelerator=o})(Ou||={});var qa=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),Iu;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof $u?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ct.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:qa})})(Iu||={});var $u=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?qa:(this._emitter||(this._emitter=new Z),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Fu;(t=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}t.withAsyncBody=i})(Fu||={});var Co=class Ye{static fromArray(e){return new Ye(i=>{i.emitMany(e)})}static fromPromise(e){return new Ye(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Ye(async i=>{await Promise.all(e.map(async s=>i.emitOne(await s)))})}static merge(e){return new Ye(async i=>{await Promise.all(e.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Z,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Ct.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Ye(async s=>{for await(let r of e)s.emitOne(i(r))})}map(e){return Ye.map(this,e)}static filter(e,i){return new Ye(async s=>{for await(let r of e)i(r)&&s.emitOne(r)})}filter(e){return Ye.filter(this,e)}static coalesce(e){return Ye.filter(e,i=>!!i)}coalesce(){return Ye.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return Ye.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Co.EMPTY=Co.fromArray([]);var{getWindow:Nu}=(function(){let t=new Map,e={window:zt,disposables:new si};t.set(zt.vscodeWindowId,e);let i=new Z,s=new Z,r=new Z;function n(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(t.has(o.vscodeWindowId))return tt.None;let a=new si,l={window:o,disposables:a.add(new si)};return t.set(o.vscodeWindowId,l),a.add(Be(()=>{t.delete(o.vscodeWindowId),s.fire(o)})),a.add($r(o,zu.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(l),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:zt},getDocument(o){return Nu(o).document}}})(),Wu=class{constructor(t,e,i,s){this._node=t,this._type=e,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 $r(t,e,i,s){return new Wu(t,e,i,s)}var zu={BEFORE_UNLOAD:"beforeunload"},Hu=class extends tt{constructor(t,e,i,s,r,n,o,a,l){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new pi,this._charAtlasDisposable=this._register(new pi),this._observerDisposable=this._register(new pi),this._model=new wu,this._workCell=new ho,this._workCell2=new ho,this._rectangleRenderer=this._register(new pi),this._glyphRenderer=this._register(new pi),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Od(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Lu(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Td(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register($r(this._canvas,"webglcontextlost",c=>{console.log("webglcontextlost event received"),c.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(c)},3e3)})),this._register($r(this._canvas,"webglcontextrestored",c=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,oo(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=ao(this._canvas,this._coreBrowserService.window,(c,d)=>this._setCanvasDevicePixelDimensions(c,d)),this._register(this._coreBrowserService.onWindowChange(c=>{this._observerDisposable.value=ao(this._canvas,c,(d,u)=>this._setCanvasDevicePixelDimensions(d,u))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Be(()=>{for(let c of this._renderLayers)c.dispose();this._canvas.parentElement?.removeChild(this._canvas),oo(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let i of this._renderLayers)i.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let t of this._renderLayers)t.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let t of this._renderLayers)t.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,i){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,t,e,i);this._model.selection.update(this._core,t,e,i),this._requestRedrawViewport()}handleCursorMove(){for(let t of this._renderLayers)t.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new xu(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new pu(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=Fa(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=ba(Ct.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Ct.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(t){this._model.clear(),t&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let i of this._renderLayers)i.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new lu(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let i=this._core,s=this._workCell,r,n,o,a,l,h,c=0,d=!0,u,_,f,S,k,A,D,B,w;t=yo(t,i.rows-1,0),e=yo(e,i.rows-1,0);let R=this._coreService.decPrivateModes.cursorStyle??i.options.cursorStyle??"block",P=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,N=P-i.buffer.ydisp,G=Math.min(this._terminal.buffer.active.cursorX,i.cols-1),ae=-1,Ee=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let W=!1;for(n=t;n<=e;n++)for(o=n+i.buffer.ydisp,a=i.buffer.lines.get(o),this._model.lineLengths[n]=0,f=P===o,c=0,l=this._characterJoinerService.getJoinedCharacters(o),B=0;B<i.cols;B++){if(r=this._cellColorResolver.result.bg,a.loadCell(B,s),B===0&&(r=this._cellColorResolver.result.bg),h=!1,d=B>=c,u=B,l.length>0&&B===l[0][0]&&d){_=l.shift();let p=this._model.selection.isCellSelected(this._terminal,_[0],o);for(D=_[0]+1;D<_[1];D++)d&&=p===this._model.selection.isCellSelected(this._terminal,D,o);d&&=!f||G<_[0]||G>=_[1],d?(h=!0,s=new Uu(s,a.translateToString(!0,_[0],_[1]),_[1]-_[0]),u=_[1]-1):c=_[1]}if(S=s.getChars(),k=s.getCode(),D=(n*i.cols+B)*cs,this._cellColorResolver.resolve(s,B,o,this.dimensions.device.cell.width),Ee&&o===P&&(B===G&&(this._model.cursor={x:G,y:N,width:s.getWidth(),style:this._coreBrowserService.isFocused?R:i.options.cursorInactiveStyle,cursorWidth:i.options.cursorWidth,dpr:this._devicePixelRatio},ae=G+s.getWidth()-1),B>=G&&B<=ae&&(this._coreBrowserService.isFocused&&R==="block"||this._coreBrowserService.isFocused===!1&&i.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),k!==0&&(this._model.lineLengths[n]=B+1),!(this._model.cells[D]===k&&this._model.cells[D+ts]===this._cellColorResolver.result.bg&&this._model.cells[D+is]===this._cellColorResolver.result.fg&&this._model.cells[D+zs]===this._cellColorResolver.result.ext)&&(W=!0,S.length>1&&(k|=Su),this._model.cells[D]=k,this._model.cells[D+ts]=this._cellColorResolver.result.bg,this._model.cells[D+is]=this._cellColorResolver.result.fg,this._model.cells[D+zs]=this._cellColorResolver.result.ext,A=s.getWidth(),this._glyphRenderer.value.updateCell(B,n,k,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,S,A,r),h)){for(s=this._workCell,B++;B<=u;B++)w=(n*i.cols+B)*cs,this._glyphRenderer.value.updateCell(B,n,0,0,0,0,Ld,0,0),this._model.cells[w]=0,this._model.cells[w+ts]=this._cellColorResolver.result.bg,this._model.cells[w+is]=this._cellColorResolver.result.fg,this._model.cells[w+zs]=this._cellColorResolver.result.ext;B--}}W&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},Uu=class extends ti{constructor(t,e,i){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function yo(t,e,i=0){return Math.max(Math.min(t,e),i)}var xo="di$target",ko="di$dependencies",Vs=new Map;function dt(t){if(Vs.has(t))return Vs.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");qu(e,i,r)};return e._id=t,Vs.set(t,e),e}function qu(t,e,i){e[xo]===e?e[ko].push({id:t,index:i}):(e[ko]=[{id:t,index:i}],e[xo]=e)}dt("BufferService");dt("CoreMouseService");dt("CoreService");dt("CharsetService");dt("InstantiationService");dt("LogService");var Ku=dt("OptionsService");dt("OscLinkService");dt("UnicodeService");dt("DecorationService");var Vu={trace:0,debug:1,info:2,warn:3,error:4,off:5},Gu="xterm.js: ",Lo=class extends tt{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Vu[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,i){this._evalLazyOptionalParams(i),t.call(console,(this._optionsService.options.logger?"":Gu)+e,...i)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};Lo=fd([gd(0,Ku)],Lo);var Yu=class extends tt{constructor(t){if(xa&&kd()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let i=e.coreService,s=e.optionsService,r=e,n=r._renderService,o=r._characterJoinerService,a=r._charSizeService,l=r._coreBrowserService,h=r._decorationService;r._logService;let c=r._themeService;this._renderer=this._register(new Hu(t,o,a,l,i,h,s,c,this._preserveDrawingBuffer)),this._register(Ct.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Ct.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Ct.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Ct.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(Be(()=>{if(this._terminal._core._store._isDisposed)return;let d=this._terminal._core._renderService;d.setRenderer(this._terminal._core._createRenderer()),d.handleResize(t.cols,t.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};const Xu=[{label:"ESC",sequence:"\x1B"},{label:"/",sequence:"/"},{label:"—",sequence:"-"},{label:"HOME",sequence:"\x1B[H"},{label:"↑",sequence:"\x1B[A",repeatable:!0},{label:"END",sequence:"\x1B[F"},{label:"PGUP",sequence:"\x1B[5~"}],ju=[{label:"TAB",sequence:" "},{label:"CTRL",sequence:null,isModifier:!0},{label:"ALT",sequence:null,isModifier:!0},{label:"SHIFT",sequence:null,isModifier:!0},{label:"←",sequence:"\x1B[D",repeatable:!0},{label:"↓",sequence:"\x1B[B",repeatable:!0},{label:"→",sequence:"\x1B[C",repeatable:!0},{label:"PGDN",sequence:"\x1B[6~"}];let Ze=!1,Ue=!1,wt=!1,Fr=null,Nr=null,Ka=null;function Wr(t){if(!Ze&&!Ue&&!wt)return t;let e=t;const i=1+((wt?1:0)|(Ue?2:0)|(Ze?4:0)),s=e.match(/^\x1b\[([A-Z])$/),r=e.match(/^\x1b\[(\d+)~$/);if(e===" "&&wt&&!Ze&&!Ue)e="\x1B[Z";else if(s)e=`\x1B[1;${i}${s[1]}`;else if(r)e=`\x1B[${r[1]};${i}~`;else if(e==="\r"||e===`
80
- `)e=`\x1B[13;${i}u`;else if(e.length===1){if(wt&&!Ze&&!Ue&&(e=e.toUpperCase()),Ze){const n=e.toUpperCase().charCodeAt(0);n>=64&&n<=95&&(e=String.fromCharCode(n-64))}Ue&&(e="\x1B"+e)}else Ue&&(e="\x1B"+e);return Ze=!1,Fr?.classList.remove("active"),Ue=!1,Nr?.classList.remove("active"),wt=!1,Ka?.classList.remove("active"),e}function Zu(){return Ze||Ue||wt}function Ju(t,e){function i(s){const r=document.createElement("div");r.className="extra-keys-row";for(const n of s){const o=document.createElement("button");o.className="extra-key",o.textContent=n.label,o.setAttribute("tabindex","-1"),n.isModifier&&(o.classList.add("modifier"),n.label==="CTRL"&&(Fr=o),n.label==="ALT"&&(Nr=o),n.label==="SHIFT"&&(Ka=o));const a=l=>{if(l.preventDefault(),l.stopPropagation(),n.isModifier)n.label==="CTRL"?(Ze=!Ze,o.classList.toggle("active",Ze),Ze&&(Ue=!1,Nr?.classList.remove("active"))):n.label==="ALT"?(Ue=!Ue,o.classList.toggle("active",Ue),Ue&&(Ze=!1,Fr?.classList.remove("active"))):n.label==="SHIFT"&&(wt=!wt,o.classList.toggle("active",wt));else if(n.sequence!==null){const h=Wr(n.sequence);e(h)}};if(n.repeatable&&n.sequence!==null){let l=null,h=null,c=!1;const d=()=>{l!==null&&(clearTimeout(l),l=null),h!==null&&(clearInterval(h),h=null)},u=_=>{_.preventDefault(),_.stopPropagation(),d();const f=Wr(n.sequence);e(f),l=setTimeout(()=>{h=setInterval(()=>{e(n.sequence)},60)},300)};o.addEventListener("touchstart",_=>{c=!0,u(_)},{passive:!1}),o.addEventListener("touchend",d),o.addEventListener("touchcancel",d),o.addEventListener("mousedown",_=>{if(c){c=!1;return}u(_)}),o.addEventListener("mouseup",d),o.addEventListener("mouseleave",d)}else o.addEventListener("touchstart",a,{passive:!1}),o.addEventListener("click",a);r.appendChild(o)}return r}t.appendChild(i(Xu)),t.appendChild(i(ju))}let We=null,Eo=!1,Di=null,Ai=null,Ti=null,ds="",ri=null;function Qu(t){Di=t.statusBar,Ai=t.statusDot,Ti=t.statusText,ds=document.title,console.log("[itwillsync] Notification system initialized (sound + visual)")}function Va(){if(!Eo){Eo=!0;try{We=new AudioContext,We.state==="suspended"&&We.resume(),console.log("[itwillsync] Audio unlocked for notifications")}catch{console.log("[itwillsync] AudioContext not available")}}}function e_(){if(!We)return;We.state==="suspended"&&We.resume();const t=We.currentTime,e=We.createOscillator(),i=We.createGain();e.frequency.value=587.33,e.type="sine",i.gain.setValueAtTime(.3,t),i.gain.exponentialRampToValueAtTime(.01,t+.3),e.connect(i),i.connect(We.destination),e.start(t),e.stop(t+.3);const s=We.createOscillator(),r=We.createGain();s.frequency.value=880,s.type="sine",r.gain.setValueAtTime(.3,t+.15),r.gain.exponentialRampToValueAtTime(.01,t+.45),s.connect(r),r.connect(We.destination),s.start(t+.15),s.stop(t+.45)}function t_(t){if(!Di||!Ai||!Ti)return;Di.classList.add("notify"),Ai.classList.add("notify"),Ti.textContent=t;let e=!0;ds="itwillsync",ri&&clearInterval(ri),ri=setInterval(()=>{document.title=e?"⚠️ Agent needs you":ds,e=!e},1e3)}function i_(){Di&&Di.classList.remove("notify"),Ai&&Ai.classList.remove("notify"),Ti&&(Ti.textContent="Connected"),ri&&(clearInterval(ri),ri=null),document.title=ds||"itwillsync"}function Ss(t){console.log(`[itwillsync] Notifying: ${t}`),e_(),t_(t)}function s_(){i_()}const r_=1e4,n_=1e3,o_=1.5;class a_{constructor(e){this.cb=e,this.setupLifecycleHandlers()}ws=null;attempts=0;timer=null;wakeLock=null;destroyed=!1;connect(){this.destroyed||(this.clearTimer(),this.ws=new WebSocket(this.cb.getUrl()),this.ws.onopen=()=>{this.attempts=0,this.cb.onStatusChange("connected",0),this.cb.onOpen(),this.requestWakeLock()},this.ws.onmessage=e=>this.cb.onMessage(e),this.ws.onclose=()=>{this.cb.onStatusChange("reconnecting",this.attempts),this.scheduleReconnect()},this.ws.onerror=()=>{})}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}destroy(){this.destroyed=!0,this.clearTimer(),this.releaseWakeLock(),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}scheduleReconnect(){if(this.destroyed)return;this.attempts++;const e=Math.min(n_*Math.pow(o_,this.attempts-1),r_);this.timer=setTimeout(()=>this.connect(),e)}reconnectNow(){this.destroyed||this.ws?.readyState===WebSocket.OPEN||(this.clearTimer(),this.ws?.readyState===WebSocket.CONNECTING&&(this.ws.onclose=null,this.ws.close()),this.attempts=0,this.connect())}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}setupLifecycleHandlers(){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(this.isConnected||this.reconnectNow(),this.requestWakeLock()):this.releaseWakeLock()}),document.addEventListener("freeze",()=>{this.releaseWakeLock()}),document.addEventListener("resume",()=>{this.isConnected||this.reconnectNow()})}async requestWakeLock(){if(!(this.wakeLock||!("wakeLock"in navigator)))try{this.wakeLock=await navigator.wakeLock.request("screen"),this.wakeLock.addEventListener("release",()=>{this.wakeLock=null})}catch{}}releaseWakeLock(){this.wakeLock&&(this.wakeLock.release(),this.wakeLock=null)}}const Tt=document.getElementById("terminal-container"),zr=document.getElementById("extra-keys"),Ga=document.getElementById("status-dot"),tn=document.getElementById("status-text"),Ya=new URLSearchParams(window.location.search),Xa=Ya.get("token"),us=Ya.get("hub");if(!Xa)throw tn.textContent="Error: No auth token in URL",new Error("Missing token parameter");const Mo=document.getElementById("back-btn");us&&(Mo.classList.remove("hidden"),Mo.href=us);const oe=new cd({cursorBlink:!0,fontSize:14,fontFamily:'"Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Monaco, monospace',theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#e94560",selectionBackground:"#0f346080",black:"#1a1a2e",red:"#e94560",green:"#2ecc71",yellow:"#f39c12",blue:"#3498db",magenta:"#9b59b6",cyan:"#1abc9c",white:"#e0e0e0",brightBlack:"#555577",brightRed:"#ff6b81",brightGreen:"#55efc4",brightYellow:"#ffeaa7",brightBlue:"#74b9ff",brightMagenta:"#a29bfe",brightCyan:"#81ecec",brightWhite:"#ffffff"},allowProposedApi:!0}),ws=new _d;oe.loadAddon(ws);oe.open(Tt);try{const t=new Yu;t.onContextLoss(()=>{t.dispose()}),oe.loadAddon(t)}catch{}ws.fit();oe.onBell(()=>{Ss("Agent needs your attention")});oe.parser.registerOscHandler(9,t=>(t.startsWith("4;")||Ss("Agent needs your attention"),!0));oe.parser.registerOscHandler(99,()=>(Ss("Agent needs your attention"),!0));oe.parser.registerOscHandler(777,()=>(Ss("Agent needs your attention"),!0));let yt=null;const h_=12,l_=14;function c_(){const e=document.createElement("canvas").getContext("2d");return e.font=`10px ${oe.options.fontFamily}`,e.measureText("W").width/10}function ja(){if(!yt)return;const t=Tt.clientWidth,e=8,i=oe.options.scrollback===0?0:14,s=t-e-i,r=c_(),n=s/(yt.cols*r),o=Math.max(h_,Math.min(l_,Math.floor(n*10)/10));oe.options.fontSize=o;const a=ws.proposeDimensions(),l=a?a.rows:yt.rows;oe.resize(yt.cols,l)}function Za(){if(!yt)return;const t=oe.buffer.active.cursorX,i=oe._core._renderService.dimensions.css.cell.width;if(!i)return;const s=t*i,r=Tt.clientWidth,n=yt.cols*i;if(n<=r){Tt.scrollLeft=0;return}const o=r*.3,a=Tt.scrollLeft;s<a+o?Tt.scrollLeft=Math.max(0,s-o):s>a+r-o&&(Tt.scrollLeft=Math.min(s-r+o,n-r))}oe.onRender(()=>{yt&&requestAnimationFrame(Za)});let et=null,Jt=null,Gs=-1;const d_=15e3;function u_(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}?token=${Xa}`}function __(){const t=document.createElement("div");t.id="reconnect-overlay";const e=document.createElement("div");e.className="spinner",t.appendChild(e);const i=document.createElement("div");if(i.className="reconnect-text",i.textContent="Reconnecting...",t.appendChild(i),us){const s=document.createElement("a");s.className="reconnect-dashboard-btn",s.href=us,s.textContent="← Back to Dashboard",t.appendChild(s)}return t}function f_(){if(!et)return;Fi.destroy(),et.classList.add("ended");const t=et.querySelector(".spinner");t&&t.remove();const e=et.querySelector(".reconnect-text");e&&(e.textContent="Session ended");const i=et.querySelector(".reconnect-dashboard-btn");i&&i.classList.add("primary")}function g_(t,e){Ga.className=t==="connected"?"connected":t==="reconnecting"?"reconnecting":"",tn.textContent=t==="connected"?"Connected":t==="reconnecting"?e>5?"Waiting for laptop to wake up...":`Reconnecting (attempt ${e})...`:"Disconnected",t==="reconnecting"&&!et?(et=__(),document.body.appendChild(et),Jt&&clearTimeout(Jt),Jt=setTimeout(f_,d_)):t==="connected"&&et&&(et.remove(),et=null,Jt&&(clearTimeout(Jt),Jt=null))}const Fi=new a_({getUrl:u_,onOpen:()=>{Gs>=0&&Fi.send(JSON.stringify({type:"resume",lastSeq:Gs})),Ja()},onMessage:t=>{try{const e=JSON.parse(t.data);switch(e.type){case"data":oe.write(e.data),typeof e.seq=="number"&&(Gs=e.seq);break;case"resize":typeof e.cols=="number"&&typeof e.rows=="number"&&(yt={cols:e.cols,rows:e.rows},ja());break}}catch{oe.write(typeof t.data=="string"?t.data:new Uint8Array(t.data))}},onStatusChange:g_});function Ja(){Fi.send(JSON.stringify({type:"resize",cols:oe.cols,rows:oe.rows}))}function Qa(t){Fi.send(JSON.stringify({type:"input",data:t}))}oe.onData(t=>{const e=Zu()?Wr(t):t;Qa(e),s_()});Ju(zr,Qa);let Ys=0;function _s(){const t=window.visualViewport,e=zr.offsetHeight;if(t){const s=window.innerHeight-t.height-t.offsetTop;Ys=Math.max(0,s),zr.style.bottom=`${Ys}px`}const i=e+Ys;document.documentElement.style.setProperty("--extra-keys-height",`${i}px`),yt?(ja(),Za()):(ws.fit(),Ja())}window.addEventListener("resize",_s);window.visualViewport&&(window.visualViewport.addEventListener("resize",_s),window.visualViewport.addEventListener("scroll",_s));requestAnimationFrame(_s);Tt.addEventListener("touchstart",()=>{oe.focus()});document.addEventListener("click",()=>Va(),{once:!0});document.addEventListener("touchstart",()=>Va(),{once:!0});window.__itwillsync_loaded=!0;Qu({statusBar:document.getElementById("status-bar"),statusDot:Ga,statusText:tn});oe.focus();Fi.connect();
79
+ }`,wt=8,qs=wt*Float32Array.BYTES_PER_ELEMENT,Mu=20*wt,go=class{constructor(){this.attributes=new Float32Array(Mu),this.count=0}},vt=0,po=0,vo=0,mo=0,So=0,wo=0,bo=0,Bu=class extends it{constructor(t,e,i,s){super(),this._terminal=t,this._gl=e,this._dimensions=i,this._themeService=s,this._vertices=new go,this._verticesCursor=new go;let r=this._gl;this._program=le(Ka(r,Lu,Eu)),this._register(Be(()=>r.deleteProgram(this._program))),this._projectionLocation=le(r.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(Be(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=r.createBuffer();this._register(Be(()=>r.deleteBuffer(l))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,l),r.bufferData(r.ELEMENT_ARRAY_BUFFER,a,r.STATIC_DRAW),this._attributesBuffer=le(r.createBuffer()),this._register(Be(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,r.FLOAT,!1,qs,0),r.vertexAttribDivisor(0,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,qs,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,4,r.FLOAT,!1,qs,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(h=>{this._updateCachedColors(h),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,qa),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,i=this._vertices,s=1,r,n,o,a,l,h,c,d,u,_,f;for(r=0;r<e.rows;r++){for(o=-1,a=0,l=0,h=!1,n=0;n<e.cols;n++)c=(r*e.cols+n)*us,d=t.cells[c+ss],u=t.cells[c+rs],_=!!(u&67108864),(d!==a||u!==l&&(h||_))&&((a!==0||h&&l!==0)&&(f=s++*wt,this._updateRectangle(i,f,l,a,o,n,r)),o=n,a=d,l=u,h=_);(a!==0||h&&l!==0)&&(f=s++*wt,this._updateRectangle(i,f,l,a,o,e.cols,r))}i.count=s}updateCursor(t){let e=this._verticesCursor,i=t.cursor;if(!i||i.style==="block"){e.count=0;return}let s,r=0;(i.style==="bar"||i.style==="outline")&&(s=r++*wt,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.style==="bar"?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(i.style==="underline"||i.style==="outline")&&(s=r++*wt,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),i.style==="outline"&&(s=r++*wt,this._addRectangleFloat(e.attributes,s,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),s=r++*wt,this._addRectangleFloat(e.attributes,s,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=r}_updateRectangle(t,e,i,s,r,n,o){if(i&67108864)switch(i&50331648){case 16777216:case 33554432:vt=this._themeService.colors.ansi[i&255].rgba;break;case 50331648:vt=(i&16777215)<<8;break;default:vt=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:vt=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:vt=(s&16777215)<<8;break;default:vt=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=pu(t.attributes,this._terminal.rows*this._terminal.cols*wt)),po=r*this._dimensions.device.cell.width,vo=o*this._dimensions.device.cell.height,mo=(vt>>24&255)/255,So=(vt>>16&255)/255,wo=(vt>>8&255)/255,bo=1,this._addRectangle(t.attributes,e,po,vo,(n-r)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,mo,So,wo,bo)}_addRectangle(t,e,i,s,r,n,o,a,l,h){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=r/this._dimensions.device.canvas.width,t[e+3]=n/this._dimensions.device.canvas.height,t[e+4]=o,t[e+5]=a,t[e+6]=l,t[e+7]=h}_addRectangleFloat(t,e,i,s,r,n,o){t[e]=i/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=r/this._dimensions.device.canvas.width,t[e+3]=n/this._dimensions.device.canvas.height,t[e+4]=o[0],t[e+5]=o[1],t[e+6]=o[2],t[e+7]=o[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},Ru=class extends it{constructor(t,e,i,s,r,n,o,a){super(),this._container=e,this._alpha=r,this._coreBrowserService=n,this._optionsService=o,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(l=>{this._refreshCharAtlas(t,l),this.reset(t)})),this._register(Be(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=le(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,i){}handleSelectionChanged(t,e,i,s=!1){}_setTransparency(t,e){if(e===this._alpha)return;let i=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=Ha(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,i=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,i,s){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(t,e,i,s){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=Ra,this._clipCell(i,s,e.getWidth()),this._ctx.fillText(e.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,i){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,i){let s=e?t.options.fontWeightBold:t.options.fontWeight;return`${i?"italic":""} ${s} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},Au=class extends Ru{constructor(t,e,i,s,r,n,o){super(i,t,"link",e,!0,r,n,o),this._register(s.onShowLinkUnderline(a=>this._handleShowLinkUnderline(a))),this._register(s.onHideLinkUnderline(a=>this._handleHideLinkUnderline(a)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&_u(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},zt=typeof window=="object"?window:globalThis,Nr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Nr.INSTANCE=new Nr;var Va=Nr;function Du(t,e,i){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",i)}Va.INSTANCE.onDidChangeZoomLevel;Va.INSTANCE.onDidChangeFullscreen;var hi=typeof navigator=="object"?navigator.userAgent:"";hi.indexOf("Firefox")>=0;hi.indexOf("AppleWebKit")>=0;var Tu=hi.indexOf("Chrome")>=0;!Tu&&hi.indexOf("Safari")>=0;hi.indexOf("Electron/")>=0;hi.indexOf("Android")>=0;var Ks=!1;if(typeof zt.matchMedia=="function"){let t=zt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=zt.matchMedia("(display-mode: fullscreen)");Ks=t.matches,Du(zt,t,({matches:i})=>{Ks&&e.matches||(Ks=i)})}var ii="en",Vs=!1,Ga=!1,Xi,ns=ii,Co=ii,Pu,St,qt=globalThis,He;typeof qt.vscode<"u"&&typeof qt.vscode.process<"u"?He=qt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(He=process);var Ou=typeof He?.versions?.electron=="string",Iu=Ou&&He?.type==="renderer";if(typeof He=="object"){He.platform,He.platform,Vs=He.platform==="linux",Vs&&He.env.SNAP&&He.env.SNAP_REVISION,He.env.CI||He.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Xi=ii,ns=ii;let t=He.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Xi=e.userLocale,Co=e.osLocale,ns=e.resolvedLanguage||ii,Pu=e.languagePack?.translationsConfigFile}catch{}Ga=!0}else typeof navigator=="object"&&!Iu?(St=navigator.userAgent,St.indexOf("Windows")>=0,St.indexOf("Macintosh")>=0,(St.indexOf("Macintosh")>=0||St.indexOf("iPad")>=0||St.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Vs=St.indexOf("Linux")>=0,St?.indexOf("Mobi")>=0,ns=globalThis._VSCODE_NLS_LANGUAGE||ii,Xi=navigator.language.toLowerCase(),Co=Xi):console.error("Unable to resolve platform.");var yo=Ga,dt=St,Rt=ns,$u;(t=>{function e(){return Rt}t.value=e;function i(){return Rt.length===2?Rt==="en":Rt.length>=3?Rt[0]==="e"&&Rt[1]==="n"&&Rt[2]==="-":!1}t.isDefaultVariant=i;function s(){return Rt==="en"}t.isDefault=s})($u||={});var Fu=typeof qt.postMessage=="function"&&!qt.importScripts;(()=>{if(Fu){let t=[];qt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=t.length;s<r;s++){let n=t[s];if(n.id===i.data.vscodeScheduleAsyncWork){t.splice(s,1),n.callback();return}}});let e=0;return i=>{let s=++e;t.push({id:s,callback:i}),qt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var Nu=!!(dt&&dt.indexOf("Chrome")>=0);dt&&dt.indexOf("Firefox")>=0;!Nu&&dt&&dt.indexOf("Safari")>=0;dt&&dt.indexOf("Edg/")>=0;dt&&dt.indexOf("Android")>=0;var Zt=typeof navigator=="object"?navigator:{};yo||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zt&&Zt.clipboard&&Zt.clipboard.writeText,yo||Zt&&Zt.clipboard&&Zt.clipboard.readText;var rn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Gs=new rn,xo=new rn,ko=new rn;new Array(230);var Wu;(t=>{function e(a){return Gs.keyCodeToStr(a)}t.toString=e;function i(a){return Gs.strToKeyCode(a)}t.fromString=i;function s(a){return xo.keyCodeToStr(a)}t.toUserSettingsUS=s;function r(a){return ko.keyCodeToStr(a)}t.toUserSettingsGeneral=r;function n(a){return xo.strToKeyCode(a)||ko.strToKeyCode(a)}t.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Gs.keyCodeToStr(a)}t.toElectronAccelerator=o})(Wu||={});var Ya=Object.freeze(function(t,e){let i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}),zu;(t=>{function e(i){return i===t.None||i===t.Cancelled||i instanceof Hu?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:yt.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ya})})(zu||={});var Hu=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?Ya:(this._emitter||(this._emitter=new Z),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Uu;(t=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}t.settled=e;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}t.withAsyncBody=i})(Uu||={});var Lo=class Ye{static fromArray(e){return new Ye(i=>{i.emitMany(e)})}static fromPromise(e){return new Ye(async i=>{i.emitMany(await e)})}static fromPromises(e){return new Ye(async i=>{await Promise.all(e.map(async s=>i.emitOne(await s)))})}static merge(e){return new Ye(async i=>{await Promise.all(e.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Z,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await yt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(e,i){return new Ye(async s=>{for await(let r of e)s.emitOne(i(r))})}map(e){return Ye.map(this,e)}static filter(e,i){return new Ye(async s=>{for await(let r of e)i(r)&&s.emitOne(r)})}filter(e){return Ye.filter(this,e)}static coalesce(e){return Ye.filter(e,i=>!!i)}coalesce(){return Ye.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return Ye.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Lo.EMPTY=Lo.fromArray([]);var{getWindow:qu}=(function(){let t=new Map,e={window:zt,disposables:new si};t.set(zt.vscodeWindowId,e);let i=new Z,s=new Z,r=new Z;function n(o,a){return(typeof o=="number"?t.get(o):void 0)??(a?e:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(t.has(o.vscodeWindowId))return it.None;let a=new si,l={window:o,disposables:a.add(new si)};return t.set(o.vscodeWindowId,l),a.add(Be(()=>{t.delete(o.vscodeWindowId),s.fire(o)})),a.add(Wr(o,Vu.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(l),a},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return t.has(o)},getWindowById:n,getWindow(o){let a=o;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let l=o;return l?.view?l.view.window:zt},getDocument(o){return qu(o).document}}})(),Ku=class{constructor(t,e,i,s){this._node=t,this._type=e,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 Wr(t,e,i,s){return new Ku(t,e,i,s)}var Vu={BEFORE_UNLOAD:"beforeunload"},Gu=class extends it{constructor(t,e,i,s,r,n,o,a,l){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new pi,this._charAtlasDisposable=this._register(new pi),this._observerDisposable=this._register(new pi),this._model=new ku,this._workCell=new _o,this._workCell2=new _o,this._rectangleRenderer=this._register(new pi),this._glyphRenderer=this._register(new pi),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Wd(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Au(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Fd(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Wr(this._canvas,"webglcontextlost",c=>{console.log("webglcontextlost event received"),c.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(c)},3e3)})),this._register(Wr(this._canvas,"webglcontextrestored",c=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,co(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=uo(this._canvas,this._coreBrowserService.window,(c,d)=>this._setCanvasDevicePixelDimensions(c,d)),this._register(this._coreBrowserService.onWindowChange(c=>{this._observerDisposable.value=uo(this._canvas,c,(d,u)=>this._setCanvasDevicePixelDimensions(d,u))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Be(()=>{for(let c of this._renderLayers)c.dispose();this._canvas.parentElement?.removeChild(this._canvas),co(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let i of this._renderLayers)i.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let t of this._renderLayers)t.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let t of this._renderLayers)t.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,i){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,t,e,i);this._model.selection.update(this._core,t,e,i),this._requestRedrawViewport()}handleCursorMove(){for(let t of this._renderLayers)t.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Bu(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new bu(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=Ha(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=ka(yt.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),yt.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(t){this._model.clear(),t&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let i of this._renderLayers)i.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new fu(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let i=this._core,s=this._workCell,r,n,o,a,l,h,c=0,d=!0,u,_,f,S,k,D,A,B,w;t=Eo(t,i.rows-1,0),e=Eo(e,i.rows-1,0);let R=this._coreService.decPrivateModes.cursorStyle??i.options.cursorStyle??"block",P=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,N=P-i.buffer.ydisp,G=Math.min(this._terminal.buffer.active.cursorX,i.cols-1),ae=-1,Ee=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let W=!1;for(n=t;n<=e;n++)for(o=n+i.buffer.ydisp,a=i.buffer.lines.get(o),this._model.lineLengths[n]=0,f=P===o,c=0,l=this._characterJoinerService.getJoinedCharacters(o),B=0;B<i.cols;B++){if(r=this._cellColorResolver.result.bg,a.loadCell(B,s),B===0&&(r=this._cellColorResolver.result.bg),h=!1,d=B>=c,u=B,l.length>0&&B===l[0][0]&&d){_=l.shift();let p=this._model.selection.isCellSelected(this._terminal,_[0],o);for(A=_[0]+1;A<_[1];A++)d&&=p===this._model.selection.isCellSelected(this._terminal,A,o);d&&=!f||G<_[0]||G>=_[1],d?(h=!0,s=new Yu(s,a.translateToString(!0,_[0],_[1]),_[1]-_[0]),u=_[1]-1):c=_[1]}if(S=s.getChars(),k=s.getCode(),A=(n*i.cols+B)*us,this._cellColorResolver.resolve(s,B,o,this.dimensions.device.cell.width),Ee&&o===P&&(B===G&&(this._model.cursor={x:G,y:N,width:s.getWidth(),style:this._coreBrowserService.isFocused?R:i.options.cursorInactiveStyle,cursorWidth:i.options.cursorWidth,dpr:this._devicePixelRatio},ae=G+s.getWidth()-1),B>=G&&B<=ae&&(this._coreBrowserService.isFocused&&R==="block"||this._coreBrowserService.isFocused===!1&&i.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),k!==0&&(this._model.lineLengths[n]=B+1),!(this._model.cells[A]===k&&this._model.cells[A+ss]===this._cellColorResolver.result.bg&&this._model.cells[A+rs]===this._cellColorResolver.result.fg&&this._model.cells[A+Us]===this._cellColorResolver.result.ext)&&(W=!0,S.length>1&&(k|=xu),this._model.cells[A]=k,this._model.cells[A+ss]=this._cellColorResolver.result.bg,this._model.cells[A+rs]=this._cellColorResolver.result.fg,this._model.cells[A+Us]=this._cellColorResolver.result.ext,D=s.getWidth(),this._glyphRenderer.value.updateCell(B,n,k,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,S,D,r),h)){for(s=this._workCell,B++;B<=u;B++)w=(n*i.cols+B)*us,this._glyphRenderer.value.updateCell(B,n,0,0,0,0,Ad,0,0),this._model.cells[w]=0,this._model.cells[w+ss]=this._cellColorResolver.result.bg,this._model.cells[w+rs]=this._cellColorResolver.result.fg,this._model.cells[w+Us]=this._cellColorResolver.result.ext;B--}}W&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},Yu=class extends ti{constructor(t,e,i){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Eo(t,e,i=0){return Math.max(Math.min(t,e),i)}var Mo="di$target",Bo="di$dependencies",Ys=new Map;function ut(t){if(Ys.has(t))return Ys.get(t);let e=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Xu(e,i,r)};return e._id=t,Ys.set(t,e),e}function Xu(t,e,i){e[Mo]===e?e[Bo].push({id:t,index:i}):(e[Bo]=[{id:t,index:i}],e[Mo]=e)}ut("BufferService");ut("CoreMouseService");ut("CoreService");ut("CharsetService");ut("InstantiationService");ut("LogService");var ju=ut("OptionsService");ut("OscLinkService");ut("UnicodeService");ut("DecorationService");var Zu={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ju="xterm.js: ",Ro=class extends it{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Zu[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,i){this._evalLazyOptionalParams(i),t.call(console,(this._optionsService.options.logger?"":Ju)+e,...i)}trace(t,...e){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,e)}debug(t,...e){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,e)}info(t,...e){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,e)}warn(t,...e){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,e)}error(t,...e){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,e)}};Ro=Sd([wd(0,ju)],Ro);var Qu=class extends it{constructor(t){if(Ma&&Rd()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let i=e.coreService,s=e.optionsService,r=e,n=r._renderService,o=r._characterJoinerService,a=r._charSizeService,l=r._coreBrowserService,h=r._decorationService;r._logService;let c=r._themeService;this._renderer=this._register(new Gu(t,o,a,l,i,h,s,c,this._preserveDrawingBuffer)),this._register(yt.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(yt.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(yt.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(yt.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(Be(()=>{if(this._terminal._core._store._isDisposed)return;let d=this._terminal._core._renderService;d.setRenderer(this._terminal._core._createRenderer()),d.handleResize(t.cols,t.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};const e_=[{label:"ESC",sequence:"\x1B"},{label:"/",sequence:"/"},{label:"—",sequence:"-"},{label:"HOME",sequence:"\x1B[H"},{label:"↑",sequence:"\x1B[A",repeatable:!0},{label:"END",sequence:"\x1B[F"},{label:"PGUP",sequence:"\x1B[5~"}],t_=[{label:"TAB",sequence:" "},{label:"CTRL",sequence:null,isModifier:!0},{label:"ALT",sequence:null,isModifier:!0},{label:"SHIFT",sequence:null,isModifier:!0},{label:"←",sequence:"\x1B[D",repeatable:!0},{label:"↓",sequence:"\x1B[B",repeatable:!0},{label:"→",sequence:"\x1B[C",repeatable:!0},{label:"PGDN",sequence:"\x1B[6~"}];let Ze=!1,Ue=!1,bt=!1,zr=null,Hr=null,Xa=null;function Ur(t){if(!Ze&&!Ue&&!bt)return t;let e=t;const i=1+((bt?1:0)|(Ue?2:0)|(Ze?4:0)),s=e.match(/^\x1b\[([A-Z])$/),r=e.match(/^\x1b\[(\d+)~$/);if(e===" "&&bt&&!Ze&&!Ue)e="\x1B[Z";else if(s)e=`\x1B[1;${i}${s[1]}`;else if(r)e=`\x1B[${r[1]};${i}~`;else if(e==="\r"||e===`
80
+ `)e=`\x1B[13;${i}u`;else if(e.length===1){if(bt&&!Ze&&!Ue&&(e=e.toUpperCase()),Ze){const n=e.toUpperCase().charCodeAt(0);n>=64&&n<=95&&(e=String.fromCharCode(n-64))}Ue&&(e="\x1B"+e)}else Ue&&(e="\x1B"+e);return Ze=!1,zr?.classList.remove("active"),Ue=!1,Hr?.classList.remove("active"),bt=!1,Xa?.classList.remove("active"),e}function i_(){return Ze||Ue||bt}function s_(t,e){function i(s){const r=document.createElement("div");r.className="extra-keys-row";for(const n of s){const o=document.createElement("button");o.className="extra-key",o.textContent=n.label,o.setAttribute("tabindex","-1"),n.isModifier&&(o.classList.add("modifier"),n.label==="CTRL"&&(zr=o),n.label==="ALT"&&(Hr=o),n.label==="SHIFT"&&(Xa=o));const a=l=>{if(l.preventDefault(),l.stopPropagation(),n.isModifier)n.label==="CTRL"?(Ze=!Ze,o.classList.toggle("active",Ze),Ze&&(Ue=!1,Hr?.classList.remove("active"))):n.label==="ALT"?(Ue=!Ue,o.classList.toggle("active",Ue),Ue&&(Ze=!1,zr?.classList.remove("active"))):n.label==="SHIFT"&&(bt=!bt,o.classList.toggle("active",bt));else if(n.sequence!==null){const h=Ur(n.sequence);e(h)}};if(n.repeatable&&n.sequence!==null){let l=null,h=null,c=!1;const d=()=>{l!==null&&(clearTimeout(l),l=null),h!==null&&(clearInterval(h),h=null)},u=_=>{_.preventDefault(),_.stopPropagation(),d();const f=Ur(n.sequence);e(f),l=setTimeout(()=>{h=setInterval(()=>{e(n.sequence)},60)},300)};o.addEventListener("touchstart",_=>{c=!0,u(_)},{passive:!1}),o.addEventListener("touchend",d),o.addEventListener("touchcancel",d),o.addEventListener("mousedown",_=>{if(c){c=!1;return}u(_)}),o.addEventListener("mouseup",d),o.addEventListener("mouseleave",d)}else o.addEventListener("touchstart",a,{passive:!1}),o.addEventListener("click",a);r.appendChild(o)}return r}t.appendChild(i(e_)),t.appendChild(i(t_))}let We=null,Ao=!1,Di=null,Ti=null,Pi=null,_s="",ri=null;function r_(t){Di=t.statusBar,Ti=t.statusDot,Pi=t.statusText,_s=document.title,console.log("[itwillsync] Notification system initialized (sound + visual)")}function ja(){if(!Ao){Ao=!0;try{We=new AudioContext,We.state==="suspended"&&We.resume(),console.log("[itwillsync] Audio unlocked for notifications")}catch{console.log("[itwillsync] AudioContext not available")}}}function n_(){if(!We)return;We.state==="suspended"&&We.resume();const t=We.currentTime,e=We.createOscillator(),i=We.createGain();e.frequency.value=587.33,e.type="sine",i.gain.setValueAtTime(.3,t),i.gain.exponentialRampToValueAtTime(.01,t+.3),e.connect(i),i.connect(We.destination),e.start(t),e.stop(t+.3);const s=We.createOscillator(),r=We.createGain();s.frequency.value=880,s.type="sine",r.gain.setValueAtTime(.3,t+.15),r.gain.exponentialRampToValueAtTime(.01,t+.45),s.connect(r),r.connect(We.destination),s.start(t+.15),s.stop(t+.45)}function o_(t){if(!Di||!Ti||!Pi)return;Di.classList.add("notify"),Ti.classList.add("notify"),Pi.textContent=t;let e=!0;_s="itwillsync",ri&&clearInterval(ri),ri=setInterval(()=>{document.title=e?"⚠️ Agent needs you":_s,e=!e},1e3)}function a_(){Di&&Di.classList.remove("notify"),Ti&&Ti.classList.remove("notify"),Pi&&(Pi.textContent="Connected"),ri&&(clearInterval(ri),ri=null),document.title=_s||"itwillsync"}function bs(t){console.log(`[itwillsync] Notifying: ${t}`),n_(),o_(t)}function h_(){a_()}const l_=1e4,c_=1e3,d_=1.5;class u_{constructor(e){this.cb=e,this.setupLifecycleHandlers()}ws=null;attempts=0;timer=null;wakeLock=null;destroyed=!1;connect(){this.destroyed||(this.clearTimer(),this.ws=new WebSocket(this.cb.getUrl()),this.ws.onopen=()=>{this.attempts=0,this.cb.onStatusChange("connected",0),this.cb.onOpen(),this.requestWakeLock()},this.ws.onmessage=e=>this.cb.onMessage(e),this.ws.onclose=()=>{this.cb.onStatusChange("reconnecting",this.attempts),this.scheduleReconnect()},this.ws.onerror=()=>{})}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(e)}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}destroy(){this.destroyed=!0,this.clearTimer(),this.releaseWakeLock(),this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null)}scheduleReconnect(){if(this.destroyed)return;this.attempts++;const e=Math.min(c_*Math.pow(d_,this.attempts-1),l_);this.timer=setTimeout(()=>this.connect(),e)}reconnectNow(){this.destroyed||this.ws?.readyState===WebSocket.OPEN||(this.clearTimer(),this.ws?.readyState===WebSocket.CONNECTING&&(this.ws.onclose=null,this.ws.close()),this.attempts=0,this.connect())}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}setupLifecycleHandlers(){document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"?(this.isConnected||this.reconnectNow(),this.requestWakeLock()):this.releaseWakeLock()}),document.addEventListener("freeze",()=>{this.releaseWakeLock()}),document.addEventListener("resume",()=>{this.isConnected||this.reconnectNow()})}async requestWakeLock(){if(!(this.wakeLock||!("wakeLock"in navigator)))try{this.wakeLock=await navigator.wakeLock.request("screen"),this.wakeLock.addEventListener("release",()=>{this.wakeLock=null})}catch{}}releaseWakeLock(){this.wakeLock&&(this.wakeLock.release(),this.wakeLock=null)}}const tt=document.getElementById("terminal-container"),qr=document.getElementById("extra-keys"),Za=document.getElementById("status-dot"),nn=document.getElementById("status-text"),Ja=new URLSearchParams(window.location.search),Qa=Ja.get("token"),Xs=Ja.get("hub"),fs=Xs&&/^https?:\/\//i.test(Xs)?Xs:null;if(!Qa)throw nn.textContent="Error: No auth token in URL",new Error("Missing token parameter");const Do=document.getElementById("back-btn");fs&&(Do.classList.remove("hidden"),Do.href=fs);const oe=new gd({cursorBlink:!0,fontSize:14,fontFamily:'"Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Monaco, monospace',theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#e94560",selectionBackground:"#0f346080",black:"#1a1a2e",red:"#e94560",green:"#2ecc71",yellow:"#f39c12",blue:"#3498db",magenta:"#9b59b6",cyan:"#1abc9c",white:"#e0e0e0",brightBlack:"#555577",brightRed:"#ff6b81",brightGreen:"#55efc4",brightYellow:"#ffeaa7",brightBlue:"#74b9ff",brightMagenta:"#a29bfe",brightCyan:"#81ecec",brightWhite:"#ffffff"},allowProposedApi:!0}),Cs=new md;oe.loadAddon(Cs);oe.open(tt);try{const t=new Qu;t.onContextLoss(()=>{t.dispose()}),oe.loadAddon(t)}catch{}Cs.fit();oe.onBell(()=>{bs("Agent needs your attention")});oe.parser.registerOscHandler(9,t=>(t.startsWith("4;")||bs("Agent needs your attention"),!0));oe.parser.registerOscHandler(99,()=>(bs("Agent needs your attention"),!0));oe.parser.registerOscHandler(777,()=>(bs("Agent needs your attention"),!0));let xt=null;const __=6,f_=14;let ji=null;function g_(){if(ji!==null)return ji;const t=document.createElement("div");return t.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:scroll;",document.body.appendChild(t),ji=t.offsetWidth-t.clientWidth,t.remove(),ji}function p_(){const e=document.createElement("canvas").getContext("2d");return e.font=`10px ${oe.options.fontFamily}`,e.measureText("W").width/10}function eh(){if(!xt)return;const t=tt.clientWidth,e=8,i=oe.options.scrollback===0?0:g_(),s=t-e-i,r=p_(),n=s/(xt.cols*r),o=Math.max(__,Math.min(f_,Math.floor(n*10)/10));oe.options.fontSize=o;const a=Cs.proposeDimensions(),l=a?a.rows:xt.rows;oe.resize(xt.cols,l)}let on=!1,Ei=null;tt.addEventListener("touchstart",()=>{on=!0,Ei&&clearTimeout(Ei)},{passive:!0});const th=()=>{Ei&&clearTimeout(Ei),Ei=setTimeout(()=>{on=!1},1500)};tt.addEventListener("touchend",th,{passive:!0});tt.addEventListener("touchcancel",th,{passive:!0});function ih(){if(!xt||on)return;const t=oe.buffer.active.cursorX,i=oe._core._renderService.dimensions.css.cell.width;if(!i)return;const s=t*i,r=tt.clientWidth,n=xt.cols*i;if(n<=r){tt.scrollLeft=0;return}const o=r*.3,a=tt.scrollLeft;s<a+o?tt.scrollLeft=Math.max(0,s-o):s>a+r-o&&(tt.scrollLeft=Math.min(s-r+o,n-r))}oe.onRender(()=>{xt&&requestAnimationFrame(ih)});let et=null,Jt=null,js=-1;const v_=15e3;function m_(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}?token=${Qa}`}function S_(){const t=document.createElement("div");t.id="reconnect-overlay";const e=document.createElement("div");e.className="spinner",t.appendChild(e);const i=document.createElement("div");if(i.className="reconnect-text",i.textContent="Reconnecting...",t.appendChild(i),fs){const s=document.createElement("a");s.className="reconnect-dashboard-btn",s.href=fs,s.textContent="← Back to Dashboard",t.appendChild(s)}return t}function w_(){if(!et)return;Ni.destroy(),et.classList.add("ended");const t=et.querySelector(".spinner");t&&t.remove();const e=et.querySelector(".reconnect-text");e&&(e.textContent="Session ended");const i=et.querySelector(".reconnect-dashboard-btn");i&&i.classList.add("primary")}function b_(t,e){Za.className=t==="connected"?"connected":t==="reconnecting"?"reconnecting":"",nn.textContent=t==="connected"?"Connected":t==="reconnecting"?e>5?"Waiting for laptop to wake up...":`Reconnecting (attempt ${e})...`:"Disconnected",t==="reconnecting"&&!et?(et=S_(),document.body.appendChild(et),Jt&&clearTimeout(Jt),Jt=setTimeout(w_,v_)):t==="connected"&&et&&(et.remove(),et=null,Jt&&(clearTimeout(Jt),Jt=null))}const Ni=new u_({getUrl:m_,onOpen:()=>{js>=0&&Ni.send(JSON.stringify({type:"resume",lastSeq:js})),sh()},onMessage:t=>{try{const e=JSON.parse(t.data);switch(e.type){case"data":oe.write(e.data),typeof e.seq=="number"&&(js=e.seq);break;case"resize":typeof e.cols=="number"&&typeof e.rows=="number"&&(xt={cols:e.cols,rows:e.rows},eh());break}}catch{oe.write(typeof t.data=="string"?t.data:new Uint8Array(t.data))}},onStatusChange:b_});function sh(){Ni.send(JSON.stringify({type:"resize",cols:oe.cols,rows:oe.rows}))}function rh(t){Ni.send(JSON.stringify({type:"input",data:t}))}oe.onData(t=>{const e=i_()?Ur(t):t;rh(e),h_()});s_(qr,rh);let Zs=0;function gs(){const t=window.visualViewport,e=qr.offsetHeight;if(t){const s=window.innerHeight-t.height-t.offsetTop;Zs=Math.max(0,s),qr.style.bottom=`${Zs}px`}const i=e+Zs;document.documentElement.style.setProperty("--extra-keys-height",`${i}px`),xt?(eh(),ih()):(Cs.fit(),sh())}window.addEventListener("resize",gs);window.visualViewport&&(window.visualViewport.addEventListener("resize",gs),window.visualViewport.addEventListener("scroll",gs));requestAnimationFrame(gs);tt.addEventListener("touchstart",()=>{oe.focus()});document.addEventListener("click",()=>ja(),{once:!0});document.addEventListener("touchstart",()=>ja(),{once:!0});window.__itwillsync_loaded=!0;r_({statusBar:document.getElementById("status-bar"),statusDot:Za,statusText:nn});oe.focus();Ni.connect();