phirepass-widgets 0.0.40 → 0.0.42

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.
Files changed (38) hide show
  1. package/dist/cjs/{index-Rxdu9QG2.js → index-DTAHGGCM.js} +111 -44
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/phirepass-sftp-client.cjs.entry.js +225 -3
  4. package/dist/cjs/phirepass-terminal.cjs.entry.js +30 -815
  5. package/dist/cjs/phirepass-widgets.cjs.js +3 -3
  6. package/dist/cjs/protocol-C4R_gGQV.js +801 -0
  7. package/dist/collection/collection-manifest.json +1 -1
  8. package/dist/collection/common/protocol.js +20 -0
  9. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.css +142 -1
  10. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.js +509 -1
  11. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.logo.svg +6 -0
  12. package/dist/collection/components/phirepass-sftp-client/phirepass-sftp-client.max.svg +8 -0
  13. package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +12 -21
  14. package/dist/collection/phirepass-channel_bg.wasm +0 -0
  15. package/dist/components/index.js +1 -1
  16. package/dist/components/p-DgZMmpg7.js +1 -0
  17. package/dist/components/phirepass-sftp-client.js +1 -1
  18. package/dist/components/phirepass-terminal.js +5 -5
  19. package/dist/esm/{index-C8ZFkLEv.js → index-D6RLmr6w.js} +111 -44
  20. package/dist/esm/loader.js +3 -3
  21. package/dist/esm/phirepass-sftp-client.entry.js +225 -3
  22. package/dist/esm/phirepass-terminal.entry.js +9 -793
  23. package/dist/esm/phirepass-widgets.js +4 -4
  24. package/dist/esm/protocol-DgZMmpg7.js +796 -0
  25. package/dist/phirepass-widgets/p-79a71767.entry.js +1 -0
  26. package/dist/phirepass-widgets/p-D6RLmr6w.js +2 -0
  27. package/dist/phirepass-widgets/p-DgZMmpg7.js +1 -0
  28. package/dist/phirepass-widgets/p-bb70a3bd.entry.js +49 -0
  29. package/dist/phirepass-widgets/phirepass-channel_bg.wasm +0 -0
  30. package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
  31. package/dist/types/common/protocol.d.ts +17 -0
  32. package/dist/types/components/phirepass-sftp-client/phirepass-sftp-client.d.ts +42 -0
  33. package/dist/types/components/phirepass-terminal/phirepass-terminal.d.ts +1 -6
  34. package/dist/types/components.d.ts +97 -1
  35. package/package.json +5 -5
  36. package/dist/phirepass-widgets/p-376ef3af.entry.js +0 -1
  37. package/dist/phirepass-widgets/p-C8ZFkLEv.js +0 -2
  38. package/dist/phirepass-widgets/p-fa55ec4a.entry.js +0 -49
@@ -1,4 +1,4 @@
1
- import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
1
+ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";import{I as n,_ as o,C as l,a,P as u,E as c}from"./p-DgZMmpg7.js";
2
2
  /**
3
3
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
4
4
  * @license MIT
@@ -10,7 +10,7 @@ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
10
10
  * Fabrice Bellard's javascript vt100 for jslinux:
11
11
  * http://bellard.org/jslinux/
12
12
  * Copyright (c) 2011 Fabrice Bellard
13
- */var n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=(t,i,s,e)=>{for(var h,r=e>1?void 0:e?o(i,s):i,a=t.length-1;a>=0;a--)(h=t[a])&&(r=(e?h(i,s,r):h(r))||r);return e&&r&&n(i,s,r),r},l=(t,i)=>(s,e)=>i(s,e,t),c="Terminal input",u=()=>c,A="Too much output to announce, navigate to rows manually to read",f=()=>A;function d(t,i,s,e){t=function(t,i){return i?"[200~"+t+"[201~":t}(t=function(t){return t.replace(/\r?\n/g,"\r")}(t),s.decPrivateModes.bracketedPasteMode&&!0!==e.rawOptions.ignoreBracketedPasteMode),s.triggerDataEvent(t,!0),i.value=""}function g(t,i,s){let e=s.getBoundingClientRect(),h=t.clientX-e.left-10,r=t.clientY-e.top-10;i.style.width="20px",i.style.height="20px",i.style.left=h+"px",i.style.top=r+"px",i.style.zIndex="1000",i.focus()}function w(t,i,s,e,h){g(t,i,s),h&&e.rightClickSelect(t),i.value=e.selectionText,i.select()}function p(t){return t>65535?String.fromCharCode(55296+((t-=65536)>>10))+String.fromCharCode(t%1024+56320):String.fromCharCode(t)}function C(t,i=0,s=t.length){let e="";for(let h=i;h<s;++h){let i=t[h];i>65535?(i-=65536,e+=String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):e+=String.fromCharCode(i)}return e}var m=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,i){let s=t.length;if(!s)return 0;let e=0,h=0;if(this._interim){let s=t.charCodeAt(h++);56320<=s&&s<=57343?i[e++]=1024*(this._interim-55296)+s-56320+65536:(i[e++]=this._interim,i[e++]=s),this._interim=0}for(let r=h;r<s;++r){let h=t.charCodeAt(r);if(55296<=h&&h<=56319){if(++r>=s)return this._interim=h,e;let n=t.charCodeAt(r);56320<=n&&n<=57343?i[e++]=1024*(h-55296)+n-56320+65536:(i[e++]=h,i[e++]=n)}else 65279!==h&&(i[e++]=h)}return e}},I=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,i){let s=t.length;if(!s)return 0;let e,h,r,n,o=0,a=0,l=0;if(this.interim[0]){let e=!1,h=this.interim[0];h&=192==(224&h)?31:224==(240&h)?15:7;let r,n=0;for(;(r=63&this.interim[++n])&&n<4;)h<<=6,h|=r;let a=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,c=a-n;for(;l<c;){if(l>=s)return 0;if(r=t[l++],128!=(192&r)){l--,e=!0;break}this.interim[n++]=r,h<<=6,h|=63&r}e||(2===a?h<128?l--:i[o++]=h:3===a?h<2048||h>=55296&&h<=57343||65279===h||(i[o++]=h):h<65536||h>1114111||(i[o++]=h)),this.interim.fill(0)}let c=s-4,u=l;for(;u<s;){for(;!(!(u<c)||128&(e=t[u])||128&(h=t[u+1])||128&(r=t[u+2])||128&(n=t[u+3]));)i[o++]=e,i[o++]=h,i[o++]=r,i[o++]=n,u+=4;if(e=t[u++],e<128)i[o++]=e;else if(192==(224&e)){if(u>=s)return this.interim[0]=e,o;if(h=t[u++],128!=(192&h)){u--;continue}if(a=(31&e)<<6|63&h,a<128){u--;continue}i[o++]=a}else if(224==(240&e)){if(u>=s)return this.interim[0]=e,o;if(h=t[u++],128!=(192&h)){u--;continue}if(u>=s)return this.interim[0]=e,this.interim[1]=h,o;if(r=t[u++],128!=(192&r)){u--;continue}if(a=(15&e)<<12|(63&h)<<6|63&r,a<2048||a>=55296&&a<=57343||65279===a)continue;i[o++]=a}else if(240==(248&e)){if(u>=s)return this.interim[0]=e,o;if(h=t[u++],128!=(192&h)){u--;continue}if(u>=s)return this.interim[0]=e,this.interim[1]=h,o;if(r=t[u++],128!=(192&r)){u--;continue}if(u>=s)return this.interim[0]=e,this.interim[1]=h,this.interim[2]=r,o;if(n=t[u++],128!=(192&n)){u--;continue}if(a=(7&e)<<18|(63&h)<<12|(63&r)<<6|63&n,a<65536||a>1114111)continue;i[o++]=a}}return o}},v=" ",b=class t{constructor(){this.fg=0,this.bg=0,this.extended=new B}static toColorRGB(t){return[t>>>16&255,t>>>8&255,255&t]}static fromColorRGB(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]}clone(){let i=new t;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},B=class t{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},M=class t extends b{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new B,this.combinedData=""}static fromCharData(i){let s=new t;return s.setFromCharData(i),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?p(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(2===t[1].length){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let e=t[1].charCodeAt(1);56320<=e&&e<=57343?this.content=1024*(s-55296)+e-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},y="di$target",E="di$dependencies",Q=new Map;function k(t){if(Q.has(t))return Q.get(t);let i=function(t,s,e){if(3!==arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[y]===i?i[E].push({id:t,index:s}):(i[E]=[{id:t,index:s}],i[y]=i)}(i,t,e)};return i._id=t,Q.set(t,i),i}var x=k("BufferService"),D=k("CoreMouseService"),L=k("CoreService"),_=k("CharsetService"),S=k("InstantiationService"),$=k("LogService"),R=k("OptionsService"),N=k("OscLinkService"),F=k("UnicodeService"),H=k("DecorationService"),U=class{constructor(t,i,s){this._bufferService=t,this._optionsService=i,this._oscLinkService=s}provideLinks(t,i){let s=this._bufferService.buffer.lines.get(t-1);if(!s)return void i(void 0);let e=[],h=this._optionsService.rawOptions.linkHandler,r=new M,n=s.getTrimmedLength(),o=-1,a=-1,l=!1;for(let i=0;i<n;i++)if(-1!==a||s.hasContent(i)){if(s.loadCell(i,r),r.hasExtendedAttrs()&&r.extended.urlId){if(-1===a){a=i,o=r.extended.urlId;continue}l=r.extended.urlId!==o}else-1!==a&&(l=!0);if(l||-1!==a&&i===n-1){let s=this._oscLinkService.getLinkData(o)?.uri;if(s){let r={start:{x:a+1,y:t},end:{x:i+(l||i!==n-1?0:1),y:t}},o=!1;if(!h?.allowNonHttpProtocols)try{let t=new URL(s);["http:","https:"].includes(t.protocol)||(o=!0)}catch{o=!0}o||e.push({text:s,range:r,activate:(t,i)=>h?h.activate(t,i,r):T(0,i),hover:(t,i)=>h?.hover?.(t,i,r),leave:(t,i)=>h?.leave?.(t,i,r)})}l=!1,r.hasExtendedAttrs()&&r.extended.urlId?(a=i,o=r.extended.urlId):(a=-1,o=-1)}}i(e)}};function T(t,i){if(confirm(`Do you want to navigate to ${i}?\n\nWARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}U=a([l(0,x),l(1,R),l(2,N)],U);var G=k("CharSizeService"),P=k("CoreBrowserService"),J=k("MouseService"),O=k("RenderService"),W=k("SelectionService"),z=k("CharacterJoinerService"),q=k("ThemeService"),K=k("LinkProviderService"),j=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?it.isErrorNoTelemetry(t)?new it(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};function Y(t){(function(t){return t instanceof tt||t instanceof Error&&t.name===V&&t.message===V})(t)||j.onUnexpectedError(t)}var Z,X,V="Canceled",tt=class extends Error{constructor(){super(V),this.name=this.message}},it=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}},st=class t extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,t.prototype)}};function et(t,i=0){return t[t.length-(1+i)]}function ht(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function rt(t){if(X.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function nt(t){return{dispose:ht((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Z||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(X||={});var ot=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{rt(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};ot.DISABLE_DISPOSED_WARNING=!1;var at=ot,lt=class{constructor(){this._store=new at}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};lt.None=Object.freeze({dispose(){}});var ct=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}},ut="object"==typeof window?window:globalThis,At=class t{constructor(i){this.element=i,this.next=t.Undefined,this.prev=t.Undefined}};At.Undefined=new At(void 0);var ft,dt=At,gt=class{constructor(){this._first=dt.Undefined,this._last=dt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===dt.Undefined}clear(){let t=this._first;for(;t!==dt.Undefined;){let i=t.next;t.prev=dt.Undefined,t.next=dt.Undefined,t=i}this._first=dt.Undefined,this._last=dt.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,i){let s=new dt(t);if(this._first===dt.Undefined)this._first=s,this._last=s;else if(i){let t=this._last;this._last=s,s.prev=t,t.next=s}else{let t=this._first;this._first=s,s.next=t,t.prev=s}this._size+=1;let e=!1;return()=>{e||(e=!0,this._remove(s))}}shift(){if(this._first!==dt.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==dt.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==dt.Undefined&&t.next!==dt.Undefined){let i=t.prev;i.next=t.next,t.next.prev=i}else t.prev===dt.Undefined&&t.next===dt.Undefined?(this._first=dt.Undefined,this._last=dt.Undefined):t.next===dt.Undefined?(this._last=this._last.prev,this._last.next=dt.Undefined):t.prev===dt.Undefined&&(this._first=this._first.next,this._first.prev=dt.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==dt.Undefined;)yield t.element,t=t.next}},wt=globalThis.performance&&"function"==typeof globalThis.performance.now,pt=class t{static create(i){return new t(i)}constructor(t){this._now=wt&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new Qt({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,a,l,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,a=i(a,t),e&&!l&&(f.fire(a),a=void 0),c=()=>{let t=a;a=void 0,l=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(l),l=setTimeout(c,s)):void 0===l&&(l=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new Qt(A);return n?.add(f),f.event}t.None=()=>lt.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=function(...t){return nt((()=>rt(t)))}(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new Qt({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Qt({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Qt({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new Qt;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class a{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new Qt({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new a(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof at?e.add(o):Array.isArray(e)&&e.push(o),o}}})(ft||={});var Ct=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new pt,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Ct.all=new Set,Ct._idPool=0;var mt=Ct,It=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new Bt(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};It._idPool=1;var vt=It,bt=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Bt=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Mt=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},yt=0,Et=class{constructor(t){this.value=t,this.id=yt++}},Qt=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new vt(t?.onListenerError??Y,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new mt(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new Mt(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||Y)(s),lt.None}if(this._disposed)return lt.None;i&&(t=t.bind(i));let e,h=new Et(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=bt.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof Et?(this._deliveryQueue??=new kt,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=nt((()=>{e?.(),this._removeListener(h)}));return s instanceof at?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Y;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 Et)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},kt=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},xt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Qt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Qt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};xt.INSTANCE=new xt;var Dt=xt,Lt="object"==typeof navigator?navigator.userAgent:"",_t=Lt.indexOf("Firefox")>=0,St=Lt.indexOf("AppleWebKit")>=0,$t=Lt.indexOf("Chrome")>=0,Rt=!$t&&Lt.indexOf("Safari")>=0;if(Lt.indexOf("Electron/"),Lt.indexOf("Android"),"function"==typeof ut.matchMedia){let t=ut.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");ut.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=ut.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Nt,Ft,Ht="en",Ut=!1,Tt=!1,Gt=!1,Pt=!1,Jt=Ht,Ot=globalThis;typeof Ot.vscode<"u"&&typeof Ot.vscode.process<"u"?Ft=Ot.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Ft=process);var Wt="string"==typeof Ft?.versions?.electron&&"renderer"===Ft?.type;if("object"==typeof Ft){Ut="win32"===Ft.platform,Tt="darwin"===Ft.platform,Gt="linux"===Ft.platform,Jt=Ht;let t=Ft.env.VSCODE_NLS_CONFIG;if(t)try{Jt=JSON.parse(t).resolvedLanguage||Ht}catch{}Pt=!0}else"object"!=typeof navigator||Wt?console.error("Unable to resolve platform."):(Ut=(Nt=navigator.userAgent).indexOf("Windows")>=0,Tt=Nt.indexOf("Macintosh")>=0,(Nt.indexOf("Macintosh")>=0||Nt.indexOf("iPad")>=0||Nt.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Gt=Nt.indexOf("Linux")>=0,Nt?.indexOf("Mobi"),Jt=globalThis._VSCODE_NLS_LANGUAGE||Ht,navigator.language.toLowerCase());var zt,qt=Ut,Kt=Tt,jt=Gt,Yt=Pt,Zt=Nt,Xt=Jt;(t=>{t.value=function(){return Xt},t.isDefaultVariant=function(){return 2===Xt.length?"en"===Xt:Xt.length>=3&&"e"===Xt[0]&&"n"===Xt[1]&&"-"===Xt[2]},t.isDefault=function(){return"en"===Xt}})(zt||={});var Vt="function"==typeof Ot.postMessage&&!Ot.importScripts;(()=>{if(Vt){let t=[];Ot.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var ti=!!(Zt&&Zt.indexOf("Chrome")>=0);Zt&&Zt.indexOf("Firefox"),!ti&&Zt&&Zt.indexOf("Safari"),Zt&&Zt.indexOf("Edg/"),Zt&&Zt.indexOf("Android"),"object"==typeof navigator&&navigator,Yt||document.queryCommandSupported&&document.queryCommandSupported("copy");var ii,si=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,i){this._keyCodeToStr[t]=i,this._strToKeyCode[i.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},ei=new si,hi=new si,ri=new si,ni=Array(230);(t=>{t.toString=function(t){return ei.keyCodeToStr(t)},t.fromString=function(t){return ei.strToKeyCode(t)},t.toUserSettingsUS=function(t){return hi.keyCodeToStr(t)},t.toUserSettingsGeneral=function(t){return ri.keyCodeToStr(t)},t.fromUserSettings=function(t){return hi.strToKeyCode(t)||ri.strToKeyCode(t)},t.toElectronAccelerator=function(t){if(t>=98&&t<=113)return null;switch(t){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ei.keyCodeToStr(t)}})(ii||={});var oi=class t{constructor(t,i,s,e,h){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=e,this.keyCode=h}equals(i){return i instanceof t&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){return`K${this.ctrlKey?"1":"0"}${this.shiftKey?"1":"0"}${this.altKey?"1":"0"}${this.metaKey?"1":"0"}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new ai([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},ai=class{constructor(t){if(0===t.length)throw Error("Illegal argument: chords");this.chords=t}getHashCode(){let t="";for(let i=0,s=this.chords.length;i<s;i++)0!==i&&(t+=";"),t+=this.chords[i].getHashCode();return t}equals(t){if(null===t||this.chords.length!==t.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(t.chords[i]))return!1;return!0}},li=Kt?256:2048,ci=Kt?2048:256,ui=class{constructor(t){this._standardKeyboardEventBrand=!0;let i=t;this.browserEvent=i,this.target=i.target,this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.altGraphKey=i.getModifierState?.("AltGraph"),this.keyCode=function(t){if(t.charCode){let i=String.fromCharCode(t.charCode).toUpperCase();return ii.fromString(i)}let i=t.keyCode;if(3===i)return 7;if(_t)switch(i){case 59:return 85;case 60:if(jt)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Kt)return 57}else if(St){if(Kt&&93===i)return 57;if(!Kt&&92===i)return 57}return ni[i]||0}(i),this.code=i.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(t=this.keyCode);let i=0;return this.ctrlKey&&(i|=li),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=ci),i|=t,i}_computeKeyCodeChord(){let t=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(t=this.keyCode),new oi(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Ai=new WeakMap;function fi(t){if(!t.parent||t.parent===t)return null;try{let i=t.location,s=t.parent.location;if("null"!==i.origin&&"null"!==s.origin&&i.origin!==s.origin)return null}catch{return null}return t.parent}var di,gi=class{static getSameOriginWindowChain(t){let i=Ai.get(t);if(!i){i=[],Ai.set(t,i);let s,e=t;do{s=fi(e),i.push(s?{window:new WeakRef(e),iframeElement:e.frameElement||null}:{window:new WeakRef(e),iframeElement:null}),e=s}while(e)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,i){if(!i||t===i)return{top:0,left:0};let s=0,e=0,h=this.getSameOriginWindowChain(t);for(let t of h){let h=t.window.deref();if(s+=h?.scrollY??0,e+=h?.scrollX??0,h===i||!t.iframeElement)break;let r=t.iframeElement.getBoundingClientRect();s+=r.top,e+=r.left}return{top:s,left:e}}},wi=class{constructor(t,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(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=gi.getPositionOfChildWindowRelativeToAncestorWindow(t,i.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},pi=class{constructor(t,i=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=i;let e=!1;if($t){let t=navigator.userAgent.match(/Chrome\/(\d+)/);e=(t?parseInt(t[1]):123)<=122}if(t){let i=t,s=t,h=t.view?.devicePixelRatio||1;typeof i.wheelDeltaY<"u"?this.deltaY=e?i.wheelDeltaY/(120*h):i.wheelDeltaY/120:typeof s.VERTICAL_AXIS<"u"&&s.axis===s.VERTICAL_AXIS?this.deltaY=-s.detail/3:"wheel"===t.type&&(this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?_t&&!Kt?-t.deltaY/3:-t.deltaY:-t.deltaY/40),typeof i.wheelDeltaX<"u"?this.deltaX=Rt&&qt?-i.wheelDeltaX/120:e?i.wheelDeltaX/(120*h):i.wheelDeltaX/120:typeof s.HORIZONTAL_AXIS<"u"&&s.axis===s.HORIZONTAL_AXIS?this.deltaX=-t.detail/3:"wheel"===t.type&&(this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?_t&&!Kt?-t.deltaX/3:-t.deltaX:-t.deltaX/40),0===this.deltaY&&0===this.deltaX&&t.wheelDelta&&(this.deltaY=e?t.wheelDelta/(120*h):t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Ci=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof Ii||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ft.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ci})})(di||={});var mi,Ii=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?Ci:(this._emitter||(this._emitter=new Qt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},vi=class{constructor(t,i){this._isDisposed=!1,this._token=-1,"function"==typeof t&&"number"==typeof i&&this.setIfNotSet(t,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,i){if(this._isDisposed)throw new st("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout((()=>{this._token=-1,t()}),i)}setIfNotSet(t,i){if(this._isDisposed)throw new st("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout((()=>{this._token=-1,t()}),i))}},bi=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,i,s=globalThis){if(this.isDisposed)throw new st("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let e=s.setInterval((()=>{t()}),i);this.disposable=nt((()=>{s.clearInterval(e),this.disposable=void 0}))}dispose(){this.cancel(),this.isDisposed=!0}};(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(mi||={});var Bi=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Qt,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await ft.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Bi.EMPTY=Bi.fromArray([]);var{getWindow:Mi,getWindowId:yi,onDidRegisterWindow:Ei}=function(){let t=new Map,i={window:ut,disposables:new at};t.set(ut.vscodeWindowId,i);let s=new Qt,e=new Qt,h=new Qt;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return lt.None;let r=new at,n={window:i,disposables:r.add(new at)};return t.set(i.vscodeWindowId,n),r.add(nt((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(ki(i,Si.BEFORE_UNLOAD,(()=>{h.fire(i)}))),s.fire(n),r},getWindows:()=>t.values(),getWindowsCount:()=>t.size,getWindowId:t=>t.vscodeWindowId,hasWindow:i=>t.has(i),getWindowById:function(s,e){return("number"==typeof s?t.get(s):void 0)??(e?i:void 0)},getWindow(t){let i=t;if(i?.ownerDocument?.defaultView)return i.ownerDocument.defaultView.window;let s=t;return s?.view?s.view.window:ut},getDocument:t=>Mi(t).document}}(),Qi=class{constructor(t,i,s,e){this._node=t,this._type=i,this._handler=s,this._options=e||!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 ki(t,i,s,e){return new Qi(t,i,s,e)}var xi,Di=function(t,i,s,e){return ki(t,i,s,e)},Li=class extends bi{constructor(t){super(),this.defaultTarget=t&&Mi(t)}cancelAndSet(t,i,s){return super.cancelAndSet(t,i,s??this.defaultTarget)}},_i=class{constructor(t,i=0){this._runner=t,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){Y(t)}}static sort(t,i){return i.priority-t.priority}};!function(){let t=new Map,i=new Map,s=new Map,e=new Map;xi=(h,r,n=0)=>{let o=yi(h),a=new _i(r,n),l=t.get(o);return l||(l=[],t.set(o,l)),l.push(a),s.get(o)||(s.set(o,!0),h.requestAnimationFrame((()=>(h=>{s.set(h,!1);let r=t.get(h)??[];for(i.set(h,r),t.set(h,[]),e.set(h,!0);r.length>0;)r.sort(_i.sort),r.shift().execute();e.set(h,!1)})(o)))),a}}();var Si={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"},$i=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 i=Ri(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=Ri(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=Ri(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=Ri(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=Ri(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=Ri(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=Ri(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=Ri(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=Ri(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=Ri(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=Ri(t);this._paddingRight!==i&&(this._paddingRight=i,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 i=Ri(t);this._fontSize!==i&&(this._fontSize=i,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 i=Ri(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=Ri(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),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,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Ri(t){return"number"==typeof t?t+"px":t}function Ni(t){return new $i(t)}var Fi,Hi=class{constructor(){this._hooks=new at,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,i,s,e,h){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=e,this._onStopCallback=h;let r=t;try{t.setPointerCapture(i),this._hooks.add(nt((()=>{try{t.releasePointerCapture(i)}catch{}})))}catch{r=Mi(t)}this._hooks.add(ki(r,Si.POINTER_MOVE,(t=>{t.buttons===s?(t.preventDefault(),this._pointerMoveCallback(t)):this.stopMonitoring(!0)}))),this._hooks.add(ki(r,Si.POINTER_UP,(()=>this.stopMonitoring(!0))))}};(t=>{t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"})(Fi||={});var Ui=class t extends lt{constructor(){super(),this.dispatched=!1,this.targets=new gt,this.ignoreTargets=new gt,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ft.runAndSubscribe(Ei,(({window:t,disposables:i})=>{i.add(ki(t.document,"touchstart",(t=>this.onTouchStart(t)),{passive:!1})),i.add(ki(t.document,"touchend",(i=>this.onTouchEnd(t,i)))),i.add(ki(t.document,"touchmove",(t=>this.onTouchMove(t)),{passive:!1}))}),{window:ut,disposables:this._store}))}static addTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),nt(t.INSTANCE.targets.push(i))):lt.None}static ignoreTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),nt(t.INSTANCE.ignoreTargets.push(i))):lt.None}static isTouchDevice(){return"ontouchstart"in ut||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,e=t.targetTouches.length;s<e;s++){let e=t.targetTouches.item(s);this.activeTouches[e.identifier]={id:e.identifier,initialTarget:e.target,initialTimeStamp:i,initialPageX:e.pageX,initialPageY:e.pageY,rollingTimestamps:[i],rollingPageX:[e.pageX],rollingPageY:[e.pageY]};let h=this.newGestureEvent(Fi.Start,e.target);h.pageX=e.pageX,h.pageY=e.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,s){let e=Date.now(),h=Object.keys(this.activeTouches).length;for(let r=0,n=s.changedTouches.length;r<n;r++){let n=s.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(n.identifier+"")){console.warn("move of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=Date.now()-o.initialTimeStamp;if(a<t.HOLD_DELAY&&Math.abs(o.initialPageX-et(o.rollingPageX))<30&&Math.abs(o.initialPageY-et(o.rollingPageY))<30){let t=this.newGestureEvent(Fi.Tap,o.initialTarget);t.pageX=et(o.rollingPageX),t.pageY=et(o.rollingPageY),this.dispatchEvent(t)}else if(a>=t.HOLD_DELAY&&Math.abs(o.initialPageX-et(o.rollingPageX))<30&&Math.abs(o.initialPageY-et(o.rollingPageY))<30){let t=this.newGestureEvent(Fi.Contextmenu,o.initialTarget);t.pageX=et(o.rollingPageX),t.pageY=et(o.rollingPageY),this.dispatchEvent(t)}else if(1===h){let t=et(o.rollingPageX),s=et(o.rollingPageY),h=et(o.rollingTimestamps)-o.rollingTimestamps[0],r=t-o.rollingPageX[0],n=s-o.rollingPageY[0],a=[...this.targets].filter((t=>o.initialTarget instanceof Node&&t.contains(o.initialTarget)));this.inertia(i,a,e,Math.abs(r)/h,r>0?1:-1,t,Math.abs(n)/h,n>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(Fi.End,o.initialTarget)),delete this.activeTouches[n.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(i){if(i.type===Fi.Tap){let s=(new Date).getTime(),e=0;e=s-this._lastSetTapCountTime>t.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,i.tapCount=e}else(i.type===Fi.Change||i.type===Fi.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let t of this.ignoreTargets)if(t.contains(i.initialTarget))return;let t=[];for(let s of this.targets)if(s.contains(i.initialTarget)){let e=0,h=i.initialTarget;for(;h&&h!==s;)e++,h=h.parentElement;t.push([e,s])}t.sort(((t,i)=>t[0]-i[0]));for(let[s,e]of t)e.dispatchEvent(i),this.dispatched=!0}}inertia(i,s,e,h,r,n,o,a,l){this.handle=xi(i,(()=>{let c=Date.now(),u=c-e,A=0,f=0,d=!0;(h+=t.SCROLL_FRICTION*u)>0&&(d=!1,A=r*h*u),(o+=t.SCROLL_FRICTION*u)>0&&(d=!1,f=a*o*u);let g=this.newGestureEvent(Fi.Change);g.translationX=A,g.translationY=f,s.forEach((t=>t.dispatchEvent(g))),d||this.inertia(i,s,c,h,r,n+A,o,a,l+f)}))}onTouchMove(t){let i=Date.now();for(let s=0,e=t.changedTouches.length;s<e;s++){let e=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(e.identifier+"")){console.warn("end of an UNKNOWN touch",e);continue}let h=this.activeTouches[e.identifier],r=this.newGestureEvent(Fi.Change,h.initialTarget);r.translationX=e.pageX-et(h.rollingPageX),r.translationY=e.pageY-et(h.rollingPageY),r.pageX=e.pageX,r.pageY=e.pageY,this.dispatchEvent(r),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(e.pageX),h.rollingPageY.push(e.pageY),h.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ui.SCROLL_FRICTION=-.005,Ui.HOLD_DELAY=700,Ui.CLEAR_TAP_COUNT_TIME=400,a([function(t,i,s){let e=null,h=null;if("function"==typeof s.value?(e="value",h=s.value,0!==h.length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(e="get",h=s.get),!h)throw Error("not supported");let r="$memoize$"+i;s[e]=function(...t){return this.hasOwnProperty(r)||Object.defineProperty(this,r,{configurable:!1,enumerable:!1,writable:!1,value:h.apply(this,t)}),this[r]}}],Ui,"isTouchDevice",1);var Ti=Ui,Gi=class extends lt{onclick(t,i){this._register(ki(t,Si.CLICK,(s=>i(new wi(Mi(t),s)))))}onmousedown(t,i){this._register(ki(t,Si.MOUSE_DOWN,(s=>i(new wi(Mi(t),s)))))}onmouseover(t,i){this._register(ki(t,Si.MOUSE_OVER,(s=>i(new wi(Mi(t),s)))))}onmouseleave(t,i){this._register(ki(t,Si.MOUSE_LEAVE,(s=>i(new wi(Mi(t),s)))))}onkeydown(t,i){this._register(ki(t,Si.KEY_DOWN,(t=>i(new ui(t)))))}onkeyup(t,i){this._register(ki(t,Si.KEY_UP,(t=>i(new ui(t)))))}oninput(t,i){this._register(ki(t,Si.INPUT,i))}onblur(t,i){this._register(ki(t,Si.BLUR,i))}onfocus(t,i){this._register(ki(t,Si.FOCUS,i))}onchange(t,i){this._register(ki(t,Si.CHANGE,i))}ignoreGesture(t){return Ti.ignoreTarget(t)}},Pi=class extends Gi{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="11px",this.domNode.style.height="11px",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 Hi),this._register(Di(this.bgDomNode,Si.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._register(Di(this.domNode,Si.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._pointerdownRepeatTimer=this._register(new Li),this._pointerdownScheduleRepeatTimer=this._register(new vi)}_arrowPointerDown(t){t.target&&t.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet((()=>{this._pointerdownRepeatTimer.cancelAndSet((()=>this._onActivate()),1e3/24,Mi(t))}),200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(()=>{}),(()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()})),t.preventDefault())}},Ji=class t{constructor(t,i,s,e,h,r,n){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,s|=0,e|=0,h|=0,r|=0,n|=0),this.rawScrollLeft=e,this.rawScrollTop=n,i<0&&(i=0),e+i>s&&(e=s-i),e<0&&(e=0),h<0&&(h=0),n+h>r&&(n=r-h),n<0&&(n=0),this.width=i,this.scrollWidth=s,this.scrollLeft=e,this.height=h,this.scrollHeight=r,this.scrollTop=n}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(i,s){return new t(this._forceIntegerValues,typeof i.width<"u"?i.width:this.width,typeof i.scrollWidth<"u"?i.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof i.height<"u"?i.height:this.height,typeof i.scrollHeight<"u"?i.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new t(this._forceIntegerValues,this.width,this.scrollWidth,typeof i.scrollLeft<"u"?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof i.scrollTop<"u"?i.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:this.width!==t.width,scrollWidthChanged:this.scrollWidth!==t.scrollWidth,scrollLeftChanged:this.scrollLeft!==t.scrollLeft,heightChanged:this.height!==t.height,scrollHeightChanged:this.scrollHeight!==t.scrollHeight,scrollTopChanged:this.scrollTop!==t.scrollTop}}},Oi=class extends lt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Qt),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new Ji(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,i){let s=this._state.withScrollDimensions(t,i);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let i=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(t,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(t);if(this._smoothScrolling){let s,e=this._state.withScrollPosition(t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop});if(this._smoothScrolling.to.scrollLeft===e.scrollLeft&&this._smoothScrolling.to.scrollTop===e.scrollTop)return;s=i?new qi(this._smoothScrolling.from,e,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,e,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=qi.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(),i=this._state.withScrollPosition(t);if(this._setState(i,!0),this._smoothScrolling){if(t.isDone)return this._smoothScrolling.dispose(),void(this._smoothScrolling=null);this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame((()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())}))}}_setState(t,i){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,i)))}},Wi=class{constructor(t,i,s){this.scrollLeft=t,this.scrollTop=i,this.isDone=s}};function zi(t,i){let s=i-t;return function(i){return t+s*function(t){return 1-function(t){return Math.pow(t,3)}(1-t)}(i)}}var qi=class t{constructor(t,i,s,e){this.from=t,this.to=i,this.duration=e,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let e,h;return t<i?(e=t+.75*s,h=i-.75*s):(e=t-.75*s,h=i+.75*s),function(t,i,s){return function(e){return e<s?t(e/s):i((e-s)/(1-s))}}(zi(t,e),zi(h,i),.33)}return zi(t,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let t=this.scrollLeft(i),s=this.scrollTop(i);return new Wi(t,s,!1)}return new Wi(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,s,e){return t.start(i,s,e)}static start(i,s,e){e+=10;let h=Date.now()-10;return new t(i,s,h,e)}},Ki=class extends lt{constructor(t,i,s){super(),this._visibility=t,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 vi)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet((()=>{this._domNode?.setClassName(this._visibleClassName)}),0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},ji=class extends Gi{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new Ki(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Hi),this._shouldRender=!0,this.domNode=Ni(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ki(this.domNode.domNode,Si.POINTER_DOWN,(t=>this._domNodePointerDown(t))))}_createArrow(t){let i=this._register(new Pi(t));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(t,i,s,e){this.slider=Ni(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(i),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof e&&this.slider.setHeight(e),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ki(this.slider.domNode,Si.POINTER_DOWN,(t=>{0===t.button&&(t.preventDefault(),this._sliderPointerDown(t))}))),this.onclick(this.slider.domNode,(t=>{t.leftButton&&t.stopPropagation()}))}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(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(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let i=this.domNode.domNode.getClientRects()[0].top,s=i+this._scrollbarState.getSliderPosition(),e=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),h=this._sliderPointerPosition(t);s<=h&&h<=e?0===t.button&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let i,s;if(t.target===this.domNode.domNode&&"number"==typeof t.offsetX&&"number"==typeof t.offsetY)i=t.offsetX,s=t.offsetY;else{let e=function(t){let i=t.getBoundingClientRect(),s=Mi(t);return{left:i.left+s.scrollX,top:i.top+s.scrollY,width:i.width,height:i.height}}(this.domNode.domNode);i=t.pageX-e.left,s=t.pageY-e.top}let e=this._pointerDownRelativePosition(i,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(e):this._scrollbarState.getDesiredScrollPositionFromOffset(e)),0===t.button&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!(t.target&&t.target instanceof Element))return;let i=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),e=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(t=>{let h=this._sliderOrthogonalPointerPosition(t);if(qt&&Math.abs(h-s)>140)return void this._setDesiredScrollPositionNow(e.getScrollPosition());let r=this._sliderPointerPosition(t)-i;this._setDesiredScrollPositionNow(e.getDesiredScrollPositionFromDelta(r))}),(()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()})),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let i={};this.writeScrollPosition(i,t),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Yi=class t{constructor(t,i,s,e,h,r){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=e,this._scrollSize=h,this._scrollPosition=r,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new t(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,e,h){let r=Math.max(0,s-t),n=Math.max(0,r-2*i),o=e>0&&e>s;if(!o)return{computedAvailableSize:Math.round(r),computedIsNeeded:o,computedSliderSize:Math.round(n),computedSliderRatio:0,computedSliderPosition:0};let a=Math.round(Math.max(20,Math.floor(s*n/e))),l=(n-a)/(e-s),c=h*l;return{computedAvailableSize:Math.round(r),computedIsNeeded:o,computedSliderSize:Math.round(a),computedSliderRatio:l,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let i=t._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){return this._computedIsNeeded?Math.round((t-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=this._scrollPosition;return t-this._arrowSize<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){return this._computedIsNeeded?Math.round((this._computedSliderPosition+t)/this._computedSliderRatio):0}},Zi=class extends ji{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Yi(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,e.width,e.scrollWidth,h.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(t,i){this.slider.setWidth(t),this.slider.setLeft(i)}_renderDomNode(t,i){this.domNode.setWidth(t),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,i){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,i){t.scrollLeft=i}updateOptions(t){this.updateScrollbarSize(2===t.horizontal?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===t.vertical?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},Xi=class extends ji{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Yi(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,e.height,e.scrollHeight,h.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(t,i){this.slider.setHeight(t),this.slider.setTop(i)}_renderDomNode(t,i){this.domNode.setWidth(i),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,i){return i}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,i){t.scrollTop=i}updateOptions(t){this.updateScrollbarSize(2===t.vertical?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},Vi=class{constructor(t,i,s){this.timestamp=t,this.deltaX=i,this.deltaY=s,this.score=0}},ts=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let t=1,i=0,s=1,e=this._rear;for(;;){let h=e===this._front?t:Math.pow(2,-s);if(t-=h,i+=this._memory[e].score*h,e===this._front)break;e=(this._capacity+e-1)%this._capacity,s++}return i<=.5}acceptStandardWheelEvent(t){if($t){let i=function(t){return Dt.INSTANCE.getZoomFactor(t)}(Mi(t.browserEvent));this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let e=null,h=new Vi(t,i,s);-1===this._front&&-1===this._rear?(this._memory[0]=h,this._front=0,this._rear=0):(e=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]=h),h.score=this._computeScore(h,e)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let e=Math.abs(t.deltaX),h=Math.abs(t.deltaY),r=Math.abs(i.deltaX),n=Math.abs(i.deltaY),o=Math.max(Math.min(e,r),1),a=Math.max(Math.min(h,n),1);Math.max(e,r)%o==0&&Math.max(h,n)%a==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ts.INSTANCE=new ts;var is=ts,ss=class extends Gi{constructor(t,i,s){super(),this._onScroll=this._register(new Qt),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Qt),this.onWillScroll=this._onWillScroll.event,this._options=function(t){let i={lazyRender:typeof t.lazyRender<"u"&&t.lazyRender,className:typeof t.className<"u"?t.className:"",useShadows:!(typeof t.useShadows<"u")||t.useShadows,handleMouseWheel:!(typeof t.handleMouseWheel<"u")||t.handleMouseWheel,flipAxes:typeof t.flipAxes<"u"&&t.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"&&t.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"&&t.alwaysConsumeMouseWheel,scrollYToX:typeof t.scrollYToX<"u"&&t.scrollYToX,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:!(typeof t.scrollPredominantAxis<"u")||t.scrollPredominantAxis,mouseWheelSmoothScroll:!(typeof t.mouseWheelSmoothScroll<"u")||t.mouseWheelSmoothScroll,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,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"&&t.verticalHasArrows,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"&&t.scrollByPage};return i.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:i.verticalScrollbarSize,Kt&&(i.className+=" mac"),i}(i),this._scrollable=s,this._register(this._scrollable.onScroll((t=>{this._onWillScroll.fire(t),this._onDidScroll(t),this._onScroll.fire(t)})));let e={onMouseWheel:t=>this._onMouseWheel(t),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Xi(this._scrollable,this._options,e)),this._horizontalScrollbar=this._register(new Zi(this._scrollable,this._options,e)),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=Ni(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ni(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ni(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,(t=>this._onMouseOver(t))),this.onmouseleave(this._listenOnDomNode,(t=>this._onMouseLeave(t))),this._hideTimeout=this._register(new vi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=rt(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,Kt&&(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 pi(t))}_setListeningToMouseWheel(t){this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=rt(this._mouseWheelToDispose),t)&&this._mouseWheelToDispose.push(ki(this._listenOnDomNode,Si.MOUSE_WHEEL,(t=>{this._onMouseWheel(new pi(t))}),{passive:!1}))}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let i=is.INSTANCE;i.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let e=t.deltaY*this._options.mouseWheelScrollSensitivity,h=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&h+e===0?h=e=0:Math.abs(e)>=Math.abs(h)?h=0:e=0),this._options.flipAxes&&([e,h]=[h,e]),(this._options.scrollYToX||!Kt&&t.browserEvent&&t.browserEvent.shiftKey)&&!h&&(h=e,e=0),t.browserEvent&&t.browserEvent.altKey&&(h*=this._options.fastScrollSensitivity,e*=this._options.fastScrollSensitivity);let r=this._scrollable.getFutureScrollPosition(),n={};if(e){let t=50*e;this._verticalScrollbar.writeScrollPosition(n,r.scrollTop-(t<0?Math.floor(t):Math.ceil(t)))}if(h){let t=50*h;this._horizontalScrollbar.writeScrollPosition(n,r.scrollLeft-(t<0?Math.floor(t):Math.ceil(t)))}n=this._scrollable.validateScrollPosition(n),(r.scrollLeft!==n.scrollLeft||r.scrollTop!==n.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(n):this._scrollable.setScrollPositionNow(n),s=!0)}let e=s;!e&&this._options.alwaysConsumeMouseWheel&&(e=!0),!e&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(e=!0),e&&(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 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(),i=t.scrollTop>0,s=t.scrollLeft>0,e=s?" left":"",h=i?" top":"",r=s||i?" top-left-corner":"";this._leftShadowDomNode.setClassName("shadow"+e),this._topShadowDomNode.setClassName("shadow"+h),this._topLeftShadowDomNode.setClassName(`shadow${r}${h}${e}`)}}_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()),500)}},es=class extends ss{constructor(t,i,s){super(t,i,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},hs=class extends lt{constructor(t,i,s,e,h,r,n,o){super(),this._bufferService=s,this._optionsService=n,this._renderService=o,this._onRequestScrollLines=this._register(new Qt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let a=this._register(new Oi({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:t=>xi(e.window,t)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",(()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)}))),this._scrollableElement=this._register(new es(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},a)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],(()=>this._scrollableElement.updateOptions(this._getChangeOptions())))),this._register(h.onProtocolChange((t=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&t)})}))),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ft.runAndSubscribe(r.onChangeColors,(()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css}))),t.appendChild(this._scrollableElement.getDomNode()),this._register(nt((()=>this._scrollableElement.getDomNode().remove()))),this._styleElement=e.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(nt((()=>this._styleElement.remove()))),this._register(ft.runAndSubscribe(r.onChangeColors,(()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}\n.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}\n.xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${r.colors.scrollbarSliderActiveBackground.css};`,"}"].join("\n")}))),this._register(this._bufferService.onResize((()=>this.queueSync()))),this._register(this._bufferService.buffers.onBufferActivate((()=>{this._latestYDisp=void 0,this.queueSync()}))),this._register(this._bufferService.onScroll((()=>this._sync()))),this._register(this._scrollableElement.onScroll((t=>this._handleScroll(t))))}scrollLines(t){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,i){i&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:t*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(t){void 0!==t&&(this._latestYDisp=t),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback((()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)})))}_sync(t=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,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=i-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=i,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};hs=a([l(2,x),l(3,P),l(4,D),l(5,q),l(6,R),l(7,O)],hs);var rs=class extends lt{constructor(t,i,s,e,h){super(),this._screenElement=t,this._bufferService=i,this._coreBrowserService=s,this._decorationService=e,this._renderService=h,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((t=>this._removeDecoration(t)))),this._register(nt((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer","top"===t?.options?.layer),i.style.width=Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)+"px",i.style.height=(t.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(t.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=t.options.x??0;return s&&s>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(t,i),i}_refreshStyle(t){let i=t.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose((()=>{this._decorationElements.delete(t),s.remove()}))),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)+"px",s.style.height=(t.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"),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,i=t.element){if(!i)return;let s=t.options.x??0;"right"===(t.options.anchor||"left")?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(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};rs=a([l(1,x),l(2,P),l(3,H),l(4,O)],rs);var ns,os,as,ls=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(t){if(t.options.overviewRulerOptions){for(let i of this._zones)if(i.color===t.options.overviewRulerOptions.color&&i.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,t.marker.line))return;if(this._lineAdjacentToZone(i,t.marker.line,t.options.overviewRulerOptions.position))return void this._addLineToZone(i,t.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,i){return i>=t.startBufferLine&&i<=t.endBufferLine}_lineAdjacentToZone(t,i,s){return i>=t.startBufferLine-this._linePadding[s||"full"]&&i<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,i){t.startBufferLine=Math.min(t.startBufferLine,i),t.endBufferLine=Math.max(t.endBufferLine,i)}},cs={full:0,left:0,center:0,right:0},us={full:0,left:0,center:0,right:0},As={full:0,left:0,center:0,right:0},fs=class extends lt{constructor(t,i,s,e,h,r,n,o){super(),this._viewportElement=t,this._screenElement=i,this._bufferService=s,this._decorationService=e,this._renderService=h,this._optionsService=r,this._themeService=n,this._coreBrowserService=o,this._colorZoneStore=new ls,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(nt((()=>this._canvas?.remove())));let a=this._canvas.getContext("2d");if(!a)throw Error("Ctx cannot be null");this._ctx=a,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 t=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);us.full=this._canvas.width,us.left=t,us.center=i,us.right=t,this._refreshDrawHeightConstants(),As.full=1,As.left=1,As.center=1+us.left,As.right=1+us.left+us.center}_refreshDrawHeightConstants(){cs.full=Math.round(2*this._coreBrowserService.dpr);let t=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);cs.left=t,cs.center=t,cs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*cs.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=this._width+"px",this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=this._screenElement.clientHeight+"px",this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let i of t)"full"!==i.position&&this._renderColorZone(i);for(let i of t)"full"===i.position&&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(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(As[t.position||"full"],Math.round(t.startBufferLine/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)-cs[t.position||"full"]/2),us[t.position||"full"],Math.round((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)+cs[t.position||"full"]))}_queueRefresh(t,i){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};fs=a([l(2,x),l(3,H),l(4,O),l(5,R),l(6,q),l(7,P)],fs),(t=>{t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="",t.BS="\b",t.HT="\t",t.LF="\n",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="",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""})(ns||={}),(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="Ÿ"})(os||={}),(as||={}).ST=ns.ESC+"\\";var ds=class{constructor(t,i,s,e,h,r){this._textarea=t,this._compositionView=i,this._bufferService=s,this._optionsService=e,this._coreService=h,this._renderService=r,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(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(20===t.keyCode||229===t.keyCode||16===t.keyCode||17===t.keyCode||18===t.keyCode)return!1;this._finalizeComposition(!1)}return 229!==t.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let t={start:this._compositionPosition.start};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,t.start+=this._dataAlreadySent.length,i=this._isComposing?this._textarea.value.substring(t.start,this._compositionPosition.start):this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}}),0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let i=this._textarea.value,s=i.replace(t,"");this._dataAlreadySent=s,i.length>t.length?this._coreService.triggerDataEvent(s,!0):i.length<t.length?this._coreService.triggerDataEvent(""+ns.DEL,!0):i.length===t.length&&i!==t&&this._coreService.triggerDataEvent(i,!0)}}),0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1)*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let e=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(e.width,1)+"px",this._textarea.style.height=Math.max(e.height,1)+"px",this._textarea.style.lineHeight=e.height+"px"}t||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};ds=a([l(2,x),l(3,R),l(4,L),l(5,O)],ds);var gs,ws,ps,Cs,ms,Is=0,vs=0,bs=0,Bs=0,Ms={css:"#00000000",rgba:0};function ys(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Es(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${ys(t)}${ys(i)}${ys(s)}${ys(e)}`:`#${ys(t)}${ys(i)}${ys(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(gs||={}),(t=>{function i(t,i){return Bs=Math.round(255*i),[Is,vs,bs]=ms.toChannels(t.rgba),{css:gs.toCss(Is,vs,bs,Bs),rgba:gs.toRgba(Is,vs,bs,Bs)}}t.blend=function(t,i){if(1==(Bs=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:gs.toCss(Is=h+Math.round(((i.rgba>>24&255)-h)*Bs),vs=r+Math.round((s-r)*Bs),bs=n+Math.round((e-n)*Bs)),rgba:gs.toRgba(Is,vs,bs)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=ms.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return gs.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Is,vs,bs]=ms.toChannels(i),{css:gs.toCss(Is,vs,bs),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(Bs=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(ws||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return Is=parseInt(t.slice(1,2).repeat(2),16),vs=parseInt(t.slice(2,3).repeat(2),16),bs=parseInt(t.slice(3,4).repeat(2),16),gs.toColor(Is,vs,bs);case 5:return Is=parseInt(t.slice(1,2).repeat(2),16),vs=parseInt(t.slice(2,3).repeat(2),16),bs=parseInt(t.slice(3,4).repeat(2),16),Bs=parseInt(t.slice(4,5).repeat(2),16),gs.toColor(Is,vs,bs,Bs);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return gs.toColor(Is=parseInt(e[1]),vs=parseInt(e[2]),bs=parseInt(e[3]),Bs=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Is,vs,bs,Bs]=i.getImageData(0,0,1,1).data,255!==Bs)throw Error("css.toColor: Unsupported css format");return{rgba:gs.toRgba(Is,vs,bs,Bs),css:t}}})(ps||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(Cs||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Es(Cs.relativeLuminance2(n,o,a),Cs.relativeLuminance2(e,h,r));for(;l<s&&(n>0||o>0||a>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l=Es(Cs.relativeLuminance2(n,o,a),Cs.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Es(Cs.relativeLuminance2(n,o,a),Cs.relativeLuminance2(e,h,r));for(;l<s&&(n<255||o<255||a<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Es(Cs.relativeLuminance2(n,o,a),Cs.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(Bs=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return gs.toRgba(Is=h+Math.round(((i>>24&255)-h)*Bs),vs=r+Math.round((s-r)*Bs),bs=n+Math.round((e-n)*Bs))},t.ensureContrastRatio=function(t,e,h){let r=Cs.relativeLuminance(t>>8),n=Cs.relativeLuminance(e>>8);if(Es(r,n)<h){if(n<r){let n=i(t,e,h),o=Es(r,Cs.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Es(r,Cs.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=Es(r,Cs.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>Es(r,Cs.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(ms||={});var Qs=class extends b{constructor(t,i,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ks=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new M}register(t){let i={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(i),i.id}deregister(t){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===t)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(t){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(t);if(!i||0===i.length)return[];let s=[],e=i.translateToString(!0),h=0,r=0,n=0,o=i.getFg(0),a=i.getBg(0);for(let t=0;t<i.getTrimmedLength();t++)if(i.loadCell(t,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==o||this._workCell.bg!==a){if(t-h>1){let t=this._getJoinedRanges(e,n,r,i,h);for(let i=0;i<t.length;i++)s.push(t[i])}h=t,n=r,o=this._workCell.fg,a=this._workCell.bg}r+=this._workCell.getChars().length||1}if(this._bufferService.cols-h>1){let t=this._getJoinedRanges(e,n,r,i,h);for(let i=0;i<t.length;i++)s.push(t[i])}return s}_getJoinedRanges(t,i,s,e,h){let r=t.substring(i,s),n=[];try{n=this._characterJoiners[0].handler(r)}catch(t){console.error(t)}for(let t=1;t<this._characterJoiners.length;t++)try{let i=this._characterJoiners[t].handler(r);for(let t=0;t<i.length;t++)ks._mergeRanges(n,i[t])}catch(t){console.error(t)}return this._stringRangesToCellRanges(n,e,h),n}_stringRangesToCellRanges(t,i,s){let e=0,h=!1,r=0,n=t[e];if(n){for(let o=s;o<this._bufferService.cols;o++){let s=i.getWidth(o),a=i.getString(o).length||1;if(0!==s){if(!h&&n[0]<=r&&(n[0]=o,h=!0),n[1]<=r){if(n[1]=o,n=t[++e],!n)break;n[0]<=r?(n[0]=o,h=!0):h=!1}r+=a}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(t,i){let s=!1;for(let e=0;e<t.length;e++){let h=t[e];if(s){if(i[1]<=h[0])return t[e-1][1]=i[1],t;if(i[1]<=h[1])return t[e-1][1]=Math.max(i[1],h[1]),t.splice(e,1),t;t.splice(e,1),e--}else{if(i[1]<=h[0])return t.splice(e,0,i),t;if(i[1]<=h[1])return h[0]=Math.min(i[0],h[0]),t;i[0]<h[1]&&(h[0]=Math.min(i[0],h[0]),s=!0)}}return s?t[t.length-1][1]=i[1]:t.push(i),t}};ks=a([l(0,x)],ks);var xs=class{constructor(t,i,s,e,h,r,n){this._document=t,this._characterJoinerService=i,this._optionsService=s,this._coreBrowserService=e,this._coreService=h,this._decorationService=r,this._themeService=n,this._workCell=new M,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,i,s){this._selectionStart=t,this._selectionEnd=i,this._columnSelectMode=s}createRow(t,i,s,e,h,r,n,o,a,l,c){let u=[],A=this._characterJoinerService.getJoinedCharacters(i),f=this._themeService.colors,d=t.getNoBgTrimmedLength();s&&d<r+1&&(d=r+1);let g,w=0,p="",C=0,m=0,I=0,B=0,M=!1,y=0,E=!1,Q=0,k=0,x=[],D=-1!==l&&-1!==c;for(let L=0;L<d;L++){t.loadCell(L,this._workCell);let d=this._workCell.getWidth();if(0===d)continue;let _=!1,S=L>=k,$=L,R=this._workCell;if(A.length>0&&L===A[0][0]&&S){let e=A.shift(),h=this._isCellInSelection(e[0],i);for(C=e[0]+1;C<e[1];C++)S&&=h===this._isCellInSelection(C,i);S&&=!s||r<e[0]||r>=e[1],S?(_=!0,R=new Qs(this._workCell,t.translateToString(!0,e[0],e[1]),e[1]-e[0]),$=e[1]-1,d=R.getWidth()):k=e[1]}let N=this._isCellInSelection(L,i),F=s&&L===r,H=D&&L>=l&&L<=c,U=!1;this._decorationService.forEachDecorationAtCell(L,i,void 0,(()=>{U=!0}));let T=R.getChars()||v;if(" "===T&&(R.isUnderline()||R.isOverline())&&(T=" "),Q=d*o-a.get(T,R.isBold(),R.isItalic()),g){if(w&&(N&&E||!N&&!E&&R.bg===m)&&(N&&E&&f.selectionForeground||R.fg===I)&&R.extended.ext===B&&H===M&&Q===y&&!F&&!_&&!U&&S){R.isInvisible()?p+=v:p+=T,w++;continue}w&&(g.textContent=p),g=this._document.createElement("span"),w=0,p=""}else g=this._document.createElement("span");if(m=R.bg,I=R.fg,B=R.extended.ext,M=H,y=Q,E=N,_&&r>=L&&r<=$&&(r=L),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized)if(x.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&x.push("xterm-cursor-blink"),x.push("bar"===e?"xterm-cursor-bar":"underline"===e?"xterm-cursor-underline":"xterm-cursor-block");else if(h)switch(h){case"outline":x.push("xterm-cursor-outline");break;case"block":x.push("xterm-cursor-block");break;case"bar":x.push("xterm-cursor-bar");break;case"underline":x.push("xterm-cursor-underline")}if(R.isBold()&&x.push("xterm-bold"),R.isItalic()&&x.push("xterm-italic"),R.isDim()&&x.push("xterm-dim"),p=R.isInvisible()?v:R.getChars()||v,R.isUnderline()&&(x.push("xterm-underline-"+R.extended.underlineStyle)," "===p&&(p=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${b.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let t=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&t<8&&(t+=8),g.style.textDecorationColor=f.ansi[t].css}R.isOverline()&&(x.push("xterm-overline")," "===p&&(p=" ")),R.isStrikethrough()&&x.push("xterm-strikethrough"),H&&(g.style.textDecoration="underline");let G=R.getFgColor(),P=R.getFgColorMode(),J=R.getBgColor(),O=R.getBgColorMode(),W=!!R.isInverse();if(W){let t=G;G=J,J=t;let i=P;P=O,O=i}let z,q,K,j=!1;switch(this._decorationService.forEachDecorationAtCell(L,i,void 0,(t=>{"top"!==t.options.layer&&j||(t.backgroundColorRGB&&(O=50331648,J=t.backgroundColorRGB.rgba>>8&16777215,z=t.backgroundColorRGB),t.foregroundColorRGB&&(P=50331648,G=t.foregroundColorRGB.rgba>>8&16777215,q=t.foregroundColorRGB),j="top"===t.options.layer)})),!j&&N&&(z=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,J=z.rgba>>8&16777215,O=50331648,j=!0,f.selectionForeground&&(P=50331648,G=f.selectionForeground.rgba>>8&16777215,q=f.selectionForeground)),j&&x.push("xterm-decoration-top"),O){case 16777216:case 33554432:K=f.ansi[J],x.push("xterm-bg-"+J);break;case 50331648:K=gs.toColor(J>>16,J>>8&255,255&J),this._addStyle(g,"background-color:#"+Ds((J>>>0).toString(16),"0",6));break;default:W?(K=f.foreground,x.push("xterm-bg-257")):K=f.background}switch(z||R.isDim()&&(z=ws.multiplyOpacity(K,.5)),P){case 16777216:case 33554432:R.isBold()&&G<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(G+=8),this._applyMinimumContrast(g,K,f.ansi[G],R,z,void 0)||x.push("xterm-fg-"+G);break;case 50331648:let t=gs.toColor(G>>16&255,G>>8&255,255&G);this._applyMinimumContrast(g,K,t,R,z,q)||this._addStyle(g,"color:#"+Ds(G.toString(16),"0",6));break;default:this._applyMinimumContrast(g,K,f.foreground,R,z,q)||W&&x.push("xterm-fg-257")}x.length&&(g.className=x.join(" "),x.length=0),F||_||U||!S?g.textContent=p:w++,Q!==this.defaultSpacing&&(g.style.letterSpacing=Q+"px"),u.push(g),L=$}return g&&w&&(g.textContent=p),u}_applyMinimumContrast(t,i,s,e,h,r){if(1===this._optionsService.rawOptions.minimumContrastRatio||function(t){return function(t){return 57508<=t&&t<=57558}(t)||function(t){return 9472<=t&&t<=9631}(t)}(e.getCode()))return!1;let n,o=this._getContrastCache(e);if(!h&&!r&&(n=o.getColor(i.rgba,s.rgba)),void 0===n){let t=this._optionsService.rawOptions.minimumContrastRatio/(e.isDim()?2:1);n=ws.ensureContrastRatio(h||i,r||s,t),o.setColor((h||i).rgba,(r||s).rgba,n??null)}return!!n&&(this._addStyle(t,"color:"+n.css),!0)}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,i){t.setAttribute("style",`${t.getAttribute("style")||""}${i};`)}_isCellInSelection(t,i){let s=this._selectionStart,e=this._selectionEnd;return!(!s||!e)&&(this._columnSelectMode?s[0]<=e[0]?t>=s[0]&&i>=s[1]&&t<e[0]&&i<=e[1]:t<s[0]&&i>=s[1]&&t>=e[0]&&i<=e[1]:i>s[1]&&i<e[1]||s[1]===e[1]&&i===s[1]&&t>=s[0]&&t<e[0]||s[1]<e[1]&&i===e[1]&&t<e[0]||s[1]<e[1]&&i===s[1]&&t>=s[0])}};function Ds(t,i,s){for(;t.length<s;)t=i+t;return t}xs=a([l(1,z),l(2,R),l(3,P),l(4,L),l(5,H),l(6,q)],xs);var Ls=class{constructor(t,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.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=t.createElement("span");s.classList.add("xterm-char-measure-element");let e=t.createElement("span");e.classList.add("xterm-char-measure-element"),e.style.fontWeight="bold";let h=t.createElement("span");h.classList.add("xterm-char-measure-element"),h.style.fontStyle="italic";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold",r.style.fontStyle="italic",this._measureElements=[s,e,h,r],this._container.appendChild(s),this._container.appendChild(e),this._container.appendChild(h),this._container.appendChild(r),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(t,i,s,e){t===this._font&&i===this._fontSize&&s===this._weight&&e===this._weightBold||(this._font=t,this._fontSize=i,this._weight=s,this._weightBold=e,this._container.style.fontFamily=this._font,this._container.style.fontSize=this._fontSize+"px",this._measureElements[0].style.fontWeight=""+s,this._measureElements[1].style.fontWeight=""+e,this._measureElements[2].style.fontWeight=""+s,this._measureElements[3].style.fontWeight=""+e,this.clear())}get(t,i,s){let e=0;if(!i&&!s&&1===t.length&&(e=t.charCodeAt(0))<256){if(-9999!==this._flat[e])return this._flat[e];let i=this._measure(t,0);return i>0&&(this._flat[e]=i),i}let h=t;i&&(h+="B"),s&&(h+="I");let r=this._holey.get(h);if(void 0===r){let e=0;i&&(e|=1),s&&(e|=2),r=this._measure(t,e),r>0&&this._holey.set(h,r)}return r}_measure(t,i){let s=this._measureElements[i];return s.textContent=t.repeat(32),s.offsetWidth/32}},_s=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,i,s,e=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1])return void this.clear();let h=t.buffers.active.ydisp,r=i[1]-h,n=s[1]-h,o=Math.max(r,0),a=Math.min(n,t.rows-1);o>=t.rows||a<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=e,this.viewportStartRow=r,this.viewportEndRow=n,this.viewportCappedStartRow=o,this.viewportCappedEndRow=a,this.startCol=i[0],this.endCol=s[0])}isCellSelected(t,i,s){return!!this.hasSelection&&(s-=t.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)}},Ss="xterm-dom-renderer-owner-",$s="xterm-rows",Rs="xterm-fg-",Ns="xterm-bg-",Fs="xterm-focus",Hs="xterm-selection",Us=1,Ts=class extends lt{constructor(t,i,s,e,h,r,n,o,a,l,c,u,A,f){super(),this._terminal=t,this._document=i,this._element=s,this._screenElement=e,this._viewportElement=h,this._helperContainer=r,this._linkifier2=n,this._charSizeService=a,this._optionsService=l,this._bufferService=c,this._coreService=u,this._coreBrowserService=A,this._themeService=f,this._terminalClass=Us++,this._rowElements=[],this._selectionRenderModel=new _s,this.onRequestRedraw=this._register(new Qt).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add($s),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(Hs),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this._register(this._themeService.onChangeColors((t=>this._injectCss(t)))),this._injectCss(this._themeService.colors),this._rowFactory=o.createInstance(xs,document),this._element.classList.add(Ss+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline((t=>this._handleLinkHover(t)))),this._register(this._linkifier2.onHideLinkUnderline((t=>this._handleLinkLeave(t)))),this._register(nt((()=>{this._element.classList.remove(Ss+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new Ls(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 t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),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/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),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 t of this._rowElements)t.style.width=this.dimensions.css.canvas.width+"px",t.style.height=this.dimensions.css.cell.height+"px",t.style.lineHeight=this.dimensions.css.cell.height+"px",t.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement)),this._dimensionsStyleElement.textContent=`${this._terminalSelector} .${$s} span { display: inline-block; height: 100%; vertical-align: top;}`,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(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${$s} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${$s} .xterm-dim { color: ${ws.multiplyOpacity(t.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,e="blink_bar_"+this._terminalClass,h="blink_block_"+this._terminalClass;i+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,i+=`@keyframes ${e} { 50% { box-shadow: none; }}`,i+=`@keyframes ${h} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,i+=`${this._terminalSelector} .${$s}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${$s}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${$s}.${Fs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${h} 1s step-end infinite;}${this._terminalSelector} .${$s} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${$s} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${$s} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${$s} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${$s} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${Hs} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Hs} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Hs} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[s,e]of t.ansi.entries())i+=`${this._terminalSelector} .${Rs}${s} { color: ${e.css}; }${this._terminalSelector} .${Rs}${s}.xterm-dim { color: ${ws.multiplyOpacity(e,.5).css}; }${this._terminalSelector} .${Ns}${s} { background-color: ${e.css}; }`;i+=`${this._terminalSelector} .${Rs}257 { color: ${ws.opaque(t.background).css}; }${this._terminalSelector} .${Rs}257.xterm-dim { color: ${ws.multiplyOpacity(ws.opaque(t.background),.5).css}; }${this._terminalSelector} .${Ns}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=t+"px",this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,i){for(let t=this._rowElements.length;t<=i;t++){let t=this._document.createElement("div");this._rowContainer.appendChild(t),this._rowElements.push(t)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,i){this._refreshRowElements(t,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(Fs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Fs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,i,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,i,s),this.renderRows(0,this._bufferService.rows-1),!t||!i||(this._selectionRenderModel.update(this._terminal,t,i,s),!this._selectionRenderModel.hasSelection))return;let e=this._selectionRenderModel.viewportStartRow,h=this._selectionRenderModel.viewportEndRow,r=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,o=this._document.createDocumentFragment();if(s){let s=t[0]>i[0];o.appendChild(this._createSelectionElement(r,s?i[0]:t[0],s?t[0]:i[0],n-r+1))}else o.appendChild(this._createSelectionElement(r,e===r?t[0]:0,r===h?i[0]:this._bufferService.cols)),o.appendChild(this._createSelectionElement(r+1,0,this._bufferService.cols,n-r-1)),r!==n&&o.appendChild(this._createSelectionElement(n,0,h===n?i[0]:this._bufferService.cols));this._selectionContainer.appendChild(o)}_createSelectionElement(t,i,s,e=1){let h=this._document.createElement("div"),r=i*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-i);return r+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-r),h.style.height=e*this.dimensions.css.cell.height+"px",h.style.top=t*this.dimensions.css.cell.height+"px",h.style.left=r+"px",h.style.width=n+"px",h}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 t of this._rowElements)t.replaceChildren()}renderRows(t,i){let s=this._bufferService.buffer,e=s.ybase+s.y,h=Math.min(s.x,this._bufferService.cols-1),r=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,o=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=t;a<=i;a++){let t=a+s.ydisp,i=this._rowElements[a],l=s.lines.get(t);if(!i||!l)break;i.replaceChildren(...this._rowFactory.createRow(l,t,t===e,n,o,h,r,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ss}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,i,s,e,h,r){s<0&&(t=0),e<0&&(i=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),e=Math.max(Math.min(e,n),0);let o=this._bufferService.buffer,a=o.ybase+o.y,l=Math.min(o.x,(h=Math.min(h,this._bufferService.cols))-1),c=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,A=this._optionsService.rawOptions.cursorInactiveStyle;for(let n=s;n<=e;++n){let f=n+o.ydisp,d=this._rowElements[n],g=o.lines.get(f);if(!d||!g)break;d.replaceChildren(...this._rowFactory.createRow(g,f,f===a,u,A,l,c,this.dimensions.css.cell.width,this._widthCache,r?n===s?t:0:-1,r?(n===e?i:h)-1:-1))}}};Ts=a([l(7,S),l(8,G),l(9,R),l(10,x),l(11,L),l(12,P),l(13,q)],Ts);var Gs=class extends lt{constructor(t,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Qt),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Os(this._optionsService))}catch{this._measureStrategy=this._register(new Js(t,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Gs=a([l(2,R)],Gs);var Ps=class extends lt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,i){void 0!==t&&t>0&&void 0!==i&&i>0&&(this._result.width=t,this._result.height=i)}},Js=class extends Ps{constructor(t,i,s){super(),this._document=t,this._parentElement=i,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=this._optionsService.rawOptions.fontSize+"px",this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Os=class extends Ps{constructor(t){super(),this._optionsService=t,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 Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},Ws=class extends lt{constructor(t,i,s){super(),this._textarea=t,this._window=i,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new zs(this._window)),this._onDprChange=this._register(new Qt),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Qt),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange((t=>this._screenDprMonitor.setWindow(t)))),this._register(ft.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ki(this._textarea,"focus",(()=>this._isFocused=!0))),this._register(ki(this._textarea,"blur",(()=>this._isFocused=!1)))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}},zs=class extends lt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new ct),this._onDprChange=this._register(new Qt),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(nt((()=>this.clearListener())))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ki(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)}},qs=class extends lt{constructor(){super(),this.linkProviders=[],this._register(nt((()=>this.linkProviders.length=0)))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let i=this.linkProviders.indexOf(t);-1!==i&&this.linkProviders.splice(i,1)}}}};function Ks(t,i,s){let e=s.getBoundingClientRect(),h=t.getComputedStyle(s),r=parseInt(h.getPropertyValue("padding-left")),n=parseInt(h.getPropertyValue("padding-top"));return[i.clientX-e.left-r,i.clientY-e.top-n]}var js=class{constructor(t,i){this._renderService=t,this._charSizeService=i}getCoords(t,i,s,e,h){return function(t,i,s,e,h,r,n,o,a){if(!r)return;let l=Ks(t,i,s);return l?(l[0]=Math.ceil((l[0]+(a?n/2:0))/n),l[1]=Math.ceil(l[1]/o),l[0]=Math.min(Math.max(l[0],1),e+(a?1:0)),l[1]=Math.min(Math.max(l[1],1),h),l):void 0}(window,t,i,s,e,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,h)}getMouseReportCoords(t,i){let s=Ks(window,t,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])}}};js=a([l(0,O),l(1,G)],js);var Ys=class{constructor(t,i){this._renderCallback=t,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(t,i,s){this._rowCount=s,t=void 0!==t?t:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,t):t,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let t=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},Zs={};((t,i)=>{for(var s in i)n(t,s,{get:i[s],enumerable:!0})})(Zs,{getSafariVersion:()=>he,isChromeOS:()=>ce,isFirefox:()=>ie,isIpad:()=>ne,isIphone:()=>oe,isLegacyEdge:()=>se,isLinux:()=>le,isMac:()=>re,isNode:()=>Xs,isSafari:()=>ee,isWindows:()=>ae});var Xs=typeof process<"u"&&"title"in process,Vs=Xs?"node":navigator.userAgent,te=Xs?"node":navigator.platform,ie=Vs.includes("Firefox"),se=Vs.includes("Edge"),ee=/^((?!chrome|android).)*safari/i.test(Vs);function he(){if(!ee)return 0;let t=Vs.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}var re=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(te),ne="iPad"===te,oe="iPhone"===te,ae=["Windows","Win16","Win32","WinCE"].includes(te),le=te.indexOf("Linux")>=0,ce=/\bCrOS\b/.test(Vs),ue=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 i=0,s=0,e=t.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,i=Math.max(1,performance.now()-i),s=Math.max(i,s),h=t.timeRemaining(),1.5*s>h)return e-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(e-i))}ms`),void this._start();e=h}this.clear()}},Ae=!Xs&&"requestIdleCallback"in window?class extends ue{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends ue{_requestCallback(t){return setTimeout((()=>t(this._createDeadline(16))))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let i=performance.now()+t;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},fe=class{constructor(){this._queue=new Ae}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},de=class extends lt{constructor(t,i,s,e,h,r,n,o,a){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=e,this._coreService=h,this._coreBrowserService=o,this._renderer=this._register(new ct),this._pausedResizeTask=new fe,this._observerDisposable=this._register(new ct),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 Qt),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Qt),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Qt),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Qt),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Ys(((t,i)=>this._renderRows(t,i)),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ge(this._coreBrowserService,this._coreService,(()=>this._fullRefresh())),this._register(nt((()=>this._syncOutputHandler.dispose()))),this._register(this._coreBrowserService.onDprChange((()=>this.handleDevicePixelRatioChange()))),this._register(n.onResize((()=>this._fullRefresh()))),this._register(n.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this._register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this._register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this._register(r.onDecorationRegistered((()=>this._fullRefresh()))),this._register(r.onDecorationRemoved((()=>this._fullRefresh()))),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()}))),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(n.buffer.y,n.buffer.y,!0)))),this._register(a.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange((t=>this._registerIntersectionObserver(t,i))))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,i){if("IntersectionObserver"in t){let s=new t.IntersectionObserver((t=>this._handleIntersectionChange(t[t.length-1])),{threshold:0});s.observe(i),this._observerDisposable.value=nt((()=>s.disconnect()))}}_handleIntersectionChange(t){this._isPaused=void 0===t.isIntersecting?0===t.intersectionRatio:!t.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(t,i,s=!1){if(this._isPaused)return void(this._needsFullRefresh=!0);if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(t,i);let e=this._syncOutputHandler.flush();e&&(t=Math.min(t,e.start),i=Math.max(i,e.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,i,this._rowCount)}_renderRows(t,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(t,i);this._renderer.value.renderRows(t=Math.min(t,this._rowCount-1),i=Math.min(i,this._rowCount-1)),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:i}),this._onRender.fire({start:t,end:i}),this._isNextRenderRedrawOnly=!0}}resize(t,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(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw((t=>this.refreshRows(t.start,t.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_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(t,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(t,i))):this._renderer.value.handleResize(t,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,i,s){this._selectionState.start=t,this._selectionState.end=i,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,i,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};de=a([l(2,R),l(3,G),l(4,L),l(5,H),l(6,x),l(7,P),l(8,q)],de);var ge=class{constructor(t,i,s){this._coreBrowserService=t,this._coreService=i,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,i){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,i)):(this._start=t,this._end=i,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout((()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()}),1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function we(t,i,s,e){let h=t-pe(t,s),r=i-pe(i,s),n=Math.abs(h-r)-function(t,i,s){let e=0,h=t-pe(t,s),r=i-pe(i,s);for(let n=0;n<Math.abs(h-r);n++){let r="A"===Ce(t,i)?-1:1;s.buffer.lines.get(h+r*n)?.isWrapped&&e++}return e}(t,i,s);return ve(n,Ie(Ce(t,i),e))}function pe(t,i){let s=0,e=i.buffer.lines.get(t),h=e?.isWrapped;for(;h&&t>=0&&t<i.rows;)s++,e=i.buffer.lines.get(--t),h=e?.isWrapped;return s}function Ce(t,i){return t>i?"A":"B"}function me(t,i,s,e,h,r){let n=t,o=i,a="";for(;(n!==s||o!==e)&&o>=0&&o<r.buffer.lines.length;)n+=h?1:-1,h&&n>r.cols-1?(a+=r.buffer.translateBufferLineToString(o,!1,t,n),n=0,t=0,o++):!h&&n<0&&(a+=r.buffer.translateBufferLineToString(o,!1,0,t+1),n=r.cols-1,t=n,o--);return a+r.buffer.translateBufferLineToString(o,!1,t,n)}function Ie(t,i){return ns.ESC+(i?"O":"[")+t}function ve(t,i){t=Math.floor(t);let s="";for(let e=0;e<t;e++)s+=i;return s}var be=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.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,i=this.selectionEnd;return!(!t||!i)&&(t[1]>i[1]||t[1]===i[1]&&t[0]>i[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 Be(t,i){if(t.start.y>t.end.y)throw Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return i*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Me=/ /g,ye=class extends lt{constructor(t,i,s,e,h,r,n,o,a){super(),this._element=t,this._screenElement=i,this._linkifier=s,this._bufferService=e,this._coreService=h,this._mouseService=r,this._optionsService=n,this._renderService=o,this._coreBrowserService=a,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new M,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Qt),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Qt),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Qt),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Qt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=t=>this._handleMouseMove(t),this._mouseUpListener=t=>this._handleMouseUp(t),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((t=>this._handleTrim(t))),this._register(this._bufferService.buffers.onBufferActivate((t=>this._handleBufferActivate(t)))),this.enable(),this._model=new be(this._bufferService),this._activeSelectionMode=0,this._register(nt((()=>{this._removeMouseDownListeners()}))),this._register(this._bufferService.onResize((t=>{t.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 t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!(!t||!i||t[0]===i[0]&&t[1]===i[1])}get selectionText(){let t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!t||!i)return"";let s=this._bufferService.buffer,e=[];if(3===this._activeSelectionMode){if(t[0]===i[0])return"";let h=t[0]<i[0]?t[0]:i[0],r=t[0]<i[0]?i[0]:t[0];for(let n=t[1];n<=i[1];n++){let t=s.translateBufferLineToString(n,!0,h,r);e.push(t)}}else{e.push(s.translateBufferLineToString(t[1],!0,t[0],t[1]===i[1]?i[0]:void 0));for(let h=t[1]+1;h<=i[1]-1;h++){let t=s.lines.get(h),i=s.translateBufferLineToString(h,!0);t?.isWrapped?e[e.length-1]+=i:e.push(i)}if(t[1]!==i[1]){let t=s.lines.get(i[1]),h=s.translateBufferLineToString(i[1],!0,0,i[0]);t&&t.isWrapped?e[e.length-1]+=h:e.push(h)}}return e.map((t=>t.replace(Me," "))).join(ae?"\r\n":"\n")}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),le&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(t){let i=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!!(s&&e&&i)&&this._areCoordsInSelection(i,s,e)}isCellInSelection(t,i){let s=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!(!s||!e)&&this._areCoordsInSelection([t,i],s,e)}_areCoordsInSelection(t,i,s){return t[1]>i[1]&&t[1]<s[1]||i[1]===s[1]&&t[1]===i[1]&&t[0]>=i[0]&&t[0]<s[0]||i[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||i[1]<s[1]&&t[1]===i[1]&&t[0]>=i[0]}_selectWordAtCursor(t,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=Be(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let e=this._getMouseBufferCoords(t);return!!e&&(this._selectWordAt(e,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,i){this._model.clearSelection(),t=Math.max(t,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let i=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(t){let i=Ks(this._coreBrowserService.window,t,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,-50),50),i/=50,i/Math.abs(i)+Math.round(14*i))}shouldForceSelection(t){return re?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,(2!==t.button||!this.hasSelection)&&0===t.button){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):1===t.detail?this._handleSingleClick(t):2===t.detail?this._handleDoubleClick(t):3===t.detail&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!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]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let i=this._getMouseBufferCoords(t);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(t){return t.altKey&&!(re&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.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(t),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[0]=this._model.selectionEnd[1]<this._model.selectionStart[1]?0:this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),3!==this._activeSelectionMode&&(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 t=s.lines.get(this._model.selectionEnd[1]);t&&0===t.hasWidth(this._model.selectionEnd[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 t=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let i=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let t=function(t,i,s,e){let h,r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return function(t,i,s,e,h,r){return 0===we(i,e,h,r).length?"":ve(me(t,i,t,i-pe(i,h),!1,h).length,Ie("D",r))}(r,n,0,i,s,e)+we(n,i,s,e)+function(t,i,s,e,h,r){let n;n=we(i,e,h,r).length>0?e-pe(e,h):i;let o=e,a=function(t,i,s,e,h,r){let n;return n=we(s,e,h,r).length>0?e-pe(e,h):i,t<s&&n<=e||t>=s&&n<e?"C":"D"}(t,i,s,e,h,r);return ve(me(t,n,s,o,"C"===a,h).length,Ie(a,r))}(r,n,t,i,s,e);if(n===i)return h=r>t?"D":"C",ve(Math.abs(r-t),Ie(h,e));h=n>i?"D":"C";let o=Math.abs(n-i),a=function(t,i){return i.cols-t}(n>i?t:r,s)+(o-1)*s.cols+1+function(t){return t-1}(n>i?r:t);return ve(a,Ie(h,e))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(t,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,s=!(!t||!i||t[0]===i[0]&&t[1]===i[1]);s?!t||!i||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||i[0]!==this._oldSelectionEnd[0]||i[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,i,s):this._oldHasSelection&&this._fireOnSelectionChange(t,i,s)}_fireOnSelectionChange(t,i,s){this._oldSelectionStart=t,this._oldSelectionEnd=i,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim((t=>this._handleTrim(t)))}_convertViewportColToCharacterIndex(t,i){let s=i;for(let e=0;i>=e;e++){let h=t.loadCell(e,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:h>1&&i!==e&&(s+=h-1)}return s}setSelection(t,i,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,i],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,i,s=!0,e=!0){if(t[0]>=this._bufferService.cols)return;let h=this._bufferService.buffer,r=h.lines.get(t[1]);if(!r)return;let n=h.translateBufferLineToString(t[1],!1),o=this._convertViewportColToCharacterIndex(r,t[0]),a=o,l=t[0]-o,c=0,u=0,A=0,f=0;if(" "===n.charAt(o)){for(;o>0&&" "===n.charAt(o-1);)o--;for(;a<n.length&&" "===n.charAt(a+1);)a++}else{let i=t[0],s=t[0];0===r.getWidth(i)&&(c++,i--),2===r.getWidth(s)&&(u++,s++);let e=r.getString(s).length;for(e>1&&(f+=e-1,a+=e-1);i>0&&o>0&&!this._isCharWordSeparator(r.loadCell(i-1,this._workCell));){r.loadCell(i-1,this._workCell);let t=this._workCell.getChars().length;0===this._workCell.getWidth()?(c++,i--):t>1&&(A+=t-1,o-=t-1),o--,i--}for(;s<r.length&&a+1<n.length&&!this._isCharWordSeparator(r.loadCell(s+1,this._workCell));){r.loadCell(s+1,this._workCell);let t=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,s++):t>1&&(f+=t-1,a+=t-1),a++,s++}}a++;let d=o+l-c+A,g=Math.min(this._bufferService.cols,a-o+c+u-A-f);if(i||""!==n.slice(o,a).trim()){if(s&&0===d&&32!==r.getCodePoint(0)){let i=h.lines.get(t[1]-1);if(i&&r.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(i){let t=this._bufferService.cols-i.start;d-=t,g+=t}}}if(e&&d+g===this._bufferService.cols&&32!==r.getCodePoint(this._bufferService.cols-1)){let i=h.lines.get(t[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,t[1]+1],!1,!1,!0);i&&(g+=i.length)}}return{start:d,length:g}}}_selectWordAt(t,i){let s=this._getWordAt(t,i);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let i=this._getWordAt(t,!0);if(i){let s=t[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(t){return 0!==t.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let i=this._bufferService.buffer.getWrappedRangeForLine(t),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=Be(s,this._bufferService.cols)}};ye=a([l(3,x),l(4,L),l(5,J),l(6,R),l(7,O),l(8,P)],ye);var Ee=class{constructor(){this._data={}}set(t,i,s){this._data[t]||(this._data[t]={}),this._data[t][i]=s}get(t,i){return this._data[t]?this._data[t][i]:void 0}clear(){this._data={}}},Qe=class{constructor(){this._color=new Ee,this._css=new Ee}setCss(t,i,s){this._css.set(t,i,s)}getCss(t,i){return this._css.get(t,i)}setColor(t,i,s){this._color.set(t,i,s)}getColor(t,i){return this._color.get(t,i)}clear(){this._color.clear(),this._css.clear()}},ke=Object.freeze((()=>{let t=[ps.toColor("#2e3436"),ps.toColor("#cc0000"),ps.toColor("#4e9a06"),ps.toColor("#c4a000"),ps.toColor("#3465a4"),ps.toColor("#75507b"),ps.toColor("#06989a"),ps.toColor("#d3d7cf"),ps.toColor("#555753"),ps.toColor("#ef2929"),ps.toColor("#8ae234"),ps.toColor("#fce94f"),ps.toColor("#729fcf"),ps.toColor("#ad7fa8"),ps.toColor("#34e2e2"),ps.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let s=0;s<216;s++){let e=i[s/36%6|0],h=i[s/6%6|0],r=i[s%6];t.push({css:gs.toCss(e,h,r),rgba:gs.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:gs.toCss(s,s,s),rgba:gs.toRgba(s,s,s)})}return t})()),xe=ps.toColor("#ffffff"),De=ps.toColor("#000000"),Le=ps.toColor("#ffffff"),_e=De,Se={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},$e=xe,Re=class extends lt{constructor(t){super(),this._optionsService=t,this._contrastCache=new Qe,this._halfContrastCache=new Qe,this._onChangeColors=this._register(new Qt),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:xe,background:De,cursor:Le,cursorAccent:_e,selectionForeground:void 0,selectionBackgroundTransparent:Se,selectionBackgroundOpaque:ws.blend(De,Se),selectionInactiveBackgroundTransparent:Se,selectionInactiveBackgroundOpaque:ws.blend(De,Se),scrollbarSliderBackground:ws.opacity(xe,.2),scrollbarSliderHoverBackground:ws.opacity(xe,.4),scrollbarSliderActiveBackground:ws.opacity(xe,.5),overviewRulerBorder:xe,ansi:ke.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(t={}){let i=this._colors;if(i.foreground=Ne(t.foreground,xe),i.background=Ne(t.background,De),i.cursor=ws.blend(i.background,Ne(t.cursor,Le)),i.cursorAccent=ws.blend(i.background,Ne(t.cursorAccent,_e)),i.selectionBackgroundTransparent=Ne(t.selectionBackground,Se),i.selectionBackgroundOpaque=ws.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=Ne(t.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=ws.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=t.selectionForeground?Ne(t.selectionForeground,Ms):void 0,i.selectionForeground===Ms&&(i.selectionForeground=void 0),ws.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=ws.opacity(i.selectionBackgroundTransparent,.3)),ws.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=ws.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=Ne(t.scrollbarSliderBackground,ws.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=Ne(t.scrollbarSliderHoverBackground,ws.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=Ne(t.scrollbarSliderActiveBackground,ws.opacity(i.foreground,.5)),i.overviewRulerBorder=Ne(t.overviewRulerBorder,$e),i.ansi=ke.slice(),i.ansi[0]=Ne(t.black,ke[0]),i.ansi[1]=Ne(t.red,ke[1]),i.ansi[2]=Ne(t.green,ke[2]),i.ansi[3]=Ne(t.yellow,ke[3]),i.ansi[4]=Ne(t.blue,ke[4]),i.ansi[5]=Ne(t.magenta,ke[5]),i.ansi[6]=Ne(t.cyan,ke[6]),i.ansi[7]=Ne(t.white,ke[7]),i.ansi[8]=Ne(t.brightBlack,ke[8]),i.ansi[9]=Ne(t.brightRed,ke[9]),i.ansi[10]=Ne(t.brightGreen,ke[10]),i.ansi[11]=Ne(t.brightYellow,ke[11]),i.ansi[12]=Ne(t.brightBlue,ke[12]),i.ansi[13]=Ne(t.brightMagenta,ke[13]),i.ansi[14]=Ne(t.brightCyan,ke[14]),i.ansi[15]=Ne(t.brightWhite,ke[15]),t.extendedAnsi){let s=Math.min(i.ansi.length-16,t.extendedAnsi.length);for(let e=0;e<s;e++)i.ansi[e+16]=Ne(t.extendedAnsi[e],ke[e+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(void 0!==t)switch(t){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[t]=this._restoreColors.ansi[t]}else for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t]}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function Ne(t,i){if(void 0!==t)try{return ps.toColor(t)}catch{}return i}Re=a([l(0,R)],Re);var Fe=class{constructor(...t){this._entries=new Map;for(let[i,s]of t)this.set(i,s)}set(t,i){let s=this._entries.get(t);return this._entries.set(t,i),s}forEach(t){for(let[i,s]of this._entries.entries())t(i,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},He=class{constructor(){this._services=new Fe,this._services.set(S,this)}setService(t,i){this._services.set(t,i)}getService(t){return this._services.get(t)}createInstance(t,...i){let s=function(t){return t[E]||[]}(t).sort(((t,i)=>t.index-i.index)),e=[];for(let i of s){let s=this._services.get(i.id);if(!s)throw Error(`[createInstance] ${t.name} depends on UNKNOWN service ${i.id._id}.`);e.push(s)}let h=s.length>0?s[0].index:i.length;if(i.length!==h)throw Error(`[createInstance] First service dependency of ${t.name} at position ${h+1} conflicts with ${i.length} static arguments`);return new t(...i,...e)}},Ue={trace:0,debug:1,info:2,warn:3,error:4,off:5},Te=class extends lt{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=Ue[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let i=0;i<t.length;i++)"function"==typeof t[i]&&(t[i]=t[i]())}_log(t,i,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...s)}trace(t,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,i)}debug(t,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,i)}info(t,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,i)}warn(t,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,i)}error(t,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,i)}};Te=a([l(0,R)],Te);var Ge=class extends lt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Qt),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Qt),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Qt),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let i=Array(t);for(let s=0;s<Math.min(t,this.length);s++)i[s]=this._array[this._getCyclicIndex(s)];this._array=i,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let i=this._length;i<t;i++)this._array[i]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,i){this._array[this._getCyclicIndex(t)]=i}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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(t,i,...s){if(i){for(let s=t;s<this._length-i;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+i)];this._length-=i,this.onDeleteEmitter.fire({index:t,amount:i})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let t=this._length+s.length-this._maxLength;this._startIndex+=t,this._length=this._maxLength,this.onTrimEmitter.fire(t)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,i,s){if(!(i<=0)){if(t<0||t>=this._length)throw Error("start argument out of range");if(t+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let e=i-1;e>=0;e--)this.set(t+e+s,this.get(t+e));let e=t+i+s-this._length;if(e>0)for(this._length+=e;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let e=0;e<i;e++)this.set(t+e+s,this.get(t+e))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},Pe=Object.freeze(new b),Je=0,Oe=class t{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*t);let e=i||M.fromCharData([0,"",1,0]);for(let i=0;i<t;++i)this.setCell(i,e);this.length=t}get(t){let i=this._data[3*t+0],s=2097151&i;return[this._data[3*t+1],2097152&i?this._combined[t]:s?p(s):"",i>>22,2097152&i?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[3*t+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[3*t+0]=2097152|t|i[2]<<22):this._data[3*t+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[3*t+0]>>22}hasWidth(t){return 12582912&this._data[3*t+0]}getFg(t){return this._data[3*t+1]}getBg(t){return this._data[3*t+2]}hasContent(t){return 4194303&this._data[3*t+0]}getCodePoint(t){let i=this._data[3*t+0];return 2097152&i?this._combined[t].charCodeAt(this._combined[t].length-1):2097151&i}isCombined(t){return 2097152&this._data[3*t+0]}getString(t){let i=this._data[3*t+0];return 2097152&i?this._combined[t]:2097151&i?p(2097151&i):""}isProtected(t){return 536870912&this._data[3*t+2]}loadCell(t,i){return i.content=this._data[0+(Je=3*t)],i.fg=this._data[Je+1],i.bg=this._data[Je+2],2097152&i.content&&(i.combinedData=this._combined[t]),268435456&i.bg&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){2097152&i.content&&(this._combined[t]=i.combinedData),268435456&i.bg&&(this._extendedAttrs[t]=i.extended),this._data[3*t+0]=i.content,this._data[3*t+1]=i.fg,this._data[3*t+2]=i.bg}setCellFromCodepoint(t,i,s,e){268435456&e.bg&&(this._extendedAttrs[t]=e.extended),this._data[3*t+0]=i|s<<22,this._data[3*t+1]=e.fg,this._data[3*t+2]=e.bg}addCodepointToCell(t,i,s){let e=this._data[3*t+0];2097152&e?this._combined[t]+=p(i):2097151&e?(this._combined[t]=p(2097151&e)+p(i),e&=-2097152,e|=2097152):e=i|1<<22,s&&(e&=-12582913,e|=s<<22),this._data[3*t+0]=e}insertCells(t,i,s){if((t%=this.length)&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let e=new M;for(let s=this.length-t-i-1;s>=0;--s)this.setCell(t+i+s,this.loadCell(t+s,e));for(let e=0;e<i;++e)this.setCell(t+e,s)}else for(let i=t;i<this.length;++i)this.setCell(i,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(i<this.length-(t%=this.length)){let e=new M;for(let s=0;s<this.length-t-i;++s)this.setCell(t+s,this.loadCell(t+i+s,e));for(let t=this.length-i;t<this.length;++t)this.setCell(t,s)}else for(let i=t;i<this.length;++i)this.setCell(i,s);t&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),0===this.getWidth(t)&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,e=!1){if(e)for(t&&2===this.getWidth(t-1)&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;else for(t&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*t;if(t>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let t=new Uint32Array(s);t.set(this._data),this._data=t}for(let s=this.length;s<t;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,s);let i=Object.keys(this._combined);for(let s=0;s<i.length;s++){let e=parseInt(i[s],10);e>=t&&delete this._combined[e]}let e=Object.keys(this._extendedAttrs);for(let i=0;i<e.length;i++){let s=parseInt(e[i],10);s>=t&&delete this._extendedAttrs[s]}}return this.length=t,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i)for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);else{this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let i=new t(0);i._data=new Uint32Array(this._data),i.length=this.length;for(let t in this._combined)i._combined[t]=this._combined[t];for(let t in this._extendedAttrs)i._extendedAttrs[t]=this._extendedAttrs[t];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(4194303&this._data[3*t+0])return t+(this._data[3*t+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(4194303&this._data[3*t+0]||50331648&this._data[3*t+2])return t+(this._data[3*t+0]>>22);return 0}copyCellsFrom(t,i,s,e,h){let r=t._data;if(h)for(let h=e-1;h>=0;h--){for(let t=0;t<3;t++)this._data[3*(s+h)+t]=r[3*(i+h)+t];268435456&r[3*(i+h)+2]&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<e;h++){for(let t=0;t<3;t++)this._data[3*(s+h)+t]=r[3*(i+h)+t];268435456&r[3*(i+h)+2]&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let n=Object.keys(t._combined);for(let e=0;e<n.length;e++){let h=parseInt(n[e],10);h>=i&&(this._combined[h-i+s]=t._combined[h])}}translateToString(t,i,s,e){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),e&&(e.length=0);let h="";for(;i<s;){let t=this._data[3*i+0],s=2097151&t,r=2097152&t?this._combined[i]:s?p(s):v;if(h+=r,e)for(let t=0;t<r.length;++t)e.push(i);i+=t>>22||1}return e&&e.push(i),h}};function We(t,i,s){let e=[],h=t.map(((s,e)=>ze(t,e,i))).reduce(((t,i)=>t+i)),r=0,n=0,o=0;for(;o<h;){if(h-o<s){e.push(h-o);break}r+=s;let a=ze(t,n,i);r>a&&(r-=a,n++);let l=2===t[n].getWidth(r-1);l&&r--;let c=l?s-1:s;e.push(c),o+=c}return e}function ze(t,i,s){if(i===t.length-1)return t[i].getTrimmedLength();let e=!t[i].hasContent(s-1)&&1===t[i].getWidth(s-1),h=2===t[i+1].getWidth(0);return e&&h?s-1:s}var qe=class t{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=t._nextId++,this._onDispose=this.register(new Qt),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),rt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};qe._nextId=1;var Ke=qe,je={},Ye=je.B;je[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:"≥","{":"π","|":"≠","}":"£","~":"·"},je.A={"#":"£"},je.B=void 0,je[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},je.C=je[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},je.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},je.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},je.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},je.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},je.E=je[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},je.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},je.H=je[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},je["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ze=4294967295,Xe=class{constructor(t,i,s){this._hasScrollback=t,this._optionsService=i,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Pe.clone(),this.savedCharset=Ye,this.markers=[],this._nullCell=M.fromCharData([0,"",1,0]),this._whitespaceCell=M.fromCharData([0,v,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ae,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ge(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 B),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 B),this._whitespaceCell}getBlankLine(t,i){return new Oe(this._bufferService.cols,this.getNullCell(t),i)}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 i=t+this._optionsService.rawOptions.scrollback;return i>Ze?Ze:i}fillViewportRows(t){if(0===this.lines.length){void 0===t&&(t=Pe);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Ge(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,i){let s=this.getNullCell(Pe),e=0,h=this._getCorrectBufferLength(i);if(h>this.lines.maxLength&&(this.lines.maxLength=h),this.lines.length>0){if(this._cols<t)for(let i=0;i<this.lines.length;i++)e+=+this.lines.get(i).resize(t,s);let r=0;if(this._rows<i)for(let e=this._rows;e<i;e++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new Oe(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+r+1?(this.ybase--,r++,this.ydisp>0&&this.ydisp--):this.lines.push(new Oe(t,s)));else for(let t=this._rows;t>i;t--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(h<this.lines.maxLength){let t=this.lines.length-h;t>0&&(this.lines.trimStart(t),this.ybase=Math.max(this.ybase-t,0),this.ydisp=Math.max(this.ydisp-t,0),this.savedY=Math.max(this.savedY-t,0)),this.lines.maxLength=h}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,i-1),r&&(this.y+=r),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(t,i),this._cols>t))for(let i=0;i<this.lines.length;i++)e+=+this.lines.get(i).resize(t,s);this._cols=t,this._rows=i,this._memoryCleanupQueue.clear(),e>.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 i=0;for(;this._memoryCleanupPosition<this.lines.length;)if(i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),i>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&"conpty"===t.backend&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,i){this._cols!==t&&(t>this._cols?this._reflowLarger(t,i):this._reflowSmaller(t,i))}_reflowLarger(t,i){let s=this._optionsService.rawOptions.reflowCursorLine,e=function(t,i,s,e,h,r){let n=[];for(let o=0;o<t.length-1;o++){let a=o,l=t.get(++a);if(!l.isWrapped)continue;let c=[t.get(o)];for(;a<t.length&&l.isWrapped;)c.push(l),l=t.get(++a);if(!r&&e>=o&&e<a){o+=c.length-1;continue}let u=0,A=ze(c,u,i),f=1,d=0;for(;f<c.length;){let t=ze(c,f,i),e=Math.min(t-d,s-A);c[u].copyCellsFrom(c[f],d,A,e,!1),A+=e,A===s&&(u++,A=0),d+=e,d===t&&(f++,d=0),0===A&&0!==u&&2===c[u-1].getWidth(s-1)&&(c[u].copyCellsFrom(c[u-1],s-1,A++,1,!1),c[u-1].setCell(s-1,h))}c[u].replaceCells(A,s,h);let g=0;for(let t=c.length-1;t>0&&(t>u||0===c[t].getTrimmedLength());t--)g++;g>0&&(n.push(o+c.length-g),n.push(g)),o+=c.length-1}return n}(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Pe),s);if(e.length>0){let s=function(t,i){let s=[],e=0,h=i[e],r=0;for(let n=0;n<t.length;n++)if(h===n){let s=i[++e];t.onDeleteEmitter.fire({index:n-r,amount:s}),n+=s-1,r+=s,h=i[++e]}else s.push(n);return{layout:s,countRemoved:r}}(this.lines,e);(function(t,i){let s=[];for(let e=0;e<i.length;e++)s.push(t.get(i[e]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=i.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(t,i,s.countRemoved)}}_reflowLargerAdjustViewport(t,i,s){let e=this.getNullCell(Pe),h=s;for(;h-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new Oe(t,e))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,i){let s=this._optionsService.rawOptions.reflowCursorLine,e=this.getNullCell(Pe),h=[],r=0;for(let n=this.lines.length-1;n>=0;n--){let o=this.lines.get(n);if(!o||!o.isWrapped&&o.getTrimmedLength()<=t)continue;let a=[o];for(;o.isWrapped&&n>0;)o=this.lines.get(--n),a.unshift(o);if(!s){let t=this.ybase+this.y;if(t>=n&&t<n+a.length)continue}let l,c=a[a.length-1].getTrimmedLength(),u=We(a,this._cols,t),A=u.length-a.length;l=Math.max(0,0===this.ybase&&this.y!==this.lines.length-1?this.y-this.lines.maxLength+A:this.lines.length-this.lines.maxLength+A);let f=[];for(let t=0;t<A;t++){let t=this.getBlankLine(Pe,!0);f.push(t)}f.length>0&&(h.push({start:n+a.length+r,newLines:f}),r+=f.length),a.push(...f);let d=u.length-1,g=u[d];0===g&&(d--,g=u[d]);let w=a.length-A-1,p=c;for(;w>=0;){let t=Math.min(p,g);if(void 0===a[d])break;a[d].copyCellsFrom(a[w],p-t,g-t,t,!0),g-=t,0===g&&(d--,g=u[d]),p-=t,0===p&&(w--,p=ze(a,Math.max(w,0),this._cols))}for(let i=0;i<a.length;i++)u[i]<t&&a[i].setCell(u[i],e);let C=A-l;for(;C-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+A,this.ybase+i-1)}if(h.length>0){let t=[],i=[];for(let t=0;t<this.lines.length;t++)i.push(this.lines.get(t));let s=this.lines.length,e=s-1,n=0,o=h[n];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let a=0;for(let l=Math.min(this.lines.maxLength-1,s+r-1);l>=0;l--)if(o&&o.start>e+a){for(let t=o.newLines.length-1;t>=0;t--)this.lines.set(l--,o.newLines[t]);l++,t.push({index:e+1,amount:o.newLines.length}),a+=o.newLines.length,o=h[++n]}else this.lines.set(l,i[e--]);let l=0;for(let i=t.length-1;i>=0;i--)t[i].index+=l,this.lines.onInsertEmitter.fire(t[i]),l+=t[i].amount;let c=Math.max(0,s+r-this.lines.maxLength);c>0&&this.lines.onTrimEmitter.fire(c)}}translateBufferLineToString(t,i,s=0,e){let h=this.lines.get(t);return h?h.translateToString(i,s,e):""}getWrappedRangeForLine(t){let i=t,s=t;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:i,last:s}}setupTabStops(t){for(null!=t?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(null==t&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(null==t&&(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 i=0;i<this.markers.length;i++)this.markers[i].line===t&&(this.markers[i].dispose(),this.markers.splice(i--,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 i=new Ke(t);return this.markers.push(i),i.register(this.lines.onTrim((t=>{i.line-=t,i.line<0&&i.dispose()}))),i.register(this.lines.onInsert((t=>{i.line>=t.index&&(i.line+=t.amount)}))),i.register(this.lines.onDelete((t=>{i.line>=t.index&&i.line<t.index+t.amount&&i.dispose(),i.line>t.index&&(i.line-=t.amount)}))),i.register(i.onDispose((()=>this._removeMarker(i)))),i}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},Ve=class extends lt{constructor(t,i){super(),this._optionsService=t,this._bufferService=i,this._onBufferActivate=this._register(new Qt),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 Xe(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xe(!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(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),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(t,i){this._normal.resize(t,i),this._alt.resize(t,i),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},th=class extends lt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Qt),this.onResize=this._onResize.event,this._onScroll=this._register(new Qt),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,2),this.rows=Math.max(t.rawOptions.rows||0,1),this.buffers=this._register(new Ve(t,this)),this._register(this.buffers.onBufferActivate((t=>{this._onScroll.fire(t.activeBuffer.ydisp)})))}get buffer(){return this.buffers.active}resize(t,i){let s=this.cols!==t,e=this.rows!==i;this.cols=t,this.rows=i,this.buffers.resize(t,i),this._onResize.fire({cols:t,rows:i,colsChanged:s,rowsChanged:e})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,i=!1){let s,e=this.buffer;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=e.getBlankLine(t,i),this._cachedBlankLine=s),s.isWrapped=i;let h=e.ybase+e.scrollTop,r=e.ybase+e.scrollBottom;if(0===e.scrollTop){let t=e.lines.isFull;r===e.lines.length-1?t?e.lines.recycle().copyFrom(s):e.lines.push(s.clone()):e.lines.splice(r+1,0,s.clone()),t?this.isUserScrolling&&(e.ydisp=Math.max(e.ydisp-1,0)):(e.ybase++,this.isUserScrolling||e.ydisp++)}else e.lines.shiftElements(h+1,r-h+1-1,-1),e.lines.set(r,s.clone());this.isUserScrolling||(e.ydisp=e.ybase),this._onScroll.fire(e.ydisp)}scrollLines(t,i){let s=this.buffer;if(t<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let e=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),e!==s.ydisp&&(i||this._onScroll.fire(s.ydisp))}};th=a([l(0,R)],th);var ih={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:re,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},sh=["normal","bold","100","200","300","400","500","600","700","800","900"],eh=class extends lt{constructor(t){super(),this._onOptionChange=this._register(new Qt),this.onOptionChange=this._onOptionChange.event;let i={...ih};for(let s in t)if(s in i)try{i[s]=this._sanitizeAndValidateOption(s,t[s])}catch(t){console.error(t)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(nt((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(t,i){return this.onOptionChange((s=>{s===t&&i(this.rawOptions[t])}))}onMultipleOptionChange(t,i){return this.onOptionChange((s=>{-1!==t.indexOf(s)&&i()}))}_setupOptions(){let t=t=>{if(!(t in ih))throw Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,i)=>{if(!(t in ih))throw Error(`No option with key "${t}"`);i=this._sanitizeAndValidateOption(t,i),this.rawOptions[t]!==i&&(this.rawOptions[t]=i,this._onOptionChange.fire(t))};for(let s in this.rawOptions){let e={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this.options,s,e)}}_sanitizeAndValidateOption(t,i){switch(t){case"cursorStyle":if(i||(i=ih[t]),!function(t){return"block"===t||"underline"===t||"bar"===t}(i))throw Error(`"${i}" is not a valid value for ${t}`);break;case"wordSeparator":i||(i=ih[t]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=sh.includes(i)?i:ih[t];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${t} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw Error(`${t} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${t} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${t} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function hh(t,i=5){if("object"!=typeof t)return t;let s=Array.isArray(t)?[]:{};for(let e in t)s[e]=i<=1?t[e]:t[e]&&hh(t[e],i-1);return s}var rh=Object.freeze({insertMode:!1}),nh=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),oh=class extends lt{constructor(t,i,s){super(),this._bufferService=t,this._logService=i,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Qt),this.onData=this._onData.event,this._onUserInput=this._register(new Qt),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Qt),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Qt),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=hh(rh),this.decPrivateModes=hh(nh)}reset(){this.modes=hh(rh),this.decPrivateModes=hh(nh)}triggerDataEvent(t,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 "${t}"`),this._logService.trace("sending data (codes)",(()=>t.split("").map((t=>t.charCodeAt(0))))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",(()=>t.split("").map((t=>t.charCodeAt(0))))),this._onBinary.fire(t))}};oh=a([l(0,x),l(1,$),l(2,R)],oh);var ah={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>4!==t.button&&1===t.action&&(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>32!==t.action},DRAG:{events:23,restrict:t=>!(32===t.action&&3===t.button)},ANY:{events:31,restrict:()=>!0}};function lh(t,i){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return 4===t.button?(s|=64,s|=t.action):(s|=3&t.button,4&t.button&&(s|=64),8&t.button&&(s|=128),32===t.action?s|=32:0===t.action&&!i&&(s|=3)),s}var ch=String.fromCharCode,uh={DEFAULT:t=>{let i=[lh(t,!1)+32,t.col+32,t.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`${ch(i[0])}${ch(i[1])}${ch(i[2])}`},SGR:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${lh(t,!0)};${t.col};${t.row}${i}`},SGR_PIXELS:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${lh(t,!0)};${t.x};${t.y}${i}`}},Ah=class extends lt{constructor(t,i,s){super(),this._bufferService=t,this._coreService=i,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Qt),this.onProtocolChange=this._onProtocolChange.event;for(let t of Object.keys(ah))this.addProtocol(t,ah[t]);for(let t of Object.keys(uh))this.addEncoding(t,uh[t]);this.reset()}addProtocol(t,i){this._protocols[t]=i}addEncoding(t,i){this._encodings[t]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(t){if(!this._protocols[t])throw 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 Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,i,s){if(0===t.deltaY||t.shiftKey||void 0===i||void 0===s)return 0;let e=i/s,h=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(h/=e+0,Math.abs(t.deltaY)<50&&(h*=.3),this._wheelPartialScroll+=h,h=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._bufferService.rows),h}_applyScrollModifier(t,i){return i.altKey||i.ctrlKey||i.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||4===t.button&&32===t.action||3===t.button&&32!==t.action||4!==t.button&&(2===t.action||3===t.action)||(t.col++,t.row++,32===t.action&&this._lastEvent&&this._equalEvents(this._lastEvent,t,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(t))return!1;let i=this._encodings[this._activeEncoding](t);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(1&t),up:!!(2&t),drag:!!(4&t),move:!!(8&t),wheel:!!(16&t)}}_equalEvents(t,i,s){if(s){if(t.x!==i.x||t.y!==i.y)return!1}else if(t.col!==i.col||t.row!==i.row)return!1;return!(t.button!==i.button||t.action!==i.action||t.ctrl!==i.ctrl||t.alt!==i.alt||t.shift!==i.shift)}};Ah=a([l(0,x),l(1,L),l(2,R)],Ah);var fh,dh=[[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]],gh=[[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]],wh=class{constructor(){if(this.version="6",!fh){(fh=new Uint8Array(65536)).fill(1),fh[0]=0,fh.fill(0,1,32),fh.fill(0,127,160),fh.fill(2,4352,4448),fh[9001]=2,fh[9002]=2,fh.fill(2,11904,42192),fh[12351]=1,fh.fill(2,44032,55204),fh.fill(2,63744,64256),fh.fill(2,65040,65050),fh.fill(2,65072,65136),fh.fill(2,65280,65377),fh.fill(2,65504,65511);for(let t=0;t<dh.length;++t)fh.fill(0,dh[t][0],dh[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?fh[t]:function(t,i){let s,e=0,h=i.length-1;if(t<i[0][0]||t>i[h][1])return!1;for(;h>=e;)if(s=e+h>>1,t>i[s][1])e=s+1;else{if(!(t<i[s][0]))return!0;h=s-1}return!1}(t,gh)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,i){let s=this.wcwidth(t),e=0===s&&0!==i;if(e){let t=ph.extractWidth(i);0===t?e=!1:t>s&&(s=t)}return ph.createPropertyValue(0,s,e)}},ph=class t{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Qt,this.onChange=this._onChange.event;let t=new wh;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return!!(1&t)}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(16777215&t)<<3|(3&i)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(i){let s=0,e=0,h=i.length;for(let r=0;r<h;++r){let n=i.charCodeAt(r);if(55296<=n&&n<=56319){if(++r>=h)return s+this.wcwidth(n);let t=i.charCodeAt(r);56320<=t&&t<=57343?n=1024*(n-55296)+t-56320+65536:s+=this.wcwidth(t)}let o=this.charProperties(n,e),a=t.extractWidth(o);t.extractShouldJoin(o)&&(a-=t.extractWidth(e)),s+=a,e=o}return s}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Ch=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,i){this._charsets[t]=i,this.glevel===t&&(this.charset=i)}};function mh(t){let i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&i&&(s.isWrapped=0!==i[3]&&32!==i[3])}var Ih=2147483647,vh=class t{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let s=new t;if(!i.length)return s;for(let t=Array.isArray(i[0])?1:0;t<i.length;++t){let e=i[t];if(Array.isArray(e))for(let t=0;t<e.length;++t)s.addSubParam(e[t]);else s.addParam(e)}return s}clone(){let i=new t(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,e=255&this._subParamsIdx[i];e-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,e))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(t<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ih?Ih:t}}addSubParam(t){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)return void(this._rejectSubDigits=!0);if(t<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Ih?Ih:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(255&this._subParamsIdx[t])-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,e=255&this._subParamsIdx[i];e-s>0&&(t[i]=this._subParams.slice(s,e))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,e=s[i-1];s[i-1]=~e?Math.min(10*e+t,Ih):t}},bh=[],Bh=class{constructor(){this._state=0,this._active=bh,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,i){void 0===this._handlers[t]&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(i),{dispose:()=>{let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=bh}reset(){if(2===this._state)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=bh,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||bh,this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].start();else this._handlerFb(this._id,"START")}_put(t,i,s){if(this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].put(t,i,s);else this._handlerFb(this._id,"PUT",C(t,i,s))}start(){this.reset(),this._state=1}put(t,i,s){if(3!==this._state){if(1===this._state)for(;i<s;){let s=t[i++];if(59===s){this._state=2,this._start();break}if(s<48||57<s)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-i>0&&this._put(t,i,s)}}end(t,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,e=this._active.length-1,h=!1;if(this._stack.paused&&(e=this._stack.loopPosition-1,s=i,h=this._stack.fallThrough,this._stack.paused=!1),!h&&!1===s){for(;e>=0&&(s=this._active[e].end(t),!0!==s);e--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!1,s;e--}for(;e>=0;e--)if(s=this._active[e].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",t);this._active=bh,this._id=-1,this._state=0}}},Mh=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=C(t,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let i=!1;if(this._hitLimit)i=!1;else if(t&&(i=this._handler(this._data),i instanceof Promise))return i.then((t=>(this._data="",this._hitLimit=!1,t)));return this._data="",this._hitLimit=!1,i}},yh=[],Eh=class{constructor(){this._handlers=Object.create(null),this._active=yh,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=yh}registerHandler(t,i){void 0===this._handlers[t]&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(i),{dispose:()=>{let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=yh,this._ident=0}hook(t,i){if(this.reset(),this._ident=t,this._active=this._handlers[t]||yh,this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(t,i,s){if(this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].put(t,i,s);else this._handlerFb(this._ident,"PUT",C(t,i,s))}unhook(t,i=!0){if(this._active.length){let s=!1,e=this._active.length-1,h=!1;if(this._stack.paused&&(e=this._stack.loopPosition-1,s=i,h=this._stack.fallThrough,this._stack.paused=!1),!h&&!1===s){for(;e>=0&&(s=this._active[e].unhook(t),!0!==s);e--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!1,s;e--}for(;e>=0;e--)if(s=this._active[e].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",t);this._active=yh,this._ident=0}},Qh=new vh;Qh.addParam(0);var kh=class{constructor(t){this._handler=t,this._data="",this._params=Qh,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():Qh,this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=C(t,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let i=!1;if(this._hitLimit)i=!1;else if(t&&(i=this._handler(this._data,this._params),i instanceof Promise))return i.then((t=>(this._params=Qh,this._data="",this._hitLimit=!1,t)));return this._params=Qh,this._data="",this._hitLimit=!1,i}},xh=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,i){this.table.fill(t<<4|i)}add(t,i,s,e){this.table[i<<8|t]=s<<4|e}addMany(t,i,s,e){for(let h=0;h<t.length;h++)this.table[i<<8|t[h]]=s<<4|e}},Dh=160,Lh=function(){let t=new xh(4095),i=Array.apply(null,Array(256)).map(((t,i)=>i)),s=(t,s)=>i.slice(t,s),e=s(32,127),h=s(0,24);h.push(25),h.push.apply(h,s(28,32));let r,n=s(0,14);for(r in t.setDefault(1,0),t.addMany(e,0,2,0),n)t.addMany([24,26,153,154],r,3,0),t.addMany(s(128,144),r,3,0),t.addMany(s(144,152),r,3,0),t.add(156,r,0,0),t.add(27,r,11,1),t.add(157,r,4,8),t.addMany([152,158,159],r,0,7),t.add(155,r,11,3),t.add(144,r,11,9);return t.addMany(h,0,3,0),t.addMany(h,1,3,1),t.add(127,1,0,1),t.addMany(h,8,0,8),t.addMany(h,3,3,3),t.add(127,3,0,3),t.addMany(h,4,3,4),t.add(127,4,0,4),t.addMany(h,6,3,6),t.addMany(h,5,3,5),t.add(127,5,0,5),t.addMany(h,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(e,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(e,7,0,7),t.addMany(h,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(h,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(h,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(h,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(h,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(h,13,13,13),t.addMany(e,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Dh,0,2,0),t.add(Dh,8,5,8),t.add(Dh,6,0,6),t.add(Dh,11,0,11),t.add(Dh,13,13,13),t}(),_h=class extends lt{constructor(t=Lh){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new vh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=()=>{},this._executeHandlerFb=()=>{},this._csiHandlerFb=()=>{},this._escHandlerFb=()=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(nt((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this._register(new Bh),this._dcsParser=this._register(new Eh),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(t,i=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<t.intermediates.length;++i){let e=t.intermediates.charCodeAt(i);if(32>e||e>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=e}}if(1!==t.final.length)throw Error("final must be a single byte");let e=t.final.charCodeAt(0);if(i[0]>e||e>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return s<<=8,s|=e,s}identToString(t){let i=[];for(;t;)i.push(String.fromCharCode(255&t)),t>>=8;return i.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,i){let s=this._identifier(t,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let e=this._escHandlers[s];return e.push(i),{dispose:()=>{let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,i){this._executeHandlers[t.charCodeAt(0)]=i}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,i){let s=this._identifier(t);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let e=this._csiHandlers[s];return e.push(i),{dispose:()=>{let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,i){return this._dcsParser.registerHandler(this._identifier(t),i)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,i){return this._oscParser.registerHandler(t,i)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,i,s,e,h){this._parseStack.state=t,this._parseStack.handlers=i,this._parseStack.handlerPos=s,this._parseStack.transition=e,this._parseStack.chunkPos=h}parse(t,i,s){let e,h=0,r=0,n=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,r=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&r>-1)for(;r>=0&&(e=i[r](this._params),!0!==e);r--)if(e instanceof Promise)return this._parseStack.handlerPos=r,e;this._parseStack.handlers=[];break;case 4:if(!1===s&&r>-1)for(;r>=0&&(e=i[r](),!0!==e);r--)if(e instanceof Promise)return this._parseStack.handlerPos=r,e;this._parseStack.handlers=[];break;case 6:if(h=t[this._parseStack.chunkPos],e=this._dcsParser.unhook(24!==h&&26!==h,s),e)return e;27===h&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(h=t[this._parseStack.chunkPos],e=this._oscParser.end(24!==h&&26!==h,s),e)return e;27===h&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=n;s<i;++s){switch(h=t[s],r=this._transitions.table[this.currentState<<8|(h<160?h:Dh)],r>>4){case 2:for(let e=s+1;;++e){if(e>=i||(h=t[e])<32||h>126&&h<Dh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Dh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Dh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Dh){this._printHandler(t,s,e),s=e-1;break}}break;case 3:this._executeHandlers[h]?this._executeHandlers[h]():this._executeHandlerFb(h),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:h,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let n=this._csiHandlers[this._collect<<8|h],o=n?n.length-1:-1;for(;o>=0&&(e=n[o](this._params),!0!==e);o--)if(e instanceof Promise)return this._preserveStack(3,n,o,r,s),e;o<0&&this._csiHandlerFb(this._collect<<8|h,this._params),this.precedingJoinState=0;break;case 8:do{switch(h){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(h-48)}}while(++s<i&&(h=t[s])>47&&h<60);s--;break;case 9:this._collect<<=8,this._collect|=h;break;case 10:let a=this._escHandlers[this._collect<<8|h],l=a?a.length-1:-1;for(;l>=0&&(e=a[l](),!0!==e);l--)if(e instanceof Promise)return this._preserveStack(4,a,l,r,s),e;l<0&&this._escHandlerFb(this._collect<<8|h),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|h,this._params);break;case 13:for(let e=s+1;;++e)if(e>=i||24===(h=t[e])||26===h||27===h||h>127&&h<Dh){this._dcsParser.put(t,s,e),s=e-1;break}break;case 14:if(e=this._dcsParser.unhook(24!==h&&26!==h),e)return this._preserveStack(6,[],0,r,s),e;27===h&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let e=s+1;;e++)if(e>=i||(h=t[e])<32||h>127&&h<Dh){this._oscParser.put(t,s,e),s=e-1;break}break;case 6:if(e=this._oscParser.end(24!==h&&26!==h),e)return this._preserveStack(5,[],0,r,s),e;27===h&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&r}}},Sh=/^([\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})$/,$h=/^[\da-f]+$/;function Rh(t){if(!t)return;let i=t.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let t=Sh.exec(i);if(t){let i=t[1]?15:t[4]?255:t[7]?4095:65535;return[Math.round(parseInt(t[1]||t[4]||t[7]||t[10],16)/i*255),Math.round(parseInt(t[2]||t[5]||t[8]||t[11],16)/i*255),Math.round(parseInt(t[3]||t[6]||t[9]||t[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),$h.exec(i)&&[3,6,9,12].includes(i.length))){let t=i.length/3,s=[0,0,0];for(let e=0;e<3;++e){let h=parseInt(i.slice(t*e,t*e+t),16);s[e]=1===t?h<<4:2===t?h:3===t?h>>4:h>>8}return s}}function Nh(t,i){let s=t.toString(16),e=s.length<2?"0"+s:s;switch(i){case 4:return s[0];case 8:return e;case 12:return(e+e).slice(0,3);default:return e+e}}function Fh(t,i=16){let[s,e,h]=t;return`rgb:${Nh(s,i)}/${Nh(e,i)}/${Nh(h,i)}`}var Hh={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Uh=131072;function Th(t,i){if(t>24)return i.setWinLines||!1;switch(t){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var Gh=0,Ph=class extends lt{constructor(t,i,s,e,h,r,n,o,a=new _h){super(),this._bufferService=t,this._charsetService=i,this._coreService=s,this._logService=e,this._optionsService=h,this._oscLinkService=r,this._coreMouseService=n,this._unicodeService=o,this._parser=a,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new m,this._utf8Decoder=new I,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone(),this._onRequestBell=this._register(new Qt),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Qt),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Qt),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Qt),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Qt),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Qt),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Qt),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Qt),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Qt),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Qt),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Qt),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Qt),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Qt),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 Jh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((t=>this._activeBuffer=t.activeBuffer))),this._parser.setCsiHandlerFallback(((t,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(t),params:i.toArray()})})),this._parser.setEscHandlerFallback((t=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(t)})})),this._parser.setExecuteHandlerFallback((t=>{this._logService.debug("Unknown EXECUTE code: ",{code:t})})),this._parser.setOscHandlerFallback(((t,i,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:t,action:i,data:s})})),this._parser.setDcsHandlerFallback(((t,i,s)=>{"HOOK"===i&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(t),action:i,payload:s})})),this._parser.setPrintHandler(((t,i,s)=>this.print(t,i,s))),this._parser.registerCsiHandler({final:"@"},(t=>this.insertChars(t))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(t=>this.scrollLeft(t))),this._parser.registerCsiHandler({final:"A"},(t=>this.cursorUp(t))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(t=>this.scrollRight(t))),this._parser.registerCsiHandler({final:"B"},(t=>this.cursorDown(t))),this._parser.registerCsiHandler({final:"C"},(t=>this.cursorForward(t))),this._parser.registerCsiHandler({final:"D"},(t=>this.cursorBackward(t))),this._parser.registerCsiHandler({final:"E"},(t=>this.cursorNextLine(t))),this._parser.registerCsiHandler({final:"F"},(t=>this.cursorPrecedingLine(t))),this._parser.registerCsiHandler({final:"G"},(t=>this.cursorCharAbsolute(t))),this._parser.registerCsiHandler({final:"H"},(t=>this.cursorPosition(t))),this._parser.registerCsiHandler({final:"I"},(t=>this.cursorForwardTab(t))),this._parser.registerCsiHandler({final:"J"},(t=>this.eraseInDisplay(t,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(t=>this.eraseInDisplay(t,!0))),this._parser.registerCsiHandler({final:"K"},(t=>this.eraseInLine(t,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(t=>this.eraseInLine(t,!0))),this._parser.registerCsiHandler({final:"L"},(t=>this.insertLines(t))),this._parser.registerCsiHandler({final:"M"},(t=>this.deleteLines(t))),this._parser.registerCsiHandler({final:"P"},(t=>this.deleteChars(t))),this._parser.registerCsiHandler({final:"S"},(t=>this.scrollUp(t))),this._parser.registerCsiHandler({final:"T"},(t=>this.scrollDown(t))),this._parser.registerCsiHandler({final:"X"},(t=>this.eraseChars(t))),this._parser.registerCsiHandler({final:"Z"},(t=>this.cursorBackwardTab(t))),this._parser.registerCsiHandler({final:"`"},(t=>this.charPosAbsolute(t))),this._parser.registerCsiHandler({final:"a"},(t=>this.hPositionRelative(t))),this._parser.registerCsiHandler({final:"b"},(t=>this.repeatPrecedingCharacter(t))),this._parser.registerCsiHandler({final:"c"},(t=>this.sendDeviceAttributesPrimary(t))),this._parser.registerCsiHandler({prefix:">",final:"c"},(t=>this.sendDeviceAttributesSecondary(t))),this._parser.registerCsiHandler({final:"d"},(t=>this.linePosAbsolute(t))),this._parser.registerCsiHandler({final:"e"},(t=>this.vPositionRelative(t))),this._parser.registerCsiHandler({final:"f"},(t=>this.hVPosition(t))),this._parser.registerCsiHandler({final:"g"},(t=>this.tabClear(t))),this._parser.registerCsiHandler({final:"h"},(t=>this.setMode(t))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this.setModePrivate(t))),this._parser.registerCsiHandler({final:"l"},(t=>this.resetMode(t))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this.resetModePrivate(t))),this._parser.registerCsiHandler({final:"m"},(t=>this.charAttributes(t))),this._parser.registerCsiHandler({final:"n"},(t=>this.deviceStatus(t))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(t=>this.deviceStatusPrivate(t))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(t=>this.softReset(t))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(t=>this.setCursorStyle(t))),this._parser.registerCsiHandler({final:"r"},(t=>this.setScrollRegion(t))),this._parser.registerCsiHandler({final:"s"},(t=>this.saveCursor(t))),this._parser.registerCsiHandler({final:"t"},(t=>this.windowOptions(t))),this._parser.registerCsiHandler({final:"u"},(t=>this.restoreCursor(t))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(t=>this.insertColumns(t))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(t=>this.deleteColumns(t))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(t=>this.selectProtected(t))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(t=>this.requestMode(t,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(t=>this.requestMode(t,!1))),this._parser.setExecuteHandler(ns.BEL,(()=>this.bell())),this._parser.setExecuteHandler(ns.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(ns.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(ns.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(ns.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(ns.BS,(()=>this.backspace())),this._parser.setExecuteHandler(ns.HT,(()=>this.tab())),this._parser.setExecuteHandler(ns.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(ns.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(os.IND,(()=>this.index())),this._parser.setExecuteHandler(os.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(os.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new Mh((t=>(this.setTitle(t),this.setIconName(t),!0)))),this._parser.registerOscHandler(1,new Mh((t=>this.setIconName(t)))),this._parser.registerOscHandler(2,new Mh((t=>this.setTitle(t)))),this._parser.registerOscHandler(4,new Mh((t=>this.setOrReportIndexedColor(t)))),this._parser.registerOscHandler(8,new Mh((t=>this.setHyperlink(t)))),this._parser.registerOscHandler(10,new Mh((t=>this.setOrReportFgColor(t)))),this._parser.registerOscHandler(11,new Mh((t=>this.setOrReportBgColor(t)))),this._parser.registerOscHandler(12,new Mh((t=>this.setOrReportCursorColor(t)))),this._parser.registerOscHandler(104,new Mh((t=>this.restoreIndexedColor(t)))),this._parser.registerOscHandler(110,new Mh((t=>this.restoreFgColor(t)))),this._parser.registerOscHandler(111,new Mh((t=>this.restoreBgColor(t)))),this._parser.registerOscHandler(112,new Mh((t=>this.restoreCursorColor(t)))),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 t in je)this._parser.registerEscHandler({intermediates:"(",final:t},(()=>this.selectCharset("("+t))),this._parser.registerEscHandler({intermediates:")",final:t},(()=>this.selectCharset(")"+t))),this._parser.registerEscHandler({intermediates:"*",final:t},(()=>this.selectCharset("*"+t))),this._parser.registerEscHandler({intermediates:"+",final:t},(()=>this.selectCharset("+"+t))),this._parser.registerEscHandler({intermediates:"-",final:t},(()=>this.selectCharset("-"+t))),this._parser.registerEscHandler({intermediates:".",final:t},(()=>this.selectCharset("."+t))),this._parser.registerEscHandler({intermediates:"/",final:t},(()=>this.selectCharset("/"+t)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((t=>(this._logService.error("Parsing error: ",t),t))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new kh(((t,i)=>this.requestStatusString(t,i))))}getAttrData(){return this._curAttrData}_preserveStack(t,i,s,e){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=s,this._parseStack.position=e}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise(((t,i)=>setTimeout((()=>i("#SLOW_TIMEOUT")),5e3)))]).catch((t=>{if("#SLOW_TIMEOUT"!==t)throw t;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,i){let s,e=this._activeBuffer.x,h=this._activeBuffer.y,r=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(s),s;e=this._parseStack.cursorStartX,h=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Uh&&(r=this._parseStack.position+Uh)}if(this._logService.logLevel<=1&&this._logService.debug("parsing data "+("string"==typeof t?` "${t}"`:` "${Array.prototype.map.call(t,(t=>String.fromCharCode(t))).join("")}"`)),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof t?t.split("").map((t=>t.charCodeAt(0))):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Uh&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Uh))),n||this._dirtyRowTracker.clearRange(),t.length>Uh)for(let i=r;i<t.length;i+=Uh){let r=i+Uh<t.length?i+Uh:t.length,n="string"==typeof t?this._stringDecoder.decode(t.substring(i,r),this._parseBuffer):this._utf8Decoder.decode(t.subarray(i,r),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,n))return this._preserveStack(e,h,n,i),this._logSlowResolvingAsync(s),s}else if(!n){let i="string"==typeof t?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,i))return this._preserveStack(e,h,i,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==e||this._activeBuffer.y!==h)&&this._onCursorMove.fire();let o=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),a=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);a<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(a,this._bufferService.rows-1),end:Math.min(o,this._bufferService.rows-1)})}print(t,i,s){let e,h,r=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,o=this._bufferService.cols,a=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,c=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-i>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let A=this._parser.precedingJoinState;for(let f=i;f<s;++f){if(e=t[f],e<127&&r){let t=r[String.fromCharCode(e)];t&&(e=t.charCodeAt(0))}let i=this._unicodeService.charProperties(e,A);h=ph.extractWidth(i);let s=ph.extractShouldJoin(i),d=s?ph.extractWidth(A):0;if(A=i,n&&this._onA11yChar.fire(p(e)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+h-d>o)if(a){let t=u,i=this._activeBuffer.x-d;for(this._activeBuffer.x=d,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),d>0&&u instanceof Oe&&u.copyCellsFrom(t,i,0,d,!1);i<o;)t.setCellFromCodepoint(i++,0,1,c)}else if(this._activeBuffer.x=o-1,2===h)continue;if(s&&this._activeBuffer.x){let t=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-t,e,h);for(let t=h-d;--t>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}else if(l&&(u.insertCells(this._activeBuffer.x,h-d,this._activeBuffer.getNullCell(c)),2===u.getWidth(o-1)&&u.setCellFromCodepoint(o-1,0,1,c)),u.setCellFromCodepoint(this._activeBuffer.x++,e,h,c),h>0)for(;--h;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,c)}this._parser.precedingJoinState=A,this._activeBuffer.x<o&&s-i>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,i){return this._parser.registerCsiHandler(t,"t"!==t.final||t.prefix||t.intermediates?i:t=>!Th(t.params[0],this._optionsService.rawOptions.windowOptions)||i(t))}registerDcsHandler(t,i){return this._parser.registerDcsHandler(t,new kh(i))}registerEscHandler(t,i){return this._parser.registerEscHandler(t,i)}registerOscHandler(t,i){return this._parser.registerOscHandler(t,new Mh(i))}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(0===this._activeBuffer.x&&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,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=t,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+i)}cursorUp(t){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return this._moveCursor(0,i>=0?-Math.min(i,t.params[0]||1):-(t.params[0]||1)),!0}cursorDown(t){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return this._moveCursor(0,i>=0?Math.min(i,t.params[0]||1):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 i=t.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=t.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=t.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let i=t.params[0];return 1===i&&(this._curAttrData.bg|=536870912),(2===i||0===i)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,i,s,e=!1,h=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);r.replaceCells(i,s,this._activeBuffer.getNullCell(this._eraseAttrData()),h),e&&(r.isWrapped=!1)}_resetBufferLine(t,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,i=!1){let s;switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);s<this._bufferService.rows;s++)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let t=this._activeBuffer.lines.length-this._bufferService.rows;t>0&&(this._activeBuffer.lines.trimStart(t),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-t,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-t,0),this._onScroll.fire(0))}return!0}eraseInLine(t,i=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let i=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,e=this._bufferService.rows-1+this._activeBuffer.ybase-(this._bufferService.rows-1-this._activeBuffer.scrollBottom)+1;for(;i--;)this._activeBuffer.lines.splice(e-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let i=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s,e=this._activeBuffer.ybase+this._activeBuffer.y;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;i--;)this._activeBuffer.lines.splice(e,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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let i=t.params[0]||1;for(;i--;)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 i=t.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Pe));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(0,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(0,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(this._activeBuffer.x,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.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 i=this._parser.precedingJoinState;if(!i)return!0;let s=t.params[0]||1,e=ph.extractWidth(i),h=this._activeBuffer.x-e,r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(h),n=new Uint32Array(r.length*s),o=0;for(let t=0;t<r.length;){let i=r.codePointAt(t)||0;n[o++]=i,t+=i>65535?2:1}let a=o;for(let t=1;t<s;++t)n.copyWithin(a,0,o),a+=o;return this.print(n,0,a),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ns.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ns.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ns.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ns.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ns.ESC+"[>83;40003;0c")),!0}_is(t){return 0===(this._optionsService.rawOptions.termName+"").indexOf(t)}setMode(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ye),this._charsetService.setgCharset(1,Ye),this._charsetService.setgCharset(2,Ye),this._charsetService.setgCharset(3,Ye);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===t.params[i]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(t,i){let s;(t=>{t[t.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",t[t.SET=1]="SET",t[t.RESET=2]="RESET",t[t.PERMANENTLY_SET=3]="PERMANENTLY_SET",t[t.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"})(s||={});let e=this._coreService.decPrivateModes,{activeProtocol:h,activeEncoding:r}=this._coreMouseService,n=this._coreService,{buffers:o,cols:a}=this._bufferService,{active:l,alt:c}=o,u=this._optionsService.rawOptions,A=t=>t?1:2,f=t.params[0];return((t,s)=>(n.triggerDataEvent(`${ns.ESC}[${i?"":"?"}${t};${s}$y`),!0))(f,i?2===f?4:4===f?A(n.modes.insertMode):12===f?3:20===f?A(u.convertEol):0:1===f?A(e.applicationCursorKeys):3===f?u.windowOptions.setWinLines?80===a?2:132===a?1:0:0:6===f?A(e.origin):7===f?A(e.wraparound):8===f?3:9===f?A("X10"===h):12===f?A(u.cursorBlink):25===f?A(!n.isCursorHidden):45===f?A(e.reverseWraparound):66===f?A(e.applicationKeypad):67===f?4:1e3===f?A("VT200"===h):1002===f?A("DRAG"===h):1003===f?A("ANY"===h):1004===f?A(e.sendFocus):1005===f?4:1006===f?A("SGR"===r):1015===f?4:1016===f?A("SGR_PIXELS"===r):1048===f?1:47===f||1047===f||1049===f?A(l===c):2004===f?A(e.bracketedPasteMode):2026===f?A(e.synchronizedOutput):0)}_updateAttrColor(t,i,s,e,h){return 2===i?(t|=50331648,t&=-16777216,t|=b.fromColorRGB([s,e,h])):5===i&&(t&=-50331904,t|=33554432|255&s),t}_extractColor(t,i,s){let e=[0,0,-1,0,0,0],h=0,r=0;do{if(e[r+h]=t.params[i+r],t.hasSubParams(i+r)){let s=t.getSubParams(i+r),n=0;do{5===e[1]&&(h=1),e[r+n+1+h]=s[n]}while(++n<s.length&&n+r+1+h<e.length);break}if(5===e[1]&&r+h>=2||2===e[1]&&r+h>=5)break;e[1]&&(h=1)}while(++r+i<t.length&&r+h<e.length);for(let t=2;t<e.length;++t)-1===e[t]&&(e[t]=0);switch(e[0]){case 38:s.fg=this._updateAttrColor(s.fg,e[1],e[3],e[4],e[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,e[1],e[3],e[4],e[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,e[1],e[3],e[4],e[5])}return r}_processUnderline(t,i){i.extended=i.extended.clone(),(!~t||t>5)&&(t=1),i.extended.underlineStyle=t,i.fg|=268435456,0===t&&(i.fg&=-268435457),i.updateExtended()}_processSGR0(t){t.fg=Pe.fg,t.bg=Pe.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(1===t.length&&0===t.params[0])return this._processSGR0(this._curAttrData),!0;let i,s=t.length,e=this._curAttrData;for(let h=0;h<s;h++)i=t.params[h],i>=30&&i<=37?(e.fg&=-50331904,e.fg|=16777216|i-30):i>=40&&i<=47?(e.bg&=-50331904,e.bg|=16777216|i-40):i>=90&&i<=97?(e.fg&=-50331904,e.fg|=16777224|i-90):i>=100&&i<=107?(e.bg&=-50331904,e.bg|=16777224|i-100):0===i?this._processSGR0(e):1===i?e.fg|=134217728:3===i?e.bg|=67108864:4===i?(e.fg|=268435456,this._processUnderline(t.hasSubParams(h)?t.getSubParams(h)[0]:1,e)):5===i?e.fg|=536870912:7===i?e.fg|=67108864:8===i?e.fg|=1073741824:9===i?e.fg|=2147483648:2===i?e.bg|=134217728:21===i?this._processUnderline(2,e):22===i?(e.fg&=-134217729,e.bg&=-134217729):23===i?e.bg&=-67108865:24===i?(e.fg&=-268435457,this._processUnderline(0,e)):25===i?e.fg&=-536870913:27===i?e.fg&=-67108865:28===i?e.fg&=-1073741825:29===i?e.fg&=2147483647:39===i?(e.fg&=-67108864,e.fg|=16777215&Pe.fg):49===i?(e.bg&=-67108864,e.bg|=16777215&Pe.bg):38===i||48===i||58===i?h+=this._extractColor(t,h,e):53===i?e.bg|=1073741824:55===i?e.bg&=-1073741825:59===i?(e.extended=e.extended.clone(),e.extended.underlineColor=-1,e.updateExtended()):100===i?(e.fg&=-67108864,e.fg|=16777215&Pe.fg,e.bg&=-67108864,e.bg|=16777215&Pe.bg):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(ns.ESC+"[0n");break;case 6:this._coreService.triggerDataEvent(`${ns.ESC}[${this._activeBuffer.y+1};${this._activeBuffer.x+1}R`)}return!0}deviceStatusPrivate(t){return 6===t.params[0]&&this._coreService.triggerDataEvent(`${ns.ESC}[?${this._activeBuffer.y+1};${this._activeBuffer.x+1}R`),!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Pe.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(t){let i=0===t.length?1:t.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){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"}this._coreService.decPrivateModes.cursorBlink=i%2==1}return!0}setScrollRegion(t){let i,s=t.params[0]||1;return(t.length<2||(i=t.params[1])>this._bufferService.rows||0===i)&&(i=this._bufferService.rows),i>s&&(this._activeBuffer.scrollTop=s-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Th(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${ns.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}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 i=[],s=t.split(";");for(;s.length>1;){let t=s.shift(),e=s.shift();if(/^\d+$/.exec(t)){let s=parseInt(t);if(Oh(s))if("?"===e)i.push({type:0,index:s});else{let t=Rh(e);t&&i.push({type:1,index:s,color:t})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(t){let i=t.indexOf(";");if(-1===i)return!0;let s=t.slice(0,i).trim(),e=t.slice(i+1);return e?this._createHyperlink(s,e):!s.trim()&&this._finishHyperlink()}_createHyperlink(t,i){this._getCurrentLinkId()&&this._finishHyperlink();let s,e=t.split(":"),h=e.findIndex((t=>t.startsWith("id=")));return-1!==h&&(s=e[h].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,i){let s=t.split(";");for(let t=0;t<s.length&&!(i>=this._specialColors.length);++t,++i)if("?"===s[t])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let e=Rh(s[t]);e&&this._onColor.fire([{type:1,index:this._specialColors[i],color:e}])}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 i=[],s=t.split(";");for(let t=0;t<s.length;++t)if(/^\d+$/.exec(s[t])){let e=parseInt(s[t]);Oh(e)&&i.push({type:2,index:e})}return i.length&&this._onColor.fire(i),!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,Ye),!0}selectCharset(t){return 2!==t.length?(this.selectDefaultCharset(),!0):("/"===t[0]||this._charsetService.setgCharset(Hh[t[0]],je[t[1]]||Ye),!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(){return this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop?(this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop,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)):(this._activeBuffer.y--,this._restrictCursor()),!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Pe.clone(),this._eraseAttrDataInternal=Pe.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new M;t.content=4194373,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y+i);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,i){let s=this._bufferService.buffer,e=this._optionsService.rawOptions;return(t=>(this._coreService.triggerDataEvent(`${ns.ESC}${t}${ns.ESC}\\`),!0))('"q'===t?`P1$r${this._curAttrData.isProtected()?1:0}"q`:'"p'===t?'P1$r61;1"p':"r"===t?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:"m"===t?"P1$r0m":" q"===t?`P1$r${{block:2,underline:4,bar:6}[e.cursorStyle]-(e.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,i){this._dirtyRowTracker.markRangeDirty(t,i)}},Jh=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,i){t>i&&(Gh=t,t=i,i=Gh),t<this.start&&(this.start=t),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Oh(t){return 0<=t&&t<256}Jh=a([l(0,x)],Jh);var Wh=class extends lt{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Qt),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,i){if(void 0!==i&&this._syncCalls>i)return void(this._syncCalls=0);if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let s;for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let t=this._callbacks.shift();t&&t()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,i){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(i),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(i)}_innerWrite(t=0,i=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let t=this._writeBuffer[this._bufferOffset],e=this._action(t,i);if(e){let t=t=>performance.now()-s>=12?setTimeout((()=>this._innerWrite(0,t))):this._innerWrite(s,t);return void e.catch((t=>(queueMicrotask((()=>{throw t})),Promise.resolve(!1)))).then(t)}let h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=t.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},zh=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let i=this._bufferService.buffer;if(void 0===t.id){let s=i.addMarker(i.ybase+i.y),e={data:t,id:this._nextId++,lines:[s]};return s.onDispose((()=>this._removeMarkerFromLink(e,s))),this._dataByLinkId.set(e.id,e),e.id}let s=t,e=this._getEntryIdKey(s),h=this._entriesWithId.get(e);if(h)return this.addLineToLink(h.id,i.ybase+i.y),h.id;let r=i.addMarker(i.ybase+i.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[r]};return r.onDispose((()=>this._removeMarkerFromLink(n,r))),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(t,i){let s=this._dataByLinkId.get(t);if(s&&s.lines.every((t=>t.line!==i))){let t=this._bufferService.buffer.addMarker(i);s.lines.push(t),t.onDispose((()=>this._removeMarkerFromLink(s,t)))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,i){let s=t.lines.indexOf(i);-1!==s&&(t.lines.splice(s,1),0===t.lines.length&&(void 0!==t.data.id&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};zh=a([l(0,x)],zh);var qh=!1,Kh=class extends lt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new ct),this._onBinary=this._register(new Qt),this.onBinary=this._onBinary.event,this._onData=this._register(new Qt),this.onData=this._onData.event,this._onLineFeed=this._register(new Qt),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Qt),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Qt),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Qt),this._instantiationService=new He,this.optionsService=this._register(new eh(t)),this._instantiationService.setService(R,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(th)),this._instantiationService.setService(x,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Te)),this._instantiationService.setService($,this._logService),this.coreService=this._register(this._instantiationService.createInstance(oh)),this._instantiationService.setService(L,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ah)),this._instantiationService.setService(D,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ph)),this._instantiationService.setService(F,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Ch),this._instantiationService.setService(_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(zh),this._instantiationService.setService(N,this._oscLinkService),this._inputHandler=this._register(new Ph(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ft.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ft.forward(this._bufferService.onResize,this._onResize)),this._register(ft.forward(this.coreService.onData,this._onData)),this._register(ft.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 Wh(((t,i)=>this._inputHandler.parse(t,i)))),this._register(ft.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Qt),this._onScroll.event((t=>{this._onScrollApi?.fire(t.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(t){for(let i in t)this.optionsService.options[i]=t[i]}write(t,i){this._writeBuffer.write(t,i)}writeSync(t,i){this._logService.logLevel<=3&&!qh&&(this._logService.warn("writeSync is unreliable and will be removed soon."),qh=!0),this._writeBuffer.writeSync(t,i)}input(t,i=!0){this.coreService.triggerDataEvent(t,i)}resize(t,i){isNaN(t)||isNaN(i)||this._bufferService.resize(t=Math.max(t,2),i=Math.max(i,1))}scroll(t,i=!1){this._bufferService.scroll(t,i)}scrollLines(t,i){this._bufferService.scrollLines(t,i)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let i=t-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(t,i){return this._inputHandler.registerEscHandler(t,i)}registerDcsHandler(t,i){return this._inputHandler.registerDcsHandler(t,i)}registerCsiHandler(t,i){return this._inputHandler.registerCsiHandler(t,i)}registerOscHandler(t,i){return this._inputHandler.registerOscHandler(t,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?t="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(mh.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(()=>(mh(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=nt((()=>{for(let i of t)i.dispose()}))}}},jh={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:["'",'"']},Yh=0,Zh=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ae,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ae,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(t){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue((()=>this._flushInserted())),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort(((t,i)=>this._getKey(t)-this._getKey(i))),i=0,s=0,e=Array(this._array.length+this._insertedValues.length);for(let h=0;h<e.length;h++)s>=this._array.length||this._getKey(t[i])<=this._getKey(this._array[s])?(e[h]=t[i],i++):e[h]=this._array[s++];this._array=e,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(t);if(void 0===i||-1===(Yh=this._search(i))||this._getKey(this._array[Yh])!==i)return!1;do{if(this._array[Yh]===t)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue((()=>this._flushDeleted())),this._deletedIndices.push(Yh),!0}while(++Yh<this._array.length&&this._getKey(this._array[Yh])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort(((t,i)=>t-i)),i=0,s=Array(this._array.length-t.length),e=0;for(let h=0;h<this._array.length;h++)t[i]===h?i++:s[e++]=this._array[h];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((Yh=this._search(t))<0||Yh>=this._array.length)&&this._getKey(this._array[Yh])===t)do{yield this._array[Yh]}while(++Yh<this._array.length&&this._getKey(this._array[Yh])===t)}forEachByKey(t,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((Yh=this._search(t))<0||Yh>=this._array.length)&&this._getKey(this._array[Yh])===t)do{i(this._array[Yh])}while(++Yh<this._array.length&&this._getKey(this._array[Yh])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let i=0,s=this._array.length-1;for(;s>=i;){let e=i+s>>1,h=this._getKey(this._array[e]);if(h>t)s=e-1;else{if(!(h<t)){for(;e>0&&this._getKey(this._array[e-1])===t;)e--;return e}i=e+1}}return i}},Xh=0,Vh=0,tr=class extends lt{constructor(){super(),this._decorations=new Zh((t=>t?.marker.line)),this._onDecorationRegistered=this._register(new Qt),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Qt),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(nt((()=>this.reset())))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let i=new ir(t);if(i){let t=i.marker.onDispose((()=>i.dispose())),s=i.onDispose((()=>{s.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),t.dispose())}));this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,i,s){let e=0,h=0;for(let r of this._decorations.getKeyIterator(i))e=r.options.x??0,h=e+(r.options.width??1),t>=e&&t<h&&(!s||(r.options.layer??"bottom")===s)&&(yield r)}forEachDecorationAtCell(t,i,s,e){this._decorations.forEachByKey(i,(i=>{Vh=(Xh=i.options.x??0)+(i.options.width??1),t>=Xh&&t<Vh&&(!s||(i.options.layer??"bottom")===s)&&e(i)}))}},ir=class extends at{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Qt),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Qt),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 null===this._cachedBg&&(this._cachedBg=this.options.backgroundColor?ps.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this._cachedFg=this.options.foregroundColor?ps.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},sr=class{constructor(t,i=1e3){this._renderCallback=t,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,i,s){this._rowCount=s,t=void 0!==t?t:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,t):t,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let e=performance.now();if(e-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=e,this._innerRefresh();else if(!this._additionalRefreshRequested){let t=this._debounceThresholdMS-(e-this._lastRefreshMs);this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let t=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,i)}},er=class extends lt{constructor(t,i,s,e){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=e,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let h=this._coreBrowserService.mainDocument;this._accessibilityContainer=h.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=h.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let t=0;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);if(this._topBoundaryFocusListener=t=>this._handleBoundaryFocus(t,0),this._bottomBoundaryFocusListener=t=>this._handleBoundaryFocus(t,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=h.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new sr(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize((t=>this._handleResize(t.rows)))),this._register(this._terminal.onRender((t=>this._refreshRows(t.start,t.end)))),this._register(this._terminal.onScroll((()=>this._refreshRows()))),this._register(this._terminal.onA11yChar((t=>this._handleChar(t)))),this._register(this._terminal.onLineFeed((()=>this._handleChar("\n")))),this._register(this._terminal.onA11yTab((t=>this._handleTab(t)))),this._register(this._terminal.onKey((t=>this._handleKey(t.key)))),this._register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this._register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._register(ki(h,"selectionchange",(()=>this._handleSelectionChange()))),this._register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRowsDimensions(),this._refreshRows(),this._register(nt((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(t){for(let i=0;i<t;i++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,"\n"===t&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=f())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),/\p{Control}/u.test(t)||this._charsToConsume.push(t)}_refreshRows(t,i){this._liveRegionDebouncer.refresh(t,i,this._terminal.rows)}_renderRows(t,i){let s=this._terminal.buffer,e=""+s.lines.length;for(let h=t;h<=i;h++){let t=s.lines.get(s.ydisp+h),i=[],r=t?.translateToString(!0,void 0,void 0,i)||"",n=""+(s.ydisp+h+1),o=this._rowElements[h];o&&(0===r.length?(o.textContent=" ",this._rowColumns.set(o,[0,1])):(o.textContent=r,this._rowColumns.set(o,i)),o.setAttribute("aria-posinset",n),o.setAttribute("aria-setsize",e),this._alignRowWidth(o))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,i){let s,e,h=t.target,r=this._rowElements[0===i?1:this._rowElements.length-2];if(h.getAttribute("aria-posinset")!==(0===i?"1":""+this._terminal.buffer.lines.length)&&t.relatedTarget===r){if(0===i?(s=h,e=this._rowElements.pop(),this._rowContainer.removeChild(e)):(s=this._rowElements.shift(),e=h,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),e.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let t=this._createAccessibilityTreeNode();this._rowElements.unshift(t),this._rowContainer.insertAdjacentElement("afterbegin",t)}else{let t=this._createAccessibilityTreeNode();this._rowElements.push(t),this._rowContainer.appendChild(t)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed)return void(this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection());if(!t.anchorNode||!t.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let e=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(e)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:e,offset:e.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let h=({node:t,offset:i})=>{let s=t instanceof Text?t.parentNode:t,e=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(e))return console.warn("row is invalid. Race condition?"),null;let h=this._rowColumns.get(s);if(!h)return console.warn("columns is null. Race condition?"),null;let r=i<h.length?h[i]:h.slice(-1)[0]+1;return r>=this._terminal.cols&&(++e,r=0),{row:e,column:r}},r=h(i),n=h(s);if(r&&n){if(r.row>n.row||r.row===n.row&&r.column>=n.column)throw Error("invalid range");this._terminal.select(r.column,r.row,(n.row-r.row)*this._terminal.cols-r.column+n.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>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 i=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];s&&(t.style.transform=`scaleX(${s*this._renderService.dimensions.css.cell.width/i})`)}};er=a([l(1,S),l(2,P),l(3,O)],er);var hr=class extends lt{constructor(t,i,s,e,h){super(),this._element=t,this._mouseService=i,this._renderService=s,this._bufferService=e,this._linkProviderService=h,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Qt),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Qt),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(nt((()=>{rt(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(ki(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this._register(ki(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ki(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ki(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let i=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let s=t.composedPath();for(let t=0;t<s.length;t++){let i=s[t];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||i.x!==this._lastBufferCell.x||i.y!==this._lastBufferCell.y)&&(this._handleHover(i),this._lastBufferCell=i)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(t,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,i){(!this._activeProviderReplies||!i)&&(this._activeProviderReplies?.forEach((t=>{t?.forEach((t=>{t.link.dispose&&t.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[e,h]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(e)&&(s=this._checkLinkProviderResult(e,t,s)):h.provideLinks(t.y,(i=>{if(this._isMouseOut)return;let h=i?.map((t=>({link:t})));this._activeProviderReplies?.set(e,h),s=this._checkLinkProviderResult(e,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)}))}_removeIntersectingLinks(t,i){let s=new Set;for(let e=0;e<i.size;e++){let h=i.get(e);if(h)for(let i=0;i<h.length;i++){let e=h[i],r=e.link.range.end.y>t?this._bufferService.cols:e.link.range.end.x;for(let n=e.link.range.start.y<t?0:e.link.range.start.x;n<=r;n++){if(s.has(n)){h.splice(i--,1);break}s.add(n)}}}}_checkLinkProviderResult(t,i,s){if(!this._activeProviderReplies)return s;let e=this._activeProviderReplies.get(t),h=!1;for(let i=0;i<t;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(h=!0);if(!h&&e){let t=e.find((t=>this._linkAtPosition(t.link,i)));t&&(s=!0,this._handleNewLink(t))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let t=0;t<this._activeProviderReplies.size;t++){let e=this._activeProviderReplies.get(t)?.find((t=>this._linkAtPosition(t.link,i)));if(e){s=!0,this._handleNewLink(e);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let i=this._positionFromMouseEvent(t,this._element,this._mouseService);i&&this._mouseDownLink&&function(t,i){return t.text===i.text&&t.range.start.x===i.range.start.x&&t.range.start.y===i.range.start.y&&t.range.end.x===i.range.end.x&&t.range.end.y===i.range.end.y}(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,i){!this._currentLink||!this._lastMouseEvent||(!t||!i||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,rt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(t.link,i)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:void 0===t.link.decorations||t.link.decorations.underline,pointerCursor:void 0===t.link.decorations||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:t=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==t&&(this._currentLink.state.decorations.pointerCursor=t,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",t))}},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((t=>{if(!this._currentLink)return;let i=0===t.start?0:t.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+t.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._askForLink(t,!1)}}))))}_linkHover(t,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(s,i.text)}_fireUnderlineEvent(t,i){let s=t.range,e=this._bufferService.buffer.ydisp,h=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-e-1,s.end.x,s.end.y-e-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(h)}_linkLeave(t,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(s,i.text)}_linkAtPosition(t,i){let s=i.y*this._bufferService.cols+i.x;return t.range.start.y*this._bufferService.cols+t.range.start.x<=s&&s<=t.range.end.y*this._bufferService.cols+t.range.end.x}_positionFromMouseEvent(t,i,s){let e=s.getCoords(t,i,this._bufferService.cols,this._bufferService.rows);if(e)return{x:e[0],y:e[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,i,s,e,h){return{x1:t,y1:i,x2:s,y2:e,cols:this._bufferService.cols,fg:h}}};hr=a([l(1,J),l(2,O),l(3,x),l(4,K)],hr);var rr=class extends Kh{constructor(t={}){super(t),this._linkifier=this._register(new ct),this.browser=Zs,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ct),this._onCursorMove=this._register(new Qt),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Qt),this.onKey=this._onKey.event,this._onRender=this._register(new Qt),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Qt),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Qt),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Qt),this.onBell=this._onBell.event,this._onFocus=this._register(new Qt),this._onBlur=this._register(new Qt),this._onA11yCharEmitter=this._register(new Qt),this._onA11yTabEmitter=this._register(new Qt),this._onWillOpen=this._register(new Qt),this._setup(),this._decorationService=this._instantiationService.createInstance(tr),this._instantiationService.setService(H,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(qs),this._instantiationService.setService(K,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(U)),this._register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this._register(this._inputHandler.onRequestRefreshRows((t=>this.refresh(t?.start??0,t?.end??this.rows-1)))),this._register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this._register(this._inputHandler.onRequestReset((()=>this.reset()))),this._register(this._inputHandler.onRequestWindowsOptionsReport((t=>this._reportWindowsOptions(t)))),this._register(this._inputHandler.onColor((t=>this._handleColorEvent(t)))),this._register(ft.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ft.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ft.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ft.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize((t=>this._afterResize(t.cols,t.rows)))),this._register(nt((()=>{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(t){if(this._themeService)for(let i of t){let t,s="";switch(i.index){case 256:t="foreground",s="10";break;case 257:t="background",s="11";break;case 258:t="cursor",s="12";break;default:t="ansi",s="4;"+i.index}switch(i.type){case 0:let e=ws.toColorRGB("ansi"===t?this._themeService.colors.ansi[i.index]:this._themeService.colors[t]);this.coreService.triggerDataEvent(`${ns.ESC}]${s};${Fh(e)}${as.ST}`);break;case 1:if("ansi"===t)this._themeService.modifyColors((t=>t.ansi[i.index]=gs.toColor(...i.color)));else{let s=t;this._themeService.modifyColors((t=>t[s]=gs.toColor(...i.color)))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(er,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ns.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(ns.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.lines.get(this.buffer.ybase+this.buffer.y);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,e=t.getWidth(i),h=this._renderService.dimensions.css.cell.width*e,r=this.buffer.y*this._renderService.dimensions.css.cell.height;this.textarea.style.left=i*this._renderService.dimensions.css.cell.width+"px",this.textarea.style.top=r+"px",this.textarea.style.width=h+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ki(this.element,"copy",(t=>{this.hasSelection()&&function(t,i){t.clipboardData&&t.clipboardData.setData("text/plain",i.selectionText),t.preventDefault()}(t,this._selectionService)})));let t=t=>function(t,i,s,e){t.stopPropagation(),t.clipboardData&&d(t.clipboardData.getData("text/plain"),i,s,e)}(t,this.textarea,this.coreService,this.optionsService);this._register(ki(this.textarea,"paste",t)),this._register(ki(this.element,"paste",t)),this._register(ie?ki(this.element,"mousedown",(t=>{2===t.button&&w(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):ki(this.element,"contextmenu",(t=>{w(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),le&&this._register(ki(this.element,"auxclick",(t=>{1===t.button&&g(t,this.textarea,this.screenElement)})))}_bindKeys(){this._register(ki(this.textarea,"keyup",(t=>this._keyUp(t)),!0)),this._register(ki(this.textarea,"keydown",(t=>this._keyDown(t)),!0)),this._register(ki(this.textarea,"keypress",(t=>this._keyPress(t)),!0)),this._register(ki(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this._register(ki(this.textarea,"compositionupdate",(t=>this._compositionHelper.compositionupdate(t)))),this._register(ki(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this._register(ki(this.textarea,"input",(t=>this._inputEvent(t)),!0)),this._register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(t){if(!t)throw Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=t.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"),t.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(ki(this.screenElement,"mousemove",(t=>this.updateCursorStyle(t)))),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",u()),ce||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(Ws,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(P,this._coreBrowserService),this._register(ki(this.textarea,"focus",(t=>this._handleTextAreaFocus(t)))),this._register(ki(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gs,this._document,this._helperContainer),this._instantiationService.setService(G,this._charSizeService),this._themeService=this._instantiationService.createInstance(Re),this._instantiationService.setService(q,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ks),this._instantiationService.setService(z,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(de,this.rows,this.screenElement)),this._instantiationService.setService(O,this._renderService),this._register(this._renderService.onRenderedViewportChange((t=>this._onRender.fire(t)))),this.onResize((t=>this._renderService.resize(t.cols,t.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(ds,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(js),this._instantiationService.setService(J,this._mouseService);let e=this._linkifier.value=this._register(this._instantiationService.createInstance(hr,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(hs,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines((t=>{super.scrollLines(t,!1),this.refresh(0,this.rows-1)}))),this._selectionService=this._register(this._instantiationService.createInstance(ye,this.element,this.screenElement,e)),this._instantiationService.setService(W,this._selectionService),this._register(this._selectionService.onRequestScrollLines((t=>this.scrollLines(t.amount,t.suppressScrollEvent)))),this._register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this._register(this._selectionService.onRequestRedraw((t=>this._renderService.handleSelectionChanged(t.start,t.end,t.columnSelectMode)))),this._register(this._selectionService.onLinuxMouseSelection((t=>{this.textarea.value=t,this.textarea.focus(),this.textarea.select()}))),this._register(ft.any(this._onScroll.event,this._inputHandler.onScroll)((()=>{this._selectionService.refresh(),this._viewport?.queueSync()}))),this._register(this._instantiationService.createInstance(rs,this.screenElement)),this._register(ki(this.element,"mousedown",(t=>this._selectionService.handleMouseDown(t)))),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(er,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",(t=>this._handleScreenReaderModeOptionChange(t)))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",(t=>{!this._overviewRulerRenderer&&t&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fs,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ts,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,i=this.element;function s(i){let s,e,h=t._mouseService.getMouseReportCoords(i,t.screenElement);if(!h)return!1;switch(i.overrideType||i.type){case"mousemove":e=32,void 0===i.buttons?(s=3,void 0!==i.button&&(s=i.button<3?i.button:3)):s=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":e=0,s=i.button<3?i.button:3;break;case"mousedown":e=1,s=i.button<3?i.button:3;break;case"wheel":if(t._customWheelEventHandler&&!1===t._customWheelEventHandler(i))return!1;let h=i.deltaY;if(0===h||0===t.coreMouseService.consumeWheelEvent(i,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr))return!1;e=h<0?0:1,s=4;break;default:return!1}return!(void 0===e||void 0===s||s>4)&&t.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:s,action:e,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let e={mouseup:null,wheel:null,mousedrag:null,mousemove:null},h={mouseup:t=>(s(t),t.buttons||(this._document.removeEventListener("mouseup",e.mouseup),e.mousedrag&&this._document.removeEventListener("mousemove",e.mousedrag)),this.cancel(t)),wheel:t=>(s(t),this.cancel(t,!0)),mousedrag:t=>{t.buttons&&s(t)},mousemove:t=>{t.buttons||s(t)}};this._register(this.coreMouseService.onProtocolChange((t=>{t?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(t)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&t?e.mousemove||(i.addEventListener("mousemove",h.mousemove),e.mousemove=h.mousemove):(i.removeEventListener("mousemove",e.mousemove),e.mousemove=null),16&t?e.wheel||(i.addEventListener("wheel",h.wheel,{passive:!1}),e.wheel=h.wheel):(i.removeEventListener("wheel",e.wheel),e.wheel=null),2&t?e.mouseup||(e.mouseup=h.mouseup):(this._document.removeEventListener("mouseup",e.mouseup),e.mouseup=null),4&t?e.mousedrag||(e.mousedrag=h.mousedrag):(this._document.removeEventListener("mousemove",e.mousedrag),e.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ki(i,"mousedown",(t=>{if(t.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(t))return s(t),e.mouseup&&this._document.addEventListener("mouseup",e.mouseup),e.mousedrag&&this._document.addEventListener("mousemove",e.mousedrag),this.cancel(t)}))),this._register(ki(i,"wheel",(i=>{if(!e.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback)return 0!==i.deltaY&&(0===t.coreMouseService.consumeWheelEvent(i,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)||this.coreService.triggerDataEvent(ns.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B"),!0),this.cancel(i,!0))}}),{passive:!1}))}refresh(t,i){this._renderService?.refreshRows(t,i)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?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(t,i){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,i),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let i=t-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(t){d(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(t,i,s){this._selectionService.setSelection(t,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(t,i){this._selectionService?.selectLines(t,i)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(t))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!i&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!i&&("Dead"===t.key||"AltGraph"===t.key)&&(this._unprocessedDeadKey=!0);let s=function(t,i,s,e){let h={type:0,cancel:!1,key:void 0},r=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:"UIKeyInputUpArrow"===t.key?h.key=i?ns.ESC+"OA":ns.ESC+"[A":"UIKeyInputLeftArrow"===t.key?h.key=i?ns.ESC+"OD":ns.ESC+"[D":"UIKeyInputRightArrow"===t.key?h.key=i?ns.ESC+"OC":ns.ESC+"[C":"UIKeyInputDownArrow"===t.key&&(h.key=i?ns.ESC+"OB":ns.ESC+"[B");break;case 8:h.key=t.ctrlKey?"\b":ns.DEL,t.altKey&&(h.key=ns.ESC+h.key);break;case 9:if(t.shiftKey){h.key=ns.ESC+"[Z";break}h.key=ns.HT,h.cancel=!0;break;case 13:h.key=t.altKey?ns.ESC+ns.CR:ns.CR,h.cancel=!0;break;case 27:h.key=ns.ESC,t.altKey&&(h.key=ns.ESC+ns.ESC),h.cancel=!0;break;case 37:if(t.metaKey)break;h.key=r?ns.ESC+"[1;"+(r+1)+"D":i?ns.ESC+"OD":ns.ESC+"[D";break;case 39:if(t.metaKey)break;h.key=r?ns.ESC+"[1;"+(r+1)+"C":i?ns.ESC+"OC":ns.ESC+"[C";break;case 38:if(t.metaKey)break;h.key=r?ns.ESC+"[1;"+(r+1)+"A":i?ns.ESC+"OA":ns.ESC+"[A";break;case 40:if(t.metaKey)break;h.key=r?ns.ESC+"[1;"+(r+1)+"B":i?ns.ESC+"OB":ns.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(h.key=ns.ESC+"[2~");break;case 46:h.key=r?ns.ESC+"[3;"+(r+1)+"~":ns.ESC+"[3~";break;case 36:h.key=r?ns.ESC+"[1;"+(r+1)+"H":i?ns.ESC+"OH":ns.ESC+"[H";break;case 35:h.key=r?ns.ESC+"[1;"+(r+1)+"F":i?ns.ESC+"OF":ns.ESC+"[F";break;case 33:t.shiftKey?h.type=2:h.key=t.ctrlKey?ns.ESC+"[5;"+(r+1)+"~":ns.ESC+"[5~";break;case 34:t.shiftKey?h.type=3:h.key=t.ctrlKey?ns.ESC+"[6;"+(r+1)+"~":ns.ESC+"[6~";break;case 112:h.key=r?ns.ESC+"[1;"+(r+1)+"P":ns.ESC+"OP";break;case 113:h.key=r?ns.ESC+"[1;"+(r+1)+"Q":ns.ESC+"OQ";break;case 114:h.key=r?ns.ESC+"[1;"+(r+1)+"R":ns.ESC+"OR";break;case 115:h.key=r?ns.ESC+"[1;"+(r+1)+"S":ns.ESC+"OS";break;case 116:h.key=r?ns.ESC+"[15;"+(r+1)+"~":ns.ESC+"[15~";break;case 117:h.key=r?ns.ESC+"[17;"+(r+1)+"~":ns.ESC+"[17~";break;case 118:h.key=r?ns.ESC+"[18;"+(r+1)+"~":ns.ESC+"[18~";break;case 119:h.key=r?ns.ESC+"[19;"+(r+1)+"~":ns.ESC+"[19~";break;case 120:h.key=r?ns.ESC+"[20;"+(r+1)+"~":ns.ESC+"[20~";break;case 121:h.key=r?ns.ESC+"[21;"+(r+1)+"~":ns.ESC+"[21~";break;case 122:h.key=r?ns.ESC+"[23;"+(r+1)+"~":ns.ESC+"[23~";break;case 123:h.key=r?ns.ESC+"[24;"+(r+1)+"~":ns.ESC+"[24~";break;default:if(!t.ctrlKey||t.shiftKey||t.altKey||t.metaKey)if(s&&!e||!t.altKey||t.metaKey)!s||t.altKey||t.ctrlKey||t.shiftKey||!t.metaKey?t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&1===t.key.length?h.key=t.key:t.key&&t.ctrlKey&&("_"===t.key&&(h.key=ns.US),"@"===t.key&&(h.key=ns.NUL)):65===t.keyCode&&(h.type=1);else{let i=jh[t.keyCode]?.[t.shiftKey?1:0];if(i)h.key=ns.ESC+i;else if(t.keyCode>=65&&t.keyCode<=90){let i=String.fromCharCode(t.ctrlKey?t.keyCode-64:t.keyCode+32);t.shiftKey&&(i=i.toUpperCase()),h.key=ns.ESC+i}else if(32===t.keyCode)h.key=ns.ESC+(t.ctrlKey?ns.NUL:" ");else if("Dead"===t.key&&t.code.startsWith("Key")){let i=t.code.slice(3,4);t.shiftKey||(i=i.toLowerCase()),h.key=ns.ESC+i,h.cancel=!0}}else t.keyCode>=65&&t.keyCode<=90?h.key=String.fromCharCode(t.keyCode-64):32===t.keyCode?h.key=ns.NUL:t.keyCode>=51&&t.keyCode<=55?h.key=String.fromCharCode(t.keyCode-51+27):56===t.keyCode?h.key=ns.DEL:219===t.keyCode?h.key=ns.ESC:220===t.keyCode?h.key=ns.FS:221===t.keyCode&&(h.key=ns.GS)}return h}(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),3===s.type||2===s.type){let i=this.rows-1;return this.scrollLines(2===s.type?-i:i),this.cancel(t,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&1===t.key.length&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===ns.ETX||s.key===ns.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey?this.cancel(t,!0):void(this._keyDownHandled=!0)))}_isThirdLevelShift(t,i){let s=t.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||t.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||t.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(t))&&(function(t){return 16===t.keyCode||17===t.keyCode||18===t.keyCode}(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(t))return!1;if(this.cancel(t),t.charCode)i=t.charCode;else if(null==t.which)i=t.keyCode;else{if(0===t.which||0===t.charCode)return!1;i=t.which}return!(!i||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)||(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(t){return!(!t.data||"insertText"!==t.inputType||t.composed&&this._keyDownSeen||this.optionsService.rawOptions.screenReaderMode)&&(!this._keyPressHandled&&(this._unprocessedDeadKey=!1,this.coreService.triggerDataEvent(t.data,!0),this.cancel(t),!0))}resize(t,i){t!==this.cols||i!==this.rows?super.resize(t,i):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(t,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(Pe));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 t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(ns.ESC+"[I"):this.coreService.triggerDataEvent(ns.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ns.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),e=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${ns.ESC}[6;${e};${s}t`)}}cancel(t,i){if(this.options.cancelEvents||i)return t.preventDefault(),t.stopPropagation(),!1}},nr=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){i=s;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(i,1)}},or=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,i){if(!(t<0||t>=this._line.length))return i?(this._line.loadCell(t,i),i):this._line.loadCell(t,new M)}translateToString(t,i,s){return this._line.translateToString(t,i,s)}},ar=class{constructor(t,i){this._buffer=t,this.type=i}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 i=this._buffer.lines.get(t);if(i)return new or(i)}getNullCell(){return new M}},lr=class extends lt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Qt),this.onBufferChange=this._onBufferChange.event,this._normal=new ar(this._core.buffers.normal,"normal"),this._alternate=new ar(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 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)}},cr=class{constructor(t){this._core=t}registerCsiHandler(t,i){return this._core.registerCsiHandler(t,(t=>i(t.toArray())))}addCsiHandler(t,i){return this.registerCsiHandler(t,i)}registerDcsHandler(t,i){return this._core.registerDcsHandler(t,((t,s)=>i(t,s.toArray())))}addDcsHandler(t,i){return this.registerDcsHandler(t,i)}registerEscHandler(t,i){return this._core.registerEscHandler(t,i)}addEscHandler(t,i){return this.registerEscHandler(t,i)}registerOscHandler(t,i){return this._core.registerOscHandler(t,i)}addOscHandler(t,i){return this.registerOscHandler(t,i)}},ur=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},Ar=["cols","rows"],fr=0,dr=class extends lt{constructor(t){super(),this._core=this._register(new rr(t)),this._addonManager=this._register(new nr),this._publicOptions={...this._core.options};let i=t=>this._core.options[t],s=(t,i)=>{this._checkReadonlyOptions(t),this._core.options[t]=i};for(let t in this._core.options){let e={get:i.bind(this,t),set:s.bind(this,t)};Object.defineProperty(this._publicOptions,t,e)}}_checkReadonlyOptions(t){if(Ar.includes(t))throw Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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 cr(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ur(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 lr(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,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 i in t)this._publicOptions[i]=t[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,i=!0){this._core.input(t,i)}resize(t,i){this._verifyIntegers(t,i),this._core.resize(t,i)}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,i,s){this._verifyIntegers(t,i,s),this._core.select(t,i,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,i){this._verifyIntegers(t,i),this._core.selectLines(t,i)}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,i){this._core.write(t,i)}writeln(t,i){this._core.write(t),this._core.write("\r\n",i)}paste(t){this._core.paste(t)}refresh(t,i){this._verifyIntegers(t,i),this._core.refresh(t,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return u()},set promptLabel(t){(t=>{c=t})(t)},get tooMuchOutput(){return f()},set tooMuchOutput(t){(t=>{A=t})(t)}}}_verifyIntegers(...t){for(fr of t)if(fr===1/0||isNaN(fr)||fr%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(fr of t)if(fr&&(fr===1/0||isNaN(fr)||fr%1!=0||fr<0))throw Error("This API only accepts positive integers")}},gr=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();t&&this._terminal&&!isNaN(t.cols)&&!isNaN(t.rows)&&(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(this._terminal._core._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(0===t.css.cell.width||0===t.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),e=parseInt(s.getPropertyValue("height")),h=Math.max(0,parseInt(s.getPropertyValue("width"))),r=window.getComputedStyle(this._terminal.element),n=parseInt(r.getPropertyValue("padding-top")),o=parseInt(r.getPropertyValue("padding-bottom")),a=parseInt(r.getPropertyValue("padding-right")),l=parseInt(r.getPropertyValue("padding-left")),c=e-(n+o);return{cols:Math.max(2,Math.floor((h-(a+l)-i)/t.css.cell.width)),rows:Math.max(1,Math.floor(c/t.css.cell.height))}}},wr=class{constructor(t,i,s,e={}){this._terminal=t,this._regex=i,this._handler=s,this._options=e}provideLinks(t,i){let s=Cr.computeLink(t,this._regex,this._terminal,this._handler);i(this._addCallbacks(s))}_addCallbacks(t){return t.map((t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:e}=t;this._options.hover(i,s,e)}},t)))}};function pr(t){try{let i=new URL(t),s=i.password&&i.username?`${i.protocol}//${i.username}:${i.password}@${i.host}`:i.username?`${i.protocol}//${i.username}@${i.host}`:`${i.protocol}//${i.host}`;return t.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Cr=class t{static computeLink(i,s,e,h){let r,n=RegExp(s.source,(s.flags||"")+"g"),[o,a]=t._getWindowedLineStrings(i-1,e),l=o.join(""),c=[];for(;r=n.exec(l);){let i=r[0];if(!pr(i))continue;let[s,n]=t._mapStrIdx(e,a,0,r.index),[o,l]=t._mapStrIdx(e,s,n,i.length);-1!==s&&-1!==n&&-1!==o&&-1!==l&&c.push({range:{start:{x:n+1,y:s+1},end:{x:l,y:o+1}},text:i,activate:h})}return c}static _getWindowedLineStrings(t,i){let s,e=t,h=t,r=0,n="",o=[];if(s=i.buffer.active.getLine(t)){let t=s.translateToString(!0);if(s.isWrapped&&" "!==t[0]){for(r=0;(s=i.buffer.active.getLine(--e))&&r<2048&&(n=s.translateToString(!0),r+=n.length,o.push(n),s.isWrapped&&-1===n.indexOf(" ")););o.reverse()}for(o.push(t),r=0;(s=i.buffer.active.getLine(++h))&&s.isWrapped&&r<2048&&(n=s.translateToString(!0),r+=n.length,o.push(n),-1===n.indexOf(" ")););}return[o,e]}static _mapStrIdx(t,i,s,e){let h=t.buffer.active,r=h.getNullCell(),n=s;for(;e;){let t=h.getLine(i);if(!t)return[-1,-1];for(let s=n;s<t.length;++s){t.getCell(s,r);let n=r.getChars();if(r.getWidth()&&(e-=n.length||1,s===t.length-1&&""===n)){let t=h.getLine(i+1);t&&t.isWrapped&&(t.getCell(0,r),2===r.getWidth()&&(e+=1))}if(e<0)return[i,s]}i++,n=0}return[i,n]}},mr=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Ir(t,i){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}var vr=class{constructor(t=Ir,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options;this._linkProvider=this._terminal.registerLinkProvider(new wr(this._terminal,i.urlRegex||mr,this._handler,i))}dispose(){this._linkProvider?.dispose()}},br=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?kr.isErrorNoTelemetry(t)?new kr(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};
13
+ */var A=Object.defineProperty,f=Object.getOwnPropertyDescriptor,d=(t,i,s,e)=>{for(var h,r=e>1?void 0:e?f(i,s):i,n=t.length-1;n>=0;n--)(h=t[n])&&(r=(e?h(i,s,r):h(r))||r);return e&&r&&A(i,s,r),r},g=(t,i)=>(s,e)=>i(s,e,t),w="Terminal input",p=()=>w,C="Too much output to announce, navigate to rows manually to read",m=()=>C;function I(t,i,s,e){t=function(t,i){return i?"[200~"+t+"[201~":t}(t=function(t){return t.replace(/\r?\n/g,"\r")}(t),s.decPrivateModes.bracketedPasteMode&&!0!==e.rawOptions.ignoreBracketedPasteMode),s.triggerDataEvent(t,!0),i.value=""}function v(t,i,s){let e=s.getBoundingClientRect(),h=t.clientX-e.left-10,r=t.clientY-e.top-10;i.style.width="20px",i.style.height="20px",i.style.left=h+"px",i.style.top=r+"px",i.style.zIndex="1000",i.focus()}function B(t,i,s,e,h){v(t,i,s),h&&e.rightClickSelect(t),i.value=e.selectionText,i.select()}function M(t){return t>65535?String.fromCharCode(55296+((t-=65536)>>10))+String.fromCharCode(t%1024+56320):String.fromCharCode(t)}function y(t,i=0,s=t.length){let e="";for(let h=i;h<s;++h){let i=t[h];i>65535?(i-=65536,e+=String.fromCharCode(55296+(i>>10))+String.fromCharCode(i%1024+56320)):e+=String.fromCharCode(i)}return e}var Q=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,i){let s=t.length;if(!s)return 0;let e=0,h=0;if(this._interim){let s=t.charCodeAt(h++);56320<=s&&s<=57343?i[e++]=1024*(this._interim-55296)+s-56320+65536:(i[e++]=this._interim,i[e++]=s),this._interim=0}for(let r=h;r<s;++r){let h=t.charCodeAt(r);if(55296<=h&&h<=56319){if(++r>=s)return this._interim=h,e;let n=t.charCodeAt(r);56320<=n&&n<=57343?i[e++]=1024*(h-55296)+n-56320+65536:(i[e++]=h,i[e++]=n)}else 65279!==h&&(i[e++]=h)}return e}},E=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,i){let s=t.length;if(!s)return 0;let e,h,r,n,o=0,l=0,a=0;if(this.interim[0]){let e=!1,h=this.interim[0];h&=192==(224&h)?31:224==(240&h)?15:7;let r,n=0;for(;(r=63&this.interim[++n])&&n<4;)h<<=6,h|=r;let l=192==(224&this.interim[0])?2:224==(240&this.interim[0])?3:4,u=l-n;for(;a<u;){if(a>=s)return 0;if(r=t[a++],128!=(192&r)){a--,e=!0;break}this.interim[n++]=r,h<<=6,h|=63&r}e||(2===l?h<128?a--:i[o++]=h:3===l?h<2048||h>=55296&&h<=57343||65279===h||(i[o++]=h):h<65536||h>1114111||(i[o++]=h)),this.interim.fill(0)}let u=s-4,c=a;for(;c<s;){for(;!(!(c<u)||128&(e=t[c])||128&(h=t[c+1])||128&(r=t[c+2])||128&(n=t[c+3]));)i[o++]=e,i[o++]=h,i[o++]=r,i[o++]=n,c+=4;if(e=t[c++],e<128)i[o++]=e;else if(192==(224&e)){if(c>=s)return this.interim[0]=e,o;if(h=t[c++],128!=(192&h)){c--;continue}if(l=(31&e)<<6|63&h,l<128){c--;continue}i[o++]=l}else if(224==(240&e)){if(c>=s)return this.interim[0]=e,o;if(h=t[c++],128!=(192&h)){c--;continue}if(c>=s)return this.interim[0]=e,this.interim[1]=h,o;if(r=t[c++],128!=(192&r)){c--;continue}if(l=(15&e)<<12|(63&h)<<6|63&r,l<2048||l>=55296&&l<=57343||65279===l)continue;i[o++]=l}else if(240==(248&e)){if(c>=s)return this.interim[0]=e,o;if(h=t[c++],128!=(192&h)){c--;continue}if(c>=s)return this.interim[0]=e,this.interim[1]=h,o;if(r=t[c++],128!=(192&r)){c--;continue}if(c>=s)return this.interim[0]=e,this.interim[1]=h,this.interim[2]=r,o;if(n=t[c++],128!=(192&n)){c--;continue}if(l=(7&e)<<18|(63&h)<<12|(63&r)<<6|63&n,l<65536||l>1114111)continue;i[o++]=l}}return o}},b=" ",k=class t{constructor(){this.fg=0,this.bg=0,this.extended=new x}static toColorRGB(t){return[t>>>16&255,t>>>8&255,255&t]}static fromColorRGB(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]}clone(){let i=new t;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},x=class t{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},D=class t extends k{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new x,this.combinedData=""}static fromCharData(i){let s=new t;return s.setFromCharData(i),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?M(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(2===t[1].length){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let e=t[1].charCodeAt(1);56320<=e&&e<=57343?this.content=1024*(s-55296)+e-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},L="di$target",S="di$dependencies",_=new Map;function $(t){if(_.has(t))return _.get(t);let i=function(t,s,e){if(3!==arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[L]===i?i[S].push({id:t,index:s}):(i[S]=[{id:t,index:s}],i[L]=i)}(i,t,e)};return i._id=t,_.set(t,i),i}var R=$("BufferService"),N=$("CoreMouseService"),F=$("CoreService"),H=$("CharsetService"),T=$("InstantiationService"),U=$("LogService"),G=$("OptionsService"),P=$("OscLinkService"),J=$("UnicodeService"),O=$("DecorationService"),W=class{constructor(t,i,s){this._bufferService=t,this._optionsService=i,this._oscLinkService=s}provideLinks(t,i){let s=this._bufferService.buffer.lines.get(t-1);if(!s)return void i(void 0);let e=[],h=this._optionsService.rawOptions.linkHandler,r=new D,n=s.getTrimmedLength(),o=-1,l=-1,a=!1;for(let i=0;i<n;i++)if(-1!==l||s.hasContent(i)){if(s.loadCell(i,r),r.hasExtendedAttrs()&&r.extended.urlId){if(-1===l){l=i,o=r.extended.urlId;continue}a=r.extended.urlId!==o}else-1!==l&&(a=!0);if(a||-1!==l&&i===n-1){let s=this._oscLinkService.getLinkData(o)?.uri;if(s){let r={start:{x:l+1,y:t},end:{x:i+(a||i!==n-1?0:1),y:t}},o=!1;if(!h?.allowNonHttpProtocols)try{let t=new URL(s);["http:","https:"].includes(t.protocol)||(o=!0)}catch{o=!0}o||e.push({text:s,range:r,activate:(t,i)=>h?h.activate(t,i,r):z(0,i),hover:(t,i)=>h?.hover?.(t,i,r),leave:(t,i)=>h?.leave?.(t,i,r)})}a=!1,r.hasExtendedAttrs()&&r.extended.urlId?(l=i,o=r.extended.urlId):(l=-1,o=-1)}}i(e)}};function z(t,i){if(confirm(`Do you want to navigate to ${i}?\n\nWARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}}W=d([g(0,R),g(1,G),g(2,P)],W);var K=$("CharSizeService"),q=$("CoreBrowserService"),j=$("MouseService"),Y=$("RenderService"),Z=$("SelectionService"),X=$("CharacterJoinerService"),V=$("ThemeService"),tt=$("LinkProviderService"),it=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?ot.isErrorNoTelemetry(t)?new ot(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};function st(t){(function(t){return t instanceof nt||t instanceof Error&&t.name===rt&&t.message===rt})(t)||it.onUnexpectedError(t)}var et,ht,rt="Canceled",nt=class extends Error{constructor(){super(rt),this.name=this.message}},ot=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}},lt=class t extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,t.prototype)}};function at(t,i=0){return t[t.length-(1+i)]}function ut(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function ct(t){if(ht.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function At(t){return{dispose:ut((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(et||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(ht||={});var ft=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{ct(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};ft.DISABLE_DISPOSED_WARNING=!1;var dt=ft,gt=class{constructor(){this._store=new dt}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};gt.None=Object.freeze({dispose(){}});var wt=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}},pt="object"==typeof window?window:globalThis,Ct=class t{constructor(i){this.element=i,this.next=t.Undefined,this.prev=t.Undefined}};Ct.Undefined=new Ct(void 0);var mt,It=Ct,vt=class{constructor(){this._first=It.Undefined,this._last=It.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===It.Undefined}clear(){let t=this._first;for(;t!==It.Undefined;){let i=t.next;t.prev=It.Undefined,t.next=It.Undefined,t=i}this._first=It.Undefined,this._last=It.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,i){let s=new It(t);if(this._first===It.Undefined)this._first=s,this._last=s;else if(i){let t=this._last;this._last=s,s.prev=t,t.next=s}else{let t=this._first;this._first=s,s.next=t,t.prev=s}this._size+=1;let e=!1;return()=>{e||(e=!0,this._remove(s))}}shift(){if(this._first!==It.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==It.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==It.Undefined&&t.next!==It.Undefined){let i=t.prev;i.next=t.next,t.next.prev=i}else t.prev===It.Undefined&&t.next===It.Undefined?(this._first=It.Undefined,this._last=It.Undefined):t.next===It.Undefined?(this._last=this._last.prev,this._last.next=It.Undefined):t.prev===It.Undefined&&(this._first=this._first.next,this._first.prev=It.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==It.Undefined;)yield t.element,t=t.next}},Bt=globalThis.performance&&"function"==typeof globalThis.performance.now,Mt=class t{static create(i){return new t(i)}constructor(t){this._now=Bt&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new _t({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,l,a,u,c=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{c++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),u=()=>{let t=l;l=void 0,a=void 0,(!e||c>1)&&f.fire(t),c=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(u,s)):void 0===a&&(a=0,queueMicrotask(u))}))},onWillRemoveListener(){h&&c>0&&u?.()},onDidRemoveLastListener(){u=void 0,o.dispose()}},f=new _t(A);return n?.add(f),f.event}t.None=()=>gt.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=function(...t){return At((()=>ct(t)))}(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new _t({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new _t({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new _t({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new _t;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class l{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new _t({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new l(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof dt?e.add(o):Array.isArray(e)&&e.push(o),o}}})(mt||={});var yt=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new Mt,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};yt.all=new Set,yt._idPool=0;var Qt=yt,Et=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new xt(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};Et._idPool=1;var bt=Et,kt=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},xt=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Dt=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Lt=0,St=class{constructor(t){this.value=t,this.id=Lt++}},_t=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new bt(t?.onListenerError??st,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Qt(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new Dt(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||st)(s),gt.None}if(this._disposed)return gt.None;i&&(t=t.bind(i));let e,h=new St(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=kt.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof St?(this._deliveryQueue??=new $t,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=At((()=>{e?.(),this._removeListener(h)}));return s instanceof dt?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||st;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 St)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},$t=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Rt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new _t,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new _t,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Rt.INSTANCE=new Rt;var Nt=Rt,Ft="object"==typeof navigator?navigator.userAgent:"",Ht=Ft.indexOf("Firefox")>=0,Tt=Ft.indexOf("AppleWebKit")>=0,Ut=Ft.indexOf("Chrome")>=0,Gt=!Ut&&Ft.indexOf("Safari")>=0;if(Ft.indexOf("Electron/"),Ft.indexOf("Android"),"function"==typeof pt.matchMedia){let t=pt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");pt.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=pt.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Pt,Jt,Ot="en",Wt=!1,zt=!1,Kt=!1,qt=!1,jt=Ot,Yt=globalThis;typeof Yt.vscode<"u"&&typeof Yt.vscode.process<"u"?Jt=Yt.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Jt=process);var Zt="string"==typeof Jt?.versions?.electron&&"renderer"===Jt?.type;if("object"==typeof Jt){Wt="win32"===Jt.platform,zt="darwin"===Jt.platform,Kt="linux"===Jt.platform,jt=Ot;let t=Jt.env.VSCODE_NLS_CONFIG;if(t)try{jt=JSON.parse(t).resolvedLanguage||Ot}catch{}qt=!0}else"object"!=typeof navigator||Zt?console.error("Unable to resolve platform."):(Wt=(Pt=navigator.userAgent).indexOf("Windows")>=0,zt=Pt.indexOf("Macintosh")>=0,(Pt.indexOf("Macintosh")>=0||Pt.indexOf("iPad")>=0||Pt.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Kt=Pt.indexOf("Linux")>=0,Pt?.indexOf("Mobi"),jt=globalThis._VSCODE_NLS_LANGUAGE||Ot,navigator.language.toLowerCase());var Xt,Vt=Wt,ti=zt,ii=Kt,si=qt,ei=Pt,hi=jt;(t=>{t.value=function(){return hi},t.isDefaultVariant=function(){return 2===hi.length?"en"===hi:hi.length>=3&&"e"===hi[0]&&"n"===hi[1]&&"-"===hi[2]},t.isDefault=function(){return"en"===hi}})(Xt||={});var ri="function"==typeof Yt.postMessage&&!Yt.importScripts;(()=>{if(ri){let t=[];Yt.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var ni=!!(ei&&ei.indexOf("Chrome")>=0);ei&&ei.indexOf("Firefox"),!ni&&ei&&ei.indexOf("Safari"),ei&&ei.indexOf("Edg/"),ei&&ei.indexOf("Android"),"object"==typeof navigator&&navigator,si||document.queryCommandSupported&&document.queryCommandSupported("copy");var oi,li=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,i){this._keyCodeToStr[t]=i,this._strToKeyCode[i.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},ai=new li,ui=new li,ci=new li,Ai=Array(230);(t=>{t.toString=function(t){return ai.keyCodeToStr(t)},t.fromString=function(t){return ai.strToKeyCode(t)},t.toUserSettingsUS=function(t){return ui.keyCodeToStr(t)},t.toUserSettingsGeneral=function(t){return ci.keyCodeToStr(t)},t.fromUserSettings=function(t){return ui.strToKeyCode(t)||ci.strToKeyCode(t)},t.toElectronAccelerator=function(t){if(t>=98&&t<=113)return null;switch(t){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ai.keyCodeToStr(t)}})(oi||={});var fi=class t{constructor(t,i,s,e,h){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=e,this.keyCode=h}equals(i){return i instanceof t&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){return`K${this.ctrlKey?"1":"0"}${this.shiftKey?"1":"0"}${this.altKey?"1":"0"}${this.metaKey?"1":"0"}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new di([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},di=class{constructor(t){if(0===t.length)throw Error("Illegal argument: chords");this.chords=t}getHashCode(){let t="";for(let i=0,s=this.chords.length;i<s;i++)0!==i&&(t+=";"),t+=this.chords[i].getHashCode();return t}equals(t){if(null===t||this.chords.length!==t.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(t.chords[i]))return!1;return!0}},gi=ti?256:2048,wi=ti?2048:256,pi=class{constructor(t){this._standardKeyboardEventBrand=!0;let i=t;this.browserEvent=i,this.target=i.target,this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.altGraphKey=i.getModifierState?.("AltGraph"),this.keyCode=function(t){if(t.charCode){let i=String.fromCharCode(t.charCode).toUpperCase();return oi.fromString(i)}let i=t.keyCode;if(3===i)return 7;if(Ht)switch(i){case 59:return 85;case 60:if(ii)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ti)return 57}else if(Tt){if(ti&&93===i)return 57;if(!ti&&92===i)return 57}return Ai[i]||0}(i),this.code=i.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(t=this.keyCode);let i=0;return this.ctrlKey&&(i|=gi),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=wi),i|=t,i}_computeKeyCodeChord(){let t=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(t=this.keyCode),new fi(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},Ci=new WeakMap;function mi(t){if(!t.parent||t.parent===t)return null;try{let i=t.location,s=t.parent.location;if("null"!==i.origin&&"null"!==s.origin&&i.origin!==s.origin)return null}catch{return null}return t.parent}var Ii,vi=class{static getSameOriginWindowChain(t){let i=Ci.get(t);if(!i){i=[],Ci.set(t,i);let s,e=t;do{s=mi(e),i.push(s?{window:new WeakRef(e),iframeElement:e.frameElement||null}:{window:new WeakRef(e),iframeElement:null}),e=s}while(e)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,i){if(!i||t===i)return{top:0,left:0};let s=0,e=0,h=this.getSameOriginWindowChain(t);for(let t of h){let h=t.window.deref();if(s+=h?.scrollY??0,e+=h?.scrollX??0,h===i||!t.iframeElement)break;let r=t.iframeElement.getBoundingClientRect();s+=r.top,e+=r.left}return{top:s,left:e}}},Bi=class{constructor(t,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(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=vi.getPositionOfChildWindowRelativeToAncestorWindow(t,i.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Mi=class{constructor(t,i=0,s=0){this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=i;let e=!1;if(Ut){let t=navigator.userAgent.match(/Chrome\/(\d+)/);e=(t?parseInt(t[1]):123)<=122}if(t){let i=t,s=t,h=t.view?.devicePixelRatio||1;typeof i.wheelDeltaY<"u"?this.deltaY=e?i.wheelDeltaY/(120*h):i.wheelDeltaY/120:typeof s.VERTICAL_AXIS<"u"&&s.axis===s.VERTICAL_AXIS?this.deltaY=-s.detail/3:"wheel"===t.type&&(this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?Ht&&!ti?-t.deltaY/3:-t.deltaY:-t.deltaY/40),typeof i.wheelDeltaX<"u"?this.deltaX=Gt&&Vt?-i.wheelDeltaX/120:e?i.wheelDeltaX/(120*h):i.wheelDeltaX/120:typeof s.HORIZONTAL_AXIS<"u"&&s.axis===s.HORIZONTAL_AXIS?this.deltaX=-t.detail/3:"wheel"===t.type&&(this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?Ht&&!ti?-t.deltaX/3:-t.deltaX:-t.deltaX/40),0===this.deltaY&&0===this.deltaX&&t.wheelDelta&&(this.deltaY=e?t.wheelDelta/(120*h):t.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},yi=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof Ei||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:mt.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:yi})})(Ii||={});var Qi,Ei=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?yi:(this._emitter||(this._emitter=new _t),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},bi=class{constructor(t,i){this._isDisposed=!1,this._token=-1,"function"==typeof t&&"number"==typeof i&&this.setIfNotSet(t,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(t,i){if(this._isDisposed)throw new lt("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout((()=>{this._token=-1,t()}),i)}setIfNotSet(t,i){if(this._isDisposed)throw new lt("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout((()=>{this._token=-1,t()}),i))}},ki=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(t,i,s=globalThis){if(this.isDisposed)throw new lt("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let e=s.setInterval((()=>{t()}),i);this.disposable=At((()=>{s.clearInterval(e),this.disposable=void 0}))}dispose(){this.cancel(),this.isDisposed=!0}};(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(Qi||={});var xi=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new _t,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await mt.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};xi.EMPTY=xi.fromArray([]);var{getWindow:Di,getWindowId:Li,onDidRegisterWindow:Si}=function(){let t=new Map,i={window:pt,disposables:new dt};t.set(pt.vscodeWindowId,i);let s=new _t,e=new _t,h=new _t;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return gt.None;let r=new dt,n={window:i,disposables:r.add(new dt)};return t.set(i.vscodeWindowId,n),r.add(At((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add($i(i,Ti.BEFORE_UNLOAD,(()=>{h.fire(i)}))),s.fire(n),r},getWindows:()=>t.values(),getWindowsCount:()=>t.size,getWindowId:t=>t.vscodeWindowId,hasWindow:i=>t.has(i),getWindowById:function(s,e){return("number"==typeof s?t.get(s):void 0)??(e?i:void 0)},getWindow(t){let i=t;if(i?.ownerDocument?.defaultView)return i.ownerDocument.defaultView.window;let s=t;return s?.view?s.view.window:pt},getDocument:t=>Di(t).document}}(),_i=class{constructor(t,i,s,e){this._node=t,this._type=i,this._handler=s,this._options=e||!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 $i(t,i,s,e){return new _i(t,i,s,e)}var Ri,Ni=function(t,i,s,e){return $i(t,i,s,e)},Fi=class extends ki{constructor(t){super(),this.defaultTarget=t&&Di(t)}cancelAndSet(t,i,s){return super.cancelAndSet(t,i,s??this.defaultTarget)}},Hi=class{constructor(t,i=0){this._runner=t,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(t){st(t)}}static sort(t,i){return i.priority-t.priority}};!function(){let t=new Map,i=new Map,s=new Map,e=new Map;Ri=(h,r,n=0)=>{let o=Li(h),l=new Hi(r,n),a=t.get(o);return a||(a=[],t.set(o,a)),a.push(l),s.get(o)||(s.set(o,!0),h.requestAnimationFrame((()=>(h=>{s.set(h,!1);let r=t.get(h)??[];for(i.set(h,r),t.set(h,[]),e.set(h,!0);r.length>0;)r.sort(Hi.sort),r.shift().execute();e.set(h,!1)})(o)))),l}}();var Ti={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"},Ui=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 i=Gi(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=Gi(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=Gi(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=Gi(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=Gi(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=Gi(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=Gi(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=Gi(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=Gi(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=Gi(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=Gi(t);this._paddingRight!==i&&(this._paddingRight=i,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 i=Gi(t);this._fontSize!==i&&(this._fontSize=i,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 i=Gi(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=Gi(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),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,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Gi(t){return"number"==typeof t?t+"px":t}function Pi(t){return new Ui(t)}var Ji,Oi=class{constructor(){this._hooks=new dt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(t,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,t&&s&&s(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(t,i,s,e,h){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=e,this._onStopCallback=h;let r=t;try{t.setPointerCapture(i),this._hooks.add(At((()=>{try{t.releasePointerCapture(i)}catch{}})))}catch{r=Di(t)}this._hooks.add($i(r,Ti.POINTER_MOVE,(t=>{t.buttons===s?(t.preventDefault(),this._pointerMoveCallback(t)):this.stopMonitoring(!0)}))),this._hooks.add($i(r,Ti.POINTER_UP,(()=>this.stopMonitoring(!0))))}};(t=>{t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"})(Ji||={});var Wi=class t extends gt{constructor(){super(),this.dispatched=!1,this.targets=new vt,this.ignoreTargets=new vt,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(mt.runAndSubscribe(Si,(({window:t,disposables:i})=>{i.add($i(t.document,"touchstart",(t=>this.onTouchStart(t)),{passive:!1})),i.add($i(t.document,"touchend",(i=>this.onTouchEnd(t,i)))),i.add($i(t.document,"touchmove",(t=>this.onTouchMove(t)),{passive:!1}))}),{window:pt,disposables:this._store}))}static addTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),At(t.INSTANCE.targets.push(i))):gt.None}static ignoreTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),At(t.INSTANCE.ignoreTargets.push(i))):gt.None}static isTouchDevice(){return"ontouchstart"in pt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,e=t.targetTouches.length;s<e;s++){let e=t.targetTouches.item(s);this.activeTouches[e.identifier]={id:e.identifier,initialTarget:e.target,initialTimeStamp:i,initialPageX:e.pageX,initialPageY:e.pageY,rollingTimestamps:[i],rollingPageX:[e.pageX],rollingPageY:[e.pageY]};let h=this.newGestureEvent(Ji.Start,e.target);h.pageX=e.pageX,h.pageY=e.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,s){let e=Date.now(),h=Object.keys(this.activeTouches).length;for(let r=0,n=s.changedTouches.length;r<n;r++){let n=s.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(n.identifier+"")){console.warn("move of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=Date.now()-o.initialTimeStamp;if(l<t.HOLD_DELAY&&Math.abs(o.initialPageX-at(o.rollingPageX))<30&&Math.abs(o.initialPageY-at(o.rollingPageY))<30){let t=this.newGestureEvent(Ji.Tap,o.initialTarget);t.pageX=at(o.rollingPageX),t.pageY=at(o.rollingPageY),this.dispatchEvent(t)}else if(l>=t.HOLD_DELAY&&Math.abs(o.initialPageX-at(o.rollingPageX))<30&&Math.abs(o.initialPageY-at(o.rollingPageY))<30){let t=this.newGestureEvent(Ji.Contextmenu,o.initialTarget);t.pageX=at(o.rollingPageX),t.pageY=at(o.rollingPageY),this.dispatchEvent(t)}else if(1===h){let t=at(o.rollingPageX),s=at(o.rollingPageY),h=at(o.rollingTimestamps)-o.rollingTimestamps[0],r=t-o.rollingPageX[0],n=s-o.rollingPageY[0],l=[...this.targets].filter((t=>o.initialTarget instanceof Node&&t.contains(o.initialTarget)));this.inertia(i,l,e,Math.abs(r)/h,r>0?1:-1,t,Math.abs(n)/h,n>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(Ji.End,o.initialTarget)),delete this.activeTouches[n.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(i){if(i.type===Ji.Tap){let s=(new Date).getTime(),e=0;e=s-this._lastSetTapCountTime>t.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,i.tapCount=e}else(i.type===Ji.Change||i.type===Ji.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let t of this.ignoreTargets)if(t.contains(i.initialTarget))return;let t=[];for(let s of this.targets)if(s.contains(i.initialTarget)){let e=0,h=i.initialTarget;for(;h&&h!==s;)e++,h=h.parentElement;t.push([e,s])}t.sort(((t,i)=>t[0]-i[0]));for(let[s,e]of t)e.dispatchEvent(i),this.dispatched=!0}}inertia(i,s,e,h,r,n,o,l,a){this.handle=Ri(i,(()=>{let u=Date.now(),c=u-e,A=0,f=0,d=!0;(h+=t.SCROLL_FRICTION*c)>0&&(d=!1,A=r*h*c),(o+=t.SCROLL_FRICTION*c)>0&&(d=!1,f=l*o*c);let g=this.newGestureEvent(Ji.Change);g.translationX=A,g.translationY=f,s.forEach((t=>t.dispatchEvent(g))),d||this.inertia(i,s,u,h,r,n+A,o,l,a+f)}))}onTouchMove(t){let i=Date.now();for(let s=0,e=t.changedTouches.length;s<e;s++){let e=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(e.identifier+"")){console.warn("end of an UNKNOWN touch",e);continue}let h=this.activeTouches[e.identifier],r=this.newGestureEvent(Ji.Change,h.initialTarget);r.translationX=e.pageX-at(h.rollingPageX),r.translationY=e.pageY-at(h.rollingPageY),r.pageX=e.pageX,r.pageY=e.pageY,this.dispatchEvent(r),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(e.pageX),h.rollingPageY.push(e.pageY),h.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Wi.SCROLL_FRICTION=-.005,Wi.HOLD_DELAY=700,Wi.CLEAR_TAP_COUNT_TIME=400,d([function(t,i,s){let e=null,h=null;if("function"==typeof s.value?(e="value",h=s.value,0!==h.length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(e="get",h=s.get),!h)throw Error("not supported");let r="$memoize$"+i;s[e]=function(...t){return this.hasOwnProperty(r)||Object.defineProperty(this,r,{configurable:!1,enumerable:!1,writable:!1,value:h.apply(this,t)}),this[r]}}],Wi,"isTouchDevice",1);var zi=Wi,Ki=class extends gt{onclick(t,i){this._register($i(t,Ti.CLICK,(s=>i(new Bi(Di(t),s)))))}onmousedown(t,i){this._register($i(t,Ti.MOUSE_DOWN,(s=>i(new Bi(Di(t),s)))))}onmouseover(t,i){this._register($i(t,Ti.MOUSE_OVER,(s=>i(new Bi(Di(t),s)))))}onmouseleave(t,i){this._register($i(t,Ti.MOUSE_LEAVE,(s=>i(new Bi(Di(t),s)))))}onkeydown(t,i){this._register($i(t,Ti.KEY_DOWN,(t=>i(new pi(t)))))}onkeyup(t,i){this._register($i(t,Ti.KEY_UP,(t=>i(new pi(t)))))}oninput(t,i){this._register($i(t,Ti.INPUT,i))}onblur(t,i){this._register($i(t,Ti.BLUR,i))}onfocus(t,i){this._register($i(t,Ti.FOCUS,i))}onchange(t,i){this._register($i(t,Ti.CHANGE,i))}ignoreGesture(t){return zi.ignoreTarget(t)}},qi=class extends Ki{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="11px",this.domNode.style.height="11px",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 Oi),this._register(Ni(this.bgDomNode,Ti.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._register(Ni(this.domNode,Ti.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._pointerdownRepeatTimer=this._register(new Fi),this._pointerdownScheduleRepeatTimer=this._register(new bi)}_arrowPointerDown(t){t.target&&t.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet((()=>{this._pointerdownRepeatTimer.cancelAndSet((()=>this._onActivate()),1e3/24,Di(t))}),200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(()=>{}),(()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()})),t.preventDefault())}},ji=class t{constructor(t,i,s,e,h,r,n){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,s|=0,e|=0,h|=0,r|=0,n|=0),this.rawScrollLeft=e,this.rawScrollTop=n,i<0&&(i=0),e+i>s&&(e=s-i),e<0&&(e=0),h<0&&(h=0),n+h>r&&(n=r-h),n<0&&(n=0),this.width=i,this.scrollWidth=s,this.scrollLeft=e,this.height=h,this.scrollHeight=r,this.scrollTop=n}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(i,s){return new t(this._forceIntegerValues,typeof i.width<"u"?i.width:this.width,typeof i.scrollWidth<"u"?i.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof i.height<"u"?i.height:this.height,typeof i.scrollHeight<"u"?i.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new t(this._forceIntegerValues,this.width,this.scrollWidth,typeof i.scrollLeft<"u"?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof i.scrollTop<"u"?i.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:this.width!==t.width,scrollWidthChanged:this.scrollWidth!==t.scrollWidth,scrollLeftChanged:this.scrollLeft!==t.scrollLeft,heightChanged:this.height!==t.height,scrollHeightChanged:this.scrollHeight!==t.scrollHeight,scrollTopChanged:this.scrollTop!==t.scrollTop}}},Yi=class extends gt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new _t),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new ji(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,i){let s=this._state.withScrollDimensions(t,i);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(t){let i=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(t,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(t);if(this._smoothScrolling){let s,e=this._state.withScrollPosition(t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop});if(this._smoothScrolling.to.scrollLeft===e.scrollLeft&&this._smoothScrolling.to.scrollTop===e.scrollTop)return;s=i?new Vi(this._smoothScrolling.from,e,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,e,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(t);this._smoothScrolling=Vi.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(),i=this._state.withScrollPosition(t);if(this._setState(i,!0),this._smoothScrolling){if(t.isDone)return this._smoothScrolling.dispose(),void(this._smoothScrolling=null);this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame((()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())}))}}_setState(t,i){let s=this._state;s.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(s,i)))}},Zi=class{constructor(t,i,s){this.scrollLeft=t,this.scrollTop=i,this.isDone=s}};function Xi(t,i){let s=i-t;return function(i){return t+s*function(t){return 1-function(t){return Math.pow(t,3)}(1-t)}(i)}}var Vi=class t{constructor(t,i,s,e){this.from=t,this.to=i,this.duration=e,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let e,h;return t<i?(e=t+.75*s,h=i-.75*s):(e=t-.75*s,h=i+.75*s),function(t,i,s){return function(e){return e<s?t(e/s):i((e-s)/(1-s))}}(Xi(t,e),Xi(h,i),.33)}return Xi(t,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let t=this.scrollLeft(i),s=this.scrollTop(i);return new Zi(t,s,!1)}return new Zi(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,s,e){return t.start(i,s,e)}static start(i,s,e){e+=10;let h=Date.now()-10;return new t(i,s,h,e)}},ts=class extends gt{constructor(t,i,s){super(),this._visibility=t,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 bi)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this._updateShouldBeVisible())}setShouldBeVisible(t){this._rawShouldBeVisible=t,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let t=this._applyVisibilitySetting();this._shouldBeVisible!==t&&(this._shouldBeVisible=t,this.ensureVisibility())}setIsNeeded(t){this._isNeeded!==t&&(this._isNeeded=t,this.ensureVisibility())}setDomNode(t){this._domNode=t,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet((()=>{this._domNode?.setClassName(this._visibleClassName)}),0))}_hide(t){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(t?" fade":"")))}},is=class extends Ki{constructor(t){super(),this._lazyRender=t.lazyRender,this._host=t.host,this._scrollable=t.scrollable,this._scrollByPage=t.scrollByPage,this._scrollbarState=t.scrollbarState,this._visibilityController=this._register(new ts(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Oi),this._shouldRender=!0,this.domNode=Pi(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($i(this.domNode.domNode,Ti.POINTER_DOWN,(t=>this._domNodePointerDown(t))))}_createArrow(t){let i=this._register(new qi(t));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(t,i,s,e){this.slider=Pi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(t),this.slider.setLeft(i),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof e&&this.slider.setHeight(e),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register($i(this.slider.domNode,Ti.POINTER_DOWN,(t=>{0===t.button&&(t.preventDefault(),this._sliderPointerDown(t))}))),this.onclick(this.slider.domNode,(t=>{t.leftButton&&t.stopPropagation()}))}_onElementSize(t){return this._scrollbarState.setVisibleSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(t){return this._scrollbarState.setScrollSize(t)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(t){return this._scrollbarState.setScrollPosition(t)&&(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(t){t.target===this.domNode.domNode&&this._onPointerDown(t)}delegatePointerDown(t){let i=this.domNode.domNode.getClientRects()[0].top,s=i+this._scrollbarState.getSliderPosition(),e=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),h=this._sliderPointerPosition(t);s<=h&&h<=e?0===t.button&&(t.preventDefault(),this._sliderPointerDown(t)):this._onPointerDown(t)}_onPointerDown(t){let i,s;if(t.target===this.domNode.domNode&&"number"==typeof t.offsetX&&"number"==typeof t.offsetY)i=t.offsetX,s=t.offsetY;else{let e=function(t){let i=t.getBoundingClientRect(),s=Di(t);return{left:i.left+s.scrollX,top:i.top+s.scrollY,width:i.width,height:i.height}}(this.domNode.domNode);i=t.pageX-e.left,s=t.pageY-e.top}let e=this._pointerDownRelativePosition(i,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(e):this._scrollbarState.getDesiredScrollPositionFromOffset(e)),0===t.button&&(t.preventDefault(),this._sliderPointerDown(t))}_sliderPointerDown(t){if(!(t.target&&t.target instanceof Element))return;let i=this._sliderPointerPosition(t),s=this._sliderOrthogonalPointerPosition(t),e=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(t=>{let h=this._sliderOrthogonalPointerPosition(t);if(Vt&&Math.abs(h-s)>140)return void this._setDesiredScrollPositionNow(e.getScrollPosition());let r=this._sliderPointerPosition(t)-i;this._setDesiredScrollPositionNow(e.getDesiredScrollPositionFromDelta(r))}),(()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()})),this._host.onDragStart()}_setDesiredScrollPositionNow(t){let i={};this.writeScrollPosition(i,t),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(t){this._updateScrollbarSize(t),this._scrollbarState.setScrollbarSize(t),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ss=class t{constructor(t,i,s,e,h,r){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=e,this._scrollSize=h,this._scrollPosition=r,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new t(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,e,h){let r=Math.max(0,s-t),n=Math.max(0,r-2*i),o=e>0&&e>s;if(!o)return{computedAvailableSize:Math.round(r),computedIsNeeded:o,computedSliderSize:Math.round(n),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*n/e))),a=(n-l)/(e-s),u=h*a;return{computedAvailableSize:Math.round(r),computedIsNeeded:o,computedSliderSize:Math.round(l),computedSliderRatio:a,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let i=t._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){return this._computedIsNeeded?Math.round((t-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=this._scrollPosition;return t-this._arrowSize<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){return this._computedIsNeeded?Math.round((this._computedSliderPosition+t)/this._computedSliderRatio):0}},es=class extends is{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new ss(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,e.width,e.scrollWidth,h.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:t,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(t,i){this.slider.setWidth(t),this.slider.setLeft(i)}_renderDomNode(t,i){this.domNode.setWidth(t),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(t.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,i){return t}_sliderPointerPosition(t){return t.pageX}_sliderOrthogonalPointerPosition(t){return t.pageY}_updateScrollbarSize(t){this.slider.setHeight(t)}writeScrollPosition(t,i){t.scrollLeft=i}updateOptions(t){this.updateScrollbarSize(2===t.horizontal?0:t.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===t.vertical?0:t.verticalScrollbarSize),this._visibilityController.setVisibility(t.horizontal),this._scrollByPage=t.scrollByPage}},hs=class extends is{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new ss(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,e.height,e.scrollHeight,h.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(t,i){this.slider.setHeight(t),this.slider.setTop(i)}_renderDomNode(t,i){this.domNode.setWidth(i),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,i){return i}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,i){t.scrollTop=i}updateOptions(t){this.updateScrollbarSize(2===t.vertical?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},rs=class{constructor(t,i,s){this.timestamp=t,this.deltaX=i,this.deltaY=s,this.score=0}},ns=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let t=1,i=0,s=1,e=this._rear;for(;;){let h=e===this._front?t:Math.pow(2,-s);if(t-=h,i+=this._memory[e].score*h,e===this._front)break;e=(this._capacity+e-1)%this._capacity,s++}return i<=.5}acceptStandardWheelEvent(t){if(Ut){let i=function(t){return Nt.INSTANCE.getZoomFactor(t)}(Di(t.browserEvent));this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let e=null,h=new rs(t,i,s);-1===this._front&&-1===this._rear?(this._memory[0]=h,this._front=0,this._rear=0):(e=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]=h),h.score=this._computeScore(h,e)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let e=Math.abs(t.deltaX),h=Math.abs(t.deltaY),r=Math.abs(i.deltaX),n=Math.abs(i.deltaY),o=Math.max(Math.min(e,r),1),l=Math.max(Math.min(h,n),1);Math.max(e,r)%o==0&&Math.max(h,n)%l==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ns.INSTANCE=new ns;var os=ns,ls=class extends Ki{constructor(t,i,s){super(),this._onScroll=this._register(new _t),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new _t),this.onWillScroll=this._onWillScroll.event,this._options=function(t){let i={lazyRender:typeof t.lazyRender<"u"&&t.lazyRender,className:typeof t.className<"u"?t.className:"",useShadows:!(typeof t.useShadows<"u")||t.useShadows,handleMouseWheel:!(typeof t.handleMouseWheel<"u")||t.handleMouseWheel,flipAxes:typeof t.flipAxes<"u"&&t.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"&&t.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"&&t.alwaysConsumeMouseWheel,scrollYToX:typeof t.scrollYToX<"u"&&t.scrollYToX,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:!(typeof t.scrollPredominantAxis<"u")||t.scrollPredominantAxis,mouseWheelSmoothScroll:!(typeof t.mouseWheelSmoothScroll<"u")||t.mouseWheelSmoothScroll,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,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"&&t.verticalHasArrows,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"&&t.scrollByPage};return i.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:i.verticalScrollbarSize,ti&&(i.className+=" mac"),i}(i),this._scrollable=s,this._register(this._scrollable.onScroll((t=>{this._onWillScroll.fire(t),this._onDidScroll(t),this._onScroll.fire(t)})));let e={onMouseWheel:t=>this._onMouseWheel(t),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new hs(this._scrollable,this._options,e)),this._horizontalScrollbar=this._register(new es(this._scrollable,this._options,e)),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=Pi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Pi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Pi(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,(t=>this._onMouseOver(t))),this.onmouseleave(this._listenOnDomNode,(t=>this._onMouseLeave(t))),this._hideTimeout=this._register(new bi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ct(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,ti&&(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 Mi(t))}_setListeningToMouseWheel(t){this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ct(this._mouseWheelToDispose),t)&&this._mouseWheelToDispose.push($i(this._listenOnDomNode,Ti.MOUSE_WHEEL,(t=>{this._onMouseWheel(new Mi(t))}),{passive:!1}))}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let i=os.INSTANCE;i.acceptStandardWheelEvent(t);let s=!1;if(t.deltaY||t.deltaX){let e=t.deltaY*this._options.mouseWheelScrollSensitivity,h=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&h+e===0?h=e=0:Math.abs(e)>=Math.abs(h)?h=0:e=0),this._options.flipAxes&&([e,h]=[h,e]),(this._options.scrollYToX||!ti&&t.browserEvent&&t.browserEvent.shiftKey)&&!h&&(h=e,e=0),t.browserEvent&&t.browserEvent.altKey&&(h*=this._options.fastScrollSensitivity,e*=this._options.fastScrollSensitivity);let r=this._scrollable.getFutureScrollPosition(),n={};if(e){let t=50*e;this._verticalScrollbar.writeScrollPosition(n,r.scrollTop-(t<0?Math.floor(t):Math.ceil(t)))}if(h){let t=50*h;this._horizontalScrollbar.writeScrollPosition(n,r.scrollLeft-(t<0?Math.floor(t):Math.ceil(t)))}n=this._scrollable.validateScrollPosition(n),(r.scrollLeft!==n.scrollLeft||r.scrollTop!==n.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(n):this._scrollable.setScrollPositionNow(n),s=!0)}let e=s;!e&&this._options.alwaysConsumeMouseWheel&&(e=!0),!e&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(e=!0),e&&(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 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(),i=t.scrollTop>0,s=t.scrollLeft>0,e=s?" left":"",h=i?" top":"",r=s||i?" top-left-corner":"";this._leftShadowDomNode.setClassName("shadow"+e),this._topShadowDomNode.setClassName("shadow"+h),this._topLeftShadowDomNode.setClassName(`shadow${r}${h}${e}`)}}_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()),500)}},as=class extends ls{constructor(t,i,s){super(t,i,s)}setScrollPosition(t){t.reuseAnimation?this._scrollable.setScrollPositionSmooth(t,t.reuseAnimation):this._scrollable.setScrollPositionNow(t)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},us=class extends gt{constructor(t,i,s,e,h,r,n,o){super(),this._bufferService=s,this._optionsService=n,this._renderService=o,this._onRequestScrollLines=this._register(new _t),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new Yi({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:t=>Ri(e.window,t)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",(()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)}))),this._scrollableElement=this._register(new as(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},l)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],(()=>this._scrollableElement.updateOptions(this._getChangeOptions())))),this._register(h.onProtocolChange((t=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&t)})}))),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(mt.runAndSubscribe(r.onChangeColors,(()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css}))),t.appendChild(this._scrollableElement.getDomNode()),this._register(At((()=>this._scrollableElement.getDomNode().remove()))),this._styleElement=e.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(At((()=>this._styleElement.remove()))),this._register(mt.runAndSubscribe(r.onChangeColors,(()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}\n.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}\n.xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${r.colors.scrollbarSliderActiveBackground.css};`,"}"].join("\n")}))),this._register(this._bufferService.onResize((()=>this.queueSync()))),this._register(this._bufferService.buffers.onBufferActivate((()=>{this._latestYDisp=void 0,this.queueSync()}))),this._register(this._bufferService.onScroll((()=>this._sync()))),this._register(this._scrollableElement.onScroll((t=>this._handleScroll(t))))}scrollLines(t){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+t*this._renderService.dimensions.css.cell.height})}scrollToLine(t,i){i&&(this._latestYDisp=t),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:t*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(t){void 0!==t&&(this._latestYDisp=t),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback((()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)})))}_sync(t=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,t!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:t*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(t){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(t.scrollTop/this._renderService.dimensions.css.cell.height),s=i-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=i,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};us=d([g(2,R),g(3,q),g(4,N),g(5,V),g(6,G),g(7,Y)],us);var cs=class extends gt{constructor(t,i,s,e,h){super(),this._screenElement=t,this._bufferService=i,this._coreBrowserService=s,this._decorationService=e,this._renderService=h,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((t=>this._removeDecoration(t)))),this._register(At((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let t of this._decorationService.decorations)this._renderDecoration(t);this._dimensionsChanged=!1}_renderDecoration(t){this._refreshStyle(t),this._dimensionsChanged&&this._refreshXPosition(t)}_createElement(t){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer","top"===t?.options?.layer),i.style.width=Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)+"px",i.style.height=(t.options.height||1)*this._renderService.dimensions.css.cell.height+"px",i.style.top=(t.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=t.options.x??0;return s&&s>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(t,i),i}_refreshStyle(t){let i=t.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)t.element&&(t.element.style.display="none",t.onRenderEmitter.fire(t.element));else{let s=this._decorationElements.get(t);s||(s=this._createElement(t),t.element=s,this._decorationElements.set(t,s),this._container.appendChild(s),t.onDispose((()=>{this._decorationElements.delete(t),s.remove()}))),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=Math.round((t.options.width||1)*this._renderService.dimensions.css.cell.width)+"px",s.style.height=(t.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"),t.onRenderEmitter.fire(s)}}_refreshXPosition(t,i=t.element){if(!i)return;let s=t.options.x??0;"right"===(t.options.anchor||"left")?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(t){this._decorationElements.get(t)?.remove(),this._decorationElements.delete(t),t.dispose()}};cs=d([g(1,R),g(2,q),g(3,O),g(4,Y)],cs);var As,fs,ds,gs=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(t){if(t.options.overviewRulerOptions){for(let i of this._zones)if(i.color===t.options.overviewRulerOptions.color&&i.position===t.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,t.marker.line))return;if(this._lineAdjacentToZone(i,t.marker.line,t.options.overviewRulerOptions.position))return void this._addLineToZone(i,t.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=t.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=t.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=t.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=t.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:t.options.overviewRulerOptions.color,position:t.options.overviewRulerOptions.position,startBufferLine:t.marker.line,endBufferLine:t.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(t){this._linePadding=t}_lineIntersectsZone(t,i){return i>=t.startBufferLine&&i<=t.endBufferLine}_lineAdjacentToZone(t,i,s){return i>=t.startBufferLine-this._linePadding[s||"full"]&&i<=t.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(t,i){t.startBufferLine=Math.min(t.startBufferLine,i),t.endBufferLine=Math.max(t.endBufferLine,i)}},ws={full:0,left:0,center:0,right:0},ps={full:0,left:0,center:0,right:0},Cs={full:0,left:0,center:0,right:0},ms=class extends gt{constructor(t,i,s,e,h,r,n,o){super(),this._viewportElement=t,this._screenElement=i,this._bufferService=s,this._decorationService=e,this._renderService=h,this._optionsService=r,this._themeService=n,this._coreBrowserService=o,this._colorZoneStore=new gs,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(At((()=>this._canvas?.remove())));let l=this._canvas.getContext("2d");if(!l)throw Error("Ctx cannot be null");this._ctx=l,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 t=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);ps.full=this._canvas.width,ps.left=t,ps.center=i,ps.right=t,this._refreshDrawHeightConstants(),Cs.full=1,Cs.left=1,Cs.center=1+ps.left,Cs.right=1+ps.left+ps.center}_refreshDrawHeightConstants(){ws.full=Math.round(2*this._coreBrowserService.dpr);let t=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);ws.left=t,ws.center=t,ws.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ws.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ws.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ws.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ws.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=this._width+"px",this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=this._screenElement.clientHeight+"px",this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let t=this._colorZoneStore.zones;for(let i of t)"full"!==i.position&&this._renderColorZone(i);for(let i of t)"full"===i.position&&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(t){this._ctx.fillStyle=t.color,this._ctx.fillRect(Cs[t.position||"full"],Math.round(t.startBufferLine/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)-ws[t.position||"full"]/2),ps[t.position||"full"],Math.round((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)+ws[t.position||"full"]))}_queueRefresh(t,i){this._shouldUpdateDimensions=t||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};ms=d([g(2,R),g(3,O),g(4,Y),g(5,G),g(6,V),g(7,q)],ms),(t=>{t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="",t.BS="\b",t.HT="\t",t.LF="\n",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="",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""})(As||={}),(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="Ÿ"})(fs||={}),(ds||={}).ST=As.ESC+"\\";var Is=class{constructor(t,i,s,e,h,r){this._textarea=t,this._compositionView=i,this._bufferService=s,this._optionsService=e,this._coreService=h,this._renderService=r,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(t){this._compositionView.textContent=t.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(t){if(this._isComposing||this._isSendingComposition){if(20===t.keyCode||229===t.keyCode||16===t.keyCode||17===t.keyCode||18===t.keyCode)return!1;this._finalizeComposition(!1)}return 229!==t.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(t){if(this._compositionView.classList.remove("active"),this._isComposing=!1,t){let t={start:this._compositionPosition.start};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,t.start+=this._dataAlreadySent.length,i=this._isComposing?this._textarea.value.substring(t.start,this._compositionPosition.start):this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}}),0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let t=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let i=this._textarea.value,s=i.replace(t,"");this._dataAlreadySent=s,i.length>t.length?this._coreService.triggerDataEvent(s,!0):i.length<t.length?this._coreService.triggerDataEvent(""+As.DEL,!0):i.length===t.length&&i!==t&&this._coreService.triggerDataEvent(i,!0)}}),0)}updateCompositionElements(t){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1)*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=t+"px",this._compositionView.style.lineHeight=t+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let e=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(e.width,1)+"px",this._textarea.style.height=Math.max(e.height,1)+"px",this._textarea.style.lineHeight=e.height+"px"}t||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};Is=d([g(2,R),g(3,G),g(4,F),g(5,Y)],Is);var vs,Bs,Ms,ys,Qs,Es=0,bs=0,ks=0,xs=0,Ds={css:"#00000000",rgba:0};function Ls(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Ss(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${Ls(t)}${Ls(i)}${Ls(s)}${Ls(e)}`:`#${Ls(t)}${Ls(i)}${Ls(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(vs||={}),(t=>{function i(t,i){return xs=Math.round(255*i),[Es,bs,ks]=Qs.toChannels(t.rgba),{css:vs.toCss(Es,bs,ks,xs),rgba:vs.toRgba(Es,bs,ks,xs)}}t.blend=function(t,i){if(1==(xs=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:vs.toCss(Es=h+Math.round(((i.rgba>>24&255)-h)*xs),bs=r+Math.round((s-r)*xs),ks=n+Math.round((e-n)*xs)),rgba:vs.toRgba(Es,bs,ks)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=Qs.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return vs.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Es,bs,ks]=Qs.toChannels(i),{css:vs.toCss(Es,bs,ks),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(xs=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Bs||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return Es=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),ks=parseInt(t.slice(3,4).repeat(2),16),vs.toColor(Es,bs,ks);case 5:return Es=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),ks=parseInt(t.slice(3,4).repeat(2),16),xs=parseInt(t.slice(4,5).repeat(2),16),vs.toColor(Es,bs,ks,xs);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return vs.toColor(Es=parseInt(e[1]),bs=parseInt(e[2]),ks=parseInt(e[3]),xs=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Es,bs,ks,xs]=i.getImageData(0,0,1,1).data,255!==xs)throw Error("css.toColor: Unsupported css format");return{rgba:vs.toRgba(Es,bs,ks,xs),css:t}}})(Ms||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(ys||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=Ss(ys.relativeLuminance2(n,o,l),ys.relativeLuminance2(e,h,r));for(;a<s&&(n>0||o>0||l>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),l-=Math.max(0,Math.ceil(.1*l)),a=Ss(ys.relativeLuminance2(n,o,l),ys.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=Ss(ys.relativeLuminance2(n,o,l),ys.relativeLuminance2(e,h,r));for(;a<s&&(n<255||o<255||l<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),l=Math.min(255,l+Math.ceil(.1*(255-l))),a=Ss(ys.relativeLuminance2(n,o,l),ys.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}t.blend=function(t,i){if(1==(xs=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return vs.toRgba(Es=h+Math.round(((i>>24&255)-h)*xs),bs=r+Math.round((s-r)*xs),ks=n+Math.round((e-n)*xs))},t.ensureContrastRatio=function(t,e,h){let r=ys.relativeLuminance(t>>8),n=ys.relativeLuminance(e>>8);if(Ss(r,n)<h){if(n<r){let n=i(t,e,h),o=Ss(r,ys.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Ss(r,ys.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=Ss(r,ys.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>Ss(r,ys.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(Qs||={});var _s=class extends k{constructor(t,i,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},$s=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new D}register(t){let i={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(i),i.id}deregister(t){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===t)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(t){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(t);if(!i||0===i.length)return[];let s=[],e=i.translateToString(!0),h=0,r=0,n=0,o=i.getFg(0),l=i.getBg(0);for(let t=0;t<i.getTrimmedLength();t++)if(i.loadCell(t,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==o||this._workCell.bg!==l){if(t-h>1){let t=this._getJoinedRanges(e,n,r,i,h);for(let i=0;i<t.length;i++)s.push(t[i])}h=t,n=r,o=this._workCell.fg,l=this._workCell.bg}r+=this._workCell.getChars().length||1}if(this._bufferService.cols-h>1){let t=this._getJoinedRanges(e,n,r,i,h);for(let i=0;i<t.length;i++)s.push(t[i])}return s}_getJoinedRanges(t,i,s,e,h){let r=t.substring(i,s),n=[];try{n=this._characterJoiners[0].handler(r)}catch(t){console.error(t)}for(let t=1;t<this._characterJoiners.length;t++)try{let i=this._characterJoiners[t].handler(r);for(let t=0;t<i.length;t++)$s._mergeRanges(n,i[t])}catch(t){console.error(t)}return this._stringRangesToCellRanges(n,e,h),n}_stringRangesToCellRanges(t,i,s){let e=0,h=!1,r=0,n=t[e];if(n){for(let o=s;o<this._bufferService.cols;o++){let s=i.getWidth(o),l=i.getString(o).length||1;if(0!==s){if(!h&&n[0]<=r&&(n[0]=o,h=!0),n[1]<=r){if(n[1]=o,n=t[++e],!n)break;n[0]<=r?(n[0]=o,h=!0):h=!1}r+=l}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(t,i){let s=!1;for(let e=0;e<t.length;e++){let h=t[e];if(s){if(i[1]<=h[0])return t[e-1][1]=i[1],t;if(i[1]<=h[1])return t[e-1][1]=Math.max(i[1],h[1]),t.splice(e,1),t;t.splice(e,1),e--}else{if(i[1]<=h[0])return t.splice(e,0,i),t;if(i[1]<=h[1])return h[0]=Math.min(i[0],h[0]),t;i[0]<h[1]&&(h[0]=Math.min(i[0],h[0]),s=!0)}}return s?t[t.length-1][1]=i[1]:t.push(i),t}};$s=d([g(0,R)],$s);var Rs=class{constructor(t,i,s,e,h,r,n){this._document=t,this._characterJoinerService=i,this._optionsService=s,this._coreBrowserService=e,this._coreService=h,this._decorationService=r,this._themeService=n,this._workCell=new D,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(t,i,s){this._selectionStart=t,this._selectionEnd=i,this._columnSelectMode=s}createRow(t,i,s,e,h,r,n,o,l,a,u){let c=[],A=this._characterJoinerService.getJoinedCharacters(i),f=this._themeService.colors,d=t.getNoBgTrimmedLength();s&&d<r+1&&(d=r+1);let g,w=0,p="",C=0,m=0,I=0,v=0,B=!1,M=0,y=!1,Q=0,E=0,x=[],D=-1!==a&&-1!==u;for(let L=0;L<d;L++){t.loadCell(L,this._workCell);let d=this._workCell.getWidth();if(0===d)continue;let S=!1,_=L>=E,$=L,R=this._workCell;if(A.length>0&&L===A[0][0]&&_){let e=A.shift(),h=this._isCellInSelection(e[0],i);for(C=e[0]+1;C<e[1];C++)_&&=h===this._isCellInSelection(C,i);_&&=!s||r<e[0]||r>=e[1],_?(S=!0,R=new _s(this._workCell,t.translateToString(!0,e[0],e[1]),e[1]-e[0]),$=e[1]-1,d=R.getWidth()):E=e[1]}let N=this._isCellInSelection(L,i),F=s&&L===r,H=D&&L>=a&&L<=u,T=!1;this._decorationService.forEachDecorationAtCell(L,i,void 0,(()=>{T=!0}));let U=R.getChars()||b;if(" "===U&&(R.isUnderline()||R.isOverline())&&(U=" "),Q=d*o-l.get(U,R.isBold(),R.isItalic()),g){if(w&&(N&&y||!N&&!y&&R.bg===m)&&(N&&y&&f.selectionForeground||R.fg===I)&&R.extended.ext===v&&H===B&&Q===M&&!F&&!S&&!T&&_){R.isInvisible()?p+=b:p+=U,w++;continue}w&&(g.textContent=p),g=this._document.createElement("span"),w=0,p=""}else g=this._document.createElement("span");if(m=R.bg,I=R.fg,v=R.extended.ext,B=H,M=Q,y=N,S&&r>=L&&r<=$&&(r=L),!this._coreService.isCursorHidden&&F&&this._coreService.isCursorInitialized)if(x.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&x.push("xterm-cursor-blink"),x.push("bar"===e?"xterm-cursor-bar":"underline"===e?"xterm-cursor-underline":"xterm-cursor-block");else if(h)switch(h){case"outline":x.push("xterm-cursor-outline");break;case"block":x.push("xterm-cursor-block");break;case"bar":x.push("xterm-cursor-bar");break;case"underline":x.push("xterm-cursor-underline")}if(R.isBold()&&x.push("xterm-bold"),R.isItalic()&&x.push("xterm-italic"),R.isDim()&&x.push("xterm-dim"),p=R.isInvisible()?b:R.getChars()||b,R.isUnderline()&&(x.push("xterm-underline-"+R.extended.underlineStyle)," "===p&&(p=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${k.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let t=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&t<8&&(t+=8),g.style.textDecorationColor=f.ansi[t].css}R.isOverline()&&(x.push("xterm-overline")," "===p&&(p=" ")),R.isStrikethrough()&&x.push("xterm-strikethrough"),H&&(g.style.textDecoration="underline");let G=R.getFgColor(),P=R.getFgColorMode(),J=R.getBgColor(),O=R.getBgColorMode(),W=!!R.isInverse();if(W){let t=G;G=J,J=t;let i=P;P=O,O=i}let z,K,q,j=!1;switch(this._decorationService.forEachDecorationAtCell(L,i,void 0,(t=>{"top"!==t.options.layer&&j||(t.backgroundColorRGB&&(O=50331648,J=t.backgroundColorRGB.rgba>>8&16777215,z=t.backgroundColorRGB),t.foregroundColorRGB&&(P=50331648,G=t.foregroundColorRGB.rgba>>8&16777215,K=t.foregroundColorRGB),j="top"===t.options.layer)})),!j&&N&&(z=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,J=z.rgba>>8&16777215,O=50331648,j=!0,f.selectionForeground&&(P=50331648,G=f.selectionForeground.rgba>>8&16777215,K=f.selectionForeground)),j&&x.push("xterm-decoration-top"),O){case 16777216:case 33554432:q=f.ansi[J],x.push("xterm-bg-"+J);break;case 50331648:q=vs.toColor(J>>16,J>>8&255,255&J),this._addStyle(g,"background-color:#"+Ns((J>>>0).toString(16),"0",6));break;default:W?(q=f.foreground,x.push("xterm-bg-257")):q=f.background}switch(z||R.isDim()&&(z=Bs.multiplyOpacity(q,.5)),P){case 16777216:case 33554432:R.isBold()&&G<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(G+=8),this._applyMinimumContrast(g,q,f.ansi[G],R,z,void 0)||x.push("xterm-fg-"+G);break;case 50331648:let t=vs.toColor(G>>16&255,G>>8&255,255&G);this._applyMinimumContrast(g,q,t,R,z,K)||this._addStyle(g,"color:#"+Ns(G.toString(16),"0",6));break;default:this._applyMinimumContrast(g,q,f.foreground,R,z,K)||W&&x.push("xterm-fg-257")}x.length&&(g.className=x.join(" "),x.length=0),F||S||T||!_?g.textContent=p:w++,Q!==this.defaultSpacing&&(g.style.letterSpacing=Q+"px"),c.push(g),L=$}return g&&w&&(g.textContent=p),c}_applyMinimumContrast(t,i,s,e,h,r){if(1===this._optionsService.rawOptions.minimumContrastRatio||function(t){return function(t){return 57508<=t&&t<=57558}(t)||function(t){return 9472<=t&&t<=9631}(t)}(e.getCode()))return!1;let n,o=this._getContrastCache(e);if(!h&&!r&&(n=o.getColor(i.rgba,s.rgba)),void 0===n){let t=this._optionsService.rawOptions.minimumContrastRatio/(e.isDim()?2:1);n=Bs.ensureContrastRatio(h||i,r||s,t),o.setColor((h||i).rgba,(r||s).rgba,n??null)}return!!n&&(this._addStyle(t,"color:"+n.css),!0)}_getContrastCache(t){return t.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(t,i){t.setAttribute("style",`${t.getAttribute("style")||""}${i};`)}_isCellInSelection(t,i){let s=this._selectionStart,e=this._selectionEnd;return!(!s||!e)&&(this._columnSelectMode?s[0]<=e[0]?t>=s[0]&&i>=s[1]&&t<e[0]&&i<=e[1]:t<s[0]&&i>=s[1]&&t>=e[0]&&i<=e[1]:i>s[1]&&i<e[1]||s[1]===e[1]&&i===s[1]&&t>=s[0]&&t<e[0]||s[1]<e[1]&&i===e[1]&&t<e[0]||s[1]<e[1]&&i===s[1]&&t>=s[0])}};function Ns(t,i,s){for(;t.length<s;)t=i+t;return t}Rs=d([g(1,X),g(2,G),g(3,q),g(4,F),g(5,O),g(6,V)],Rs);var Fs=class{constructor(t,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=t.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=t.createElement("span");s.classList.add("xterm-char-measure-element");let e=t.createElement("span");e.classList.add("xterm-char-measure-element"),e.style.fontWeight="bold";let h=t.createElement("span");h.classList.add("xterm-char-measure-element"),h.style.fontStyle="italic";let r=t.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold",r.style.fontStyle="italic",this._measureElements=[s,e,h,r],this._container.appendChild(s),this._container.appendChild(e),this._container.appendChild(h),this._container.appendChild(r),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(t,i,s,e){t===this._font&&i===this._fontSize&&s===this._weight&&e===this._weightBold||(this._font=t,this._fontSize=i,this._weight=s,this._weightBold=e,this._container.style.fontFamily=this._font,this._container.style.fontSize=this._fontSize+"px",this._measureElements[0].style.fontWeight=""+s,this._measureElements[1].style.fontWeight=""+e,this._measureElements[2].style.fontWeight=""+s,this._measureElements[3].style.fontWeight=""+e,this.clear())}get(t,i,s){let e=0;if(!i&&!s&&1===t.length&&(e=t.charCodeAt(0))<256){if(-9999!==this._flat[e])return this._flat[e];let i=this._measure(t,0);return i>0&&(this._flat[e]=i),i}let h=t;i&&(h+="B"),s&&(h+="I");let r=this._holey.get(h);if(void 0===r){let e=0;i&&(e|=1),s&&(e|=2),r=this._measure(t,e),r>0&&this._holey.set(h,r)}return r}_measure(t,i){let s=this._measureElements[i];return s.textContent=t.repeat(32),s.offsetWidth/32}},Hs=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,i,s,e=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1])return void this.clear();let h=t.buffers.active.ydisp,r=i[1]-h,n=s[1]-h,o=Math.max(r,0),l=Math.min(n,t.rows-1);o>=t.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=e,this.viewportStartRow=r,this.viewportEndRow=n,this.viewportCappedStartRow=o,this.viewportCappedEndRow=l,this.startCol=i[0],this.endCol=s[0])}isCellSelected(t,i,s){return!!this.hasSelection&&(s-=t.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)}},Ts="xterm-dom-renderer-owner-",Us="xterm-rows",Gs="xterm-fg-",Ps="xterm-bg-",Js="xterm-focus",Os="xterm-selection",Ws=1,zs=class extends gt{constructor(t,i,s,e,h,r,n,o,l,a,u,c,A,f){super(),this._terminal=t,this._document=i,this._element=s,this._screenElement=e,this._viewportElement=h,this._helperContainer=r,this._linkifier2=n,this._charSizeService=l,this._optionsService=a,this._bufferService=u,this._coreService=c,this._coreBrowserService=A,this._themeService=f,this._terminalClass=Ws++,this._rowElements=[],this._selectionRenderModel=new Hs,this.onRequestRedraw=this._register(new _t).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Us),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(Os),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this._register(this._themeService.onChangeColors((t=>this._injectCss(t)))),this._injectCss(this._themeService.colors),this._rowFactory=o.createInstance(Rs,document),this._element.classList.add(Ts+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline((t=>this._handleLinkHover(t)))),this._register(this._linkifier2.onHideLinkUnderline((t=>this._handleLinkLeave(t)))),this._register(At((()=>{this._element.classList.remove(Ts+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new Fs(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 t=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*t,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*t),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/t),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/t),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 t of this._rowElements)t.style.width=this.dimensions.css.canvas.width+"px",t.style.height=this.dimensions.css.cell.height+"px",t.style.lineHeight=this.dimensions.css.cell.height+"px",t.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement)),this._dimensionsStyleElement.textContent=`${this._terminalSelector} .${Us} span { display: inline-block; height: 100%; vertical-align: top;}`,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(t){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${Us} { pointer-events: none; color: ${t.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${Us} .xterm-dim { color: ${Bs.multiplyOpacity(t.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,e="blink_bar_"+this._terminalClass,h="blink_block_"+this._terminalClass;i+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,i+=`@keyframes ${e} { 50% { box-shadow: none; }}`,i+=`@keyframes ${h} { 0% { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css}; } 50% { background-color: inherit; color: ${t.cursor.css}; }}`,i+=`${this._terminalSelector} .${Us}.${Js} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Us}.${Js} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${Us}.${Js} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${h} 1s step-end infinite;}${this._terminalSelector} .${Us} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Us} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Us} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Us} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Us} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${Os} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Os} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Os} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[s,e]of t.ansi.entries())i+=`${this._terminalSelector} .${Gs}${s} { color: ${e.css}; }${this._terminalSelector} .${Gs}${s}.xterm-dim { color: ${Bs.multiplyOpacity(e,.5).css}; }${this._terminalSelector} .${Ps}${s} { background-color: ${e.css}; }`;i+=`${this._terminalSelector} .${Gs}257 { color: ${Bs.opaque(t.background).css}; }${this._terminalSelector} .${Gs}257.xterm-dim { color: ${Bs.multiplyOpacity(Bs.opaque(t.background),.5).css}; }${this._terminalSelector} .${Ps}257 { background-color: ${t.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let t=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=t+"px",this._rowFactory.defaultSpacing=t}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(t,i){for(let t=this._rowElements.length;t<=i;t++){let t=this._document.createElement("div");this._rowContainer.appendChild(t),this._rowElements.push(t)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(t,i){this._refreshRowElements(t,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(Js),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Js),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(t,i,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(t,i,s),this.renderRows(0,this._bufferService.rows-1),!t||!i||(this._selectionRenderModel.update(this._terminal,t,i,s),!this._selectionRenderModel.hasSelection))return;let e=this._selectionRenderModel.viewportStartRow,h=this._selectionRenderModel.viewportEndRow,r=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,o=this._document.createDocumentFragment();if(s){let s=t[0]>i[0];o.appendChild(this._createSelectionElement(r,s?i[0]:t[0],s?t[0]:i[0],n-r+1))}else o.appendChild(this._createSelectionElement(r,e===r?t[0]:0,r===h?i[0]:this._bufferService.cols)),o.appendChild(this._createSelectionElement(r+1,0,this._bufferService.cols,n-r-1)),r!==n&&o.appendChild(this._createSelectionElement(n,0,h===n?i[0]:this._bufferService.cols));this._selectionContainer.appendChild(o)}_createSelectionElement(t,i,s,e=1){let h=this._document.createElement("div"),r=i*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-i);return r+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-r),h.style.height=e*this.dimensions.css.cell.height+"px",h.style.top=t*this.dimensions.css.cell.height+"px",h.style.left=r+"px",h.style.width=n+"px",h}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 t of this._rowElements)t.replaceChildren()}renderRows(t,i){let s=this._bufferService.buffer,e=s.ybase+s.y,h=Math.min(s.x,this._bufferService.cols-1),r=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,o=this._optionsService.rawOptions.cursorInactiveStyle;for(let l=t;l<=i;l++){let t=l+s.ydisp,i=this._rowElements[l],a=s.lines.get(t);if(!i||!a)break;i.replaceChildren(...this._rowFactory.createRow(a,t,t===e,n,o,h,r,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ts}${this._terminalClass}`}_handleLinkHover(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!0)}_handleLinkLeave(t){this._setCellUnderline(t.x1,t.x2,t.y1,t.y2,t.cols,!1)}_setCellUnderline(t,i,s,e,h,r){s<0&&(t=0),e<0&&(i=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),e=Math.max(Math.min(e,n),0);let o=this._bufferService.buffer,l=o.ybase+o.y,a=Math.min(o.x,(h=Math.min(h,this._bufferService.cols))-1),u=this._optionsService.rawOptions.cursorBlink,c=this._optionsService.rawOptions.cursorStyle,A=this._optionsService.rawOptions.cursorInactiveStyle;for(let n=s;n<=e;++n){let f=n+o.ydisp,d=this._rowElements[n],g=o.lines.get(f);if(!d||!g)break;d.replaceChildren(...this._rowFactory.createRow(g,f,f===l,c,A,a,u,this.dimensions.css.cell.width,this._widthCache,r?n===s?t:0:-1,r?(n===e?i:h)-1:-1))}}};zs=d([g(7,T),g(8,K),g(9,G),g(10,R),g(11,F),g(12,q),g(13,V)],zs);var Ks=class extends gt{constructor(t,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new _t),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Ys(this._optionsService))}catch{this._measureStrategy=this._register(new js(t,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let t=this._measureStrategy.measure();(t.width!==this.width||t.height!==this.height)&&(this.width=t.width,this.height=t.height,this._onCharSizeChange.fire())}};Ks=d([g(2,G)],Ks);var qs=class extends gt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,i){void 0!==t&&t>0&&void 0!==i&&i>0&&(this._result.width=t,this._result.height=i)}},js=class extends qs{constructor(t,i,s){super(),this._document=t,this._parentElement=i,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=this._optionsService.rawOptions.fontSize+"px",this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Ys=class extends qs{constructor(t){super(),this._optionsService=t,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 Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let t=this._ctx.measureText("W");return this._validateAndSet(t.width,t.fontBoundingBoxAscent+t.fontBoundingBoxDescent),this._result}},Zs=class extends gt{constructor(t,i,s){super(),this._textarea=t,this._window=i,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Xs(this._window)),this._onDprChange=this._register(new _t),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new _t),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange((t=>this._screenDprMonitor.setWindow(t)))),this._register(mt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register($i(this._textarea,"focus",(()=>this._isFocused=!0))),this._register($i(this._textarea,"blur",(()=>this._isFocused=!1)))}get window(){return this._window}set window(t){this._window!==t&&(this._window=t,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}},Xs=class extends gt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new wt),this._onDprChange=this._register(new _t),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(At((()=>this.clearListener())))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=$i(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)}},Vs=class extends gt{constructor(){super(),this.linkProviders=[],this._register(At((()=>this.linkProviders.length=0)))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let i=this.linkProviders.indexOf(t);-1!==i&&this.linkProviders.splice(i,1)}}}};function te(t,i,s){let e=s.getBoundingClientRect(),h=t.getComputedStyle(s),r=parseInt(h.getPropertyValue("padding-left")),n=parseInt(h.getPropertyValue("padding-top"));return[i.clientX-e.left-r,i.clientY-e.top-n]}var ie=class{constructor(t,i){this._renderService=t,this._charSizeService=i}getCoords(t,i,s,e,h){return function(t,i,s,e,h,r,n,o,l){if(!r)return;let a=te(t,i,s);return a?(a[0]=Math.ceil((a[0]+(l?n/2:0))/n),a[1]=Math.ceil(a[1]/o),a[0]=Math.min(Math.max(a[0],1),e+(l?1:0)),a[1]=Math.min(Math.max(a[1],1),h),a):void 0}(window,t,i,s,e,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,h)}getMouseReportCoords(t,i){let s=te(window,t,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])}}};ie=d([g(0,Y),g(1,K)],ie);var se=class{constructor(t,i){this._renderCallback=t,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(t){return this._refreshCallbacks.push(t),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(t,i,s){this._rowCount=s,t=void 0!==t?t:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,t):t,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let t=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let t of this._refreshCallbacks)t(0);this._refreshCallbacks=[]}},ee={};((t,i)=>{for(var s in i)A(t,s,{get:i[s],enumerable:!0})})(ee,{getSafariVersion:()=>ue,isChromeOS:()=>we,isFirefox:()=>oe,isIpad:()=>Ae,isIphone:()=>fe,isLegacyEdge:()=>le,isLinux:()=>ge,isMac:()=>ce,isNode:()=>he,isSafari:()=>ae,isWindows:()=>de});var he=typeof process<"u"&&"title"in process,re=he?"node":navigator.userAgent,ne=he?"node":navigator.platform,oe=re.includes("Firefox"),le=re.includes("Edge"),ae=/^((?!chrome|android).)*safari/i.test(re);function ue(){if(!ae)return 0;let t=re.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}var ce=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ne),Ae="iPad"===ne,fe="iPhone"===ne,de=["Windows","Win16","Win32","WinCE"].includes(ne),ge=ne.indexOf("Linux")>=0,we=/\bCrOS\b/.test(re),pe=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 i=0,s=0,e=t.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,i=Math.max(1,performance.now()-i),s=Math.max(i,s),h=t.timeRemaining(),1.5*s>h)return e-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(e-i))}ms`),void this._start();e=h}this.clear()}},Ce=!he&&"requestIdleCallback"in window?class extends pe{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends pe{_requestCallback(t){return setTimeout((()=>t(this._createDeadline(16))))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let i=performance.now()+t;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},me=class{constructor(){this._queue=new Ce}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Ie=class extends gt{constructor(t,i,s,e,h,r,n,o,l){super(),this._rowCount=t,this._optionsService=s,this._charSizeService=e,this._coreService=h,this._coreBrowserService=o,this._renderer=this._register(new wt),this._pausedResizeTask=new me,this._observerDisposable=this._register(new wt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new _t),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new _t),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new _t),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new _t),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new se(((t,i)=>this._renderRows(t,i)),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ve(this._coreBrowserService,this._coreService,(()=>this._fullRefresh())),this._register(At((()=>this._syncOutputHandler.dispose()))),this._register(this._coreBrowserService.onDprChange((()=>this.handleDevicePixelRatioChange()))),this._register(n.onResize((()=>this._fullRefresh()))),this._register(n.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this._register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this._register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this._register(r.onDecorationRegistered((()=>this._fullRefresh()))),this._register(r.onDecorationRemoved((()=>this._fullRefresh()))),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()}))),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(n.buffer.y,n.buffer.y,!0)))),this._register(l.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange((t=>this._registerIntersectionObserver(t,i))))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(t,i){if("IntersectionObserver"in t){let s=new t.IntersectionObserver((t=>this._handleIntersectionChange(t[t.length-1])),{threshold:0});s.observe(i),this._observerDisposable.value=At((()=>s.disconnect()))}}_handleIntersectionChange(t){this._isPaused=void 0===t.isIntersecting?0===t.intersectionRatio:!t.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(t,i,s=!1){if(this._isPaused)return void(this._needsFullRefresh=!0);if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(t,i);let e=this._syncOutputHandler.flush();e&&(t=Math.min(t,e.start),i=Math.max(i,e.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(t,i,this._rowCount)}_renderRows(t,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(t,i);this._renderer.value.renderRows(t=Math.min(t,this._rowCount-1),i=Math.min(i,this._rowCount-1)),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:t,end:i}),this._onRender.fire({start:t,end:i}),this._isNextRenderRedrawOnly=!0}}resize(t,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(t){this._renderer.value=t,this._renderer.value&&(this._renderer.value.onRequestRedraw((t=>this.refreshRows(t.start,t.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(t){return this._renderDebouncer.addRefreshCallback(t)}_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(t,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(t,i))):this._renderer.value.handleResize(t,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(t,i,s){this._selectionState.start=t,this._selectionState.end=i,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(t,i,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Ie=d([g(2,G),g(3,K),g(4,F),g(5,O),g(6,R),g(7,q),g(8,V)],Ie);var ve=class{constructor(t,i,s){this._coreBrowserService=t,this._coreService=i,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,i){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,i)):(this._start=t,this._end=i,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout((()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()}),1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Be(t,i,s,e){let h=t-Me(t,s),r=i-Me(i,s),n=Math.abs(h-r)-function(t,i,s){let e=0,h=t-Me(t,s),r=i-Me(i,s);for(let n=0;n<Math.abs(h-r);n++){let r="A"===ye(t,i)?-1:1;s.buffer.lines.get(h+r*n)?.isWrapped&&e++}return e}(t,i,s);return be(n,Ee(ye(t,i),e))}function Me(t,i){let s=0,e=i.buffer.lines.get(t),h=e?.isWrapped;for(;h&&t>=0&&t<i.rows;)s++,e=i.buffer.lines.get(--t),h=e?.isWrapped;return s}function ye(t,i){return t>i?"A":"B"}function Qe(t,i,s,e,h,r){let n=t,o=i,l="";for(;(n!==s||o!==e)&&o>=0&&o<r.buffer.lines.length;)n+=h?1:-1,h&&n>r.cols-1?(l+=r.buffer.translateBufferLineToString(o,!1,t,n),n=0,t=0,o++):!h&&n<0&&(l+=r.buffer.translateBufferLineToString(o,!1,0,t+1),n=r.cols-1,t=n,o--);return l+r.buffer.translateBufferLineToString(o,!1,t,n)}function Ee(t,i){return As.ESC+(i?"O":"[")+t}function be(t,i){t=Math.floor(t);let s="";for(let e=0;e<t;e++)s+=i;return s}var ke=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.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,i=this.selectionEnd;return!(!t||!i)&&(t[1]>i[1]||t[1]===i[1]&&t[0]>i[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 xe(t,i){if(t.start.y>t.end.y)throw Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return i*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var De=/ /g,Le=class extends gt{constructor(t,i,s,e,h,r,n,o,l){super(),this._element=t,this._screenElement=i,this._linkifier=s,this._bufferService=e,this._coreService=h,this._mouseService=r,this._optionsService=n,this._renderService=o,this._coreBrowserService=l,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new D,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new _t),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new _t),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new _t),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new _t),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=t=>this._handleMouseMove(t),this._mouseUpListener=t=>this._handleMouseUp(t),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((t=>this._handleTrim(t))),this._register(this._bufferService.buffers.onBufferActivate((t=>this._handleBufferActivate(t)))),this.enable(),this._model=new ke(this._bufferService),this._activeSelectionMode=0,this._register(At((()=>{this._removeMouseDownListeners()}))),this._register(this._bufferService.onResize((t=>{t.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 t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!(!t||!i||t[0]===i[0]&&t[1]===i[1])}get selectionText(){let t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!t||!i)return"";let s=this._bufferService.buffer,e=[];if(3===this._activeSelectionMode){if(t[0]===i[0])return"";let h=t[0]<i[0]?t[0]:i[0],r=t[0]<i[0]?i[0]:t[0];for(let n=t[1];n<=i[1];n++){let t=s.translateBufferLineToString(n,!0,h,r);e.push(t)}}else{e.push(s.translateBufferLineToString(t[1],!0,t[0],t[1]===i[1]?i[0]:void 0));for(let h=t[1]+1;h<=i[1]-1;h++){let t=s.lines.get(h),i=s.translateBufferLineToString(h,!0);t?.isWrapped?e[e.length-1]+=i:e.push(i)}if(t[1]!==i[1]){let t=s.lines.get(i[1]),h=s.translateBufferLineToString(i[1],!0,0,i[0]);t&&t.isWrapped?e[e.length-1]+=h:e.push(h)}}return e.map((t=>t.replace(De," "))).join(de?"\r\n":"\n")}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(t){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),ge&&t&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(t){let i=this._getMouseBufferCoords(t),s=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!!(s&&e&&i)&&this._areCoordsInSelection(i,s,e)}isCellInSelection(t,i){let s=this._model.finalSelectionStart,e=this._model.finalSelectionEnd;return!(!s||!e)&&this._areCoordsInSelection([t,i],s,e)}_areCoordsInSelection(t,i,s){return t[1]>i[1]&&t[1]<s[1]||i[1]===s[1]&&t[1]===i[1]&&t[0]>=i[0]&&t[0]<s[0]||i[1]<s[1]&&t[1]===s[1]&&t[0]<s[0]||i[1]<s[1]&&t[1]===i[1]&&t[0]>=i[0]}_selectWordAtCursor(t,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=xe(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let e=this._getMouseBufferCoords(t);return!!e&&(this._selectWordAt(e,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(t,i){this._model.clearSelection(),t=Math.max(t,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,t],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(t){this._model.handleTrim(t)&&this.refresh()}_getMouseBufferCoords(t){let i=this._mouseService.getCoords(t,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(t){let i=te(this._coreBrowserService.window,t,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,-50),50),i/=50,i/Math.abs(i)+Math.round(14*i))}shouldForceSelection(t){return ce?t.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:t.shiftKey}handleMouseDown(t){if(this._mouseDownTimeStamp=t.timeStamp,(2!==t.button||!this.hasSelection)&&0===t.button){if(!this._enabled){if(!this.shouldForceSelection(t))return;t.stopPropagation()}t.preventDefault(),this._dragScrollAmount=0,this._enabled&&t.shiftKey?this._handleIncrementalClick(t):1===t.detail?this._handleSingleClick(t):2===t.detail?this._handleDoubleClick(t):3===t.detail&&this._handleTripleClick(t),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(t){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(t))}_handleSingleClick(t){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(t)?3:0,this._model.selectionStart=this._getMouseBufferCoords(t),!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]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(t){this._selectWordAtCursor(t,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(t){let i=this._getMouseBufferCoords(t);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(t){return t.altKey&&!(ce&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(t){if(t.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(t),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[0]=this._model.selectionEnd[1]<this._model.selectionStart[1]?0:this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(t),3!==this._activeSelectionMode&&(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 t=s.lines.get(this._model.selectionEnd[1]);t&&0===t.hasWidth(this._model.selectionEnd[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 t=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(t.ydisp+this._bufferService.rows,t.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=t.ydisp),this.refresh()}}_handleMouseUp(t){let i=t.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&t.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(t,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let t=function(t,i,s,e){let h,r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return function(t,i,s,e,h,r){return 0===Be(i,e,h,r).length?"":be(Qe(t,i,t,i-Me(i,h),!1,h).length,Ee("D",r))}(r,n,0,i,s,e)+Be(n,i,s,e)+function(t,i,s,e,h,r){let n;n=Be(i,e,h,r).length>0?e-Me(e,h):i;let o=e,l=function(t,i,s,e,h,r){let n;return n=Be(s,e,h,r).length>0?e-Me(e,h):i,t<s&&n<=e||t>=s&&n<e?"C":"D"}(t,i,s,e,h,r);return be(Qe(t,n,s,o,"C"===l,h).length,Ee(l,r))}(r,n,t,i,s,e);if(n===i)return h=r>t?"D":"C",be(Math.abs(r-t),Ee(h,e));h=n>i?"D":"C";let o=Math.abs(n-i),l=function(t,i){return i.cols-t}(n>i?t:r,s)+(o-1)*s.cols+1+function(t){return t-1}(n>i?r:t);return be(l,Ee(h,e))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(t,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let t=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,s=!(!t||!i||t[0]===i[0]&&t[1]===i[1]);s?!t||!i||(!this._oldSelectionStart||!this._oldSelectionEnd||t[0]!==this._oldSelectionStart[0]||t[1]!==this._oldSelectionStart[1]||i[0]!==this._oldSelectionEnd[0]||i[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(t,i,s):this._oldHasSelection&&this._fireOnSelectionChange(t,i,s)}_fireOnSelectionChange(t,i,s){this._oldSelectionStart=t,this._oldSelectionEnd=i,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(t){this.clearSelection(),this._trimListener.dispose(),this._trimListener=t.activeBuffer.lines.onTrim((t=>this._handleTrim(t)))}_convertViewportColToCharacterIndex(t,i){let s=i;for(let e=0;i>=e;e++){let h=t.loadCell(e,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:h>1&&i!==e&&(s+=h-1)}return s}setSelection(t,i,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[t,i],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(t){this._isClickInSelection(t)||(this._selectWordAtCursor(t,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(t,i,s=!0,e=!0){if(t[0]>=this._bufferService.cols)return;let h=this._bufferService.buffer,r=h.lines.get(t[1]);if(!r)return;let n=h.translateBufferLineToString(t[1],!1),o=this._convertViewportColToCharacterIndex(r,t[0]),l=o,a=t[0]-o,u=0,c=0,A=0,f=0;if(" "===n.charAt(o)){for(;o>0&&" "===n.charAt(o-1);)o--;for(;l<n.length&&" "===n.charAt(l+1);)l++}else{let i=t[0],s=t[0];0===r.getWidth(i)&&(u++,i--),2===r.getWidth(s)&&(c++,s++);let e=r.getString(s).length;for(e>1&&(f+=e-1,l+=e-1);i>0&&o>0&&!this._isCharWordSeparator(r.loadCell(i-1,this._workCell));){r.loadCell(i-1,this._workCell);let t=this._workCell.getChars().length;0===this._workCell.getWidth()?(u++,i--):t>1&&(A+=t-1,o-=t-1),o--,i--}for(;s<r.length&&l+1<n.length&&!this._isCharWordSeparator(r.loadCell(s+1,this._workCell));){r.loadCell(s+1,this._workCell);let t=this._workCell.getChars().length;2===this._workCell.getWidth()?(c++,s++):t>1&&(f+=t-1,l+=t-1),l++,s++}}l++;let d=o+a-u+A,g=Math.min(this._bufferService.cols,l-o+u+c-A-f);if(i||""!==n.slice(o,l).trim()){if(s&&0===d&&32!==r.getCodePoint(0)){let i=h.lines.get(t[1]-1);if(i&&r.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,t[1]-1],!1,!0,!1);if(i){let t=this._bufferService.cols-i.start;d-=t,g+=t}}}if(e&&d+g===this._bufferService.cols&&32!==r.getCodePoint(this._bufferService.cols-1)){let i=h.lines.get(t[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,t[1]+1],!1,!1,!0);i&&(g+=i.length)}}return{start:d,length:g}}}_selectWordAt(t,i){let s=this._getWordAt(t,i);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,t[1]--;this._model.selectionStart=[s.start,t[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(t){let i=this._getWordAt(t,!0);if(i){let s=t[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(t){return 0!==t.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(t.getChars())>=0}_selectLineAt(t){let i=this._bufferService.buffer.getWrappedRangeForLine(t),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=xe(s,this._bufferService.cols)}};Le=d([g(3,R),g(4,F),g(5,j),g(6,G),g(7,Y),g(8,q)],Le);var Se=class{constructor(){this._data={}}set(t,i,s){this._data[t]||(this._data[t]={}),this._data[t][i]=s}get(t,i){return this._data[t]?this._data[t][i]:void 0}clear(){this._data={}}},_e=class{constructor(){this._color=new Se,this._css=new Se}setCss(t,i,s){this._css.set(t,i,s)}getCss(t,i){return this._css.get(t,i)}setColor(t,i,s){this._color.set(t,i,s)}getColor(t,i){return this._color.get(t,i)}clear(){this._color.clear(),this._css.clear()}},$e=Object.freeze((()=>{let t=[Ms.toColor("#2e3436"),Ms.toColor("#cc0000"),Ms.toColor("#4e9a06"),Ms.toColor("#c4a000"),Ms.toColor("#3465a4"),Ms.toColor("#75507b"),Ms.toColor("#06989a"),Ms.toColor("#d3d7cf"),Ms.toColor("#555753"),Ms.toColor("#ef2929"),Ms.toColor("#8ae234"),Ms.toColor("#fce94f"),Ms.toColor("#729fcf"),Ms.toColor("#ad7fa8"),Ms.toColor("#34e2e2"),Ms.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let s=0;s<216;s++){let e=i[s/36%6|0],h=i[s/6%6|0],r=i[s%6];t.push({css:vs.toCss(e,h,r),rgba:vs.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:vs.toCss(s,s,s),rgba:vs.toRgba(s,s,s)})}return t})()),Re=Ms.toColor("#ffffff"),Ne=Ms.toColor("#000000"),Fe=Ms.toColor("#ffffff"),He=Ne,Te={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ue=Re,Ge=class extends gt{constructor(t){super(),this._optionsService=t,this._contrastCache=new _e,this._halfContrastCache=new _e,this._onChangeColors=this._register(new _t),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Re,background:Ne,cursor:Fe,cursorAccent:He,selectionForeground:void 0,selectionBackgroundTransparent:Te,selectionBackgroundOpaque:Bs.blend(Ne,Te),selectionInactiveBackgroundTransparent:Te,selectionInactiveBackgroundOpaque:Bs.blend(Ne,Te),scrollbarSliderBackground:Bs.opacity(Re,.2),scrollbarSliderHoverBackground:Bs.opacity(Re,.4),scrollbarSliderActiveBackground:Bs.opacity(Re,.5),overviewRulerBorder:Re,ansi:$e.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(t={}){let i=this._colors;if(i.foreground=Pe(t.foreground,Re),i.background=Pe(t.background,Ne),i.cursor=Bs.blend(i.background,Pe(t.cursor,Fe)),i.cursorAccent=Bs.blend(i.background,Pe(t.cursorAccent,He)),i.selectionBackgroundTransparent=Pe(t.selectionBackground,Te),i.selectionBackgroundOpaque=Bs.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=Pe(t.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=Bs.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=t.selectionForeground?Pe(t.selectionForeground,Ds):void 0,i.selectionForeground===Ds&&(i.selectionForeground=void 0),Bs.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=Bs.opacity(i.selectionBackgroundTransparent,.3)),Bs.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=Bs.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=Pe(t.scrollbarSliderBackground,Bs.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=Pe(t.scrollbarSliderHoverBackground,Bs.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=Pe(t.scrollbarSliderActiveBackground,Bs.opacity(i.foreground,.5)),i.overviewRulerBorder=Pe(t.overviewRulerBorder,Ue),i.ansi=$e.slice(),i.ansi[0]=Pe(t.black,$e[0]),i.ansi[1]=Pe(t.red,$e[1]),i.ansi[2]=Pe(t.green,$e[2]),i.ansi[3]=Pe(t.yellow,$e[3]),i.ansi[4]=Pe(t.blue,$e[4]),i.ansi[5]=Pe(t.magenta,$e[5]),i.ansi[6]=Pe(t.cyan,$e[6]),i.ansi[7]=Pe(t.white,$e[7]),i.ansi[8]=Pe(t.brightBlack,$e[8]),i.ansi[9]=Pe(t.brightRed,$e[9]),i.ansi[10]=Pe(t.brightGreen,$e[10]),i.ansi[11]=Pe(t.brightYellow,$e[11]),i.ansi[12]=Pe(t.brightBlue,$e[12]),i.ansi[13]=Pe(t.brightMagenta,$e[13]),i.ansi[14]=Pe(t.brightCyan,$e[14]),i.ansi[15]=Pe(t.brightWhite,$e[15]),t.extendedAnsi){let s=Math.min(i.ansi.length-16,t.extendedAnsi.length);for(let e=0;e<s;e++)i.ansi[e+16]=Pe(t.extendedAnsi[e],$e[e+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(t){this._restoreColor(t),this._onChangeColors.fire(this.colors)}_restoreColor(t){if(void 0!==t)switch(t){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[t]=this._restoreColors.ansi[t]}else for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t]}modifyColors(t){t(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function Pe(t,i){if(void 0!==t)try{return Ms.toColor(t)}catch{}return i}Ge=d([g(0,G)],Ge);var Je=class{constructor(...t){this._entries=new Map;for(let[i,s]of t)this.set(i,s)}set(t,i){let s=this._entries.get(t);return this._entries.set(t,i),s}forEach(t){for(let[i,s]of this._entries.entries())t(i,s)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},Oe=class{constructor(){this._services=new Je,this._services.set(T,this)}setService(t,i){this._services.set(t,i)}getService(t){return this._services.get(t)}createInstance(t,...i){let s=function(t){return t[S]||[]}(t).sort(((t,i)=>t.index-i.index)),e=[];for(let i of s){let s=this._services.get(i.id);if(!s)throw Error(`[createInstance] ${t.name} depends on UNKNOWN service ${i.id._id}.`);e.push(s)}let h=s.length>0?s[0].index:i.length;if(i.length!==h)throw Error(`[createInstance] First service dependency of ${t.name} at position ${h+1} conflicts with ${i.length} static arguments`);return new t(...i,...e)}},We={trace:0,debug:1,info:2,warn:3,error:4,off:5},ze=class extends gt{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=We[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let i=0;i<t.length;i++)"function"==typeof t[i]&&(t[i]=t[i]())}_log(t,i,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...s)}trace(t,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,i)}debug(t,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,i)}info(t,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,i)}warn(t,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,i)}error(t,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,i)}};ze=d([g(0,G)],ze);var Ke=class extends gt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new _t),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new _t),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new _t),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let i=Array(t);for(let s=0;s<Math.min(t,this.length);s++)i[s]=this._array[this._getCyclicIndex(s)];this._array=i,this._maxLength=t,this._startIndex=0}get length(){return this._length}set length(t){if(t>this._length)for(let i=this._length;i<t;i++)this._array[i]=void 0;this._length=t}get(t){return this._array[this._getCyclicIndex(t)]}set(t,i){this._array[this._getCyclicIndex(t)]=i}push(t){this._array[this._getCyclicIndex(this._length)]=t,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw 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(t,i,...s){if(i){for(let s=t;s<this._length-i;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+i)];this._length-=i,this.onDeleteEmitter.fire({index:t,amount:i})}for(let i=this._length-1;i>=t;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(t+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:t,amount:s.length}),this._length+s.length>this._maxLength){let t=this._length+s.length-this._maxLength;this._startIndex+=t,this._length=this._maxLength,this.onTrimEmitter.fire(t)}else this._length+=s.length}trimStart(t){t>this._length&&(t=this._length),this._startIndex+=t,this._length-=t,this.onTrimEmitter.fire(t)}shiftElements(t,i,s){if(!(i<=0)){if(t<0||t>=this._length)throw Error("start argument out of range");if(t+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let e=i-1;e>=0;e--)this.set(t+e+s,this.get(t+e));let e=t+i+s-this._length;if(e>0)for(this._length+=e;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let e=0;e<i;e++)this.set(t+e+s,this.get(t+e))}}_getCyclicIndex(t){return(this._startIndex+t)%this._maxLength}},qe=Object.freeze(new k),je=0,Ye=class t{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*t);let e=i||D.fromCharData([0,"",1,0]);for(let i=0;i<t;++i)this.setCell(i,e);this.length=t}get(t){let i=this._data[3*t+0],s=2097151&i;return[this._data[3*t+1],2097152&i?this._combined[t]:s?M(s):"",i>>22,2097152&i?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[3*t+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[3*t+0]=2097152|t|i[2]<<22):this._data[3*t+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[3*t+0]>>22}hasWidth(t){return 12582912&this._data[3*t+0]}getFg(t){return this._data[3*t+1]}getBg(t){return this._data[3*t+2]}hasContent(t){return 4194303&this._data[3*t+0]}getCodePoint(t){let i=this._data[3*t+0];return 2097152&i?this._combined[t].charCodeAt(this._combined[t].length-1):2097151&i}isCombined(t){return 2097152&this._data[3*t+0]}getString(t){let i=this._data[3*t+0];return 2097152&i?this._combined[t]:2097151&i?M(2097151&i):""}isProtected(t){return 536870912&this._data[3*t+2]}loadCell(t,i){return i.content=this._data[0+(je=3*t)],i.fg=this._data[je+1],i.bg=this._data[je+2],2097152&i.content&&(i.combinedData=this._combined[t]),268435456&i.bg&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){2097152&i.content&&(this._combined[t]=i.combinedData),268435456&i.bg&&(this._extendedAttrs[t]=i.extended),this._data[3*t+0]=i.content,this._data[3*t+1]=i.fg,this._data[3*t+2]=i.bg}setCellFromCodepoint(t,i,s,e){268435456&e.bg&&(this._extendedAttrs[t]=e.extended),this._data[3*t+0]=i|s<<22,this._data[3*t+1]=e.fg,this._data[3*t+2]=e.bg}addCodepointToCell(t,i,s){let e=this._data[3*t+0];2097152&e?this._combined[t]+=M(i):2097151&e?(this._combined[t]=M(2097151&e)+M(i),e&=-2097152,e|=2097152):e=i|1<<22,s&&(e&=-12582913,e|=s<<22),this._data[3*t+0]=e}insertCells(t,i,s){if((t%=this.length)&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let e=new D;for(let s=this.length-t-i-1;s>=0;--s)this.setCell(t+i+s,this.loadCell(t+s,e));for(let e=0;e<i;++e)this.setCell(t+e,s)}else for(let i=t;i<this.length;++i)this.setCell(i,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(i<this.length-(t%=this.length)){let e=new D;for(let s=0;s<this.length-t-i;++s)this.setCell(t+s,this.loadCell(t+i+s,e));for(let t=this.length-i;t<this.length;++t)this.setCell(t,s)}else for(let i=t;i<this.length;++i)this.setCell(i,s);t&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),0===this.getWidth(t)&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,e=!1){if(e)for(t&&2===this.getWidth(t-1)&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;else for(t&&2===this.getWidth(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*t;if(t>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let t=new Uint32Array(s);t.set(this._data),this._data=t}for(let s=this.length;s<t;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,s);let i=Object.keys(this._combined);for(let s=0;s<i.length;s++){let e=parseInt(i[s],10);e>=t&&delete this._combined[e]}let e=Object.keys(this._extendedAttrs);for(let i=0;i<e.length;i++){let s=parseInt(e[i],10);s>=t&&delete this._extendedAttrs[s]}}return this.length=t,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i)for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);else{this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let i=new t(0);i._data=new Uint32Array(this._data),i.length=this.length;for(let t in this._combined)i._combined[t]=this._combined[t];for(let t in this._extendedAttrs)i._extendedAttrs[t]=this._extendedAttrs[t];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(4194303&this._data[3*t+0])return t+(this._data[3*t+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(4194303&this._data[3*t+0]||50331648&this._data[3*t+2])return t+(this._data[3*t+0]>>22);return 0}copyCellsFrom(t,i,s,e,h){let r=t._data;if(h)for(let h=e-1;h>=0;h--){for(let t=0;t<3;t++)this._data[3*(s+h)+t]=r[3*(i+h)+t];268435456&r[3*(i+h)+2]&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<e;h++){for(let t=0;t<3;t++)this._data[3*(s+h)+t]=r[3*(i+h)+t];268435456&r[3*(i+h)+2]&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let n=Object.keys(t._combined);for(let e=0;e<n.length;e++){let h=parseInt(n[e],10);h>=i&&(this._combined[h-i+s]=t._combined[h])}}translateToString(t,i,s,e){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),e&&(e.length=0);let h="";for(;i<s;){let t=this._data[3*i+0],s=2097151&t,r=2097152&t?this._combined[i]:s?M(s):b;if(h+=r,e)for(let t=0;t<r.length;++t)e.push(i);i+=t>>22||1}return e&&e.push(i),h}};function Ze(t,i,s){let e=[],h=t.map(((s,e)=>Xe(t,e,i))).reduce(((t,i)=>t+i)),r=0,n=0,o=0;for(;o<h;){if(h-o<s){e.push(h-o);break}r+=s;let l=Xe(t,n,i);r>l&&(r-=l,n++);let a=2===t[n].getWidth(r-1);a&&r--;let u=a?s-1:s;e.push(u),o+=u}return e}function Xe(t,i,s){if(i===t.length-1)return t[i].getTrimmedLength();let e=!t[i].hasContent(s-1)&&1===t[i].getWidth(s-1),h=2===t[i+1].getWidth(0);return e&&h?s-1:s}var Ve=class t{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=t._nextId++,this._onDispose=this.register(new _t),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ct(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Ve._nextId=1;var th=Ve,ih={},sh=ih.B;ih[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:"≥","{":"π","|":"≠","}":"£","~":"·"},ih.A={"#":"£"},ih.B=void 0,ih[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},ih.C=ih[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},ih.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},ih.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},ih.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},ih.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},ih.E=ih[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},ih.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},ih.H=ih[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},ih["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var eh=4294967295,hh=class{constructor(t,i,s){this._hasScrollback=t,this._optionsService=i,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=qe.clone(),this.savedCharset=sh,this.markers=[],this._nullCell=D.fromCharData([0,"",1,0]),this._whitespaceCell=D.fromCharData([0,b,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ce,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ke(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 x),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 x),this._whitespaceCell}getBlankLine(t,i){return new Ye(this._bufferService.cols,this.getNullCell(t),i)}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 i=t+this._optionsService.rawOptions.scrollback;return i>eh?eh:i}fillViewportRows(t){if(0===this.lines.length){void 0===t&&(t=qe);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Ke(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,i){let s=this.getNullCell(qe),e=0,h=this._getCorrectBufferLength(i);if(h>this.lines.maxLength&&(this.lines.maxLength=h),this.lines.length>0){if(this._cols<t)for(let i=0;i<this.lines.length;i++)e+=+this.lines.get(i).resize(t,s);let r=0;if(this._rows<i)for(let e=this._rows;e<i;e++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new Ye(t,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+r+1?(this.ybase--,r++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ye(t,s)));else for(let t=this._rows;t>i;t--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(h<this.lines.maxLength){let t=this.lines.length-h;t>0&&(this.lines.trimStart(t),this.ybase=Math.max(this.ybase-t,0),this.ydisp=Math.max(this.ydisp-t,0),this.savedY=Math.max(this.savedY-t,0)),this.lines.maxLength=h}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,i-1),r&&(this.y+=r),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(t,i),this._cols>t))for(let i=0;i<this.lines.length;i++)e+=+this.lines.get(i).resize(t,s);this._cols=t,this._rows=i,this._memoryCleanupQueue.clear(),e>.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 i=0;for(;this._memoryCleanupPosition<this.lines.length;)if(i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),i>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&"conpty"===t.backend&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,i){this._cols!==t&&(t>this._cols?this._reflowLarger(t,i):this._reflowSmaller(t,i))}_reflowLarger(t,i){let s=this._optionsService.rawOptions.reflowCursorLine,e=function(t,i,s,e,h,r){let n=[];for(let o=0;o<t.length-1;o++){let l=o,a=t.get(++l);if(!a.isWrapped)continue;let u=[t.get(o)];for(;l<t.length&&a.isWrapped;)u.push(a),a=t.get(++l);if(!r&&e>=o&&e<l){o+=u.length-1;continue}let c=0,A=Xe(u,c,i),f=1,d=0;for(;f<u.length;){let t=Xe(u,f,i),e=Math.min(t-d,s-A);u[c].copyCellsFrom(u[f],d,A,e,!1),A+=e,A===s&&(c++,A=0),d+=e,d===t&&(f++,d=0),0===A&&0!==c&&2===u[c-1].getWidth(s-1)&&(u[c].copyCellsFrom(u[c-1],s-1,A++,1,!1),u[c-1].setCell(s-1,h))}u[c].replaceCells(A,s,h);let g=0;for(let t=u.length-1;t>0&&(t>c||0===u[t].getTrimmedLength());t--)g++;g>0&&(n.push(o+u.length-g),n.push(g)),o+=u.length-1}return n}(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(qe),s);if(e.length>0){let s=function(t,i){let s=[],e=0,h=i[e],r=0;for(let n=0;n<t.length;n++)if(h===n){let s=i[++e];t.onDeleteEmitter.fire({index:n-r,amount:s}),n+=s-1,r+=s,h=i[++e]}else s.push(n);return{layout:s,countRemoved:r}}(this.lines,e);(function(t,i){let s=[];for(let e=0;e<i.length;e++)s.push(t.get(i[e]));for(let i=0;i<s.length;i++)t.set(i,s[i]);t.length=i.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(t,i,s.countRemoved)}}_reflowLargerAdjustViewport(t,i,s){let e=this.getNullCell(qe),h=s;for(;h-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new Ye(t,e))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(t,i){let s=this._optionsService.rawOptions.reflowCursorLine,e=this.getNullCell(qe),h=[],r=0;for(let n=this.lines.length-1;n>=0;n--){let o=this.lines.get(n);if(!o||!o.isWrapped&&o.getTrimmedLength()<=t)continue;let l=[o];for(;o.isWrapped&&n>0;)o=this.lines.get(--n),l.unshift(o);if(!s){let t=this.ybase+this.y;if(t>=n&&t<n+l.length)continue}let a,u=l[l.length-1].getTrimmedLength(),c=Ze(l,this._cols,t),A=c.length-l.length;a=Math.max(0,0===this.ybase&&this.y!==this.lines.length-1?this.y-this.lines.maxLength+A:this.lines.length-this.lines.maxLength+A);let f=[];for(let t=0;t<A;t++){let t=this.getBlankLine(qe,!0);f.push(t)}f.length>0&&(h.push({start:n+l.length+r,newLines:f}),r+=f.length),l.push(...f);let d=c.length-1,g=c[d];0===g&&(d--,g=c[d]);let w=l.length-A-1,p=u;for(;w>=0;){let t=Math.min(p,g);if(void 0===l[d])break;l[d].copyCellsFrom(l[w],p-t,g-t,t,!0),g-=t,0===g&&(d--,g=c[d]),p-=t,0===p&&(w--,p=Xe(l,Math.max(w,0),this._cols))}for(let i=0;i<l.length;i++)c[i]<t&&l[i].setCell(c[i],e);let C=A-a;for(;C-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+r)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+A,this.ybase+i-1)}if(h.length>0){let t=[],i=[];for(let t=0;t<this.lines.length;t++)i.push(this.lines.get(t));let s=this.lines.length,e=s-1,n=0,o=h[n];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+r);let l=0;for(let a=Math.min(this.lines.maxLength-1,s+r-1);a>=0;a--)if(o&&o.start>e+l){for(let t=o.newLines.length-1;t>=0;t--)this.lines.set(a--,o.newLines[t]);a++,t.push({index:e+1,amount:o.newLines.length}),l+=o.newLines.length,o=h[++n]}else this.lines.set(a,i[e--]);let a=0;for(let i=t.length-1;i>=0;i--)t[i].index+=a,this.lines.onInsertEmitter.fire(t[i]),a+=t[i].amount;let u=Math.max(0,s+r-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(t,i,s=0,e){let h=this.lines.get(t);return h?h.translateToString(i,s,e):""}getWrappedRangeForLine(t){let i=t,s=t;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:i,last:s}}setupTabStops(t){for(null!=t?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(null==t&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(null==t&&(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 i=0;i<this.markers.length;i++)this.markers[i].line===t&&(this.markers[i].dispose(),this.markers.splice(i--,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 i=new th(t);return this.markers.push(i),i.register(this.lines.onTrim((t=>{i.line-=t,i.line<0&&i.dispose()}))),i.register(this.lines.onInsert((t=>{i.line>=t.index&&(i.line+=t.amount)}))),i.register(this.lines.onDelete((t=>{i.line>=t.index&&i.line<t.index+t.amount&&i.dispose(),i.line>t.index&&(i.line-=t.amount)}))),i.register(i.onDispose((()=>this._removeMarker(i)))),i}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},rh=class extends gt{constructor(t,i){super(),this._optionsService=t,this._bufferService=i,this._onBufferActivate=this._register(new _t),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new hh(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new hh(!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(t){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(t),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(t,i){this._normal.resize(t,i),this._alt.resize(t,i),this.setupTabStops(t)}setupTabStops(t){this._normal.setupTabStops(t),this._alt.setupTabStops(t)}},nh=class extends gt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new _t),this.onResize=this._onResize.event,this._onScroll=this._register(new _t),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,2),this.rows=Math.max(t.rawOptions.rows||0,1),this.buffers=this._register(new rh(t,this)),this._register(this.buffers.onBufferActivate((t=>{this._onScroll.fire(t.activeBuffer.ydisp)})))}get buffer(){return this.buffers.active}resize(t,i){let s=this.cols!==t,e=this.rows!==i;this.cols=t,this.rows=i,this.buffers.resize(t,i),this._onResize.fire({cols:t,rows:i,colsChanged:s,rowsChanged:e})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,i=!1){let s,e=this.buffer;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=e.getBlankLine(t,i),this._cachedBlankLine=s),s.isWrapped=i;let h=e.ybase+e.scrollTop,r=e.ybase+e.scrollBottom;if(0===e.scrollTop){let t=e.lines.isFull;r===e.lines.length-1?t?e.lines.recycle().copyFrom(s):e.lines.push(s.clone()):e.lines.splice(r+1,0,s.clone()),t?this.isUserScrolling&&(e.ydisp=Math.max(e.ydisp-1,0)):(e.ybase++,this.isUserScrolling||e.ydisp++)}else e.lines.shiftElements(h+1,r-h+1-1,-1),e.lines.set(r,s.clone());this.isUserScrolling||(e.ydisp=e.ybase),this._onScroll.fire(e.ydisp)}scrollLines(t,i){let s=this.buffer;if(t<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else t+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let e=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+t,s.ybase),0),e!==s.ydisp&&(i||this._onScroll.fire(s.ydisp))}};nh=d([g(0,G)],nh);var oh={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:ce,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},lh=["normal","bold","100","200","300","400","500","600","700","800","900"],ah=class extends gt{constructor(t){super(),this._onOptionChange=this._register(new _t),this.onOptionChange=this._onOptionChange.event;let i={...oh};for(let s in t)if(s in i)try{i[s]=this._sanitizeAndValidateOption(s,t[s])}catch(t){console.error(t)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(At((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(t,i){return this.onOptionChange((s=>{s===t&&i(this.rawOptions[t])}))}onMultipleOptionChange(t,i){return this.onOptionChange((s=>{-1!==t.indexOf(s)&&i()}))}_setupOptions(){let t=t=>{if(!(t in oh))throw Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,i)=>{if(!(t in oh))throw Error(`No option with key "${t}"`);i=this._sanitizeAndValidateOption(t,i),this.rawOptions[t]!==i&&(this.rawOptions[t]=i,this._onOptionChange.fire(t))};for(let s in this.rawOptions){let e={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this.options,s,e)}}_sanitizeAndValidateOption(t,i){switch(t){case"cursorStyle":if(i||(i=oh[t]),!function(t){return"block"===t||"underline"===t||"bar"===t}(i))throw Error(`"${i}" is not a valid value for ${t}`);break;case"wordSeparator":i||(i=oh[t]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=lh.includes(i)?i:oh[t];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${t} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,4294967295))<0)throw Error(`${t} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${t} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${t} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function uh(t,i=5){if("object"!=typeof t)return t;let s=Array.isArray(t)?[]:{};for(let e in t)s[e]=i<=1?t[e]:t[e]&&uh(t[e],i-1);return s}var ch=Object.freeze({insertMode:!1}),Ah=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),fh=class extends gt{constructor(t,i,s){super(),this._bufferService=t,this._logService=i,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new _t),this.onData=this._onData.event,this._onUserInput=this._register(new _t),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new _t),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new _t),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=uh(ch),this.decPrivateModes=uh(Ah)}reset(){this.modes=uh(ch),this.decPrivateModes=uh(Ah)}triggerDataEvent(t,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 "${t}"`),this._logService.trace("sending data (codes)",(()=>t.split("").map((t=>t.charCodeAt(0))))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",(()=>t.split("").map((t=>t.charCodeAt(0))))),this._onBinary.fire(t))}};fh=d([g(0,R),g(1,U),g(2,G)],fh);var dh={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>4!==t.button&&1===t.action&&(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>32!==t.action},DRAG:{events:23,restrict:t=>!(32===t.action&&3===t.button)},ANY:{events:31,restrict:()=>!0}};function gh(t,i){let s=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return 4===t.button?(s|=64,s|=t.action):(s|=3&t.button,4&t.button&&(s|=64),8&t.button&&(s|=128),32===t.action?s|=32:0===t.action&&!i&&(s|=3)),s}var wh=String.fromCharCode,ph={DEFAULT:t=>{let i=[gh(t,!1)+32,t.col+32,t.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`${wh(i[0])}${wh(i[1])}${wh(i[2])}`},SGR:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${gh(t,!0)};${t.col};${t.row}${i}`},SGR_PIXELS:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${gh(t,!0)};${t.x};${t.y}${i}`}},Ch=class extends gt{constructor(t,i,s){super(),this._bufferService=t,this._coreService=i,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _t),this.onProtocolChange=this._onProtocolChange.event;for(let t of Object.keys(dh))this.addProtocol(t,dh[t]);for(let t of Object.keys(ph))this.addEncoding(t,ph[t]);this.reset()}addProtocol(t,i){this._protocols[t]=i}addEncoding(t,i){this._encodings[t]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(t){if(!this._protocols[t])throw 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 Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,i,s){if(0===t.deltaY||t.shiftKey||void 0===i||void 0===s)return 0;let e=i/s,h=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(h/=e+0,Math.abs(t.deltaY)<50&&(h*=.3),this._wheelPartialScroll+=h,h=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(h*=this._bufferService.rows),h}_applyScrollModifier(t,i){return i.altKey||i.ctrlKey||i.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||4===t.button&&32===t.action||3===t.button&&32!==t.action||4!==t.button&&(2===t.action||3===t.action)||(t.col++,t.row++,32===t.action&&this._lastEvent&&this._equalEvents(this._lastEvent,t,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(t))return!1;let i=this._encodings[this._activeEncoding](t);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(1&t),up:!!(2&t),drag:!!(4&t),move:!!(8&t),wheel:!!(16&t)}}_equalEvents(t,i,s){if(s){if(t.x!==i.x||t.y!==i.y)return!1}else if(t.col!==i.col||t.row!==i.row)return!1;return!(t.button!==i.button||t.action!==i.action||t.ctrl!==i.ctrl||t.alt!==i.alt||t.shift!==i.shift)}};Ch=d([g(0,R),g(1,F),g(2,G)],Ch);var mh,Ih=[[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]],vh=[[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]],Bh=class{constructor(){if(this.version="6",!mh){(mh=new Uint8Array(65536)).fill(1),mh[0]=0,mh.fill(0,1,32),mh.fill(0,127,160),mh.fill(2,4352,4448),mh[9001]=2,mh[9002]=2,mh.fill(2,11904,42192),mh[12351]=1,mh.fill(2,44032,55204),mh.fill(2,63744,64256),mh.fill(2,65040,65050),mh.fill(2,65072,65136),mh.fill(2,65280,65377),mh.fill(2,65504,65511);for(let t=0;t<Ih.length;++t)mh.fill(0,Ih[t][0],Ih[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?mh[t]:function(t,i){let s,e=0,h=i.length-1;if(t<i[0][0]||t>i[h][1])return!1;for(;h>=e;)if(s=e+h>>1,t>i[s][1])e=s+1;else{if(!(t<i[s][0]))return!0;h=s-1}return!1}(t,vh)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,i){let s=this.wcwidth(t),e=0===s&&0!==i;if(e){let t=Mh.extractWidth(i);0===t?e=!1:t>s&&(s=t)}return Mh.createPropertyValue(0,s,e)}},Mh=class t{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new _t,this.onChange=this._onChange.event;let t=new Bh;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return!!(1&t)}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(16777215&t)<<3|(3&i)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(i){let s=0,e=0,h=i.length;for(let r=0;r<h;++r){let n=i.charCodeAt(r);if(55296<=n&&n<=56319){if(++r>=h)return s+this.wcwidth(n);let t=i.charCodeAt(r);56320<=t&&t<=57343?n=1024*(n-55296)+t-56320+65536:s+=this.wcwidth(t)}let o=this.charProperties(n,e),l=t.extractWidth(o);t.extractShouldJoin(o)&&(l-=t.extractWidth(e)),s+=l,e=o}return s}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},yh=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,i){this._charsets[t]=i,this.glevel===t&&(this.charset=i)}};function Qh(t){let i=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1)?.get(t.cols-1),s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);s&&i&&(s.isWrapped=0!==i[3]&&32!==i[3])}var Eh=2147483647,bh=class t{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let s=new t;if(!i.length)return s;for(let t=Array.isArray(i[0])?1:0;t<i.length;++t){let e=i[t];if(Array.isArray(e))for(let t=0;t<e.length;++t)s.addSubParam(e[t]);else s.addParam(e)}return s}clone(){let i=new t(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,e=255&this._subParamsIdx[i];e-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,e))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(t<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Eh?Eh:t}}addSubParam(t){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)return void(this._rejectSubDigits=!0);if(t<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Eh?Eh:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(255&this._subParamsIdx[t])-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=255&this._subParamsIdx[t];return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,e=255&this._subParamsIdx[i];e-s>0&&(t[i]=this._subParams.slice(s,e))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,e=s[i-1];s[i-1]=~e?Math.min(10*e+t,Eh):t}},kh=[],xh=class{constructor(){this._state=0,this._active=kh,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,i){void 0===this._handlers[t]&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(i),{dispose:()=>{let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kh}reset(){if(2===this._state)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=kh,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||kh,this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].start();else this._handlerFb(this._id,"START")}_put(t,i,s){if(this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].put(t,i,s);else this._handlerFb(this._id,"PUT",y(t,i,s))}start(){this.reset(),this._state=1}put(t,i,s){if(3!==this._state){if(1===this._state)for(;i<s;){let s=t[i++];if(59===s){this._state=2,this._start();break}if(s<48||57<s)return void(this._state=3);-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-i>0&&this._put(t,i,s)}}end(t,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,e=this._active.length-1,h=!1;if(this._stack.paused&&(e=this._stack.loopPosition-1,s=i,h=this._stack.fallThrough,this._stack.paused=!1),!h&&!1===s){for(;e>=0&&(s=this._active[e].end(t),!0!==s);e--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!1,s;e--}for(;e>=0;e--)if(s=this._active[e].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",t);this._active=kh,this._id=-1,this._state=0}}},Dh=class{constructor(t){this._handler=t,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=y(t,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(t){let i=!1;if(this._hitLimit)i=!1;else if(t&&(i=this._handler(this._data),i instanceof Promise))return i.then((t=>(this._data="",this._hitLimit=!1,t)));return this._data="",this._hitLimit=!1,i}},Lh=[],Sh=class{constructor(){this._handlers=Object.create(null),this._active=Lh,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Lh}registerHandler(t,i){void 0===this._handlers[t]&&(this._handlers[t]=[]);let s=this._handlers[t];return s.push(i),{dispose:()=>{let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=Lh,this._ident=0}hook(t,i){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Lh,this._active.length)for(let t=this._active.length-1;t>=0;t--)this._active[t].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(t,i,s){if(this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].put(t,i,s);else this._handlerFb(this._ident,"PUT",y(t,i,s))}unhook(t,i=!0){if(this._active.length){let s=!1,e=this._active.length-1,h=!1;if(this._stack.paused&&(e=this._stack.loopPosition-1,s=i,h=this._stack.fallThrough,this._stack.paused=!1),!h&&!1===s){for(;e>=0&&(s=this._active[e].unhook(t),!0!==s);e--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!1,s;e--}for(;e>=0;e--)if(s=this._active[e].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=e,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",t);this._active=Lh,this._ident=0}},_h=new bh;_h.addParam(0);var $h=class{constructor(t){this._handler=t,this._data="",this._params=_h,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():_h,this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=y(t,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let i=!1;if(this._hitLimit)i=!1;else if(t&&(i=this._handler(this._data,this._params),i instanceof Promise))return i.then((t=>(this._params=_h,this._data="",this._hitLimit=!1,t)));return this._params=_h,this._data="",this._hitLimit=!1,i}},Rh=class{constructor(t){this.table=new Uint8Array(t)}setDefault(t,i){this.table.fill(t<<4|i)}add(t,i,s,e){this.table[i<<8|t]=s<<4|e}addMany(t,i,s,e){for(let h=0;h<t.length;h++)this.table[i<<8|t[h]]=s<<4|e}},Nh=160,Fh=function(){let t=new Rh(4095),i=Array.apply(null,Array(256)).map(((t,i)=>i)),s=(t,s)=>i.slice(t,s),e=s(32,127),h=s(0,24);h.push(25),h.push.apply(h,s(28,32));let r,n=s(0,14);for(r in t.setDefault(1,0),t.addMany(e,0,2,0),n)t.addMany([24,26,153,154],r,3,0),t.addMany(s(128,144),r,3,0),t.addMany(s(144,152),r,3,0),t.add(156,r,0,0),t.add(27,r,11,1),t.add(157,r,4,8),t.addMany([152,158,159],r,0,7),t.add(155,r,11,3),t.add(144,r,11,9);return t.addMany(h,0,3,0),t.addMany(h,1,3,1),t.add(127,1,0,1),t.addMany(h,8,0,8),t.addMany(h,3,3,3),t.add(127,3,0,3),t.addMany(h,4,3,4),t.add(127,4,0,4),t.addMany(h,6,3,6),t.addMany(h,5,3,5),t.add(127,5,0,5),t.addMany(h,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(e,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(s(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(e,7,0,7),t.addMany(h,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(s(64,127),3,7,0),t.addMany(s(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(s(48,60),4,8,4),t.addMany(s(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(s(32,64),6,0,6),t.add(127,6,0,6),t.addMany(s(64,127),6,0,0),t.addMany(s(32,48),3,9,5),t.addMany(s(32,48),5,9,5),t.addMany(s(48,64),5,0,6),t.addMany(s(64,127),5,7,0),t.addMany(s(32,48),4,9,5),t.addMany(s(32,48),1,9,2),t.addMany(s(32,48),2,9,2),t.addMany(s(48,127),2,10,0),t.addMany(s(48,80),1,10,0),t.addMany(s(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(s(96,127),1,10,0),t.add(80,1,11,9),t.addMany(h,9,0,9),t.add(127,9,0,9),t.addMany(s(28,32),9,0,9),t.addMany(s(32,48),9,9,12),t.addMany(s(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(h,11,0,11),t.addMany(s(32,128),11,0,11),t.addMany(s(28,32),11,0,11),t.addMany(h,10,0,10),t.add(127,10,0,10),t.addMany(s(28,32),10,0,10),t.addMany(s(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(s(32,48),10,9,12),t.addMany(h,12,0,12),t.add(127,12,0,12),t.addMany(s(28,32),12,0,12),t.addMany(s(32,48),12,9,12),t.addMany(s(48,64),12,0,11),t.addMany(s(64,127),12,12,13),t.addMany(s(64,127),10,12,13),t.addMany(s(64,127),9,12,13),t.addMany(h,13,13,13),t.addMany(e,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(Nh,0,2,0),t.add(Nh,8,5,8),t.add(Nh,6,0,6),t.add(Nh,11,0,11),t.add(Nh,13,13,13),t}(),Hh=class extends gt{constructor(t=Fh){super(),this._transitions=t,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new bh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=()=>{},this._executeHandlerFb=()=>{},this._csiHandlerFb=()=>{},this._escHandlerFb=()=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(At((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this._register(new xh),this._dcsParser=this._register(new Sh),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(t,i=[64,126]){let s=0;if(t.prefix){if(t.prefix.length>1)throw Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<t.intermediates.length;++i){let e=t.intermediates.charCodeAt(i);if(32>e||e>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=e}}if(1!==t.final.length)throw Error("final must be a single byte");let e=t.final.charCodeAt(0);if(i[0]>e||e>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return s<<=8,s|=e,s}identToString(t){let i=[];for(;t;)i.push(String.fromCharCode(255&t)),t>>=8;return i.reverse().join("")}setPrintHandler(t){this._printHandler=t}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(t,i){let s=this._identifier(t,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let e=this._escHandlers[s];return e.push(i),{dispose:()=>{let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}clearEscHandler(t){this._escHandlers[this._identifier(t,[48,126])]&&delete this._escHandlers[this._identifier(t,[48,126])]}setEscHandlerFallback(t){this._escHandlerFb=t}setExecuteHandler(t,i){this._executeHandlers[t.charCodeAt(0)]=i}clearExecuteHandler(t){this._executeHandlers[t.charCodeAt(0)]&&delete this._executeHandlers[t.charCodeAt(0)]}setExecuteHandlerFallback(t){this._executeHandlerFb=t}registerCsiHandler(t,i){let s=this._identifier(t);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let e=this._csiHandlers[s];return e.push(i),{dispose:()=>{let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}}clearCsiHandler(t){this._csiHandlers[this._identifier(t)]&&delete this._csiHandlers[this._identifier(t)]}setCsiHandlerFallback(t){this._csiHandlerFb=t}registerDcsHandler(t,i){return this._dcsParser.registerHandler(this._identifier(t),i)}clearDcsHandler(t){this._dcsParser.clearHandler(this._identifier(t))}setDcsHandlerFallback(t){this._dcsParser.setHandlerFallback(t)}registerOscHandler(t,i){return this._oscParser.registerHandler(t,i)}clearOscHandler(t){this._oscParser.clearHandler(t)}setOscHandlerFallback(t){this._oscParser.setHandlerFallback(t)}setErrorHandler(t){this._errorHandler=t}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(t,i,s,e,h){this._parseStack.state=t,this._parseStack.handlers=i,this._parseStack.handlerPos=s,this._parseStack.transition=e,this._parseStack.chunkPos=h}parse(t,i,s){let e,h=0,r=0,n=0;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,r=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&r>-1)for(;r>=0&&(e=i[r](this._params),!0!==e);r--)if(e instanceof Promise)return this._parseStack.handlerPos=r,e;this._parseStack.handlers=[];break;case 4:if(!1===s&&r>-1)for(;r>=0&&(e=i[r](),!0!==e);r--)if(e instanceof Promise)return this._parseStack.handlerPos=r,e;this._parseStack.handlers=[];break;case 6:if(h=t[this._parseStack.chunkPos],e=this._dcsParser.unhook(24!==h&&26!==h,s),e)return e;27===h&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(h=t[this._parseStack.chunkPos],e=this._oscParser.end(24!==h&&26!==h,s),e)return e;27===h&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=n;s<i;++s){switch(h=t[s],r=this._transitions.table[this.currentState<<8|(h<160?h:Nh)],r>>4){case 2:for(let e=s+1;;++e){if(e>=i||(h=t[e])<32||h>126&&h<Nh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Nh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Nh){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<Nh){this._printHandler(t,s,e),s=e-1;break}}break;case 3:this._executeHandlers[h]?this._executeHandlers[h]():this._executeHandlerFb(h),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:h,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let n=this._csiHandlers[this._collect<<8|h],o=n?n.length-1:-1;for(;o>=0&&(e=n[o](this._params),!0!==e);o--)if(e instanceof Promise)return this._preserveStack(3,n,o,r,s),e;o<0&&this._csiHandlerFb(this._collect<<8|h,this._params),this.precedingJoinState=0;break;case 8:do{switch(h){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(h-48)}}while(++s<i&&(h=t[s])>47&&h<60);s--;break;case 9:this._collect<<=8,this._collect|=h;break;case 10:let l=this._escHandlers[this._collect<<8|h],a=l?l.length-1:-1;for(;a>=0&&(e=l[a](),!0!==e);a--)if(e instanceof Promise)return this._preserveStack(4,l,a,r,s),e;a<0&&this._escHandlerFb(this._collect<<8|h),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|h,this._params);break;case 13:for(let e=s+1;;++e)if(e>=i||24===(h=t[e])||26===h||27===h||h>127&&h<Nh){this._dcsParser.put(t,s,e),s=e-1;break}break;case 14:if(e=this._dcsParser.unhook(24!==h&&26!==h),e)return this._preserveStack(6,[],0,r,s),e;27===h&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let e=s+1;;e++)if(e>=i||(h=t[e])<32||h>127&&h<Nh){this._oscParser.put(t,s,e),s=e-1;break}break;case 6:if(e=this._oscParser.end(24!==h&&26!==h),e)return this._preserveStack(5,[],0,r,s),e;27===h&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&r}}},Th=/^([\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})$/,Uh=/^[\da-f]+$/;function Gh(t){if(!t)return;let i=t.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let t=Th.exec(i);if(t){let i=t[1]?15:t[4]?255:t[7]?4095:65535;return[Math.round(parseInt(t[1]||t[4]||t[7]||t[10],16)/i*255),Math.round(parseInt(t[2]||t[5]||t[8]||t[11],16)/i*255),Math.round(parseInt(t[3]||t[6]||t[9]||t[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),Uh.exec(i)&&[3,6,9,12].includes(i.length))){let t=i.length/3,s=[0,0,0];for(let e=0;e<3;++e){let h=parseInt(i.slice(t*e,t*e+t),16);s[e]=1===t?h<<4:2===t?h:3===t?h>>4:h>>8}return s}}function Ph(t,i){let s=t.toString(16),e=s.length<2?"0"+s:s;switch(i){case 4:return s[0];case 8:return e;case 12:return(e+e).slice(0,3);default:return e+e}}function Jh(t,i=16){let[s,e,h]=t;return`rgb:${Ph(s,i)}/${Ph(e,i)}/${Ph(h,i)}`}var Oh={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Wh=131072;function zh(t,i){if(t>24)return i.setWinLines||!1;switch(t){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var Kh=0,qh=class extends gt{constructor(t,i,s,e,h,r,n,o,l=new Hh){super(),this._bufferService=t,this._charsetService=i,this._coreService=s,this._logService=e,this._optionsService=h,this._oscLinkService=r,this._coreMouseService=n,this._unicodeService=o,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Q,this._utf8Decoder=new E,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=qe.clone(),this._eraseAttrDataInternal=qe.clone(),this._onRequestBell=this._register(new _t),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new _t),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new _t),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new _t),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new _t),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new _t),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new _t),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new _t),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new _t),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new _t),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new _t),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new _t),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new _t),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new jh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((t=>this._activeBuffer=t.activeBuffer))),this._parser.setCsiHandlerFallback(((t,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(t),params:i.toArray()})})),this._parser.setEscHandlerFallback((t=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(t)})})),this._parser.setExecuteHandlerFallback((t=>{this._logService.debug("Unknown EXECUTE code: ",{code:t})})),this._parser.setOscHandlerFallback(((t,i,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:t,action:i,data:s})})),this._parser.setDcsHandlerFallback(((t,i,s)=>{"HOOK"===i&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(t),action:i,payload:s})})),this._parser.setPrintHandler(((t,i,s)=>this.print(t,i,s))),this._parser.registerCsiHandler({final:"@"},(t=>this.insertChars(t))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(t=>this.scrollLeft(t))),this._parser.registerCsiHandler({final:"A"},(t=>this.cursorUp(t))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(t=>this.scrollRight(t))),this._parser.registerCsiHandler({final:"B"},(t=>this.cursorDown(t))),this._parser.registerCsiHandler({final:"C"},(t=>this.cursorForward(t))),this._parser.registerCsiHandler({final:"D"},(t=>this.cursorBackward(t))),this._parser.registerCsiHandler({final:"E"},(t=>this.cursorNextLine(t))),this._parser.registerCsiHandler({final:"F"},(t=>this.cursorPrecedingLine(t))),this._parser.registerCsiHandler({final:"G"},(t=>this.cursorCharAbsolute(t))),this._parser.registerCsiHandler({final:"H"},(t=>this.cursorPosition(t))),this._parser.registerCsiHandler({final:"I"},(t=>this.cursorForwardTab(t))),this._parser.registerCsiHandler({final:"J"},(t=>this.eraseInDisplay(t,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(t=>this.eraseInDisplay(t,!0))),this._parser.registerCsiHandler({final:"K"},(t=>this.eraseInLine(t,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(t=>this.eraseInLine(t,!0))),this._parser.registerCsiHandler({final:"L"},(t=>this.insertLines(t))),this._parser.registerCsiHandler({final:"M"},(t=>this.deleteLines(t))),this._parser.registerCsiHandler({final:"P"},(t=>this.deleteChars(t))),this._parser.registerCsiHandler({final:"S"},(t=>this.scrollUp(t))),this._parser.registerCsiHandler({final:"T"},(t=>this.scrollDown(t))),this._parser.registerCsiHandler({final:"X"},(t=>this.eraseChars(t))),this._parser.registerCsiHandler({final:"Z"},(t=>this.cursorBackwardTab(t))),this._parser.registerCsiHandler({final:"`"},(t=>this.charPosAbsolute(t))),this._parser.registerCsiHandler({final:"a"},(t=>this.hPositionRelative(t))),this._parser.registerCsiHandler({final:"b"},(t=>this.repeatPrecedingCharacter(t))),this._parser.registerCsiHandler({final:"c"},(t=>this.sendDeviceAttributesPrimary(t))),this._parser.registerCsiHandler({prefix:">",final:"c"},(t=>this.sendDeviceAttributesSecondary(t))),this._parser.registerCsiHandler({final:"d"},(t=>this.linePosAbsolute(t))),this._parser.registerCsiHandler({final:"e"},(t=>this.vPositionRelative(t))),this._parser.registerCsiHandler({final:"f"},(t=>this.hVPosition(t))),this._parser.registerCsiHandler({final:"g"},(t=>this.tabClear(t))),this._parser.registerCsiHandler({final:"h"},(t=>this.setMode(t))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this.setModePrivate(t))),this._parser.registerCsiHandler({final:"l"},(t=>this.resetMode(t))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this.resetModePrivate(t))),this._parser.registerCsiHandler({final:"m"},(t=>this.charAttributes(t))),this._parser.registerCsiHandler({final:"n"},(t=>this.deviceStatus(t))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(t=>this.deviceStatusPrivate(t))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(t=>this.softReset(t))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(t=>this.setCursorStyle(t))),this._parser.registerCsiHandler({final:"r"},(t=>this.setScrollRegion(t))),this._parser.registerCsiHandler({final:"s"},(t=>this.saveCursor(t))),this._parser.registerCsiHandler({final:"t"},(t=>this.windowOptions(t))),this._parser.registerCsiHandler({final:"u"},(t=>this.restoreCursor(t))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(t=>this.insertColumns(t))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(t=>this.deleteColumns(t))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(t=>this.selectProtected(t))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(t=>this.requestMode(t,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(t=>this.requestMode(t,!1))),this._parser.setExecuteHandler(As.BEL,(()=>this.bell())),this._parser.setExecuteHandler(As.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(As.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(As.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(As.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(As.BS,(()=>this.backspace())),this._parser.setExecuteHandler(As.HT,(()=>this.tab())),this._parser.setExecuteHandler(As.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(As.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(fs.IND,(()=>this.index())),this._parser.setExecuteHandler(fs.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(fs.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new Dh((t=>(this.setTitle(t),this.setIconName(t),!0)))),this._parser.registerOscHandler(1,new Dh((t=>this.setIconName(t)))),this._parser.registerOscHandler(2,new Dh((t=>this.setTitle(t)))),this._parser.registerOscHandler(4,new Dh((t=>this.setOrReportIndexedColor(t)))),this._parser.registerOscHandler(8,new Dh((t=>this.setHyperlink(t)))),this._parser.registerOscHandler(10,new Dh((t=>this.setOrReportFgColor(t)))),this._parser.registerOscHandler(11,new Dh((t=>this.setOrReportBgColor(t)))),this._parser.registerOscHandler(12,new Dh((t=>this.setOrReportCursorColor(t)))),this._parser.registerOscHandler(104,new Dh((t=>this.restoreIndexedColor(t)))),this._parser.registerOscHandler(110,new Dh((t=>this.restoreFgColor(t)))),this._parser.registerOscHandler(111,new Dh((t=>this.restoreBgColor(t)))),this._parser.registerOscHandler(112,new Dh((t=>this.restoreCursorColor(t)))),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 t in ih)this._parser.registerEscHandler({intermediates:"(",final:t},(()=>this.selectCharset("("+t))),this._parser.registerEscHandler({intermediates:")",final:t},(()=>this.selectCharset(")"+t))),this._parser.registerEscHandler({intermediates:"*",final:t},(()=>this.selectCharset("*"+t))),this._parser.registerEscHandler({intermediates:"+",final:t},(()=>this.selectCharset("+"+t))),this._parser.registerEscHandler({intermediates:"-",final:t},(()=>this.selectCharset("-"+t))),this._parser.registerEscHandler({intermediates:".",final:t},(()=>this.selectCharset("."+t))),this._parser.registerEscHandler({intermediates:"/",final:t},(()=>this.selectCharset("/"+t)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((t=>(this._logService.error("Parsing error: ",t),t))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new $h(((t,i)=>this.requestStatusString(t,i))))}getAttrData(){return this._curAttrData}_preserveStack(t,i,s,e){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=s,this._parseStack.position=e}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise(((t,i)=>setTimeout((()=>i("#SLOW_TIMEOUT")),5e3)))]).catch((t=>{if("#SLOW_TIMEOUT"!==t)throw t;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,i){let s,e=this._activeBuffer.x,h=this._activeBuffer.y,r=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(s),s;e=this._parseStack.cursorStartX,h=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Wh&&(r=this._parseStack.position+Wh)}if(this._logService.logLevel<=1&&this._logService.debug("parsing data "+("string"==typeof t?` "${t}"`:` "${Array.prototype.map.call(t,(t=>String.fromCharCode(t))).join("")}"`)),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof t?t.split("").map((t=>t.charCodeAt(0))):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Wh&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Wh))),n||this._dirtyRowTracker.clearRange(),t.length>Wh)for(let i=r;i<t.length;i+=Wh){let r=i+Wh<t.length?i+Wh:t.length,n="string"==typeof t?this._stringDecoder.decode(t.substring(i,r),this._parseBuffer):this._utf8Decoder.decode(t.subarray(i,r),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,n))return this._preserveStack(e,h,n,i),this._logSlowResolvingAsync(s),s}else if(!n){let i="string"==typeof t?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,i))return this._preserveStack(e,h,i,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==e||this._activeBuffer.y!==h)&&this._onCursorMove.fire();let o=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(o,this._bufferService.rows-1)})}print(t,i,s){let e,h,r=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,o=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,a=this._coreService.modes.insertMode,u=this._curAttrData,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-i>0&&2===c.getWidth(this._activeBuffer.x-1)&&c.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let A=this._parser.precedingJoinState;for(let f=i;f<s;++f){if(e=t[f],e<127&&r){let t=r[String.fromCharCode(e)];t&&(e=t.charCodeAt(0))}let i=this._unicodeService.charProperties(e,A);h=Mh.extractWidth(i);let s=Mh.extractShouldJoin(i),d=s?Mh.extractWidth(A):0;if(A=i,n&&this._onA11yChar.fire(M(e)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+h-d>o)if(l){let t=c,i=this._activeBuffer.x-d;for(this._activeBuffer.x=d,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),c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),d>0&&c instanceof Ye&&c.copyCellsFrom(t,i,0,d,!1);i<o;)t.setCellFromCodepoint(i++,0,1,u)}else if(this._activeBuffer.x=o-1,2===h)continue;if(s&&this._activeBuffer.x){let t=c.getWidth(this._activeBuffer.x-1)?1:2;c.addCodepointToCell(this._activeBuffer.x-t,e,h);for(let t=h-d;--t>=0;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(a&&(c.insertCells(this._activeBuffer.x,h-d,this._activeBuffer.getNullCell(u)),2===c.getWidth(o-1)&&c.setCellFromCodepoint(o-1,0,1,u)),c.setCellFromCodepoint(this._activeBuffer.x++,e,h,u),h>0)for(;--h;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=A,this._activeBuffer.x<o&&s-i>0&&0===c.getWidth(this._activeBuffer.x)&&!c.hasContent(this._activeBuffer.x)&&c.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,i){return this._parser.registerCsiHandler(t,"t"!==t.final||t.prefix||t.intermediates?i:t=>!zh(t.params[0],this._optionsService.rawOptions.windowOptions)||i(t))}registerDcsHandler(t,i){return this._parser.registerDcsHandler(t,new $h(i))}registerEscHandler(t,i){return this._parser.registerEscHandler(t,i)}registerOscHandler(t,i){return this._parser.registerOscHandler(t,new Dh(i))}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(0===this._activeBuffer.x&&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,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=t,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+i)}cursorUp(t){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return this._moveCursor(0,i>=0?-Math.min(i,t.params[0]||1):-(t.params[0]||1)),!0}cursorDown(t){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return this._moveCursor(0,i>=0?Math.min(i,t.params[0]||1):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 i=t.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=t.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=t.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let i=t.params[0];return 1===i&&(this._curAttrData.bg|=536870912),(2===i||0===i)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,i,s,e=!1,h=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);r.replaceCells(i,s,this._activeBuffer.getNullCell(this._eraseAttrData()),h),e&&(r.isWrapped=!1)}_resetBufferLine(t,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),s.isWrapped=!1)}eraseInDisplay(t,i=!1){let s;switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);s<this._bufferService.rows;s++)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let t=this._activeBuffer.lines.length-this._bufferService.rows;t>0&&(this._activeBuffer.lines.trimStart(t),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-t,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-t,0),this._onScroll.fire(0))}return!0}eraseInLine(t,i=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let i=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,e=this._bufferService.rows-1+this._activeBuffer.ybase-(this._bufferService.rows-1-this._activeBuffer.scrollBottom)+1;for(;i--;)this._activeBuffer.lines.splice(e-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(t){this._restrictCursor();let i=t.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s,e=this._activeBuffer.ybase+this._activeBuffer.y;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;i--;)this._activeBuffer.lines.splice(e,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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.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 i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let i=t.params[0]||1;for(;i--;)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 i=t.params[0]||1;for(;i--;)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(qe));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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(0,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(0,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(this._activeBuffer.x,i,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 i=t.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.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 i=this._parser.precedingJoinState;if(!i)return!0;let s=t.params[0]||1,e=Mh.extractWidth(i),h=this._activeBuffer.x-e,r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(h),n=new Uint32Array(r.length*s),o=0;for(let t=0;t<r.length;){let i=r.codePointAt(t)||0;n[o++]=i,t+=i>65535?2:1}let l=o;for(let t=1;t<s;++t)n.copyWithin(l,0,o),l+=o;return this.print(n,0,l),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(As.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(As.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(As.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(As.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(As.ESC+"[>83;40003;0c")),!0}_is(t){return 0===(this._optionsService.rawOptions.termName+"").indexOf(t)}setMode(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,sh),this._charsetService.setgCharset(1,sh),this._charsetService.setgCharset(2,sh),this._charsetService.setgCharset(3,sh);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(t){for(let i=0;i<t.length;i++)switch(t.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===t.params[i]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(t,i){let s;(t=>{t[t.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",t[t.SET=1]="SET",t[t.RESET=2]="RESET",t[t.PERMANENTLY_SET=3]="PERMANENTLY_SET",t[t.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"})(s||={});let e=this._coreService.decPrivateModes,{activeProtocol:h,activeEncoding:r}=this._coreMouseService,n=this._coreService,{buffers:o,cols:l}=this._bufferService,{active:a,alt:u}=o,c=this._optionsService.rawOptions,A=t=>t?1:2,f=t.params[0];return((t,s)=>(n.triggerDataEvent(`${As.ESC}[${i?"":"?"}${t};${s}$y`),!0))(f,i?2===f?4:4===f?A(n.modes.insertMode):12===f?3:20===f?A(c.convertEol):0:1===f?A(e.applicationCursorKeys):3===f?c.windowOptions.setWinLines?80===l?2:132===l?1:0:0:6===f?A(e.origin):7===f?A(e.wraparound):8===f?3:9===f?A("X10"===h):12===f?A(c.cursorBlink):25===f?A(!n.isCursorHidden):45===f?A(e.reverseWraparound):66===f?A(e.applicationKeypad):67===f?4:1e3===f?A("VT200"===h):1002===f?A("DRAG"===h):1003===f?A("ANY"===h):1004===f?A(e.sendFocus):1005===f?4:1006===f?A("SGR"===r):1015===f?4:1016===f?A("SGR_PIXELS"===r):1048===f?1:47===f||1047===f||1049===f?A(a===u):2004===f?A(e.bracketedPasteMode):2026===f?A(e.synchronizedOutput):0)}_updateAttrColor(t,i,s,e,h){return 2===i?(t|=50331648,t&=-16777216,t|=k.fromColorRGB([s,e,h])):5===i&&(t&=-50331904,t|=33554432|255&s),t}_extractColor(t,i,s){let e=[0,0,-1,0,0,0],h=0,r=0;do{if(e[r+h]=t.params[i+r],t.hasSubParams(i+r)){let s=t.getSubParams(i+r),n=0;do{5===e[1]&&(h=1),e[r+n+1+h]=s[n]}while(++n<s.length&&n+r+1+h<e.length);break}if(5===e[1]&&r+h>=2||2===e[1]&&r+h>=5)break;e[1]&&(h=1)}while(++r+i<t.length&&r+h<e.length);for(let t=2;t<e.length;++t)-1===e[t]&&(e[t]=0);switch(e[0]){case 38:s.fg=this._updateAttrColor(s.fg,e[1],e[3],e[4],e[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,e[1],e[3],e[4],e[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,e[1],e[3],e[4],e[5])}return r}_processUnderline(t,i){i.extended=i.extended.clone(),(!~t||t>5)&&(t=1),i.extended.underlineStyle=t,i.fg|=268435456,0===t&&(i.fg&=-268435457),i.updateExtended()}_processSGR0(t){t.fg=qe.fg,t.bg=qe.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(1===t.length&&0===t.params[0])return this._processSGR0(this._curAttrData),!0;let i,s=t.length,e=this._curAttrData;for(let h=0;h<s;h++)i=t.params[h],i>=30&&i<=37?(e.fg&=-50331904,e.fg|=16777216|i-30):i>=40&&i<=47?(e.bg&=-50331904,e.bg|=16777216|i-40):i>=90&&i<=97?(e.fg&=-50331904,e.fg|=16777224|i-90):i>=100&&i<=107?(e.bg&=-50331904,e.bg|=16777224|i-100):0===i?this._processSGR0(e):1===i?e.fg|=134217728:3===i?e.bg|=67108864:4===i?(e.fg|=268435456,this._processUnderline(t.hasSubParams(h)?t.getSubParams(h)[0]:1,e)):5===i?e.fg|=536870912:7===i?e.fg|=67108864:8===i?e.fg|=1073741824:9===i?e.fg|=2147483648:2===i?e.bg|=134217728:21===i?this._processUnderline(2,e):22===i?(e.fg&=-134217729,e.bg&=-134217729):23===i?e.bg&=-67108865:24===i?(e.fg&=-268435457,this._processUnderline(0,e)):25===i?e.fg&=-536870913:27===i?e.fg&=-67108865:28===i?e.fg&=-1073741825:29===i?e.fg&=2147483647:39===i?(e.fg&=-67108864,e.fg|=16777215&qe.fg):49===i?(e.bg&=-67108864,e.bg|=16777215&qe.bg):38===i||48===i||58===i?h+=this._extractColor(t,h,e):53===i?e.bg|=1073741824:55===i?e.bg&=-1073741825:59===i?(e.extended=e.extended.clone(),e.extended.underlineColor=-1,e.updateExtended()):100===i?(e.fg&=-67108864,e.fg|=16777215&qe.fg,e.bg&=-67108864,e.bg|=16777215&qe.bg):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(As.ESC+"[0n");break;case 6:this._coreService.triggerDataEvent(`${As.ESC}[${this._activeBuffer.y+1};${this._activeBuffer.x+1}R`)}return!0}deviceStatusPrivate(t){return 6===t.params[0]&&this._coreService.triggerDataEvent(`${As.ESC}[?${this._activeBuffer.y+1};${this._activeBuffer.x+1}R`),!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=qe.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 i=0===t.length?1:t.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){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"}this._coreService.decPrivateModes.cursorBlink=i%2==1}return!0}setScrollRegion(t){let i,s=t.params[0]||1;return(t.length<2||(i=t.params[1])>this._bufferService.rows||0===i)&&(i=this._bufferService.rows),i>s&&(this._activeBuffer.scrollTop=s-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(t){if(!zh(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${As.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}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 i=[],s=t.split(";");for(;s.length>1;){let t=s.shift(),e=s.shift();if(/^\d+$/.exec(t)){let s=parseInt(t);if(Yh(s))if("?"===e)i.push({type:0,index:s});else{let t=Gh(e);t&&i.push({type:1,index:s,color:t})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(t){let i=t.indexOf(";");if(-1===i)return!0;let s=t.slice(0,i).trim(),e=t.slice(i+1);return e?this._createHyperlink(s,e):!s.trim()&&this._finishHyperlink()}_createHyperlink(t,i){this._getCurrentLinkId()&&this._finishHyperlink();let s,e=t.split(":"),h=e.findIndex((t=>t.startsWith("id=")));return-1!==h&&(s=e[h].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,i){let s=t.split(";");for(let t=0;t<s.length&&!(i>=this._specialColors.length);++t,++i)if("?"===s[t])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let e=Gh(s[t]);e&&this._onColor.fire([{type:1,index:this._specialColors[i],color:e}])}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 i=[],s=t.split(";");for(let t=0;t<s.length;++t)if(/^\d+$/.exec(s[t])){let e=parseInt(s[t]);Yh(e)&&i.push({type:2,index:e})}return i.length&&this._onColor.fire(i),!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,sh),!0}selectCharset(t){return 2!==t.length?(this.selectDefaultCharset(),!0):("/"===t[0]||this._charsetService.setgCharset(Oh[t[0]],ih[t[1]]||sh),!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(){return this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop?(this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop,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)):(this._activeBuffer.y--,this._restrictCursor()),!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=qe.clone(),this._eraseAttrDataInternal=qe.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new D;t.content=4194373,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y+i);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,i){let s=this._bufferService.buffer,e=this._optionsService.rawOptions;return(t=>(this._coreService.triggerDataEvent(`${As.ESC}${t}${As.ESC}\\`),!0))('"q'===t?`P1$r${this._curAttrData.isProtected()?1:0}"q`:'"p'===t?'P1$r61;1"p':"r"===t?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:"m"===t?"P1$r0m":" q"===t?`P1$r${{block:2,underline:4,bar:6}[e.cursorStyle]-(e.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,i){this._dirtyRowTracker.markRangeDirty(t,i)}},jh=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,i){t>i&&(Kh=t,t=i,i=Kh),t<this.start&&(this.start=t),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Yh(t){return 0<=t&&t<256}jh=d([g(0,R)],jh);var Zh=class extends gt{constructor(t){super(),this._action=t,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new _t),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(t,i){if(void 0!==i&&this._syncCalls>i)return void(this._syncCalls=0);if(this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let s;for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let t=this._callbacks.shift();t&&t()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(t,i){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(i),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=t.length,this._writeBuffer.push(t),this._callbacks.push(i)}_innerWrite(t=0,i=!0){let s=t||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let t=this._writeBuffer[this._bufferOffset],e=this._action(t,i);if(e){let t=t=>performance.now()-s>=12?setTimeout((()=>this._innerWrite(0,t))):this._innerWrite(s,t);return void e.catch((t=>(queueMicrotask((()=>{throw t})),Promise.resolve(!1)))).then(t)}let h=this._callbacks[this._bufferOffset];if(h&&h(),this._bufferOffset++,this._pendingData-=t.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Xh=class{constructor(t){this._bufferService=t,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(t){let i=this._bufferService.buffer;if(void 0===t.id){let s=i.addMarker(i.ybase+i.y),e={data:t,id:this._nextId++,lines:[s]};return s.onDispose((()=>this._removeMarkerFromLink(e,s))),this._dataByLinkId.set(e.id,e),e.id}let s=t,e=this._getEntryIdKey(s),h=this._entriesWithId.get(e);if(h)return this.addLineToLink(h.id,i.ybase+i.y),h.id;let r=i.addMarker(i.ybase+i.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[r]};return r.onDispose((()=>this._removeMarkerFromLink(n,r))),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(t,i){let s=this._dataByLinkId.get(t);if(s&&s.lines.every((t=>t.line!==i))){let t=this._bufferService.buffer.addMarker(i);s.lines.push(t),t.onDispose((()=>this._removeMarkerFromLink(s,t)))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,i){let s=t.lines.indexOf(i);-1!==s&&(t.lines.splice(s,1),0===t.lines.length&&(void 0!==t.data.id&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};Xh=d([g(0,R)],Xh);var Vh=!1,tr=class extends gt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new wt),this._onBinary=this._register(new _t),this.onBinary=this._onBinary.event,this._onData=this._register(new _t),this.onData=this._onData.event,this._onLineFeed=this._register(new _t),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new _t),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new _t),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new _t),this._instantiationService=new Oe,this.optionsService=this._register(new ah(t)),this._instantiationService.setService(G,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(nh)),this._instantiationService.setService(R,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ze)),this._instantiationService.setService(U,this._logService),this.coreService=this._register(this._instantiationService.createInstance(fh)),this._instantiationService.setService(F,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ch)),this._instantiationService.setService(N,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Mh)),this._instantiationService.setService(J,this.unicodeService),this._charsetService=this._instantiationService.createInstance(yh),this._instantiationService.setService(H,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Xh),this._instantiationService.setService(P,this._oscLinkService),this._inputHandler=this._register(new qh(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(mt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(mt.forward(this._bufferService.onResize,this._onResize)),this._register(mt.forward(this.coreService.onData,this._onData)),this._register(mt.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 Zh(((t,i)=>this._inputHandler.parse(t,i)))),this._register(mt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new _t),this._onScroll.event((t=>{this._onScrollApi?.fire(t.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(t){for(let i in t)this.optionsService.options[i]=t[i]}write(t,i){this._writeBuffer.write(t,i)}writeSync(t,i){this._logService.logLevel<=3&&!Vh&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Vh=!0),this._writeBuffer.writeSync(t,i)}input(t,i=!0){this.coreService.triggerDataEvent(t,i)}resize(t,i){isNaN(t)||isNaN(i)||this._bufferService.resize(t=Math.max(t,2),i=Math.max(i,1))}scroll(t,i=!1){this._bufferService.scroll(t,i)}scrollLines(t,i){this._bufferService.scrollLines(t,i)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let i=t-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(t,i){return this._inputHandler.registerEscHandler(t,i)}registerDcsHandler(t,i){return this._inputHandler.registerDcsHandler(t,i)}registerCsiHandler(t,i){return this._inputHandler.registerCsiHandler(t,i)}registerOscHandler(t,i){return this._inputHandler.registerOscHandler(t,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let t=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?t="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(t=!0),t?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let t=[];t.push(this.onLineFeed(Qh.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(()=>(Qh(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=At((()=>{for(let i of t)i.dispose()}))}}},ir={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:["'",'"']},sr=0,er=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ce,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ce,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(t){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue((()=>this._flushInserted())),this._insertedValues.push(t)}_flushInserted(){let t=this._insertedValues.sort(((t,i)=>this._getKey(t)-this._getKey(i))),i=0,s=0,e=Array(this._array.length+this._insertedValues.length);for(let h=0;h<e.length;h++)s>=this._array.length||this._getKey(t[i])<=this._getKey(this._array[s])?(e[h]=t[i],i++):e[h]=this._array[s++];this._array=e,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(t){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(t);if(void 0===i||-1===(sr=this._search(i))||this._getKey(this._array[sr])!==i)return!1;do{if(this._array[sr]===t)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue((()=>this._flushDeleted())),this._deletedIndices.push(sr),!0}while(++sr<this._array.length&&this._getKey(this._array[sr])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort(((t,i)=>t-i)),i=0,s=Array(this._array.length-t.length),e=0;for(let h=0;h<this._array.length;h++)t[i]===h?i++:s[e++]=this._array[h];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((sr=this._search(t))<0||sr>=this._array.length)&&this._getKey(this._array[sr])===t)do{yield this._array[sr]}while(++sr<this._array.length&&this._getKey(this._array[sr])===t)}forEachByKey(t,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((sr=this._search(t))<0||sr>=this._array.length)&&this._getKey(this._array[sr])===t)do{i(this._array[sr])}while(++sr<this._array.length&&this._getKey(this._array[sr])===t)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(t){let i=0,s=this._array.length-1;for(;s>=i;){let e=i+s>>1,h=this._getKey(this._array[e]);if(h>t)s=e-1;else{if(!(h<t)){for(;e>0&&this._getKey(this._array[e-1])===t;)e--;return e}i=e+1}}return i}},hr=0,rr=0,nr=class extends gt{constructor(){super(),this._decorations=new er((t=>t?.marker.line)),this._onDecorationRegistered=this._register(new _t),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new _t),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(At((()=>this.reset())))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let i=new or(t);if(i){let t=i.marker.onDispose((()=>i.dispose())),s=i.onDispose((()=>{s.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),t.dispose())}));this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,i,s){let e=0,h=0;for(let r of this._decorations.getKeyIterator(i))e=r.options.x??0,h=e+(r.options.width??1),t>=e&&t<h&&(!s||(r.options.layer??"bottom")===s)&&(yield r)}forEachDecorationAtCell(t,i,s,e){this._decorations.forEachByKey(i,(i=>{rr=(hr=i.options.x??0)+(i.options.width??1),t>=hr&&t<rr&&(!s||(i.options.layer??"bottom")===s)&&e(i)}))}},or=class extends dt{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new _t),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new _t),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this._cachedBg=this.options.backgroundColor?Ms.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this._cachedFg=this.options.foregroundColor?Ms.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},lr=class{constructor(t,i=1e3){this._renderCallback=t,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(t,i,s){this._rowCount=s,t=void 0!==t?t:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,t):t,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let e=performance.now();if(e-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=e,this._innerRefresh();else if(!this._additionalRefreshRequested){let t=this._debounceThresholdMS-(e-this._lastRefreshMs);this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let t=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(t,i)}},ar=class extends gt{constructor(t,i,s,e){super(),this._terminal=t,this._coreBrowserService=s,this._renderService=e,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let h=this._coreBrowserService.mainDocument;this._accessibilityContainer=h.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=h.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let t=0;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);if(this._topBoundaryFocusListener=t=>this._handleBoundaryFocus(t,0),this._bottomBoundaryFocusListener=t=>this._handleBoundaryFocus(t,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=h.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new lr(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize((t=>this._handleResize(t.rows)))),this._register(this._terminal.onRender((t=>this._refreshRows(t.start,t.end)))),this._register(this._terminal.onScroll((()=>this._refreshRows()))),this._register(this._terminal.onA11yChar((t=>this._handleChar(t)))),this._register(this._terminal.onLineFeed((()=>this._handleChar("\n")))),this._register(this._terminal.onA11yTab((t=>this._handleTab(t)))),this._register(this._terminal.onKey((t=>this._handleKey(t.key)))),this._register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this._register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._register($i(h,"selectionchange",(()=>this._handleSelectionChange()))),this._register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRowsDimensions(),this._refreshRows(),this._register(At((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(t){for(let i=0;i<t;i++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,"\n"===t&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=m())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),/\p{Control}/u.test(t)||this._charsToConsume.push(t)}_refreshRows(t,i){this._liveRegionDebouncer.refresh(t,i,this._terminal.rows)}_renderRows(t,i){let s=this._terminal.buffer,e=""+s.lines.length;for(let h=t;h<=i;h++){let t=s.lines.get(s.ydisp+h),i=[],r=t?.translateToString(!0,void 0,void 0,i)||"",n=""+(s.ydisp+h+1),o=this._rowElements[h];o&&(0===r.length?(o.textContent=" ",this._rowColumns.set(o,[0,1])):(o.textContent=r,this._rowColumns.set(o,i)),o.setAttribute("aria-posinset",n),o.setAttribute("aria-setsize",e),this._alignRowWidth(o))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,i){let s,e,h=t.target,r=this._rowElements[0===i?1:this._rowElements.length-2];if(h.getAttribute("aria-posinset")!==(0===i?"1":""+this._terminal.buffer.lines.length)&&t.relatedTarget===r){if(0===i?(s=h,e=this._rowElements.pop(),this._rowContainer.removeChild(e)):(s=this._rowElements.shift(),e=h,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),e.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let t=this._createAccessibilityTreeNode();this._rowElements.unshift(t),this._rowContainer.insertAdjacentElement("afterbegin",t)}else{let t=this._createAccessibilityTreeNode();this._rowElements.push(t),this._rowContainer.appendChild(t)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed)return void(this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection());if(!t.anchorNode||!t.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:t.anchorNode,offset:t.anchorOffset},s={node:t.focusNode,offset:t.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let e=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(e)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:e,offset:e.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let h=({node:t,offset:i})=>{let s=t instanceof Text?t.parentNode:t,e=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(e))return console.warn("row is invalid. Race condition?"),null;let h=this._rowColumns.get(s);if(!h)return console.warn("columns is null. Race condition?"),null;let r=i<h.length?h[i]:h.slice(-1)[0]+1;return r>=this._terminal.cols&&(++e,r=0),{row:e,column:r}},r=h(i),n=h(s);if(r&&n){if(r.row>n.row||r.row===n.row&&r.column>=n.column)throw Error("invalid range");this._terminal.select(r.column,r.row,(n.row-r.row)*this._terminal.cols-r.column+n.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>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 i=t.getBoundingClientRect().width,s=this._rowColumns.get(t)?.slice(-1)?.[0];s&&(t.style.transform=`scaleX(${s*this._renderService.dimensions.css.cell.width/i})`)}};ar=d([g(1,T),g(2,q),g(3,Y)],ar);var ur=class extends gt{constructor(t,i,s,e,h){super(),this._element=t,this._mouseService=i,this._renderService=s,this._bufferService=e,this._linkProviderService=h,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new _t),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new _t),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(At((()=>{ct(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($i(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this._register($i(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register($i(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register($i(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let i=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let s=t.composedPath();for(let t=0;t<s.length;t++){let i=s[t];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||i.x!==this._lastBufferCell.x||i.y!==this._lastBufferCell.y)&&(this._handleHover(i),this._lastBufferCell=i)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(t,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,i){(!this._activeProviderReplies||!i)&&(this._activeProviderReplies?.forEach((t=>{t?.forEach((t=>{t.link.dispose&&t.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=t.y);let s=!1;for(let[e,h]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(e)&&(s=this._checkLinkProviderResult(e,t,s)):h.provideLinks(t.y,(i=>{if(this._isMouseOut)return;let h=i?.map((t=>({link:t})));this._activeProviderReplies?.set(e,h),s=this._checkLinkProviderResult(e,t,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)}))}_removeIntersectingLinks(t,i){let s=new Set;for(let e=0;e<i.size;e++){let h=i.get(e);if(h)for(let i=0;i<h.length;i++){let e=h[i],r=e.link.range.end.y>t?this._bufferService.cols:e.link.range.end.x;for(let n=e.link.range.start.y<t?0:e.link.range.start.x;n<=r;n++){if(s.has(n)){h.splice(i--,1);break}s.add(n)}}}}_checkLinkProviderResult(t,i,s){if(!this._activeProviderReplies)return s;let e=this._activeProviderReplies.get(t),h=!1;for(let i=0;i<t;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(h=!0);if(!h&&e){let t=e.find((t=>this._linkAtPosition(t.link,i)));t&&(s=!0,this._handleNewLink(t))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let t=0;t<this._activeProviderReplies.size;t++){let e=this._activeProviderReplies.get(t)?.find((t=>this._linkAtPosition(t.link,i)));if(e){s=!0,this._handleNewLink(e);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let i=this._positionFromMouseEvent(t,this._element,this._mouseService);i&&this._mouseDownLink&&function(t,i){return t.text===i.text&&t.range.start.x===i.range.start.x&&t.range.start.y===i.range.start.y&&t.range.end.x===i.range.end.x&&t.range.end.y===i.range.end.y}(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,i)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,i){!this._currentLink||!this._lastMouseEvent||(!t||!i||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,ct(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(t.link,i)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:void 0===t.link.decorations||t.link.decorations.underline,pointerCursor:void 0===t.link.decorations||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:t=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==t&&(this._currentLink.state.decorations.pointerCursor=t,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",t))}},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((t=>{if(!this._currentLink)return;let i=0===t.start?0:t.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+t.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._askForLink(t,!1)}}))))}_linkHover(t,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(s,i.text)}_fireUnderlineEvent(t,i){let s=t.range,e=this._bufferService.buffer.ydisp,h=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-e-1,s.end.x,s.end.y-e-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(h)}_linkLeave(t,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(s,i.text)}_linkAtPosition(t,i){let s=i.y*this._bufferService.cols+i.x;return t.range.start.y*this._bufferService.cols+t.range.start.x<=s&&s<=t.range.end.y*this._bufferService.cols+t.range.end.x}_positionFromMouseEvent(t,i,s){let e=s.getCoords(t,i,this._bufferService.cols,this._bufferService.rows);if(e)return{x:e[0],y:e[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,i,s,e,h){return{x1:t,y1:i,x2:s,y2:e,cols:this._bufferService.cols,fg:h}}};ur=d([g(1,j),g(2,Y),g(3,R),g(4,tt)],ur);var cr=class extends tr{constructor(t={}){super(t),this._linkifier=this._register(new wt),this.browser=ee,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new wt),this._onCursorMove=this._register(new _t),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _t),this.onKey=this._onKey.event,this._onRender=this._register(new _t),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _t),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _t),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _t),this.onBell=this._onBell.event,this._onFocus=this._register(new _t),this._onBlur=this._register(new _t),this._onA11yCharEmitter=this._register(new _t),this._onA11yTabEmitter=this._register(new _t),this._onWillOpen=this._register(new _t),this._setup(),this._decorationService=this._instantiationService.createInstance(nr),this._instantiationService.setService(O,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Vs),this._instantiationService.setService(tt,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(W)),this._register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this._register(this._inputHandler.onRequestRefreshRows((t=>this.refresh(t?.start??0,t?.end??this.rows-1)))),this._register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this._register(this._inputHandler.onRequestReset((()=>this.reset()))),this._register(this._inputHandler.onRequestWindowsOptionsReport((t=>this._reportWindowsOptions(t)))),this._register(this._inputHandler.onColor((t=>this._handleColorEvent(t)))),this._register(mt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(mt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(mt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(mt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize((t=>this._afterResize(t.cols,t.rows)))),this._register(At((()=>{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(t){if(this._themeService)for(let i of t){let t,s="";switch(i.index){case 256:t="foreground",s="10";break;case 257:t="background",s="11";break;case 258:t="cursor",s="12";break;default:t="ansi",s="4;"+i.index}switch(i.type){case 0:let e=Bs.toColorRGB("ansi"===t?this._themeService.colors.ansi[i.index]:this._themeService.colors[t]);this.coreService.triggerDataEvent(`${As.ESC}]${s};${Jh(e)}${ds.ST}`);break;case 1:if("ansi"===t)this._themeService.modifyColors((t=>t.ansi[i.index]=vs.toColor(...i.color)));else{let s=t;this._themeService.modifyColors((t=>t[s]=vs.toColor(...i.color)))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(t){t?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ar,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(As.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(As.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let t=this.buffer.lines.get(this.buffer.ybase+this.buffer.y);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,e=t.getWidth(i),h=this._renderService.dimensions.css.cell.width*e,r=this.buffer.y*this._renderService.dimensions.css.cell.height;this.textarea.style.left=i*this._renderService.dimensions.css.cell.width+"px",this.textarea.style.top=r+"px",this.textarea.style.width=h+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register($i(this.element,"copy",(t=>{this.hasSelection()&&function(t,i){t.clipboardData&&t.clipboardData.setData("text/plain",i.selectionText),t.preventDefault()}(t,this._selectionService)})));let t=t=>function(t,i,s,e){t.stopPropagation(),t.clipboardData&&I(t.clipboardData.getData("text/plain"),i,s,e)}(t,this.textarea,this.coreService,this.optionsService);this._register($i(this.textarea,"paste",t)),this._register($i(this.element,"paste",t)),this._register(oe?$i(this.element,"mousedown",(t=>{2===t.button&&B(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):$i(this.element,"contextmenu",(t=>{B(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),ge&&this._register($i(this.element,"auxclick",(t=>{1===t.button&&v(t,this.textarea,this.screenElement)})))}_bindKeys(){this._register($i(this.textarea,"keyup",(t=>this._keyUp(t)),!0)),this._register($i(this.textarea,"keydown",(t=>this._keyDown(t)),!0)),this._register($i(this.textarea,"keypress",(t=>this._keyPress(t)),!0)),this._register($i(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this._register($i(this.textarea,"compositionupdate",(t=>this._compositionHelper.compositionupdate(t)))),this._register($i(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this._register($i(this.textarea,"input",(t=>this._inputEvent(t)),!0)),this._register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(t){if(!t)throw Error("Terminal requires a parent element.");if(t.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=t.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"),t.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($i(this.screenElement,"mousemove",(t=>this.updateCursorStyle(t)))),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",p()),we||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(Zs,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(q,this._coreBrowserService),this._register($i(this.textarea,"focus",(t=>this._handleTextAreaFocus(t)))),this._register($i(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Ks,this._document,this._helperContainer),this._instantiationService.setService(K,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ge),this._instantiationService.setService(V,this._themeService),this._characterJoinerService=this._instantiationService.createInstance($s),this._instantiationService.setService(X,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ie,this.rows,this.screenElement)),this._instantiationService.setService(Y,this._renderService),this._register(this._renderService.onRenderedViewportChange((t=>this._onRender.fire(t)))),this.onResize((t=>this._renderService.resize(t.cols,t.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Is,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ie),this._instantiationService.setService(j,this._mouseService);let e=this._linkifier.value=this._register(this._instantiationService.createInstance(ur,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(us,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines((t=>{super.scrollLines(t,!1),this.refresh(0,this.rows-1)}))),this._selectionService=this._register(this._instantiationService.createInstance(Le,this.element,this.screenElement,e)),this._instantiationService.setService(Z,this._selectionService),this._register(this._selectionService.onRequestScrollLines((t=>this.scrollLines(t.amount,t.suppressScrollEvent)))),this._register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this._register(this._selectionService.onRequestRedraw((t=>this._renderService.handleSelectionChanged(t.start,t.end,t.columnSelectMode)))),this._register(this._selectionService.onLinuxMouseSelection((t=>{this.textarea.value=t,this.textarea.focus(),this.textarea.select()}))),this._register(mt.any(this._onScroll.event,this._inputHandler.onScroll)((()=>{this._selectionService.refresh(),this._viewport?.queueSync()}))),this._register(this._instantiationService.createInstance(cs,this.screenElement)),this._register($i(this.element,"mousedown",(t=>this._selectionService.handleMouseDown(t)))),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(ar,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",(t=>this._handleScreenReaderModeOptionChange(t)))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ms,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",(t=>{!this._overviewRulerRenderer&&t&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ms,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zs,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let t=this,i=this.element;function s(i){let s,e,h=t._mouseService.getMouseReportCoords(i,t.screenElement);if(!h)return!1;switch(i.overrideType||i.type){case"mousemove":e=32,void 0===i.buttons?(s=3,void 0!==i.button&&(s=i.button<3?i.button:3)):s=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":e=0,s=i.button<3?i.button:3;break;case"mousedown":e=1,s=i.button<3?i.button:3;break;case"wheel":if(t._customWheelEventHandler&&!1===t._customWheelEventHandler(i))return!1;let h=i.deltaY;if(0===h||0===t.coreMouseService.consumeWheelEvent(i,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr))return!1;e=h<0?0:1,s=4;break;default:return!1}return!(void 0===e||void 0===s||s>4)&&t.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:s,action:e,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let e={mouseup:null,wheel:null,mousedrag:null,mousemove:null},h={mouseup:t=>(s(t),t.buttons||(this._document.removeEventListener("mouseup",e.mouseup),e.mousedrag&&this._document.removeEventListener("mousemove",e.mousedrag)),this.cancel(t)),wheel:t=>(s(t),this.cancel(t,!0)),mousedrag:t=>{t.buttons&&s(t)},mousemove:t=>{t.buttons||s(t)}};this._register(this.coreMouseService.onProtocolChange((t=>{t?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(t)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&t?e.mousemove||(i.addEventListener("mousemove",h.mousemove),e.mousemove=h.mousemove):(i.removeEventListener("mousemove",e.mousemove),e.mousemove=null),16&t?e.wheel||(i.addEventListener("wheel",h.wheel,{passive:!1}),e.wheel=h.wheel):(i.removeEventListener("wheel",e.wheel),e.wheel=null),2&t?e.mouseup||(e.mouseup=h.mouseup):(this._document.removeEventListener("mouseup",e.mouseup),e.mouseup=null),4&t?e.mousedrag||(e.mousedrag=h.mousedrag):(this._document.removeEventListener("mousemove",e.mousedrag),e.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register($i(i,"mousedown",(t=>{if(t.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(t))return s(t),e.mouseup&&this._document.addEventListener("mouseup",e.mouseup),e.mousedrag&&this._document.addEventListener("mousemove",e.mousedrag),this.cancel(t)}))),this._register($i(i,"wheel",(i=>{if(!e.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback)return 0!==i.deltaY&&(0===t.coreMouseService.consumeWheelEvent(i,t._renderService?.dimensions?.device?.cell?.height,t._coreBrowserService?.dpr)||this.coreService.triggerDataEvent(As.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B"),!0),this.cancel(i,!0))}}),{passive:!1}))}refresh(t,i){this._renderService?.refreshRows(t,i)}updateCursorStyle(t){this._selectionService?.shouldColumnSelect(t)?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(t,i){this._viewport?this._viewport.scrollLines(t):super.scrollLines(t,i),this.refresh(0,this.rows-1)}scrollPages(t){this.scrollLines(t*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(t){t&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(t){let i=t-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(t){I(t,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(t){this._customKeyEventHandler=t}attachCustomWheelEventHandler(t){this._customWheelEventHandler=t}registerLinkProvider(t){return this._linkProviderService.registerLinkProvider(t)}registerCharacterJoiner(t){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(t);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(t){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(t)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(t){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+t)}registerDecoration(t){return this._decorationService.registerDecoration(t)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(t,i,s){this._selectionService.setSelection(t,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(t,i){this._selectionService?.selectLines(t,i)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(t))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!i&&!this._compositionHelper.keydown(t))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!i&&("Dead"===t.key||"AltGraph"===t.key)&&(this._unprocessedDeadKey=!0);let s=function(t,i,s,e){let h={type:0,cancel:!1,key:void 0},r=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:"UIKeyInputUpArrow"===t.key?h.key=i?As.ESC+"OA":As.ESC+"[A":"UIKeyInputLeftArrow"===t.key?h.key=i?As.ESC+"OD":As.ESC+"[D":"UIKeyInputRightArrow"===t.key?h.key=i?As.ESC+"OC":As.ESC+"[C":"UIKeyInputDownArrow"===t.key&&(h.key=i?As.ESC+"OB":As.ESC+"[B");break;case 8:h.key=t.ctrlKey?"\b":As.DEL,t.altKey&&(h.key=As.ESC+h.key);break;case 9:if(t.shiftKey){h.key=As.ESC+"[Z";break}h.key=As.HT,h.cancel=!0;break;case 13:h.key=t.altKey?As.ESC+As.CR:As.CR,h.cancel=!0;break;case 27:h.key=As.ESC,t.altKey&&(h.key=As.ESC+As.ESC),h.cancel=!0;break;case 37:if(t.metaKey)break;h.key=r?As.ESC+"[1;"+(r+1)+"D":i?As.ESC+"OD":As.ESC+"[D";break;case 39:if(t.metaKey)break;h.key=r?As.ESC+"[1;"+(r+1)+"C":i?As.ESC+"OC":As.ESC+"[C";break;case 38:if(t.metaKey)break;h.key=r?As.ESC+"[1;"+(r+1)+"A":i?As.ESC+"OA":As.ESC+"[A";break;case 40:if(t.metaKey)break;h.key=r?As.ESC+"[1;"+(r+1)+"B":i?As.ESC+"OB":As.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(h.key=As.ESC+"[2~");break;case 46:h.key=r?As.ESC+"[3;"+(r+1)+"~":As.ESC+"[3~";break;case 36:h.key=r?As.ESC+"[1;"+(r+1)+"H":i?As.ESC+"OH":As.ESC+"[H";break;case 35:h.key=r?As.ESC+"[1;"+(r+1)+"F":i?As.ESC+"OF":As.ESC+"[F";break;case 33:t.shiftKey?h.type=2:h.key=t.ctrlKey?As.ESC+"[5;"+(r+1)+"~":As.ESC+"[5~";break;case 34:t.shiftKey?h.type=3:h.key=t.ctrlKey?As.ESC+"[6;"+(r+1)+"~":As.ESC+"[6~";break;case 112:h.key=r?As.ESC+"[1;"+(r+1)+"P":As.ESC+"OP";break;case 113:h.key=r?As.ESC+"[1;"+(r+1)+"Q":As.ESC+"OQ";break;case 114:h.key=r?As.ESC+"[1;"+(r+1)+"R":As.ESC+"OR";break;case 115:h.key=r?As.ESC+"[1;"+(r+1)+"S":As.ESC+"OS";break;case 116:h.key=r?As.ESC+"[15;"+(r+1)+"~":As.ESC+"[15~";break;case 117:h.key=r?As.ESC+"[17;"+(r+1)+"~":As.ESC+"[17~";break;case 118:h.key=r?As.ESC+"[18;"+(r+1)+"~":As.ESC+"[18~";break;case 119:h.key=r?As.ESC+"[19;"+(r+1)+"~":As.ESC+"[19~";break;case 120:h.key=r?As.ESC+"[20;"+(r+1)+"~":As.ESC+"[20~";break;case 121:h.key=r?As.ESC+"[21;"+(r+1)+"~":As.ESC+"[21~";break;case 122:h.key=r?As.ESC+"[23;"+(r+1)+"~":As.ESC+"[23~";break;case 123:h.key=r?As.ESC+"[24;"+(r+1)+"~":As.ESC+"[24~";break;default:if(!t.ctrlKey||t.shiftKey||t.altKey||t.metaKey)if(s&&!e||!t.altKey||t.metaKey)!s||t.altKey||t.ctrlKey||t.shiftKey||!t.metaKey?t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&1===t.key.length?h.key=t.key:t.key&&t.ctrlKey&&("_"===t.key&&(h.key=As.US),"@"===t.key&&(h.key=As.NUL)):65===t.keyCode&&(h.type=1);else{let i=ir[t.keyCode]?.[t.shiftKey?1:0];if(i)h.key=As.ESC+i;else if(t.keyCode>=65&&t.keyCode<=90){let i=String.fromCharCode(t.ctrlKey?t.keyCode-64:t.keyCode+32);t.shiftKey&&(i=i.toUpperCase()),h.key=As.ESC+i}else if(32===t.keyCode)h.key=As.ESC+(t.ctrlKey?As.NUL:" ");else if("Dead"===t.key&&t.code.startsWith("Key")){let i=t.code.slice(3,4);t.shiftKey||(i=i.toLowerCase()),h.key=As.ESC+i,h.cancel=!0}}else t.keyCode>=65&&t.keyCode<=90?h.key=String.fromCharCode(t.keyCode-64):32===t.keyCode?h.key=As.NUL:t.keyCode>=51&&t.keyCode<=55?h.key=String.fromCharCode(t.keyCode-51+27):56===t.keyCode?h.key=As.DEL:219===t.keyCode?h.key=As.ESC:220===t.keyCode?h.key=As.FS:221===t.keyCode&&(h.key=As.GS)}return h}(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),3===s.type||2===s.type){let i=this.rows-1;return this.scrollLines(2===s.type?-i:i),this.cancel(t,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,t)||(s.cancel&&this.cancel(t,!0),!s.key)||t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&1===t.key.length&&t.key.charCodeAt(0)>=65&&t.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===As.ETX||s.key===As.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||t.altKey||t.ctrlKey?this.cancel(t,!0):void(this._keyDownHandled=!0)))}_isThirdLevelShift(t,i){let s=t.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||t.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||t.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(t){this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(t))&&(function(t){return 16===t.keyCode||17===t.keyCode||18===t.keyCode}(t)||this.focus(),this.updateCursorStyle(t),this._keyPressHandled=!1)}_keyPress(t){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(t))return!1;if(this.cancel(t),t.charCode)i=t.charCode;else if(null==t.which)i=t.keyCode;else{if(0===t.which||0===t.charCode)return!1;i=t.which}return!(!i||(t.altKey||t.ctrlKey||t.metaKey)&&!this._isThirdLevelShift(this.browser,t)||(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(t){return!(!t.data||"insertText"!==t.inputType||t.composed&&this._keyDownSeen||this.optionsService.rawOptions.screenReaderMode)&&(!this._keyPressHandled&&(this._unprocessedDeadKey=!1,this.coreService.triggerDataEvent(t.data,!0),this.cancel(t),!0))}resize(t,i){t!==this.cols||i!==this.rows?super.resize(t,i):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(t,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let t=1;t<this.rows;t++)this.buffer.lines.push(this.buffer.getBlankLine(qe));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 t=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(As.ESC+"[I"):this.coreService.triggerDataEvent(As.ESC+"[O")}_reportWindowsOptions(t){if(this._renderService)switch(t){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${As.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),e=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${As.ESC}[6;${e};${s}t`)}}cancel(t,i){if(this.options.cancelEvents||i)return t.preventDefault(),t.stopPropagation(),!1}},Ar=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===t){i=s;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(i,1)}},fr=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,i){if(!(t<0||t>=this._line.length))return i?(this._line.loadCell(t,i),i):this._line.loadCell(t,new D)}translateToString(t,i,s){return this._line.translateToString(t,i,s)}},dr=class{constructor(t,i){this._buffer=t,this.type=i}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 i=this._buffer.lines.get(t);if(i)return new fr(i)}getNullCell(){return new D}},gr=class extends gt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new _t),this.onBufferChange=this._onBufferChange.event,this._normal=new dr(this._core.buffers.normal,"normal"),this._alternate=new dr(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 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)}},wr=class{constructor(t){this._core=t}registerCsiHandler(t,i){return this._core.registerCsiHandler(t,(t=>i(t.toArray())))}addCsiHandler(t,i){return this.registerCsiHandler(t,i)}registerDcsHandler(t,i){return this._core.registerDcsHandler(t,((t,s)=>i(t,s.toArray())))}addDcsHandler(t,i){return this.registerDcsHandler(t,i)}registerEscHandler(t,i){return this._core.registerEscHandler(t,i)}addEscHandler(t,i){return this.registerEscHandler(t,i)}registerOscHandler(t,i){return this._core.registerOscHandler(t,i)}addOscHandler(t,i){return this.registerOscHandler(t,i)}},pr=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}},Cr=["cols","rows"],mr=0,Ir=class extends gt{constructor(t){super(),this._core=this._register(new cr(t)),this._addonManager=this._register(new Ar),this._publicOptions={...this._core.options};let i=t=>this._core.options[t],s=(t,i)=>{this._checkReadonlyOptions(t),this._core.options[t]=i};for(let t in this._core.options){let e={get:i.bind(this,t),set:s.bind(this,t)};Object.defineProperty(this._publicOptions,t,e)}}_checkReadonlyOptions(t){if(Cr.includes(t))throw Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw 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 wr(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new pr(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 gr(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,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 i in t)this._publicOptions[i]=t[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,i=!0){this._core.input(t,i)}resize(t,i){this._verifyIntegers(t,i),this._core.resize(t,i)}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,i,s){this._verifyIntegers(t,i,s),this._core.select(t,i,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,i){this._verifyIntegers(t,i),this._core.selectLines(t,i)}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,i){this._core.write(t,i)}writeln(t,i){this._core.write(t),this._core.write("\r\n",i)}paste(t){this._core.paste(t)}refresh(t,i){this._verifyIntegers(t,i),this._core.refresh(t,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return p()},set promptLabel(t){(t=>{w=t})(t)},get tooMuchOutput(){return m()},set tooMuchOutput(t){(t=>{C=t})(t)}}}_verifyIntegers(...t){for(mr of t)if(mr===1/0||isNaN(mr)||mr%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(mr of t)if(mr&&(mr===1/0||isNaN(mr)||mr%1!=0||mr<0))throw Error("This API only accepts positive integers")}},vr=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();t&&this._terminal&&!isNaN(t.cols)&&!isNaN(t.rows)&&(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(this._terminal._core._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(0===t.css.cell.width||0===t.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),e=parseInt(s.getPropertyValue("height")),h=Math.max(0,parseInt(s.getPropertyValue("width"))),r=window.getComputedStyle(this._terminal.element),n=parseInt(r.getPropertyValue("padding-top")),o=parseInt(r.getPropertyValue("padding-bottom")),l=parseInt(r.getPropertyValue("padding-right")),a=parseInt(r.getPropertyValue("padding-left")),u=e-(n+o);return{cols:Math.max(2,Math.floor((h-(l+a)-i)/t.css.cell.width)),rows:Math.max(1,Math.floor(u/t.css.cell.height))}}},Br=class{constructor(t,i,s,e={}){this._terminal=t,this._regex=i,this._handler=s,this._options=e}provideLinks(t,i){let s=yr.computeLink(t,this._regex,this._terminal,this._handler);i(this._addCallbacks(s))}_addCallbacks(t){return t.map((t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:e}=t;this._options.hover(i,s,e)}},t)))}};function Mr(t){try{let i=new URL(t),s=i.password&&i.username?`${i.protocol}//${i.username}:${i.password}@${i.host}`:i.username?`${i.protocol}//${i.username}@${i.host}`:`${i.protocol}//${i.host}`;return t.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var yr=class t{static computeLink(i,s,e,h){let r,n=RegExp(s.source,(s.flags||"")+"g"),[o,l]=t._getWindowedLineStrings(i-1,e),a=o.join(""),u=[];for(;r=n.exec(a);){let i=r[0];if(!Mr(i))continue;let[s,n]=t._mapStrIdx(e,l,0,r.index),[o,a]=t._mapStrIdx(e,s,n,i.length);-1!==s&&-1!==n&&-1!==o&&-1!==a&&u.push({range:{start:{x:n+1,y:s+1},end:{x:a,y:o+1}},text:i,activate:h})}return u}static _getWindowedLineStrings(t,i){let s,e=t,h=t,r=0,n="",o=[];if(s=i.buffer.active.getLine(t)){let t=s.translateToString(!0);if(s.isWrapped&&" "!==t[0]){for(r=0;(s=i.buffer.active.getLine(--e))&&r<2048&&(n=s.translateToString(!0),r+=n.length,o.push(n),s.isWrapped&&-1===n.indexOf(" ")););o.reverse()}for(o.push(t),r=0;(s=i.buffer.active.getLine(++h))&&s.isWrapped&&r<2048&&(n=s.translateToString(!0),r+=n.length,o.push(n),-1===n.indexOf(" ")););}return[o,e]}static _mapStrIdx(t,i,s,e){let h=t.buffer.active,r=h.getNullCell(),n=s;for(;e;){let t=h.getLine(i);if(!t)return[-1,-1];for(let s=n;s<t.length;++s){t.getCell(s,r);let n=r.getChars();if(r.getWidth()&&(e-=n.length||1,s===t.length-1&&""===n)){let t=h.getLine(i+1);t&&t.isWrapped&&(t.getCell(0,r),2===r.getWidth()&&(e+=1))}if(e<0)return[i,s]}i++,n=0}return[i,n]}},Qr=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Er(t,i){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=i}else console.warn("Opening link blocked as opener could not be cleared")}var br=class{constructor(t=Er,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options;this._linkProvider=this._terminal.registerLinkProvider(new Br(this._terminal,i.urlRegex||Qr,this._handler,i))}dispose(){this._linkProvider?.dispose()}},kr=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?$r.isErrorNoTelemetry(t)?new $r(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};
14
14
  /**
15
15
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
16
16
  * @license MIT
@@ -22,7 +22,7 @@ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
22
22
  * Fabrice Bellard's javascript vt100 for jslinux:
23
23
  * http://bellard.org/jslinux/
24
24
  * Copyright (c) 2011 Fabrice Bellard
25
- */function Br(t){(function(t){return t instanceof Qr||t instanceof Error&&t.name===Er&&t.message===Er})(t)||br.onUnexpectedError(t)}var Mr,yr,Er="Canceled",Qr=class extends Error{constructor(){super(Er),this.name=this.message}},kr=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}};function xr(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function Dr(t){if(yr.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function Lr(...t){return _r((()=>Dr(t)))}function _r(t){return{dispose:xr((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Mr||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(yr||={});var Sr=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Dr(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Sr.DISABLE_DISPOSED_WARNING=!1;var $r=Sr,Rr=class{constructor(){this._store=new $r}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};Rr.None=Object.freeze({dispose(){}});var Nr,Fr=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}},Hr=globalThis.performance&&"function"==typeof globalThis.performance.now,Ur=class t{static create(i){return new t(i)}constructor(t){this._now=Hr&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new Yr({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,a,l,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,a=i(a,t),e&&!l&&(f.fire(a),a=void 0),c=()=>{let t=a;a=void 0,l=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(l),l=setTimeout(c,s)):void 0===l&&(l=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new Yr(A);return n?.add(f),f.event}t.None=()=>Rr.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=Lr(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new Yr({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Yr({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Yr({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new Yr;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class a{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new Yr({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new a(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof $r?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Nr||={});var Tr=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new Ur,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Tr.all=new Set,Tr._idPool=0;var Gr=Tr,Pr=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new zr(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};Pr._idPool=1;var Jr,Or=Pr,Wr=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},zr=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},qr=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Kr=0,jr=class{constructor(t){this.value=t,this.id=Kr++}},Yr=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Or(t?.onListenerError??Br,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Gr(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new qr(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||Br)(s),Rr.None}if(this._disposed)return Rr.None;i&&(t=t.bind(i));let e,h=new jr(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Wr.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof jr?(this._deliveryQueue??=new Zr,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=_r((()=>{e?.(),this._removeListener(h)}));return s instanceof $r?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||Br;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 jr)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Zr=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Xr=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof sn||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Nr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Xr})})(Jr||={});var Vr,tn,sn=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?Xr:(this._emitter||(this._emitter=new Yr),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},en="en",hn=en,rn=globalThis;typeof rn.vscode<"u"&&typeof rn.vscode.process<"u"?tn=rn.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(tn=process);var nn="string"==typeof tn?.versions?.electron&&"renderer"===tn?.type;if("object"==typeof tn){hn=en;let t=tn.env.VSCODE_NLS_CONFIG;if(t)try{hn=JSON.parse(t).resolvedLanguage||en}catch{}}else"object"!=typeof navigator||nn?console.error("Unable to resolve platform."):((Vr=navigator.userAgent).indexOf("Windows"),Vr.indexOf("Macintosh"),(Vr.indexOf("Macintosh")>=0||Vr.indexOf("iPad")>=0||Vr.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Vr.indexOf("Linux"),Vr?.indexOf("Mobi"),hn=globalThis._VSCODE_NLS_LANGUAGE||en,navigator.language.toLowerCase());var on,an=Vr,ln=hn;(t=>{t.value=function(){return ln},t.isDefaultVariant=function(){return 2===ln.length?"en"===ln:ln.length>=3&&"e"===ln[0]&&"n"===ln[1]&&"-"===ln[2]},t.isDefault=function(){return"en"===ln}})(on||={});var cn="function"==typeof rn.postMessage&&!rn.importScripts;(()=>{if(cn){let t=[];rn.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var un,An=!!(an&&an.indexOf("Chrome")>=0);function fn(t,i=0){let s=setTimeout((()=>{t()}),i);return _r((()=>{clearTimeout(s)}))}an&&an.indexOf("Firefox"),!An&&an&&an.indexOf("Safari"),an&&an.indexOf("Edg/"),an&&an.indexOf("Android"),(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(un||={});var dn=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Yr,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await Nr.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};dn.EMPTY=dn.fromArray([]);var gn=class extends Rr{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Fr),this._linesCacheDisposables=this._register(new Fr),this._register(_r((()=>this._destroyLinesCache())))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Lr(this._terminal.onLineFeed((()=>this._destroyLinesCache())),this._terminal.onCursorMove((()=>this._destroyLinesCache())),this._terminal.onResize((()=>this._destroyLinesCache())))),this._linesCacheTimeout.value=fn((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(t){return this._linesCache?.[t]}setLineInCache(t,i){this._linesCache&&(this._linesCache[t]=i)}translateBufferLineToStringWithWrap(t,i){let s=[],e=[0],h=this._terminal.buffer.active.getLine(t);for(;h;){let r=this._terminal.buffer.active.getLine(t+1),n=!!r&&r.isWrapped,o=h.translateToString(!n&&i);if(n&&r){let t=h.getCell(h.length-1);t&&0===t.getCode()&&1===t.getWidth()&&2===r.getCell(0)?.getWidth()&&(o=o.slice(0,-1))}if(s.push(o),!n)break;e.push(e[e.length-1]+o.length),t++,h=r}return[s.join(""),e]}},wn=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return!this._lastSearchOptions||!!t&&(this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord)}shouldUpdateHighlighting(t,i){return!!i?.decorations&&(void 0===this._cachedSearchTerm||t!==this._cachedSearchTerm||this.didOptionsChange(i))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},pn=class{constructor(t,i){this._terminal=t,this._lineCache=i}find(t,i,s,e){if(!t||0===t.length)return void this._terminal.clearSelection();if(s>this._terminal.cols)throw Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let h={startRow:i,startCol:s},r=this._findInLine(t,h,e);if(!r)for(let s=i+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(h.startRow=s,h.startCol=0,r=this._findInLine(t,h,e),!r);s++);return r}findNextWithSelection(t,i,s){if(!t||0===t.length)return void this._terminal.clearSelection();let e=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=0,r=0;e&&(s===t?(h=e.end.x,r=e.end.y):(h=e.start.x,r=e.start.y)),this._lineCache.initLinesCache();let n={startRow:r,startCol:h},o=this._findInLine(t,n,i);if(!o)for(let s=r+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=s,n.startCol=0,o=this._findInLine(t,n,i),!o);s++);if(!o&&0!==r)for(let s=0;s<r&&(n.startRow=s,n.startCol=0,o=this._findInLine(t,n,i),!o);s++);return!o&&e&&(n.startRow=e.start.y,n.startCol=0,o=this._findInLine(t,n,i)),o}findPreviousWithSelection(t,i,s){if(!t||0===t.length)return void this._terminal.clearSelection();let e=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=this._terminal.buffer.active.baseY+this._terminal.rows-1,r=this._terminal.cols,n=!0;this._lineCache.initLinesCache();let o,a={startRow:h,startCol:r};if(e&&(a.startRow=h=e.start.y,a.startCol=r=e.start.x,s!==t&&(o=this._findInLine(t,a,i,!1),o||(a.startRow=h=e.end.y,a.startCol=r=e.end.x))),o||(o=this._findInLine(t,a,i,n)),!o){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let s=h-1;s>=0&&(a.startRow=s,o=this._findInLine(t,a,i,n),!o);s--);}if(!o&&h!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let s=this._terminal.buffer.active.baseY+this._terminal.rows-1;s>=h&&(a.startRow=s,o=this._findInLine(t,a,i,n),!o);s--);return o}_isWholeWord(t,i,s){return(0===t||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t-1]))&&(t+s.length===i.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t+s.length]))}_findInLine(t,i,s={},e=!1){let h=i.startRow,r=i.startCol;if(this._terminal.buffer.active.getLine(h)?.isWrapped)return e?void(i.startCol+=this._terminal.cols):(i.startRow--,i.startCol+=this._terminal.cols,this._findInLine(t,i,s));let n=this._lineCache.getLineFromCache(h);n||(n=this._lineCache.translateBufferLineToStringWithWrap(h,!0),this._lineCache.setLineInCache(h,n));let[o,a]=n,l=this._bufferColsToStringOffset(h,r),c=t,u=o;s.regex||(c=s.caseSensitive?t:t.toLowerCase(),u=s.caseSensitive?o:o.toLowerCase());let A=-1;if(s.regex){let i,h=RegExp(c,s.caseSensitive?"g":"gi");if(e)for(;i=h.exec(u.slice(0,l));)A=h.lastIndex-i[0].length,h.lastIndex-=(t=i[0]).length-1;else i=h.exec(u.slice(l)),i&&i[0].length>0&&(A=l+(h.lastIndex-i[0].length),t=i[0])}else e?l-c.length>=0&&(A=u.lastIndexOf(c,l-c.length)):A=u.indexOf(c,l);if(A>=0){if(s.wholeWord&&!this._isWholeWord(A,u,t))return;let i=0;for(;i<a.length-1&&A>=a[i+1];)i++;let e=i;for(;e<a.length-1&&A+t.length>=a[e+1];)e++;let r=A+t.length-a[e],n=this._stringLengthToBufferSize(h+i,A-a[i]);return{term:t,col:n,row:h+i,size:this._stringLengthToBufferSize(h+e,r)-n+this._terminal.cols*(e-i)}}}_stringLengthToBufferSize(t,i){let s=this._terminal.buffer.active.getLine(t);if(!s)return 0;for(let t=0;t<i;t++){let e=s.getCell(t);if(!e)break;let h=e.getChars();h.length>1&&(i-=h.length-1);let r=s.getCell(t+1);r&&0===r.getWidth()&&i++}return i}_bufferColsToStringOffset(t,i){let s=t,e=0,h=this._terminal.buffer.active.getLine(s);for(;i>0&&h;){for(let t=0;t<i&&t<this._terminal.cols;t++){let i=h.getCell(t);if(!i)break;i.getWidth()&&(e+=0===i.getCode()?1:i.getChars().length)}if(s++,h=this._terminal.buffer.active.getLine(s),h&&!h.isWrapped)break;i-=this._terminal.cols}return e}},Cn=class extends Rr{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(_r((()=>this.clearHighlightDecorations())))}createHighlightDecorations(t,i){this.clearHighlightDecorations();for(let s of t){let t=this._createResultDecorations(s,i,!1);if(t)for(let i of t)this._storeDecoration(i,s)}}createActiveDecoration(t,i){let s=this._createResultDecorations(t,i,!0);if(s)return{decorations:s,match:t,dispose(){Dr(s)}}}clearHighlightDecorations(){Dr(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,i){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:i,dispose(){t.dispose()}})}_applyStyles(t,i,s){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),i&&(t.style.outline="1px solid "+i)),s&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,i,s){let e=[],h=t.col,r=t.size,n=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;r>0;){let t=Math.min(this._terminal.cols-h,r);e.push([n,h,t]),h=0,r-=t,n++}let o=[];for(let t of e){let e=this._terminal.registerMarker(t[0]),h=this._terminal.registerDecoration({marker:e,x:t[1],width:t[2],backgroundColor:s?i.activeMatchBackground:i.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:s?i.activeMatchColorOverviewRuler:i.matchOverviewRuler,position:"center"}});if(h){let t=[];t.push(e),t.push(h.onRender((t=>this._applyStyles(t,s?i.activeMatchBorder:i.matchBorder,!1)))),t.push(h.onDispose((()=>Dr(t)))),o.push(h)}}return 0===o.length?void 0:o}},mn=class extends Rr{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Yr)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,i){this._searchResults=t.slice(0,i)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let i=0;i<this._searchResults.length;i++){let s=this._searchResults[i];if(s.row===t.row&&s.col===t.col&&s.size===t.size)return i}return-1}fireResultsChanged(t){if(!t)return;let i=-1;this._selectedDecoration&&(i=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:i,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},In=class extends Rr{constructor(t){super(),this._highlightTimeout=this._register(new Fr),this._lineCache=this._register(new Fr),this._state=new wn,this._resultTracker=this._register(new mn),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new gn(t),this._engine=new pn(t,this._lineCache.value),this._decorationManager=new Cn(t),this._register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this._register(this._terminal.onResize((()=>this._updateMatches()))),this._register(_r((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=fn((()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})}),200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,i,s){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let e=this._findNextAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,e}_highlightAllMatches(t,i){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t))return void this.clearDecorations();this.clearDecorations(!0);let s,e=[],h=this._engine.find(t,0,0,i);for(;h&&(s?.row!==h.row||s?.col!==h.col)&&!(e.length>=this._highlightLimit);)s=h,e.push(s),h=this._engine.find(t,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,i);this._resultTracker.updateResults(e,this._highlightLimit),i.decorations&&this._decorationManager.createHighlightDecorations(e,i.decorations)}_findNextAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let e=this._engine.findNextWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(e,i?.decorations,s?.noScroll)}findPrevious(t,i,s){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let e=this._findPreviousAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,e}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let e=this._engine.findPreviousWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(e,i?.decorations,s?.noScroll)}_selectResult(t,i,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),i){let s=this._decorationManager.createActiveDecoration(t,i);s&&(this._resultTracker.selectedDecoration=s)}if(!s&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let i=t.row-this._terminal.buffer.active.viewportY;i-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(i)}return!0}},vn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?Qn.isErrorNoTelemetry(t)?new Qn(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};function bn(t){(function(t){return t instanceof En||t instanceof Error&&t.name===yn&&t.message===yn})(t)||vn.onUnexpectedError(t)}var Bn,Mn,yn="Canceled",En=class extends Error{constructor(){super(yn),this.name=this.message}},Qn=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}};function kn(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function xn(t){if(Mn.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function Dn(...t){return Ln((()=>xn(t)))}function Ln(t){return{dispose:kn((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Bn||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Mn||={});var _n=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{xn(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};_n.DISABLE_DISPOSED_WARNING=!1;var Sn=_n,$n=class{constructor(){this._store=new Sn}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};$n.None=Object.freeze({dispose(){}});var Rn=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}},Nn=typeof process<"u"&&"title"in process,Fn=Nn?"node":navigator.userAgent,Hn=Nn?"node":navigator.platform,Un=Fn.includes("Firefox"),Tn=Fn.includes("Edge"),Gn=/^((?!chrome|android).)*safari/i.test(Fn);Hn.indexOf("Linux");var Pn,Jn,On,Wn,zn,qn=0,Kn=0,jn=0,Yn=0,Zn={css:"#00000000",rgba:0};function Xn(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Vn(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}function to(t){if(!t)throw Error("value must not be falsy");return t}function io(t){return 57508<=t&&t<=57558}function so(t){return io(t)||function(t){return 9472<=t&&t<=9631}(t)}function eo(t,i,s=0){return(t-(2*Math.round(i)-s))%(2*Math.round(i))}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${Xn(t)}${Xn(i)}${Xn(s)}${Xn(e)}`:`#${Xn(t)}${Xn(i)}${Xn(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(Pn||={}),(t=>{function i(t,i){return Yn=Math.round(255*i),[qn,Kn,jn]=zn.toChannels(t.rgba),{css:Pn.toCss(qn,Kn,jn,Yn),rgba:Pn.toRgba(qn,Kn,jn,Yn)}}t.blend=function(t,i){if(1==(Yn=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:Pn.toCss(qn=h+Math.round(((i.rgba>>24&255)-h)*Yn),Kn=r+Math.round((s-r)*Yn),jn=n+Math.round((e-n)*Yn)),rgba:Pn.toRgba(qn,Kn,jn)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=zn.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return Pn.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[qn,Kn,jn]=zn.toChannels(i),{css:Pn.toCss(qn,Kn,jn),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(Yn=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Jn||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return qn=parseInt(t.slice(1,2).repeat(2),16),Kn=parseInt(t.slice(2,3).repeat(2),16),jn=parseInt(t.slice(3,4).repeat(2),16),Pn.toColor(qn,Kn,jn);case 5:return qn=parseInt(t.slice(1,2).repeat(2),16),Kn=parseInt(t.slice(2,3).repeat(2),16),jn=parseInt(t.slice(3,4).repeat(2),16),Yn=parseInt(t.slice(4,5).repeat(2),16),Pn.toColor(qn,Kn,jn,Yn);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return Pn.toColor(qn=parseInt(e[1]),Kn=parseInt(e[2]),jn=parseInt(e[3]),Yn=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[qn,Kn,jn,Yn]=i.getImageData(0,0,1,1).data,255!==Yn)throw Error("css.toColor: Unsupported css format");return{rgba:Pn.toRgba(qn,Kn,jn,Yn),css:t}}})(On||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(Wn||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Vn(Wn.relativeLuminance2(n,o,a),Wn.relativeLuminance2(e,h,r));for(;l<s&&(n>0||o>0||a>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l=Vn(Wn.relativeLuminance2(n,o,a),Wn.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Vn(Wn.relativeLuminance2(n,o,a),Wn.relativeLuminance2(e,h,r));for(;l<s&&(n<255||o<255||a<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Vn(Wn.relativeLuminance2(n,o,a),Wn.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(Yn=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return Pn.toRgba(qn=h+Math.round(((i>>24&255)-h)*Yn),Kn=r+Math.round((s-r)*Yn),jn=n+Math.round((e-n)*Yn))},t.ensureContrastRatio=function(t,e,h){let r=Wn.relativeLuminance(t>>8),n=Wn.relativeLuminance(e>>8);if(Vn(r,n)<h){if(n<r){let n=i(t,e,h),o=Vn(r,Wn.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Vn(r,Wn.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=Vn(r,Wn.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>Vn(r,Wn.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(zn||={});var ho,ro=0,no=0,oo=!1,ao=!1,lo=!1,co=0,uo=class{constructor(t,i,s,e,h,r){this._terminal=t,this._optionService=i,this._selectionRenderModel=s,this._decorationService=e,this._coreBrowserService=h,this._themeService=r,this.result={fg:0,bg:0,ext:0}}resolve(t,i,s,e){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=268435456&t.bg?t.extended.ext:0,no=0,ro=0,ao=!1,oo=!1,lo=!1,ho=this._themeService.colors,co=0,0!==t.getCode()&&4===t.extended.underlineStyle&&(co=i*e%(2*Math.round(Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15))))),this._decorationService.forEachDecorationAtCell(i,s,"bottom",(t=>{t.backgroundColorRGB&&(no=t.backgroundColorRGB.rgba>>8&16777215,ao=!0),t.foregroundColorRGB&&(ro=t.foregroundColorRGB.rgba>>8&16777215,oo=!0)})),lo=this._selectionRenderModel.isCellSelected(this._terminal,i,s)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:no=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:no=(16777215&this.result.fg)<<8|255;break;default:no=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:no=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:no=(16777215&this.result.bg)<<8|255}no=zn.blend(no,4294967040&(this._coreBrowserService.isFocused?ho.selectionBackgroundOpaque:ho.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else no=(this._coreBrowserService.isFocused?ho.selectionBackgroundOpaque:ho.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(ao=!0,ho.selectionForeground&&(ro=ho.selectionForeground.rgba>>8&16777215,oo=!0),so(t.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))ro=(this._coreBrowserService.isFocused?ho.selectionBackgroundOpaque:ho.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:ro=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:ro=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:ro=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:ro=(16777215&this.result.fg)<<8|255;break;default:ro=this._themeService.colors.foreground.rgba}ro=zn.blend(ro,4294967040&(this._coreBrowserService.isFocused?ho.selectionBackgroundOpaque:ho.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}oo=!0}}this._decorationService.forEachDecorationAtCell(i,s,"top",(t=>{t.backgroundColorRGB&&(no=t.backgroundColorRGB.rgba>>8&16777215,ao=!0),t.foregroundColorRGB&&(ro=t.foregroundColorRGB.rgba>>8&16777215,oo=!0)})),ao&&(no=lo?-16777216&t.bg&-134217729|no|50331648:-16777216&t.bg|no|50331648),oo&&(ro=-16777216&t.fg&-67108865|ro|50331648),67108864&this.result.fg&&(ao&&!oo&&(ro=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&ho.background.rgba>>8|50331648,oo=!0),!ao&&oo&&(no=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&ho.foreground.rgba>>8|50331648,ao=!0)),ho=void 0,this.result.bg=ao?no:this.result.bg,this.result.fg=oo?ro:this.result.fg,this.result.ext&=536870911,this.result.ext|=co<<29&3758096384}},Ao=Un||Tn?"bottom":"ideographic",fo={"▀":[{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}]},go={"░":[[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]]},wo={"─":{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,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"║":{1:t=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,i)=>`M.5,1 L.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╓":{1:t=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,i)=>`M1,${.5-i} L${.5-t},${.5-i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1`},"╕":{1:(t,i)=>`M0,${.5-i} L.5,${.5-i} L.5,1 M0,${.5+i} L.5,${.5+i}`},"╖":{1:t=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,i)=>`M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M0,${.5-i} L${.5+t},${.5-i} L${.5+t},1`},"╘":{1:(t,i)=>`M.5,0 L.5,${.5+i} L1,${.5+i} M.5,${.5-i} L1,${.5-i}`},"╙":{1:t=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,i)=>`M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0 M1,${.5+i} L${.5-t},${.5+i} L${.5-t},0`},"╛":{1:(t,i)=>`M0,${.5+i} L.5,${.5+i} L.5,0 M0,${.5-i} L.5,${.5-i}`},"╜":{1:t=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,i)=>`M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M0,${.5+i} L${.5+t},${.5+i} L${.5+t},0`},"╞":{1:(t,i)=>`M.5,0 L.5,1 M.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╟":{1:t=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,i)=>`M${.5-t},0 L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1 M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0`},"╡":{1:(t,i)=>`M.5,0 L.5,1 M0,${.5-i} L.5,${.5-i} M0,${.5+i} L.5,${.5+i}`},"╢":{1:t=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,i)=>`M${.5+t},0 L${.5+t},1 M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0`},"╤":{1:(t,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i} M.5,${.5+i} L.5,1`},"╥":{1:t=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1`},"╧":{1:(t,i)=>`M.5,0 L.5,${.5-i} M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╨":{1:t=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,i)=>`M0,${.5+i} L1,${.5+i} M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0`},"╪":{1:(t,i)=>`M.5,0 L.5,1 M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╫":{1:t=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,i)=>`M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1 M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M1,${.5-i} L${.5+t},${.5-i} 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,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,1,.5`},"╮":{1:(t,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,0,.5`},"╯":{1:(t,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,0,.5`},"╰":{1:(t,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,1,.5`}},po={"":{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}};po[""]=po[""],po[""]=po[""];var Co=new Map;function mo(t,i,s=0){return Math.max(Math.min(t,i),s)}var Io={C:(t,i)=>t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]),L:(t,i)=>t.lineTo(i[0],i[1]),M:(t,i)=>t.moveTo(i[0],i[1])};function vo(t,i,s,e,h,r,n,o=0,a=0){let l=t.map((t=>parseFloat(t)||parseInt(t)));if(l.length<2)throw Error("Too few arguments for instruction");for(let t=0;t<l.length;t+=2)l[t]*=i-o*n-a*n,r&&0!==l[t]&&(l[t]=mo(Math.round(l[t]+.5)-.5,i,0)),l[t]+=e+o*n;for(let t=1;t<l.length;t+=2)l[t]*=s,r&&0!==l[t]&&(l[t]=mo(Math.round(l[t]+.5)-.5,s,0)),l[t]+=h;return l}var bo,Bo=class{constructor(){this._data={}}set(t,i,s){this._data[t]||(this._data[t]={}),this._data[t][i]=s}get(t,i){return this._data[t]?this._data[t][i]:void 0}clear(){this._data={}}},Mo=class{constructor(){this._data=new Bo}set(t,i,s,e,h){this._data.get(t,i)||this._data.set(t,i,new Bo),this._data.get(t,i).set(s,e,h)}get(t,i,s,e){return this._data.get(t,i)?.get(s,e)}clear(){this._data.clear()}},yo=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 i=0,s=0,e=t.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,i=Math.max(1,performance.now()-i),s=Math.max(i,s),h=t.timeRemaining(),1.5*s>h)return e-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(e-i))}ms`),void this._start();e=h}this.clear()}},Eo=!Nn&&"requestIdleCallback"in window?class extends yo{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends yo{_requestCallback(t){return setTimeout((()=>t(this._createDeadline(16))))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let i=performance.now()+t;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},Qo=class t{constructor(){this.fg=0,this.bg=0,this.extended=new ko}static toColorRGB(t){return[t>>>16&255,t>>>8&255,255&t]}static fromColorRGB(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]}clone(){let i=new t;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ko=class t{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},xo=globalThis.performance&&"function"==typeof globalThis.performance.now,Do=class t{static create(i){return new t(i)}constructor(t){this._now=xo&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new Go({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,a,l,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,a=i(a,t),e&&!l&&(f.fire(a),a=void 0),c=()=>{let t=a;a=void 0,l=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(l),l=setTimeout(c,s)):void 0===l&&(l=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new Go(A);return n?.add(f),f.event}t.None=()=>$n.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=Dn(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new Go({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Go({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Go({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new Go;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class a{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new Go({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new a(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof Sn?e.add(o):Array.isArray(e)&&e.push(o),o}}})(bo||={});var Lo=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new Do,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Lo.all=new Set,Lo._idPool=0;var _o=Lo,So=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new Fo(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};So._idPool=1;var $o,Ro=So,No=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Fo=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Ho=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Uo=0,To=class{constructor(t){this.value=t,this.id=Uo++}},Go=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Ro(t?.onListenerError??bn,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new _o(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new Ho(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||bn)(s),$n.None}if(this._disposed)return $n.None;i&&(t=t.bind(i));let e,h=new To(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=No.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof To?(this._deliveryQueue??=new Po,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Ln((()=>{e?.(),this._removeListener(h)}));return s instanceof Sn?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||bn;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 To)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Po=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Jo={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}},Oo=class t{constructor(t,i,s){this._document=t,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new Mo,this._cacheMapCombined=new Mo,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Qo,this._textureSize=512,this._onAddTextureAtlasCanvas=new Go,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Go,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=qo(t,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=to(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new Eo;for(let i=33;i<126;i++)t.enqueue((()=>{if(!this._cacheMap.get(i,0,0,0)){let t=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,t)}}))}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(t.maxAtlasPages&&this._pages.length>=Math.max(4,t.maxAtlasPages)){let i=this._pages.filter((i=>2*i.canvas.width<=(t.maxTextureSize||4096))).sort(((t,i)=>i.canvas.width!==t.canvas.width?i.canvas.width-t.canvas.width:i.percentageUsed-t.percentageUsed)),s=-1,e=0;for(let t=0;t<i.length;t++)if(i[t].canvas.width!==e)s=t,e=i[t].canvas.width;else if(t-s==3)break;let h=i.slice(s,s+4),r=h.map((t=>t.glyphs[0].texturePage)).sort(((t,i)=>t>i?1:-1)),n=this._mergePages(h,this.pages.length-h.length);n.version++;for(let t=r.length-1;t>=0;t--)this._deletePage(r[t]);this.pages.push(n),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(n.canvas)}let i=new Wo(this._document,this._textureSize);return this._pages.push(i),this._activePages.push(i),this._onAddTextureAtlasCanvas.fire(i.canvas),i}_mergePages(t,i){let s=2*t[0].canvas.width,e=new Wo(this._document,s,t);for(let[h,r]of t.entries()){let t=h*r.canvas.width%s,n=Math.floor(h/2)*r.canvas.height;e.ctx.drawImage(r.canvas,t,n);for(let e of r.glyphs)e.texturePage=i,e.sizeClipSpace.x=e.size.x/s,e.sizeClipSpace.y=e.size.y/s,e.texturePosition.x+=t,e.texturePosition.y+=n,e.texturePositionClipSpace.x=e.texturePosition.x/s,e.texturePositionClipSpace.y=e.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(r.canvas);let o=this._activePages.indexOf(r);-1!==o&&this._activePages.splice(o,1)}return e}_deletePage(t){this._pages.splice(t,1);for(let i=t;i<this._pages.length;i++){let t=this._pages[i];for(let i of t.glyphs)i.texturePage--;t.version++}}getRasterizedGlyphCombinedChar(t,i,s,e,h,r){return this._getFromCacheMap(this._cacheMapCombined,t,i,s,e,h,r)}getRasterizedGlyph(t,i,s,e,h,r){return this._getFromCacheMap(this._cacheMap,t,i,s,e,h,r)}_getFromCacheMap(t,i,s,e,h,r,n){return($o=t.get(i,s,e,h))||($o=this._drawToCache(i,s,e,h,r,n),t.set(i,s,e,h,$o)),$o}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,i,s,e){if(this._config.allowTransparency)return Zn;let h;switch(t){case 16777216:case 33554432:h=this._getColorFromAnsiIndex(i);break;case 50331648:let t=Qo.toColorRGB(i);h=Pn.toColor(t[0],t[1],t[2]);break;default:h=s?Jn.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(h=Jn.opaque(h)),h}_getForegroundColor(t,i,s,e,h,r,n,o,a,l){let c,u=this._getMinimumContrastColor(t,i,s,e,h,r,n,a,o,l);if(u)return u;switch(h){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&a&&r<8&&(r+=8),c=this._getColorFromAnsiIndex(r);break;case 50331648:let t=Qo.toColorRGB(r);c=Pn.toColor(t[0],t[1],t[2]);break;default:c=n?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(c=Jn.opaque(c)),o&&(c=Jn.multiplyOpacity(c,.5)),c}_resolveBackgroundRgba(t,i,s){switch(t){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(t,i,s,e){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&e&&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(t,i,s,e,h,r,n,o,a,l){if(1===this._config.minimumContrastRatio||l)return;let c=this._getContrastCache(a),u=c.getColor(t,e);if(void 0!==u)return u||void 0;let A=this._resolveBackgroundRgba(i,s,n),f=this._resolveForegroundRgba(h,r,n,o),d=zn.ensureContrastRatio(A,f,this._config.minimumContrastRatio/(a?2:1));if(!d)return void c.setColor(t,e,null);let g=Pn.toColor(d>>24&255,d>>16&255,d>>8&255);return c.setColor(t,e,g),g}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(i,s,e,h,r,n){let o="number"==typeof i?String.fromCharCode(i):i;n&&this._tmpCanvas.parentElement!==n&&(this._tmpCanvas.style.display="none",n.append(this._tmpCanvas));let a=Math.min(this._config.deviceCellWidth*Math.max(o.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<a&&(this._tmpCanvas.width=a);let l=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<l&&(this._tmpCanvas.height=l),this._tmpCtx.save(),this._workAttributeData.fg=e,this._workAttributeData.bg=s,this._workAttributeData.extended.ext=h,this._workAttributeData.isInvisible())return Jo;let c=!!this._workAttributeData.isBold(),u=!!this._workAttributeData.isInverse(),A=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),d=!!this._workAttributeData.isUnderline(),g=!!this._workAttributeData.isStrikethrough(),w=!!this._workAttributeData.isOverline(),p=this._workAttributeData.getFgColor(),C=this._workAttributeData.getFgColorMode(),m=this._workAttributeData.getBgColor(),I=this._workAttributeData.getBgColorMode();if(u){let t=p;p=m,m=t;let i=C;C=I,I=i}let v=this._getBackgroundColor(I,m,u,A);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=v.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over",this._tmpCtx.font=`${f?"italic":""} ${c?this._config.fontWeightBold:this._config.fontWeight} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=Ao;let b=1===o.length&&io(o.charCodeAt(0)),B=1===o.length&&function(t){return 57520<=t&&t<=57527}(o.charCodeAt(0)),M=this._getForegroundColor(s,I,m,e,C,p,u,A,c,so(o.charCodeAt(0)));this._tmpCtx.fillStyle=M.css;let y=B?0:4,E=!1;!1!==this._config.customGlyphs&&(E=function(t,i,s,e,h,r,n,o){let a=fo[i];if(a)return function(t,i,s,e,h,r){for(let n=0;n<i.length;n++){let o=i[n],a=h/8,l=r/8;t.fillRect(s+o.x*a,e+o.y*l,o.w*a,o.h*l)}}(t,a,s,e,h,r),!0;let l=go[i];if(l)return function(t,i,s,e,h,r){let n=Co.get(i);n||(n=new Map,Co.set(i,n));let o=t.fillStyle;if("string"!=typeof o)throw Error(`Unexpected fillStyle type "${o}"`);let a=n.get(o);if(!a){let s=i[0].length,e=i.length,h=t.canvas.ownerDocument.createElement("canvas");h.width=s,h.height=e;let r,l,c,u,A=to(h.getContext("2d")),f=new ImageData(s,e);if(o.startsWith("#"))r=parseInt(o.slice(1,3),16),l=parseInt(o.slice(3,5),16),c=parseInt(o.slice(5,7),16),u=o.length>7&&parseInt(o.slice(7,9),16)||1;else{if(!o.startsWith("rgba"))throw Error(`Unexpected fillStyle color format "${o}" when drawing pattern glyph`);[r,l,c,u]=o.substring(5,o.length-1).split(",").map((t=>parseFloat(t)))}for(let t=0;t<e;t++)for(let e=0;e<s;e++)f.data[4*(t*s+e)]=r,f.data[4*(t*s+e)+1]=l,f.data[4*(t*s+e)+2]=c,f.data[4*(t*s+e)+3]=i[t][e]*(255*u);A.putImageData(f,0,0),a=to(t.createPattern(h,null)),n.set(o,a)}t.fillStyle=a,t.fillRect(s,e,h,r)}(t,l,s,e,h,r),!0;let c=wo[i];if(c)return function(t,i,s,e,h,r,n){t.strokeStyle=t.fillStyle;for(let[o,a]of Object.entries(i)){let i;t.beginPath(),t.lineWidth=n*Number.parseInt(o),i="function"==typeof a?a(.15,.15/r*h):a;for(let o of i.split(" ")){let i=o[0],a=Io[i];if(!a){console.error(`Could not find drawing instructions for "${i}"`);continue}let l=o.substring(1).split(",");!l[0]||!l[1]||a(t,vo(l,h,r,s,e,!0,n))}t.stroke(),t.closePath()}}(t,c,s,e,h,r,o),!0;let u=po[i];return!!u&&(function(t,i,s,e,h,r,n,o){let a=new Path2D;a.rect(s,e,h,r),t.clip(a),t.beginPath();let l=n/12;t.lineWidth=o*l;for(let n of i.d.split(" ")){let a=n[0],c=Io[a];if(!c){console.error(`Could not find drawing instructions for "${a}"`);continue}let u=n.substring(1).split(",");!u[0]||!u[1]||c(t,vo(u,h,r,s,e,!1,o,(i.leftPadding??0)*(l/2),(i.rightPadding??0)*(l/2)))}1===i.type?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}(t,u,s,e,h,r,n,o),!0)}(this._tmpCtx,o,y,y,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let Q,k=!b;if(Q="number"==typeof i?this._unicodeService.wcwidth(i):this._unicodeService.getStringCellWidth(i),d){this._tmpCtx.save();let t=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),i=t%2==1?.5:0;if(this._tmpCtx.lineWidth=t,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())k=!1,this._tmpCtx.strokeStyle=`rgb(${Qo.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{k=!1;let t=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&t<8&&(t+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(t).css}this._tmpCtx.beginPath();let s=y,e=Math.ceil(y+this._config.deviceCharHeight)-i-(r?2*t:0),h=e+t,n=e+2*t,a=this._workAttributeData.getUnderlineVariantOffset();for(let r=0;r<Q;r++){this._tmpCtx.save();let o=s+r*this._config.deviceCellWidth,l=s+(r+1)*this._config.deviceCellWidth,c=o+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(l,e),this._tmpCtx.moveTo(o,n),this._tmpCtx.lineTo(l,n);break;case 3:let s=t<=1?n:Math.ceil(y+this._config.deviceCharHeight-t/2)-i,r=t<=1?e:Math.ceil(y+this._config.deviceCharHeight+t/2)-i,u=new Path2D;u.rect(o,e,this._config.deviceCellWidth,n-e),this._tmpCtx.clip(u),this._tmpCtx.moveTo(o-this._config.deviceCellWidth/2,h),this._tmpCtx.bezierCurveTo(o-this._config.deviceCellWidth/2,r,o,r,o,h),this._tmpCtx.bezierCurveTo(o,s,c,s,c,h),this._tmpCtx.bezierCurveTo(c,r,l,r,l,h),this._tmpCtx.bezierCurveTo(l,s,l+this._config.deviceCellWidth/2,s,l+this._config.deviceCellWidth/2,h);break;case 4:let A=0===a?0:a>=t?2*t-a:t-a;0==!(a>=t)||0===A?(this._tmpCtx.setLineDash([Math.round(t),Math.round(t)]),this._tmpCtx.moveTo(o+A,e),this._tmpCtx.lineTo(l,e)):(this._tmpCtx.setLineDash([Math.round(t),Math.round(t)]),this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(o+A,e),this._tmpCtx.moveTo(o+A+t,e),this._tmpCtx.lineTo(l,e)),a=eo(l-o,t,a);break;case 5:let f=.3,d=l-o,g=Math.floor(.6*d),w=Math.floor(f*d);this._tmpCtx.setLineDash([g,w,d-g-w]),this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(l,e);break;default:this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(l,e)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!E&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==o){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let i=this._tmpCtx.measureText(o);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in i&&i.actualBoundingBoxDescent>0){this._tmpCtx.save();let i=new Path2D;i.rect(s,e-Math.ceil(t/2),this._config.deviceCellWidth*Q,n-e+Math.ceil(t/2)),this._tmpCtx.clip(i),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=v.css,this._tmpCtx.strokeText(o,y,y+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(w){let t=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),i=t%2==1?.5:0;this._tmpCtx.lineWidth=t,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(y,y+i),this._tmpCtx.lineTo(y+this._config.deviceCharWidth*Q,y+i),this._tmpCtx.stroke()}if(E||this._tmpCtx.fillText(o,y,y+this._config.deviceCharHeight),"_"===o&&!this._config.allowTransparency){let t=zo(this._tmpCtx.getImageData(y,y,this._config.deviceCellWidth,this._config.deviceCellHeight),v,M,k);if(t)for(let i=1;i<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=v.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(o,y,y+this._config.deviceCharHeight-i),t=zo(this._tmpCtx.getImageData(y,y,this._config.deviceCellWidth,this._config.deviceCellHeight),v,M,k),t);i++);}if(g){let t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(y,y+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(y+this._config.deviceCharWidth*Q,y+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let x,D=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(x=this._config.allowTransparency?function(t){for(let i=0;i<t.data.length;i+=4)if(t.data[i+3]>0)return!1;return!0}(D):zo(D,v,M,k),x)return Jo;let L,_,S=this._findGlyphBoundingBox(D,this._workBoundingBox,a,B,E,y);for(;;){if(0===this._activePages.length){let t=this._createNewPage();L=t,_=t.currentRow,_.height=S.size.y;break}L=this._activePages[this._activePages.length-1],_=L.currentRow;for(let t of this._activePages)S.size.y<=t.currentRow.height&&(L=t,_=t.currentRow);for(let t=this._activePages.length-1;t>=0;t--)for(let i of this._activePages[t].fixedRows)i.height<=_.height&&S.size.y<=i.height&&(L=this._activePages[t],_=i);if(S.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Wo(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),L=this._overflowSizePage,_=this._overflowSizePage.currentRow,_.x+S.size.x>=L.canvas.width&&(_.x=0,_.y+=_.height,_.height=0);break}if(_.y+S.size.y>=L.canvas.height||_.height>S.size.y+2){let i=!1;if(L.currentRow.y+L.currentRow.height+S.size.y>=L.canvas.height){let s;for(let t of this._activePages)if(t.currentRow.y+t.currentRow.height+S.size.y<t.canvas.height){s=t;break}if(s)L=s;else if(t.maxAtlasPages&&this._pages.length>=t.maxAtlasPages&&_.y+S.size.y<=L.canvas.height&&_.height>=S.size.y&&_.x+S.size.x<=L.canvas.width)i=!0;else{let t=this._createNewPage();L=t,_=t.currentRow,_.height=S.size.y,i=!0}}i||(L.currentRow.height>0&&L.fixedRows.push(L.currentRow),_={x:0,y:L.currentRow.y+L.currentRow.height,height:S.size.y},L.fixedRows.push(_),L.currentRow={x:0,y:_.y+_.height,height:0})}if(_.x+S.size.x<=L.canvas.width)break;_===L.currentRow?(_.x=0,_.y+=_.height,_.height=0):L.fixedRows.splice(L.fixedRows.indexOf(_),1)}return S.texturePage=this._pages.indexOf(L),S.texturePosition.x=_.x,S.texturePosition.y=_.y,S.texturePositionClipSpace.x=_.x/L.canvas.width,S.texturePositionClipSpace.y=_.y/L.canvas.height,S.sizeClipSpace.x/=L.canvas.width,S.sizeClipSpace.y/=L.canvas.height,_.height=Math.max(_.height,S.size.y),_.x+=S.size.x,L.ctx.putImageData(D,S.texturePosition.x-this._workBoundingBox.left,S.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,S.size.x,S.size.y),L.addGlyph(S),L.version++,S}_findGlyphBoundingBox(t,i,s,e,h,r){i.top=0;let n=e?this._config.deviceCellHeight:this._tmpCanvas.height,o=e?this._config.deviceCellWidth:s,a=!1;for(let s=0;s<n;s++){for(let e=0;e<o;e++)if(0!==t.data[s*this._tmpCanvas.width*4+4*e+3]){i.top=s,a=!0;break}if(a)break}i.left=0,a=!1;for(let s=0;s<r+o;s++){for(let e=0;e<n;e++)if(0!==t.data[e*this._tmpCanvas.width*4+4*s+3]){i.left=s,a=!0;break}if(a)break}i.right=o,a=!1;for(let s=r+o-1;s>=r;s--){for(let e=0;e<n;e++)if(0!==t.data[e*this._tmpCanvas.width*4+4*s+3]){i.right=s,a=!0;break}if(a)break}i.bottom=n,a=!1;for(let s=n-1;s>=0;s--){for(let e=0;e<o;e++)if(0!==t.data[s*this._tmpCanvas.width*4+4*e+3]){i.bottom=s,a=!0;break}if(a)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+r+(e||h?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+r+(e||h?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Wo=class{constructor(t,i,s){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],s)for(let t of s)this._glyphs.push(...t.glyphs),this._usedPixels+=t._usedPixels;this.canvas=qo(t,i,i),this.ctx=to(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 zo(t,i,s,e){let h=i.rgba>>>24,r=i.rgba>>>16&255,n=i.rgba>>>8&255,o=s.rgba>>>16&255,a=s.rgba>>>8&255,l=Math.floor((Math.abs(h-(s.rgba>>>24))+Math.abs(r-o)+Math.abs(n-a))/12),c=!0;for(let i=0;i<t.data.length;i+=4)t.data[i]===h&&t.data[i+1]===r&&t.data[i+2]===n||e&&Math.abs(t.data[i]-h)+Math.abs(t.data[i+1]-r)+Math.abs(t.data[i+2]-n)<l?t.data[i+3]=0:c=!1;return c}function qo(t,i,s){let e=t.createElement("canvas");return e.width=i,e.height=s,e}function Ko(t,i){for(let s=0;s<t.colors.ansi.length;s++)if(t.colors.ansi[s].rgba!==i.colors.ansi[s].rgba)return!1;return t.devicePixelRatio===i.devicePixelRatio&&t.customGlyphs===i.customGlyphs&&t.lineHeight===i.lineHeight&&t.letterSpacing===i.letterSpacing&&t.fontFamily===i.fontFamily&&t.fontSize===i.fontSize&&t.fontWeight===i.fontWeight&&t.fontWeightBold===i.fontWeightBold&&t.allowTransparency===i.allowTransparency&&t.deviceCharWidth===i.deviceCharWidth&&t.deviceCharHeight===i.deviceCharHeight&&t.drawBoldTextInBrightColors===i.drawBoldTextInBrightColors&&t.minimumContrastRatio===i.minimumContrastRatio&&t.colors.foreground.rgba===i.colors.foreground.rgba&&t.colors.background.rgba===i.colors.background.rgba}var jo=[];function Yo(t,i,s,e,h,r,n,o,a){let l=function(t,i,s,e,h,r,n,o){let a={foreground:r.foreground,background:r.background,cursor:Zn,cursorAccent:Zn,selectionForeground:Zn,selectionBackgroundTransparent:Zn,selectionBackgroundOpaque:Zn,selectionInactiveBackgroundTransparent:Zn,selectionInactiveBackgroundOpaque:Zn,overviewRulerBorder:Zn,scrollbarSliderBackground:Zn,scrollbarSliderHoverBackground:Zn,scrollbarSliderActiveBackground:Zn,ansi:r.ansi.slice(),contrastCache:r.contrastCache,halfContrastCache:r.halfContrastCache};return{customGlyphs:h.customGlyphs,devicePixelRatio:n,deviceMaxTextureSize:o,letterSpacing:h.letterSpacing,lineHeight:h.lineHeight,deviceCellWidth:t,deviceCellHeight:i,deviceCharWidth:s,deviceCharHeight:e,fontFamily:h.fontFamily,fontSize:h.fontSize,fontWeight:h.fontWeight,fontWeightBold:h.fontWeightBold,allowTransparency:h.allowTransparency,drawBoldTextInBrightColors:h.drawBoldTextInBrightColors,minimumContrastRatio:h.minimumContrastRatio,colors:a}}(e,h,r,n,i,s,o,a);for(let i=0;i<jo.length;i++){let s=jo[i],e=s.ownedBy.indexOf(t);if(e>=0){if(Ko(s.config,l))return s.atlas;1===s.ownedBy.length?(s.atlas.dispose(),jo.splice(i,1)):s.ownedBy.splice(e,1);break}}for(let i=0;i<jo.length;i++){let s=jo[i];if(Ko(s.config,l))return s.ownedBy.push(t),s.atlas}let c={atlas:new Oo(document,l,t._core.unicodeService),config:l,ownedBy:[t]};return jo.push(c),c.atlas}function Zo(t){for(let i=0;i<jo.length;i++){let s=jo[i].ownedBy.indexOf(t);if(-1!==s){1===jo[i].ownedBy.length?(jo[i].atlas.dispose(),jo.splice(i,1)):jo[i].ownedBy.splice(s,1);break}}}var Xo=600,Vo=class{constructor(t,i){this._renderCallback=t,this._coreBrowserService=i,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=Xo){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout((()=>{if(this._animationTimeRestarted){let t=Xo-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0)return void this._restartInterval(t)}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 t=Xo-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(t)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._renderCallback(),this._animationFrame=void 0}))}),Xo)}),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 ta(t,i,s){let e=new i.ResizeObserver((i=>{let h=i.find((i=>i.target===t));if(!h)return;if(!("devicePixelContentBoxSize"in h))return e?.disconnect(),void(e=void 0);let r=h.devicePixelContentBoxSize[0].inlineSize,n=h.devicePixelContentBoxSize[0].blockSize;r>0&&n>0&&s(r,n)}));try{e.observe(t,{box:["device-pixel-content-box"]})}catch{e.disconnect(),e=void 0}return Ln((()=>e?.disconnect()))}var ia=class t extends Qo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ko,this.combinedData=""}static fromCharData(i){let s=new t;return s.setFromCharData(i),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(t){return t>65535?String.fromCharCode(55296+((t-=65536)>>10))+String.fromCharCode(t%1024+56320):String.fromCharCode(t)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(2===t[1].length){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let e=t[1].charCodeAt(1);56320<=e&&e<=57343?this.content=1024*(s-55296)+e-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},sa=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function ea(t,i,s){let e=to(t.createProgram());if(t.attachShader(e,to(ha(t,t.VERTEX_SHADER,i))),t.attachShader(e,to(ha(t,t.FRAGMENT_SHADER,s))),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS))return e;console.error(t.getProgramInfoLog(e)),t.deleteProgram(e)}function ha(t,i,s){let e=to(t.createShader(i));if(t.shaderSource(e,s),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS))return e;console.error(t.getShaderInfoLog(e)),t.deleteShader(e)}var ra,na=class{constructor(t){this.texture=t,this.version=-1}},oa=11,aa=oa*Float32Array.BYTES_PER_ELEMENT,la=0,ca=0,ua=0,Aa=class extends $n{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._optionsService=e,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let h=this._gl;void 0===Oo.maxAtlasPages&&(Oo.maxAtlasPages=Math.min(32,to(h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS))),Oo.maxTextureSize=to(h.getParameter(h.MAX_TEXTURE_SIZE))),this._program=to(ea(h,"#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in float a_texpage;\nlayout (location = 5) in vec2 a_texcoord;\nlayout (location = 6) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\nflat out int v_texpage;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texpage = int(a_texpage);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",function(t){let i="";for(let s=1;s<t;s++)i+=` else if (v_texpage == ${s}) { outColor = texture(u_texture[${s}], v_texcoord); }`;return`#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${t}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${i}\n}`}(Oo.maxAtlasPages))),this._register(Ln((()=>h.deleteProgram(this._program)))),this._projectionLocation=to(h.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=to(h.getUniformLocation(this._program,"u_resolution")),this._textureLocation=to(h.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=h.createVertexArray(),h.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),n=h.createBuffer();this._register(Ln((()=>h.deleteBuffer(n)))),h.bindBuffer(h.ARRAY_BUFFER,n),h.bufferData(h.ARRAY_BUFFER,r,h.STATIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let o=new Uint8Array([0,1,2,3]),a=h.createBuffer();this._register(Ln((()=>h.deleteBuffer(a)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,a),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=to(h.createBuffer()),this._register(Ln((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,2,h.FLOAT,!1,aa,0),h.vertexAttribDivisor(2,1),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,h.FLOAT,!1,aa,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(3,1),h.enableVertexAttribArray(4),h.vertexAttribPointer(4,1,h.FLOAT,!1,aa,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(4,1),h.enableVertexAttribArray(5),h.vertexAttribPointer(5,2,h.FLOAT,!1,aa,5*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(5,1),h.enableVertexAttribArray(6),h.vertexAttribPointer(6,2,h.FLOAT,!1,aa,7*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(6,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,aa,9*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.useProgram(this._program);let l=new Int32Array(Oo.maxAtlasPages);for(let t=0;t<Oo.maxAtlasPages;t++)l[t]=t;h.uniform1iv(this._textureLocation,l),h.uniformMatrix4fv(this._projectionLocation,!1,sa),this._atlasTextures=[];for(let t=0;t<Oo.maxAtlasPages;t++){let i=new na(to(h.createTexture()));this._register(Ln((()=>h.deleteTexture(i.texture)))),h.activeTexture(h.TEXTURE0+t),h.bindTexture(h.TEXTURE_2D,i.texture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,1,1,0,h.RGBA,h.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[t]=i}h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(t,i,s,e,h,r,n,o,a){this._updateCell(this._vertices.attributes,t,i,s,e,h,r,n,o,a)}_updateCell(t,i,s,e,h,r,n,o,a,l){la=(s*this._terminal.cols+i)*oa,0!==e&&void 0!==e?this._atlas&&(ra=o&&o.length>1?this._atlas.getRasterizedGlyphCombinedChar(o,h,r,n,!1,this._terminal.element):this._atlas.getRasterizedGlyph(e,h,r,n,!1,this._terminal.element),ca=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),h!==l&&ra.offset.x>ca?(t[la]=-(ra.offset.x-(ua=ra.offset.x-ca))+this._dimensions.device.char.left,t[la+1]=-ra.offset.y+this._dimensions.device.char.top,t[la+2]=(ra.size.x-ua)/this._dimensions.device.canvas.width,t[la+3]=ra.size.y/this._dimensions.device.canvas.height,t[la+4]=ra.texturePage,t[la+5]=ra.texturePositionClipSpace.x+ua/this._atlas.pages[ra.texturePage].canvas.width,t[la+6]=ra.texturePositionClipSpace.y,t[la+7]=ra.sizeClipSpace.x-ua/this._atlas.pages[ra.texturePage].canvas.width,t[la+8]=ra.sizeClipSpace.y):(t[la]=-ra.offset.x+this._dimensions.device.char.left,t[la+1]=-ra.offset.y+this._dimensions.device.char.top,t[la+2]=ra.size.x/this._dimensions.device.canvas.width,t[la+3]=ra.size.y/this._dimensions.device.canvas.height,t[la+4]=ra.texturePage,t[la+5]=ra.texturePositionClipSpace.x,t[la+6]=ra.texturePositionClipSpace.y,t[la+7]=ra.sizeClipSpace.x,t[la+8]=ra.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(t,i,s,e){return 1===i&&ra.size.x>Math.ceil(1.5*e)&&void 0!==t&&t>255&&!function(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}(t)&&!io(t)&&!function(t){return 57344<=t&&t<=63743}(t)}(e,a,0,this._dimensions.device.cell.width)&&(t[la+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):t.fill(0,la,la+oa-1-2)}clear(){let t=this._terminal,i=t.cols*t.rows*oa;this._vertices.count!==i?this._vertices.attributes=new Float32Array(i):this._vertices.attributes.fill(0);let s=0;for(;s<this._vertices.attributesBuffers.length;s++)this._vertices.count!==i?this._vertices.attributesBuffers[s]=new Float32Array(i):this._vertices.attributesBuffers[s].fill(0);this._vertices.count=i,s=0;for(let i=0;i<t.rows;i++)for(let e=0;e<t.cols;e++)this._vertices.attributes[s+9]=e/t.cols,this._vertices.attributes[s+10]=i/t.rows,s+=oa}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 i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let s=this._vertices.attributesBuffers[this._activeBuffer],e=0;for(let i=0;i<t.lineLengths.length;i++){let h=i*this._terminal.cols*oa,r=this._vertices.attributes.subarray(h,h+t.lineLengths[i]*oa);s.set(r,e),e+=r.length}i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,e),i.STREAM_DRAW);for(let t=0;t<this._atlas.pages.length;t++)this._atlas.pages[t].version!==this._atlasTextures[t].version&&this._bindAtlasPageTexture(i,this._atlas,t);i.drawElementsInstanced(i.TRIANGLE_STRIP,4,i.UNSIGNED_BYTE,0,e/oa)}setAtlas(t){this._atlas=t;for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(t,i,s){t.activeTexture(t.TEXTURE0+s),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[s].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,i.pages[s].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[s].version=i.pages[s].version}setDimensions(t){this._dimensions=t}},fa=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,i,s,e=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1])return void this.clear();let h=t.buffers.active.ydisp,r=i[1]-h,n=s[1]-h,o=Math.max(r,0),a=Math.min(n,t.rows-1);o>=t.rows||a<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=e,this.viewportStartRow=r,this.viewportEndRow=n,this.viewportCappedStartRow=o,this.viewportCappedEndRow=a,this.startCol=i[0],this.endCol=s[0])}isCellSelected(t,i,s){return!!this.hasSelection&&(s-=t.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)}},da=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new fa}resize(t,i){let s=t*i*4;s!==this.cells.length&&(this.cells=new Uint32Array(s),this.lineLengths=new Uint32Array(i))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},ga=8*Float32Array.BYTES_PER_ELEMENT,wa=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},pa=0,Ca=class extends $n{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._themeService=e,this._vertices=new wa,this._verticesCursor=new wa;let h=this._gl;this._program=to(ea(h,"#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec4 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\n\nout vec4 v_color;\n\nvoid main() {\n vec2 zeroToOne = a_position + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}","#version 300 es\nprecision lowp float;\n\nin vec4 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = v_color;\n}")),this._register(Ln((()=>h.deleteProgram(this._program)))),this._projectionLocation=to(h.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=h.createVertexArray(),h.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),n=h.createBuffer();this._register(Ln((()=>h.deleteBuffer(n)))),h.bindBuffer(h.ARRAY_BUFFER,n),h.bufferData(h.ARRAY_BUFFER,r,h.STATIC_DRAW),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let o=new Uint8Array([0,1,2,3]),a=h.createBuffer();this._register(Ln((()=>h.deleteBuffer(a)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,a),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=to(h.createBuffer()),this._register(Ln((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,ga,0),h.vertexAttribDivisor(0,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,ga,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,4,h.FLOAT,!1,ga,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(2,1),this._updateCachedColors(e.colors),this._register(this._themeService.onChangeColors((t=>{this._updateCachedColors(t),this._updateViewportRectangle()})))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),i.uniformMatrix4fv(this._projectionLocation,!1,sa),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,t.attributes,i.DYNAMIC_DRAW),i.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,i.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 i,s,e,h,r,n,o,a,l,c,u,A=this._terminal,f=this._vertices,d=1;for(i=0;i<A.rows;i++){for(e=-1,h=0,r=0,n=!1,s=0;s<A.cols;s++)o=4*(i*A.cols+s),a=t.cells[o+1],l=t.cells[o+2],c=!!(67108864&l),(a!==h||l!==r&&(n||c))&&((0!==h||n&&0!==r)&&(u=8*d++,this._updateRectangle(f,u,r,h,e,s,i)),e=s,h=a,r=l,n=c);(0!==h||n&&0!==r)&&(u=8*d++,this._updateRectangle(f,u,r,h,e,A.cols,i))}f.count=d}updateCursor(t){let i=this._verticesCursor,s=t.cursor;if(!s||"block"===s.style)return void(i.count=0);let e,h=0;("bar"===s.style||"outline"===s.style)&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,s.y*this._dimensions.device.cell.height,"bar"===s.style?s.dpr*s.cursorWidth:s.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===s.style||"outline"===s.style)&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,(s.y+1)*this._dimensions.device.cell.height-s.dpr,s.width*this._dimensions.device.cell.width,s.dpr,this._cursorFloat)),"outline"===s.style&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,s.y*this._dimensions.device.cell.height,s.width*this._dimensions.device.cell.width,s.dpr,this._cursorFloat),e=8*h++,this._addRectangleFloat(i.attributes,e,(s.x+s.width)*this._dimensions.device.cell.width-s.dpr,s.y*this._dimensions.device.cell.height,s.dpr,this._dimensions.device.cell.height,this._cursorFloat)),i.count=h}_updateRectangle(t,i,s,e,h,r,n){if(67108864&s)switch(50331648&s){case 16777216:case 33554432:pa=this._themeService.colors.ansi[255&s].rgba;break;case 50331648:pa=(16777215&s)<<8;break;default:pa=this._themeService.colors.foreground.rgba}else switch(50331648&e){case 16777216:case 33554432:pa=this._themeService.colors.ansi[255&e].rgba;break;case 50331648:pa=(16777215&e)<<8;break;default:pa=this._themeService.colors.background.rgba}t.attributes.length<i+4&&(t.attributes=function(t,i){let s=new Float32Array(Math.min(2*t.length,i));for(let i=0;i<t.length;i++)s[i]=t[i];return s}(t.attributes,this._terminal.rows*this._terminal.cols*8)),this._addRectangle(t.attributes,i,h*this._dimensions.device.cell.width,n*this._dimensions.device.cell.height,(r-h)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,(pa>>24&255)/255,(pa>>16&255)/255,(pa>>8&255)/255,1)}_addRectangle(t,i,s,e,h,r,n,o,a,l){t[i]=s/this._dimensions.device.canvas.width,t[i+1]=e/this._dimensions.device.canvas.height,t[i+2]=h/this._dimensions.device.canvas.width,t[i+3]=r/this._dimensions.device.canvas.height,t[i+4]=n,t[i+5]=o,t[i+6]=a,t[i+7]=l}_addRectangleFloat(t,i,s,e,h,r,n){t[i]=s/this._dimensions.device.canvas.width,t[i+1]=e/this._dimensions.device.canvas.height,t[i+2]=h/this._dimensions.device.canvas.width,t[i+3]=r/this._dimensions.device.canvas.height,t[i+4]=n[0],t[i+5]=n[1],t[i+6]=n[2],t[i+7]=n[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(255&t.rgba)/255])}},ma=class extends $n{constructor(t,i,s,e,h,r,n,o){super(),this._container=i,this._alpha=h,this._coreBrowserService=r,this._optionsService=n,this._themeService=o,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-${s}-layer`),this._canvas.style.zIndex=""+e,this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors((i=>{this._refreshCharAtlas(t,i),this.reset(t)}))),this._register(Ln((()=>{this._canvas.remove()})))}_initCanvas(){this._ctx=to(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,i,s){}handleSelectionChanged(t,i,s,e=!1){}_setTransparency(t,i){if(i===this._alpha)return;let s=this._canvas;this._alpha=i,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,s),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,i){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=Yo(t,this._optionsService.rawOptions,i,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,i){this._deviceCellWidth=i.device.cell.width,this._deviceCellHeight=i.device.cell.height,this._deviceCharWidth=i.device.char.width,this._deviceCharHeight=i.device.char.height,this._deviceCharLeft=i.device.char.left,this._deviceCharTop=i.device.char.top,this._canvas.width=i.device.canvas.width,this._canvas.height=i.device.canvas.height,this._canvas.style.width=i.css.canvas.width+"px",this._canvas.style.height=i.css.canvas.height+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,i,s=1){this._ctx.fillRect(t*this._deviceCellWidth,(i+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,s*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,i,s,e){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,e*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,e*this._deviceCellHeight))}_fillCharTrueColor(t,i,s,e){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=Ao,this._clipCell(s,e,i.getWidth()),this._ctx.fillText(i.getChars(),s*this._deviceCellWidth+this._deviceCharLeft,e*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,i,s){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,i,s){return`${s?"italic":""} ${i?t.options.fontWeightBold:t.options.fontWeight} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},Ia=class extends ma{constructor(t,i,s,e,h,r,n){super(s,t,"link",i,!0,h,r,n),this._register(e.onShowLinkUnderline((t=>this._handleShowLinkUnderline(t)))),this._register(e.onHideLinkUnderline((t=>this._handleHideLinkUnderline(t))))}resize(t,i){super.resize(t,i),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(this._ctx.fillStyle=257===t.fg?this._themeService.colors.background.css:void 0!==t.fg&&function(t){return 16777216==(50331648&t)||33554432==(50331648&t)}(t.fg)?this._themeService.colors.ansi[t.fg].css: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 i=t.y1+1;i<t.y2;i++)this._fillBottomLineAtCells(0,i,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},va="object"==typeof window?window:globalThis,ba=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Go,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Go,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ba.INSTANCE=new ba;var Ba="object"==typeof navigator?navigator.userAgent:"";if(Ba.indexOf("Firefox"),Ba.indexOf("AppleWebKit"),!(Ba.indexOf("Chrome")>=0)&&Ba.indexOf("Safari"),Ba.indexOf("Electron/"),Ba.indexOf("Android"),"function"==typeof va.matchMedia){let t=va.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");va.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=va.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Ma,ya,Ea="en",Qa=!1,ka=Ea,xa=globalThis;typeof xa.vscode<"u"&&typeof xa.vscode.process<"u"?ya=xa.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(ya=process);var Da="string"==typeof ya?.versions?.electron&&"renderer"===ya?.type;if("object"==typeof ya){ka=Ea;let t=ya.env.VSCODE_NLS_CONFIG;if(t)try{ka=JSON.parse(t).resolvedLanguage||Ea}catch{}Qa=!0}else"object"!=typeof navigator||Da?console.error("Unable to resolve platform."):((Ma=navigator.userAgent).indexOf("Windows"),Ma.indexOf("Macintosh"),(Ma.indexOf("Macintosh")>=0||Ma.indexOf("iPad")>=0||Ma.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Ma.indexOf("Linux"),Ma?.indexOf("Mobi"),ka=globalThis._VSCODE_NLS_LANGUAGE||Ea,navigator.language.toLowerCase());var La,_a=Qa,Sa=Ma,$a=ka;(t=>{t.value=function(){return $a},t.isDefaultVariant=function(){return 2===$a.length?"en"===$a:$a.length>=3&&"e"===$a[0]&&"n"===$a[1]&&"-"===$a[2]},t.isDefault=function(){return"en"===$a}})(La||={});var Ra="function"==typeof xa.postMessage&&!xa.importScripts;(()=>{if(Ra){let t=[];xa.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var Na=!!(Sa&&Sa.indexOf("Chrome")>=0);Sa&&Sa.indexOf("Firefox"),!Na&&Sa&&Sa.indexOf("Safari"),Sa&&Sa.indexOf("Edg/"),Sa&&Sa.indexOf("Android"),"object"==typeof navigator&&navigator,_a||document.queryCommandSupported&&document.queryCommandSupported("copy");var Fa,Ha=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,i){this._keyCodeToStr[t]=i,this._strToKeyCode[i.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Ua=new Ha,Ta=new Ha,Ga=new Ha;Array(230),(t=>{t.toString=function(t){return Ua.keyCodeToStr(t)},t.fromString=function(t){return Ua.strToKeyCode(t)},t.toUserSettingsUS=function(t){return Ta.keyCodeToStr(t)},t.toUserSettingsGeneral=function(t){return Ga.keyCodeToStr(t)},t.fromUserSettings=function(t){return Ta.strToKeyCode(t)||Ga.strToKeyCode(t)},t.toElectronAccelerator=function(t){if(t>=98&&t<=113)return null;switch(t){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ua.keyCodeToStr(t)}})(Fa||={});var Pa,Ja=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof Wa||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:bo.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ja})})(Pa||={});var Oa,Wa=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?Ja:(this._emitter||(this._emitter=new Go),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(Oa||={});var za=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Go,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await bo.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};za.EMPTY=za.fromArray([]);var{getWindow:qa}=function(){let t=new Map,i={window:va,disposables:new Sn};t.set(va.vscodeWindowId,i);let s=new Go,e=new Go,h=new Go;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return $n.None;let r=new Sn,n={window:i,disposables:r.add(new Sn)};return t.set(i.vscodeWindowId,n),r.add(Ln((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(ja(i,Ya.BEFORE_UNLOAD,(()=>{h.fire(i)}))),s.fire(n),r},getWindows:()=>t.values(),getWindowsCount:()=>t.size,getWindowId:t=>t.vscodeWindowId,hasWindow:i=>t.has(i),getWindowById:function(s,e){return("number"==typeof s?t.get(s):void 0)??(e?i:void 0)},getWindow(t){let i=t;if(i?.ownerDocument?.defaultView)return i.ownerDocument.defaultView.window;let s=t;return s?.view?s.view.window:va},getDocument:t=>qa(t).document}}(),Ka=class{constructor(t,i,s,e){this._node=t,this._type=i,this._handler=s,this._options=e||!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 ja(t,i,s,e){return new Ka(t,i,s,e)}var Ya={BEFORE_UNLOAD:"beforeunload"},Za=class extends $n{constructor(t,i,s,e,h,r,n,o,a){if(super(),this._terminal=t,this._characterJoinerService=i,this._charSizeService=s,this._coreBrowserService=e,this._coreService=h,this._decorationService=r,this._optionsService=n,this._themeService=o,this._cursorBlinkStateManager=new Rn,this._charAtlasDisposable=this._register(new Rn),this._observerDisposable=this._register(new Rn),this._model=new da,this._workCell=new ia,this._workCell2=new ia,this._rectangleRenderer=this._register(new Rn),this._glyphRenderer=this._register(new Rn),this._onChangeTextureAtlas=this._register(new Go),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Go),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Go),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Go),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Go),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._gl=this._canvas.getContext("webgl2",{antialias:!1,depth:!1,preserveDrawingBuffer:a}),!this._gl)throw Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors((()=>this._handleColorChange()))),this._cellColorResolver=new uo(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Ia(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,n,this._themeService)],this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(n.onOptionChange((()=>this._handleOptionsChanged()))),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(ja(this._canvas,"webglcontextlost",(t=>{console.log("webglcontextlost event received"),t.preventDefault(),this._contextRestorationTimeout=setTimeout((()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(t)}),3e3)}))),this._register(ja(this._canvas,"webglcontextrestored",(()=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Zo(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()}))),this._observerDisposable.value=ta(this._canvas,this._coreBrowserService.window,((t,i)=>this._setCanvasDevicePixelDimensions(t,i))),this._register(this._coreBrowserService.onWindowChange((t=>{this._observerDisposable.value=ta(this._canvas,t,((t,i)=>this._setCanvasDevicePixelDimensions(t,i)))}))),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Ln((()=>{for(let t of this._renderLayers)t.dispose();this._canvas.parentElement?.removeChild(this._canvas),Zo(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,i){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let t of this._renderLayers)t.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,i,s){for(let e of this._renderLayers)e.handleSelectionChanged(this._terminal,t,i,s);this._model.selection.update(this._core,t,i,s),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 Ca(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Aa(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)return void(this._isAttached=!1);let t=Yo(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=Dn(bo.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),bo.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,i){if(!this._isAttached){if(!(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let s of this._renderLayers)s.handleGridChanged(this._terminal,t,i);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,i),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 Vo((()=>{this._requestRedrawCursor()}),this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,i){let s,e,h,r,n,o,a,l,c,u,A,f,d,g,w,p=this._core,C=this._workCell,m=0,I=!0;t=Va(t,p.rows-1,0),i=Va(i,p.rows-1,0);let v=this._coreService.decPrivateModes.cursorStyle??p.options.cursorStyle??"block",b=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,B=b-p.buffer.ydisp,M=Math.min(this._terminal.buffer.active.cursorX,p.cols-1),y=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let Q=!1;for(e=t;e<=i;e++)for(h=e+p.buffer.ydisp,r=p.buffer.lines.get(h),this._model.lineLengths[e]=0,c=b===h,m=0,n=this._characterJoinerService.getJoinedCharacters(h),g=0;g<p.cols;g++){if(s=this._cellColorResolver.result.bg,r.loadCell(g,C),0===g&&(s=this._cellColorResolver.result.bg),o=!1,I=g>=m,a=g,n.length>0&&g===n[0][0]&&I){l=n.shift();let t=this._model.selection.isCellSelected(this._terminal,l[0],h);for(d=l[0]+1;d<l[1];d++)I&&=t===this._model.selection.isCellSelected(this._terminal,d,h);I&&=!c||M<l[0]||M>=l[1],I?(o=!0,C=new Xa(C,r.translateToString(!0,l[0],l[1]),l[1]-l[0]),a=l[1]-1):m=l[1]}if(u=C.getChars(),A=C.getCode(),d=4*(e*p.cols+g),this._cellColorResolver.resolve(C,g,h,this.dimensions.device.cell.width),E&&h===b&&(g===M&&(this._model.cursor={x:M,y:B,width:C.getWidth(),style:this._coreBrowserService.isFocused?v:p.options.cursorInactiveStyle,cursorWidth:p.options.cursorWidth,dpr:this._devicePixelRatio},y=M+C.getWidth()-1),g>=M&&g<=y&&(this._coreBrowserService.isFocused&&"block"===v||!1===this._coreBrowserService.isFocused&&"block"===p.options.cursorInactiveStyle)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),0!==A&&(this._model.lineLengths[e]=g+1),(this._model.cells[d]!==A||this._model.cells[d+1]!==this._cellColorResolver.result.bg||this._model.cells[d+2]!==this._cellColorResolver.result.fg||this._model.cells[d+3]!==this._cellColorResolver.result.ext)&&(Q=!0,u.length>1&&(A|=2147483648),this._model.cells[d]=A,this._model.cells[d+1]=this._cellColorResolver.result.bg,this._model.cells[d+2]=this._cellColorResolver.result.fg,this._model.cells[d+3]=this._cellColorResolver.result.ext,f=C.getWidth(),this._glyphRenderer.value.updateCell(g,e,A,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,u,f,s),o)){for(C=this._workCell,g++;g<=a;g++)w=4*(e*p.cols+g),this._glyphRenderer.value.updateCell(g,e,0,0,0,0,"",0,0),this._model.cells[w]=0,this._model.cells[w+1]=this._cellColorResolver.result.bg,this._model.cells[w+2]=this._cellColorResolver.result.fg,this._model.cells[w+3]=this._cellColorResolver.result.ext;g--}}Q&&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=1===this._optionsService.rawOptions.lineHeight?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,i){this._canvas.width===t&&this._canvas.height===i||(this._canvas.width=t,this._canvas.height=i,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})}},Xa=class extends Qo{constructor(t,i,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Va(t,i,s=0){return Math.max(Math.min(t,i),s)}var tl="di$target",il="di$dependencies",sl=new Map;function el(t){if(sl.has(t))return sl.get(t);let i=function(t,s,e){if(3!==arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[tl]===i?i[il].push({id:t,index:s}):(i[il]=[{id:t,index:s}],i[tl]=i)}(i,t,e)};return i._id=t,sl.set(t,i),i}el("BufferService"),el("CoreMouseService"),el("CoreService"),el("CharsetService"),el("InstantiationService"),el("LogService");var hl=el("OptionsService");el("OscLinkService"),el("UnicodeService"),el("DecorationService");var rl={trace:0,debug:1,info:2,warn:3,error:4,off:5},nl=class extends $n{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=rl[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let i=0;i<t.length;i++)"function"==typeof t[i]&&(t[i]=t[i]())}_log(t,i,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...s)}trace(t,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,i)}debug(t,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,i)}info(t,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,i)}warn(t,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,i)}error(t,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,i)}};nl=(t=>{for(var i,s=nl,e=t.length-1;e>=0;e--)(i=t[e])&&(s=i(s)||s);return s})([((t,i)=>(t,s)=>i(t,s,0))(0,hl)]);var ol,al,ll,cl,ul,Al=class extends $n{constructor(t){if(Gn&&function(){if(!Gn)return 0;let t=Fn.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new Go),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Go),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Go),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Go),this.onContextLoss=this._onContextLoss.event}activate(t){let i=t._core;if(!t.element)return void this._register(i.onWillOpen((()=>this.activate(t))));this._terminal=t;let s=i._renderService;this._renderer=this._register(new Za(t,i._characterJoinerService,i._charSizeService,i._coreBrowserService,i.coreService,i._decorationService,i.optionsService,i._themeService,this._preserveDrawingBuffer)),this._register(bo.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(bo.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(bo.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(bo.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),s.setRenderer(this._renderer),this._register(Ln((()=>{if(this._terminal._core._store._isDisposed)return;let i=this._terminal._core._renderService;i.setRenderer(this._terminal._core._createRenderer()),i.handleResize(t.cols,t.rows)})))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},fl=0,dl=0,gl=0,wl=0;
25
+ */function xr(t){(function(t){return t instanceof _r||t instanceof Error&&t.name===Sr&&t.message===Sr})(t)||kr.onUnexpectedError(t)}var Dr,Lr,Sr="Canceled",_r=class extends Error{constructor(){super(Sr),this.name=this.message}},$r=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}};function Rr(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function Nr(t){if(Lr.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function Fr(...t){return Hr((()=>Nr(t)))}function Hr(t){return{dispose:Rr((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(Dr||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Lr||={});var Tr=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Nr(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Tr.DISABLE_DISPOSED_WARNING=!1;var Ur=Tr,Gr=class{constructor(){this._store=new Ur}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};Gr.None=Object.freeze({dispose(){}});var Pr,Jr=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}},Or=globalThis.performance&&"function"==typeof globalThis.performance.now,Wr=class t{static create(i){return new t(i)}constructor(t){this._now=Or&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new en({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,l,a,u,c=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{c++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),u=()=>{let t=l;l=void 0,a=void 0,(!e||c>1)&&f.fire(t),c=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(u,s)):void 0===a&&(a=0,queueMicrotask(u))}))},onWillRemoveListener(){h&&c>0&&u?.()},onDidRemoveLastListener(){u=void 0,o.dispose()}},f=new en(A);return n?.add(f),f.event}t.None=()=>Gr.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=Fr(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new en({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new en({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new en({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new en;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class l{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new en({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new l(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof Ur?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Pr||={});var zr=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new Wr,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};zr.all=new Set,zr._idPool=0;var Kr=zr,qr=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new Xr(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};qr._idPool=1;var jr,Yr=qr,Zr=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Xr=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Vr=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},tn=0,sn=class{constructor(t){this.value=t,this.id=tn++}},en=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Yr(t?.onListenerError??xr,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Kr(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new Vr(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||xr)(s),Gr.None}if(this._disposed)return Gr.None;i&&(t=t.bind(i));let e,h=new sn(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Zr.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof sn?(this._deliveryQueue??=new hn,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Hr((()=>{e?.(),this._removeListener(h)}));return s instanceof Ur?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||xr;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 sn)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},hn=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},rn=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof ln||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Pr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:rn})})(jr||={});var nn,on,ln=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?rn:(this._emitter||(this._emitter=new en),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},an="en",un=an,cn=globalThis;typeof cn.vscode<"u"&&typeof cn.vscode.process<"u"?on=cn.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(on=process);var An="string"==typeof on?.versions?.electron&&"renderer"===on?.type;if("object"==typeof on){un=an;let t=on.env.VSCODE_NLS_CONFIG;if(t)try{un=JSON.parse(t).resolvedLanguage||an}catch{}}else"object"!=typeof navigator||An?console.error("Unable to resolve platform."):((nn=navigator.userAgent).indexOf("Windows"),nn.indexOf("Macintosh"),(nn.indexOf("Macintosh")>=0||nn.indexOf("iPad")>=0||nn.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,nn.indexOf("Linux"),nn?.indexOf("Mobi"),un=globalThis._VSCODE_NLS_LANGUAGE||an,navigator.language.toLowerCase());var fn,dn=nn,gn=un;(t=>{t.value=function(){return gn},t.isDefaultVariant=function(){return 2===gn.length?"en"===gn:gn.length>=3&&"e"===gn[0]&&"n"===gn[1]&&"-"===gn[2]},t.isDefault=function(){return"en"===gn}})(fn||={});var wn="function"==typeof cn.postMessage&&!cn.importScripts;(()=>{if(wn){let t=[];cn.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var pn,Cn=!!(dn&&dn.indexOf("Chrome")>=0);function mn(t,i=0){let s=setTimeout((()=>{t()}),i);return Hr((()=>{clearTimeout(s)}))}dn&&dn.indexOf("Firefox"),!Cn&&dn&&dn.indexOf("Safari"),dn&&dn.indexOf("Edg/"),dn&&dn.indexOf("Android"),(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(pn||={});var In=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new en,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await Pr.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};In.EMPTY=In.fromArray([]);var vn=class extends Gr{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Jr),this._linesCacheDisposables=this._register(new Jr),this._register(Hr((()=>this._destroyLinesCache())))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Fr(this._terminal.onLineFeed((()=>this._destroyLinesCache())),this._terminal.onCursorMove((()=>this._destroyLinesCache())),this._terminal.onResize((()=>this._destroyLinesCache())))),this._linesCacheTimeout.value=mn((()=>this._destroyLinesCache()),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(t){return this._linesCache?.[t]}setLineInCache(t,i){this._linesCache&&(this._linesCache[t]=i)}translateBufferLineToStringWithWrap(t,i){let s=[],e=[0],h=this._terminal.buffer.active.getLine(t);for(;h;){let r=this._terminal.buffer.active.getLine(t+1),n=!!r&&r.isWrapped,o=h.translateToString(!n&&i);if(n&&r){let t=h.getCell(h.length-1);t&&0===t.getCode()&&1===t.getWidth()&&2===r.getCell(0)?.getWidth()&&(o=o.slice(0,-1))}if(s.push(o),!n)break;e.push(e[e.length-1]+o.length),t++,h=r}return[s.join(""),e]}},Bn=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(t){this._cachedSearchTerm=t}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(t){this._lastSearchOptions=t}isValidSearchTerm(t){return!!(t&&t.length>0)}didOptionsChange(t){return!this._lastSearchOptions||!!t&&(this._lastSearchOptions.caseSensitive!==t.caseSensitive||this._lastSearchOptions.regex!==t.regex||this._lastSearchOptions.wholeWord!==t.wholeWord)}shouldUpdateHighlighting(t,i){return!!i?.decorations&&(void 0===this._cachedSearchTerm||t!==this._cachedSearchTerm||this.didOptionsChange(i))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Mn=class{constructor(t,i){this._terminal=t,this._lineCache=i}find(t,i,s,e){if(!t||0===t.length)return void this._terminal.clearSelection();if(s>this._terminal.cols)throw Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let h={startRow:i,startCol:s},r=this._findInLine(t,h,e);if(!r)for(let s=i+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(h.startRow=s,h.startCol=0,r=this._findInLine(t,h,e),!r);s++);return r}findNextWithSelection(t,i,s){if(!t||0===t.length)return void this._terminal.clearSelection();let e=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=0,r=0;e&&(s===t?(h=e.end.x,r=e.end.y):(h=e.start.x,r=e.start.y)),this._lineCache.initLinesCache();let n={startRow:r,startCol:h},o=this._findInLine(t,n,i);if(!o)for(let s=r+1;s<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=s,n.startCol=0,o=this._findInLine(t,n,i),!o);s++);if(!o&&0!==r)for(let s=0;s<r&&(n.startRow=s,n.startCol=0,o=this._findInLine(t,n,i),!o);s++);return!o&&e&&(n.startRow=e.start.y,n.startCol=0,o=this._findInLine(t,n,i)),o}findPreviousWithSelection(t,i,s){if(!t||0===t.length)return void this._terminal.clearSelection();let e=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=this._terminal.buffer.active.baseY+this._terminal.rows-1,r=this._terminal.cols,n=!0;this._lineCache.initLinesCache();let o,l={startRow:h,startCol:r};if(e&&(l.startRow=h=e.start.y,l.startCol=r=e.start.x,s!==t&&(o=this._findInLine(t,l,i,!1),o||(l.startRow=h=e.end.y,l.startCol=r=e.end.x))),o||(o=this._findInLine(t,l,i,n)),!o){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let s=h-1;s>=0&&(l.startRow=s,o=this._findInLine(t,l,i,n),!o);s--);}if(!o&&h!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let s=this._terminal.buffer.active.baseY+this._terminal.rows-1;s>=h&&(l.startRow=s,o=this._findInLine(t,l,i,n),!o);s--);return o}_isWholeWord(t,i,s){return(0===t||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t-1]))&&(t+s.length===i.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(i[t+s.length]))}_findInLine(t,i,s={},e=!1){let h=i.startRow,r=i.startCol;if(this._terminal.buffer.active.getLine(h)?.isWrapped)return e?void(i.startCol+=this._terminal.cols):(i.startRow--,i.startCol+=this._terminal.cols,this._findInLine(t,i,s));let n=this._lineCache.getLineFromCache(h);n||(n=this._lineCache.translateBufferLineToStringWithWrap(h,!0),this._lineCache.setLineInCache(h,n));let[o,l]=n,a=this._bufferColsToStringOffset(h,r),u=t,c=o;s.regex||(u=s.caseSensitive?t:t.toLowerCase(),c=s.caseSensitive?o:o.toLowerCase());let A=-1;if(s.regex){let i,h=RegExp(u,s.caseSensitive?"g":"gi");if(e)for(;i=h.exec(c.slice(0,a));)A=h.lastIndex-i[0].length,h.lastIndex-=(t=i[0]).length-1;else i=h.exec(c.slice(a)),i&&i[0].length>0&&(A=a+(h.lastIndex-i[0].length),t=i[0])}else e?a-u.length>=0&&(A=c.lastIndexOf(u,a-u.length)):A=c.indexOf(u,a);if(A>=0){if(s.wholeWord&&!this._isWholeWord(A,c,t))return;let i=0;for(;i<l.length-1&&A>=l[i+1];)i++;let e=i;for(;e<l.length-1&&A+t.length>=l[e+1];)e++;let r=A+t.length-l[e],n=this._stringLengthToBufferSize(h+i,A-l[i]);return{term:t,col:n,row:h+i,size:this._stringLengthToBufferSize(h+e,r)-n+this._terminal.cols*(e-i)}}}_stringLengthToBufferSize(t,i){let s=this._terminal.buffer.active.getLine(t);if(!s)return 0;for(let t=0;t<i;t++){let e=s.getCell(t);if(!e)break;let h=e.getChars();h.length>1&&(i-=h.length-1);let r=s.getCell(t+1);r&&0===r.getWidth()&&i++}return i}_bufferColsToStringOffset(t,i){let s=t,e=0,h=this._terminal.buffer.active.getLine(s);for(;i>0&&h;){for(let t=0;t<i&&t<this._terminal.cols;t++){let i=h.getCell(t);if(!i)break;i.getWidth()&&(e+=0===i.getCode()?1:i.getChars().length)}if(s++,h=this._terminal.buffer.active.getLine(s),h&&!h.isWrapped)break;i-=this._terminal.cols}return e}},yn=class extends Gr{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Hr((()=>this.clearHighlightDecorations())))}createHighlightDecorations(t,i){this.clearHighlightDecorations();for(let s of t){let t=this._createResultDecorations(s,i,!1);if(t)for(let i of t)this._storeDecoration(i,s)}}createActiveDecoration(t,i){let s=this._createResultDecorations(t,i,!0);if(s)return{decorations:s,match:t,dispose(){Nr(s)}}}clearHighlightDecorations(){Nr(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(t,i){this._highlightedLines.add(t.marker.line),this._highlightDecorations.push({decoration:t,match:i,dispose(){t.dispose()}})}_applyStyles(t,i,s){t.classList.contains("xterm-find-result-decoration")||(t.classList.add("xterm-find-result-decoration"),i&&(t.style.outline="1px solid "+i)),s&&t.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(t,i,s){let e=[],h=t.col,r=t.size,n=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+t.row;for(;r>0;){let t=Math.min(this._terminal.cols-h,r);e.push([n,h,t]),h=0,r-=t,n++}let o=[];for(let t of e){let e=this._terminal.registerMarker(t[0]),h=this._terminal.registerDecoration({marker:e,x:t[1],width:t[2],backgroundColor:s?i.activeMatchBackground:i.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:s?i.activeMatchColorOverviewRuler:i.matchOverviewRuler,position:"center"}});if(h){let t=[];t.push(e),t.push(h.onRender((t=>this._applyStyles(t,s?i.activeMatchBorder:i.matchBorder,!1)))),t.push(h.onDispose((()=>Nr(t)))),o.push(h)}}return 0===o.length?void 0:o}},Qn=class extends Gr{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new en)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(t){this._selectedDecoration=t}updateResults(t,i){this._searchResults=t.slice(0,i)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(t){for(let i=0;i<this._searchResults.length;i++){let s=this._searchResults[i];if(s.row===t.row&&s.col===t.col&&s.size===t.size)return i}return-1}fireResultsChanged(t){if(!t)return;let i=-1;this._selectedDecoration&&(i=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:i,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},En=class extends Gr{constructor(t){super(),this._highlightTimeout=this._register(new Jr),this._lineCache=this._register(new Jr),this._state=new Bn,this._resultTracker=this._register(new Qn),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new vn(t),this._engine=new Mn(t,this._lineCache.value),this._decorationManager=new yn(t),this._register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this._register(this._terminal.onResize((()=>this._updateMatches()))),this._register(Hr((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=mn((()=>{let t=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(t,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})}),200))}clearDecorations(t){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),t||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(t,i,s){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let e=this._findNextAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,e}_highlightAllMatches(t,i){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(t))return void this.clearDecorations();this.clearDecorations(!0);let s,e=[],h=this._engine.find(t,0,0,i);for(;h&&(s?.row!==h.row||s?.col!==h.col)&&!(e.length>=this._highlightLimit);)s=h,e.push(s),h=this._engine.find(t,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,i);this._resultTracker.updateResults(e,this._highlightLimit),i.decorations&&this._decorationManager.createHighlightDecorations(e,i.decorations)}_findNextAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let e=this._engine.findNextWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(e,i?.decorations,s?.noScroll)}findPrevious(t,i,s){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=i,this._state.shouldUpdateHighlighting(t,i)&&this._highlightAllMatches(t,i);let e=this._findPreviousAndSelect(t,i,s);return this._fireResults(i),this._state.cachedSearchTerm=t,e}_fireResults(t){this._resultTracker.fireResultsChanged(!!t?.decorations)}_findPreviousAndSelect(t,i,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(t))return this._terminal.clearSelection(),this.clearDecorations(),!1;let e=this._engine.findPreviousWithSelection(t,i,this._state.cachedSearchTerm);return this._selectResult(e,i?.decorations,s?.noScroll)}_selectResult(t,i,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!t)return this._terminal.clearSelection(),!1;if(this._terminal.select(t.col,t.row,t.size),i){let s=this._decorationManager.createActiveDecoration(t,i);s&&(this._resultTracker.selectedDecoration=s)}if(!s&&(t.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||t.row<this._terminal.buffer.active.viewportY)){let i=t.row-this._terminal.buffer.active.viewportY;i-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(i)}return!0}},bn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?_n.isErrorNoTelemetry(t)?new _n(t.message+"\n\n"+t.stack):Error(t.message+"\n\n"+t.stack):t}),0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach((i=>{i(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)}};function kn(t){(function(t){return t instanceof Sn||t instanceof Error&&t.name===Ln&&t.message===Ln})(t)||bn.onUnexpectedError(t)}var xn,Dn,Ln="Canceled",Sn=class extends Error{constructor(){super(Ln),this.name=this.message}},_n=class t extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(i){if(i instanceof t)return i;let s=new t;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(t){return"CodeExpectedError"===t.name}};function $n(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function Rn(t){if(Dn.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}if(t)return t.dispose(),t}function Nn(...t){return Fn((()=>Rn(t)))}function Fn(t){return{dispose:$n((()=>{t()}))}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(xn||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Dn||={});var Hn=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{Rn(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Hn.DISABLE_DISPOSED_WARNING=!1;var Tn=Hn,Un=class{constructor(){this._store=new Tn}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};Un.None=Object.freeze({dispose(){}});var Gn=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}},Pn=typeof process<"u"&&"title"in process,Jn=Pn?"node":navigator.userAgent,On=Pn?"node":navigator.platform,Wn=Jn.includes("Firefox"),zn=Jn.includes("Edge"),Kn=/^((?!chrome|android).)*safari/i.test(Jn);On.indexOf("Linux");var qn,jn,Yn,Zn,Xn,Vn=0,to=0,io=0,so=0,eo={css:"#00000000",rgba:0};function ho(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ro(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}function no(t){if(!t)throw Error("value must not be falsy");return t}function oo(t){return 57508<=t&&t<=57558}function lo(t){return oo(t)||function(t){return 9472<=t&&t<=9631}(t)}function ao(t,i,s=0){return(t-(2*Math.round(i)-s))%(2*Math.round(i))}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${ho(t)}${ho(i)}${ho(s)}${ho(e)}`:`#${ho(t)}${ho(i)}${ho(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(qn||={}),(t=>{function i(t,i){return so=Math.round(255*i),[Vn,to,io]=Xn.toChannels(t.rgba),{css:qn.toCss(Vn,to,io,so),rgba:qn.toRgba(Vn,to,io,so)}}t.blend=function(t,i){if(1==(so=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:qn.toCss(Vn=h+Math.round(((i.rgba>>24&255)-h)*so),to=r+Math.round((s-r)*so),io=n+Math.round((e-n)*so)),rgba:qn.toRgba(Vn,to,io)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=Xn.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return qn.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Vn,to,io]=Xn.toChannels(i),{css:qn.toCss(Vn,to,io),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(so=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(jn||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return Vn=parseInt(t.slice(1,2).repeat(2),16),to=parseInt(t.slice(2,3).repeat(2),16),io=parseInt(t.slice(3,4).repeat(2),16),qn.toColor(Vn,to,io);case 5:return Vn=parseInt(t.slice(1,2).repeat(2),16),to=parseInt(t.slice(2,3).repeat(2),16),io=parseInt(t.slice(3,4).repeat(2),16),so=parseInt(t.slice(4,5).repeat(2),16),qn.toColor(Vn,to,io,so);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return qn.toColor(Vn=parseInt(e[1]),to=parseInt(e[2]),io=parseInt(e[3]),so=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Vn,to,io,so]=i.getImageData(0,0,1,1).data,255!==so)throw Error("css.toColor: Unsupported css format");return{rgba:qn.toRgba(Vn,to,io,so),css:t}}})(Yn||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(Zn||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=ro(Zn.relativeLuminance2(n,o,l),Zn.relativeLuminance2(e,h,r));for(;a<s&&(n>0||o>0||l>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),l-=Math.max(0,Math.ceil(.1*l)),a=ro(Zn.relativeLuminance2(n,o,l),Zn.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=ro(Zn.relativeLuminance2(n,o,l),Zn.relativeLuminance2(e,h,r));for(;a<s&&(n<255||o<255||l<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),l=Math.min(255,l+Math.ceil(.1*(255-l))),a=ro(Zn.relativeLuminance2(n,o,l),Zn.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}t.blend=function(t,i){if(1==(so=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return qn.toRgba(Vn=h+Math.round(((i>>24&255)-h)*so),to=r+Math.round((s-r)*so),io=n+Math.round((e-n)*so))},t.ensureContrastRatio=function(t,e,h){let r=Zn.relativeLuminance(t>>8),n=Zn.relativeLuminance(e>>8);if(ro(r,n)<h){if(n<r){let n=i(t,e,h),o=ro(r,Zn.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ro(r,Zn.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=ro(r,Zn.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>ro(r,Zn.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(Xn||={});var uo,co=0,Ao=0,fo=!1,go=!1,wo=!1,po=0,Co=class{constructor(t,i,s,e,h,r){this._terminal=t,this._optionService=i,this._selectionRenderModel=s,this._decorationService=e,this._coreBrowserService=h,this._themeService=r,this.result={fg:0,bg:0,ext:0}}resolve(t,i,s,e){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=268435456&t.bg?t.extended.ext:0,Ao=0,co=0,go=!1,fo=!1,wo=!1,uo=this._themeService.colors,po=0,0!==t.getCode()&&4===t.extended.underlineStyle&&(po=i*e%(2*Math.round(Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15))))),this._decorationService.forEachDecorationAtCell(i,s,"bottom",(t=>{t.backgroundColorRGB&&(Ao=t.backgroundColorRGB.rgba>>8&16777215,go=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,fo=!0)})),wo=this._selectionRenderModel.isCellSelected(this._terminal,i,s)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:Ao=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:Ao=(16777215&this.result.fg)<<8|255;break;default:Ao=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:Ao=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:Ao=(16777215&this.result.bg)<<8|255}Ao=Xn.blend(Ao,4294967040&(this._coreBrowserService.isFocused?uo.selectionBackgroundOpaque:uo.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else Ao=(this._coreBrowserService.isFocused?uo.selectionBackgroundOpaque:uo.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(go=!0,uo.selectionForeground&&(co=uo.selectionForeground.rgba>>8&16777215,fo=!0),lo(t.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))co=(this._coreBrowserService.isFocused?uo.selectionBackgroundOpaque:uo.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:co=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:co=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:co=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:co=(16777215&this.result.fg)<<8|255;break;default:co=this._themeService.colors.foreground.rgba}co=Xn.blend(co,4294967040&(this._coreBrowserService.isFocused?uo.selectionBackgroundOpaque:uo.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}fo=!0}}this._decorationService.forEachDecorationAtCell(i,s,"top",(t=>{t.backgroundColorRGB&&(Ao=t.backgroundColorRGB.rgba>>8&16777215,go=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,fo=!0)})),go&&(Ao=wo?-16777216&t.bg&-134217729|Ao|50331648:-16777216&t.bg|Ao|50331648),fo&&(co=-16777216&t.fg&-67108865|co|50331648),67108864&this.result.fg&&(go&&!fo&&(co=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&uo.background.rgba>>8|50331648,fo=!0),!go&&fo&&(Ao=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&uo.foreground.rgba>>8|50331648,go=!0)),uo=void 0,this.result.bg=go?Ao:this.result.bg,this.result.fg=fo?co:this.result.fg,this.result.ext&=536870911,this.result.ext|=po<<29&3758096384}},mo=Wn||zn?"bottom":"ideographic",Io={"▀":[{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}]},vo={"░":[[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]]},Bo={"─":{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,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"║":{1:t=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,i)=>`M.5,1 L.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╓":{1:t=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,i)=>`M1,${.5-i} L${.5-t},${.5-i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1`},"╕":{1:(t,i)=>`M0,${.5-i} L.5,${.5-i} L.5,1 M0,${.5+i} L.5,${.5+i}`},"╖":{1:t=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,i)=>`M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M0,${.5-i} L${.5+t},${.5-i} L${.5+t},1`},"╘":{1:(t,i)=>`M.5,0 L.5,${.5+i} L1,${.5+i} M.5,${.5-i} L1,${.5-i}`},"╙":{1:t=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,i)=>`M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0 M1,${.5+i} L${.5-t},${.5+i} L${.5-t},0`},"╛":{1:(t,i)=>`M0,${.5+i} L.5,${.5+i} L.5,0 M0,${.5-i} L.5,${.5-i}`},"╜":{1:t=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,i)=>`M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M0,${.5+i} L${.5+t},${.5+i} L${.5+t},0`},"╞":{1:(t,i)=>`M.5,0 L.5,1 M.5,${.5-i} L1,${.5-i} M.5,${.5+i} L1,${.5+i}`},"╟":{1:t=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,i)=>`M${.5-t},0 L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1 M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0`},"╡":{1:(t,i)=>`M.5,0 L.5,1 M0,${.5-i} L.5,${.5-i} M0,${.5+i} L.5,${.5+i}`},"╢":{1:t=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,i)=>`M${.5+t},0 L${.5+t},1 M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0`},"╤":{1:(t,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i} M.5,${.5+i} L.5,1`},"╥":{1:t=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,i)=>`M0,${.5-i} L1,${.5-i} M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1`},"╧":{1:(t,i)=>`M.5,0 L.5,${.5-i} M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╨":{1:t=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,i)=>`M0,${.5+i} L1,${.5+i} M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M1,${.5-i} L${.5+t},${.5-i} L${.5+t},0`},"╪":{1:(t,i)=>`M.5,0 L.5,1 M0,${.5-i} L1,${.5-i} M0,${.5+i} L1,${.5+i}`},"╫":{1:t=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,i)=>`M0,${.5+i} L${.5-t},${.5+i} L${.5-t},1 M1,${.5+i} L${.5+t},${.5+i} L${.5+t},1 M0,${.5-i} L${.5-t},${.5-i} L${.5-t},0 M1,${.5-i} L${.5+t},${.5-i} 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,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,1,.5`},"╮":{1:(t,i)=>`M.5,1 L.5,${.5+i/.15*.5} C.5,${.5+i/.15*.5},.5,.5,0,.5`},"╯":{1:(t,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,0,.5`},"╰":{1:(t,i)=>`M.5,0 L.5,${.5-i/.15*.5} C.5,${.5-i/.15*.5},.5,.5,1,.5`}},Mo={"":{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}};Mo[""]=Mo[""],Mo[""]=Mo[""];var yo=new Map;function Qo(t,i,s=0){return Math.max(Math.min(t,i),s)}var Eo={C:(t,i)=>t.bezierCurveTo(i[0],i[1],i[2],i[3],i[4],i[5]),L:(t,i)=>t.lineTo(i[0],i[1]),M:(t,i)=>t.moveTo(i[0],i[1])};function bo(t,i,s,e,h,r,n,o=0,l=0){let a=t.map((t=>parseFloat(t)||parseInt(t)));if(a.length<2)throw Error("Too few arguments for instruction");for(let t=0;t<a.length;t+=2)a[t]*=i-o*n-l*n,r&&0!==a[t]&&(a[t]=Qo(Math.round(a[t]+.5)-.5,i,0)),a[t]+=e+o*n;for(let t=1;t<a.length;t+=2)a[t]*=s,r&&0!==a[t]&&(a[t]=Qo(Math.round(a[t]+.5)-.5,s,0)),a[t]+=h;return a}var ko,xo=class{constructor(){this._data={}}set(t,i,s){this._data[t]||(this._data[t]={}),this._data[t][i]=s}get(t,i){return this._data[t]?this._data[t][i]:void 0}clear(){this._data={}}},Do=class{constructor(){this._data=new xo}set(t,i,s,e,h){this._data.get(t,i)||this._data.set(t,i,new xo),this._data.get(t,i).set(s,e,h)}get(t,i,s,e){return this._data.get(t,i)?.get(s,e)}clear(){this._data.clear()}},Lo=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 i=0,s=0,e=t.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,i=Math.max(1,performance.now()-i),s=Math.max(i,s),h=t.timeRemaining(),1.5*s>h)return e-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(e-i))}ms`),void this._start();e=h}this.clear()}},So=!Pn&&"requestIdleCallback"in window?class extends Lo{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends Lo{_requestCallback(t){return setTimeout((()=>t(this._createDeadline(16))))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let i=performance.now()+t;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},_o=class t{constructor(){this.fg=0,this.bg=0,this.extended=new $o}static toColorRGB(t){return[t>>>16&255,t>>>8&255,255&t]}static fromColorRGB(t){return(255&t[0])<<16|(255&t[1])<<8|255&t[2]}clone(){let i=new t;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},$o=class t{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new t(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},Ro=globalThis.performance&&"function"==typeof globalThis.performance.now,No=class t{static create(i){return new t(i)}constructor(t){this._now=Ro&&!1===t?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(t=>{function i(t){return(i,s=null,e)=>{let h,r=!1;return h=t((t=>{if(!r)return h?h.dispose():r=!0,i.call(s,t)}),null,e),r&&h.dispose(),h}}function s(t,i,s){return h(((s,e=null,h)=>t((t=>s.call(e,i(t))),null,h)),s)}function e(t,i,s){return h(((s,e=null,h)=>t((t=>i(t)&&s.call(e,t)),null,h)),s)}function h(t,i){let s,e=new Ko({onWillAddFirstListener(){s=t(e.fire,e)},onDidRemoveLastListener(){s?.dispose()}});return i?.add(e),e.event}function r(t,i,s=100,e=!1,h=!1,r,n){let o,l,a,u,c=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{c++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),u=()=>{let t=l;l=void 0,a=void 0,(!e||c>1)&&f.fire(t),c=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(u,s)):void 0===a&&(a=0,queueMicrotask(u))}))},onWillRemoveListener(){h&&c>0&&u?.()},onDidRemoveLastListener(){u=void 0,o.dispose()}},f=new Ko(A);return n?.add(f),f.event}t.None=()=>Un.None,t.defer=function(t,i){return r(t,(()=>{}),0,void 0,!0,void 0,i)},t.once=i,t.map=s,t.forEach=function(t,i,s){return h(((s,e=null,h)=>t((t=>{i(t),s.call(e,t)}),null,h)),s)},t.filter=e,t.signal=function(t){return t},t.any=function(...t){return(i,s=null,e)=>{let h=Nn(...t.map((t=>t((t=>i.call(s,t))))));return function(t,i){return i instanceof Array?i.push(t):i&&i.add(t),t}(h,e)}},t.reduce=function(t,i,e,h){let r=e;return s(t,(t=>(r=i(r,t),r)),h)},t.debounce=r,t.accumulate=function(i,s=0,e){return t.debounce(i,((t,i)=>t?(t.push(i),t):[i]),s,void 0,!0,void 0,e)},t.latch=function(t,i=(t,i)=>t===i,s){let h,r=!0;return e(t,(t=>{let s=r||!i(t,h);return r=!1,h=t,s}),s)},t.split=function(i,s,e){return[t.filter(i,s,e),t.filter(i,(t=>!s(t)),e)]},t.buffer=function(t,i=!1,s=[],e){let h=s.slice(),r=t((t=>{h?h.push(t):o.fire(t)}));e&&e.add(r);let n=()=>{h?.forEach((t=>o.fire(t))),h=null},o=new Ko({onWillAddFirstListener(){r||(r=t((t=>o.fire(t))),e&&e.add(r))},onDidAddFirstListener(){h&&(i?setTimeout(n):n())},onDidRemoveLastListener(){r&&r.dispose(),r=null}});return e&&e.add(o),o.event},t.chain=function(t,i){return(s,e,h)=>{let r=i(new o);return t((function(t){let i=r.evaluate(t);i!==n&&s.call(e,i)}),void 0,h)}};let n=Symbol("HaltChainable");class o{constructor(){this.steps=[]}map(t){return this.steps.push(t),this}forEach(t){return this.steps.push((i=>(t(i),i))),this}filter(t){return this.steps.push((i=>t(i)?i:n)),this}reduce(t,i){let s=i;return this.steps.push((i=>(s=t(s,i),s))),this}latch(t=(t,i)=>t===i){let i,s=!0;return this.steps.push((e=>{let h=s||!t(e,i);return s=!1,i=e,h?e:n})),this}evaluate(t){for(let i of this.steps)if((t=i(t))===n)break;return t}}t.fromNodeEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Ko({onWillAddFirstListener:()=>t.on(i,e),onDidRemoveLastListener:()=>t.removeListener(i,e)});return h.event},t.fromDOMEventEmitter=function(t,i,s=t=>t){let e=(...t)=>h.fire(s(...t)),h=new Ko({onWillAddFirstListener:()=>t.addEventListener(i,e),onDidRemoveLastListener:()=>t.removeEventListener(i,e)});return h.event},t.toPromise=function(t){return new Promise((s=>i(t)(s)))},t.fromPromise=function(t){let i=new Ko;return t.then((t=>{i.fire(t)}),(()=>{i.fire(void 0)})).finally((()=>{i.dispose()})),i.event},t.forward=function(t,i){return t((t=>i.fire(t)))},t.runAndSubscribe=function(t,i,s){return i(s),t((t=>i(t)))};class l{constructor(t,i){this._observable=t,this._counter=0,this._hasChanged=!1,this.emitter=new Ko({onWillAddFirstListener:()=>{t.addObserver(this)},onDidRemoveLastListener:()=>{t.removeObserver(this)}}),i&&i.add(this.emitter)}beginUpdate(t){this._counter++}handlePossibleChange(t){}handleChange(t,i){this._hasChanged=!0}endUpdate(t){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}t.fromObservable=function(t,i){return new l(t,i).emitter.event},t.fromObservableLight=function(t){return(i,s,e)=>{let h=0,r=!1,n={beginUpdate(){h++},endUpdate(){h--,0===h&&(t.reportChanges(),r&&(r=!1,i.call(s)))},handlePossibleChange(){},handleChange(){r=!0}};t.addObserver(n),t.reportChanges();let o={dispose(){t.removeObserver(n)}};return e instanceof Tn?e.add(o):Array.isArray(e)&&e.push(o),o}}})(ko||={});var Fo=class t{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${t._idPool++}`,t.all.add(this)}start(t){this._stopWatch=new No,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Fo.all=new Set,Fo._idPool=0;var Ho=Fo,To=class t{constructor(i,s,e=(t._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=e,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let e=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,e+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[t,e]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${e}):`;console.warn(h),console.warn(t);let r=new Jo(h,t);this._errorHandler(r)}return()=>{let i=this._stacks.get(t.value)||0;this._stacks.set(t.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,e]of this._stacks)(!t||i<e)&&(t=[s,e],i=e);return t}};To._idPool=1;var Uo,Go=To,Po=class t{constructor(t){this.value=t}static create(){return new t(Error().stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Jo=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Oo=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Wo=0,zo=class{constructor(t){this.value=t,this.id=Wo++}},Ko=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Go(t?.onListenerError??kn,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Ho(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,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let t=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(t);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new Oo(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||kn)(s),Un.None}if(this._disposed)return Un.None;i&&(t=t.bind(i));let e,h=new zo(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Po.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof zo?(this._deliveryQueue??=new qo,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Fn((()=>{e?.(),this._removeListener(h)}));return s instanceof Tn?s.add(r):Array.isArray(s)&&s.push(r),r},this._event}_removeListener(t){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let i=this._listeners,s=i.indexOf(t);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let e=this._deliveryQueue.current===this;if(2*this._size<=i.length){let t=0;for(let s=0;s<i.length;s++)i[s]?i[t++]=i[s]:e&&(this._deliveryQueue.end--,t<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=t}}_deliver(t,i){if(!t)return;let s=this._options?.onListenerError||kn;if(s)try{t.value(i)}catch(t){s(t)}else t.value(i)}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[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 zo)this._deliver(this._listeners,t);else{let i=this._deliveryQueue;i.enqueue(this,t,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},qo=class{constructor(){this.i=-1,this.end=0}enqueue(t,i,s){this.i=0,this.end=s,this.current=t,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jo={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}},Yo=class t{constructor(t,i,s){this._document=t,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new Do,this._cacheMapCombined=new Do,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new _o,this._textureSize=512,this._onAddTextureAtlasCanvas=new Ko,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new Ko,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Vo(t,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=no(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new So;for(let i=33;i<126;i++)t.enqueue((()=>{if(!this._cacheMap.get(i,0,0,0)){let t=this._drawToCache(i,0,0,0,!1,void 0);this._cacheMap.set(i,0,0,0,t)}}))}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(t.maxAtlasPages&&this._pages.length>=Math.max(4,t.maxAtlasPages)){let i=this._pages.filter((i=>2*i.canvas.width<=(t.maxTextureSize||4096))).sort(((t,i)=>i.canvas.width!==t.canvas.width?i.canvas.width-t.canvas.width:i.percentageUsed-t.percentageUsed)),s=-1,e=0;for(let t=0;t<i.length;t++)if(i[t].canvas.width!==e)s=t,e=i[t].canvas.width;else if(t-s==3)break;let h=i.slice(s,s+4),r=h.map((t=>t.glyphs[0].texturePage)).sort(((t,i)=>t>i?1:-1)),n=this._mergePages(h,this.pages.length-h.length);n.version++;for(let t=r.length-1;t>=0;t--)this._deletePage(r[t]);this.pages.push(n),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(n.canvas)}let i=new Zo(this._document,this._textureSize);return this._pages.push(i),this._activePages.push(i),this._onAddTextureAtlasCanvas.fire(i.canvas),i}_mergePages(t,i){let s=2*t[0].canvas.width,e=new Zo(this._document,s,t);for(let[h,r]of t.entries()){let t=h*r.canvas.width%s,n=Math.floor(h/2)*r.canvas.height;e.ctx.drawImage(r.canvas,t,n);for(let e of r.glyphs)e.texturePage=i,e.sizeClipSpace.x=e.size.x/s,e.sizeClipSpace.y=e.size.y/s,e.texturePosition.x+=t,e.texturePosition.y+=n,e.texturePositionClipSpace.x=e.texturePosition.x/s,e.texturePositionClipSpace.y=e.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(r.canvas);let o=this._activePages.indexOf(r);-1!==o&&this._activePages.splice(o,1)}return e}_deletePage(t){this._pages.splice(t,1);for(let i=t;i<this._pages.length;i++){let t=this._pages[i];for(let i of t.glyphs)i.texturePage--;t.version++}}getRasterizedGlyphCombinedChar(t,i,s,e,h,r){return this._getFromCacheMap(this._cacheMapCombined,t,i,s,e,h,r)}getRasterizedGlyph(t,i,s,e,h,r){return this._getFromCacheMap(this._cacheMap,t,i,s,e,h,r)}_getFromCacheMap(t,i,s,e,h,r,n){return(Uo=t.get(i,s,e,h))||(Uo=this._drawToCache(i,s,e,h,r,n),t.set(i,s,e,h,Uo)),Uo}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,i,s,e){if(this._config.allowTransparency)return eo;let h;switch(t){case 16777216:case 33554432:h=this._getColorFromAnsiIndex(i);break;case 50331648:let t=_o.toColorRGB(i);h=qn.toColor(t[0],t[1],t[2]);break;default:h=s?jn.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(h=jn.opaque(h)),h}_getForegroundColor(t,i,s,e,h,r,n,o,l,a){let u,c=this._getMinimumContrastColor(t,i,s,e,h,r,n,l,o,a);if(c)return c;switch(h){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&r<8&&(r+=8),u=this._getColorFromAnsiIndex(r);break;case 50331648:let t=_o.toColorRGB(r);u=qn.toColor(t[0],t[1],t[2]);break;default:u=n?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(u=jn.opaque(u)),o&&(u=jn.multiplyOpacity(u,.5)),u}_resolveBackgroundRgba(t,i,s){switch(t){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(t,i,s,e){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&e&&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(t,i,s,e,h,r,n,o,l,a){if(1===this._config.minimumContrastRatio||a)return;let u=this._getContrastCache(l),c=u.getColor(t,e);if(void 0!==c)return c||void 0;let A=this._resolveBackgroundRgba(i,s,n),f=this._resolveForegroundRgba(h,r,n,o),d=Xn.ensureContrastRatio(A,f,this._config.minimumContrastRatio/(l?2:1));if(!d)return void u.setColor(t,e,null);let g=qn.toColor(d>>24&255,d>>16&255,d>>8&255);return u.setColor(t,e,g),g}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(i,s,e,h,r,n){let o="number"==typeof i?String.fromCharCode(i):i;n&&this._tmpCanvas.parentElement!==n&&(this._tmpCanvas.style.display="none",n.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(o.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let a=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<a&&(this._tmpCanvas.height=a),this._tmpCtx.save(),this._workAttributeData.fg=e,this._workAttributeData.bg=s,this._workAttributeData.extended.ext=h,this._workAttributeData.isInvisible())return jo;let u=!!this._workAttributeData.isBold(),c=!!this._workAttributeData.isInverse(),A=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),d=!!this._workAttributeData.isUnderline(),g=!!this._workAttributeData.isStrikethrough(),w=!!this._workAttributeData.isOverline(),p=this._workAttributeData.getFgColor(),C=this._workAttributeData.getFgColorMode(),m=this._workAttributeData.getBgColor(),I=this._workAttributeData.getBgColorMode();if(c){let t=p;p=m,m=t;let i=C;C=I,I=i}let v=this._getBackgroundColor(I,m,c,A);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=v.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over",this._tmpCtx.font=`${f?"italic":""} ${u?this._config.fontWeightBold:this._config.fontWeight} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=mo;let B=1===o.length&&oo(o.charCodeAt(0)),M=1===o.length&&function(t){return 57520<=t&&t<=57527}(o.charCodeAt(0)),y=this._getForegroundColor(s,I,m,e,C,p,c,A,u,lo(o.charCodeAt(0)));this._tmpCtx.fillStyle=y.css;let Q=M?0:4,E=!1;!1!==this._config.customGlyphs&&(E=function(t,i,s,e,h,r,n,o){let l=Io[i];if(l)return function(t,i,s,e,h,r){for(let n=0;n<i.length;n++){let o=i[n],l=h/8,a=r/8;t.fillRect(s+o.x*l,e+o.y*a,o.w*l,o.h*a)}}(t,l,s,e,h,r),!0;let a=vo[i];if(a)return function(t,i,s,e,h,r){let n=yo.get(i);n||(n=new Map,yo.set(i,n));let o=t.fillStyle;if("string"!=typeof o)throw Error(`Unexpected fillStyle type "${o}"`);let l=n.get(o);if(!l){let s=i[0].length,e=i.length,h=t.canvas.ownerDocument.createElement("canvas");h.width=s,h.height=e;let r,a,u,c,A=no(h.getContext("2d")),f=new ImageData(s,e);if(o.startsWith("#"))r=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),u=parseInt(o.slice(5,7),16),c=o.length>7&&parseInt(o.slice(7,9),16)||1;else{if(!o.startsWith("rgba"))throw Error(`Unexpected fillStyle color format "${o}" when drawing pattern glyph`);[r,a,u,c]=o.substring(5,o.length-1).split(",").map((t=>parseFloat(t)))}for(let t=0;t<e;t++)for(let e=0;e<s;e++)f.data[4*(t*s+e)]=r,f.data[4*(t*s+e)+1]=a,f.data[4*(t*s+e)+2]=u,f.data[4*(t*s+e)+3]=i[t][e]*(255*c);A.putImageData(f,0,0),l=no(t.createPattern(h,null)),n.set(o,l)}t.fillStyle=l,t.fillRect(s,e,h,r)}(t,a,s,e,h,r),!0;let u=Bo[i];if(u)return function(t,i,s,e,h,r,n){t.strokeStyle=t.fillStyle;for(let[o,l]of Object.entries(i)){let i;t.beginPath(),t.lineWidth=n*Number.parseInt(o),i="function"==typeof l?l(.15,.15/r*h):l;for(let o of i.split(" ")){let i=o[0],l=Eo[i];if(!l){console.error(`Could not find drawing instructions for "${i}"`);continue}let a=o.substring(1).split(",");!a[0]||!a[1]||l(t,bo(a,h,r,s,e,!0,n))}t.stroke(),t.closePath()}}(t,u,s,e,h,r,o),!0;let c=Mo[i];return!!c&&(function(t,i,s,e,h,r,n,o){let l=new Path2D;l.rect(s,e,h,r),t.clip(l),t.beginPath();let a=n/12;t.lineWidth=o*a;for(let n of i.d.split(" ")){let l=n[0],u=Eo[l];if(!u){console.error(`Could not find drawing instructions for "${l}"`);continue}let c=n.substring(1).split(",");!c[0]||!c[1]||u(t,bo(c,h,r,s,e,!1,o,(i.leftPadding??0)*(a/2),(i.rightPadding??0)*(a/2)))}1===i.type?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}(t,c,s,e,h,r,n,o),!0)}(this._tmpCtx,o,Q,Q,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let b,k=!B;if(b="number"==typeof i?this._unicodeService.wcwidth(i):this._unicodeService.getStringCellWidth(i),d){this._tmpCtx.save();let t=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),i=t%2==1?.5:0;if(this._tmpCtx.lineWidth=t,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())k=!1,this._tmpCtx.strokeStyle=`rgb(${_o.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{k=!1;let t=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&t<8&&(t+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(t).css}this._tmpCtx.beginPath();let s=Q,e=Math.ceil(Q+this._config.deviceCharHeight)-i-(r?2*t:0),h=e+t,n=e+2*t,l=this._workAttributeData.getUnderlineVariantOffset();for(let r=0;r<b;r++){this._tmpCtx.save();let o=s+r*this._config.deviceCellWidth,a=s+(r+1)*this._config.deviceCellWidth,u=o+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(a,e),this._tmpCtx.moveTo(o,n),this._tmpCtx.lineTo(a,n);break;case 3:let s=t<=1?n:Math.ceil(Q+this._config.deviceCharHeight-t/2)-i,r=t<=1?e:Math.ceil(Q+this._config.deviceCharHeight+t/2)-i,c=new Path2D;c.rect(o,e,this._config.deviceCellWidth,n-e),this._tmpCtx.clip(c),this._tmpCtx.moveTo(o-this._config.deviceCellWidth/2,h),this._tmpCtx.bezierCurveTo(o-this._config.deviceCellWidth/2,r,o,r,o,h),this._tmpCtx.bezierCurveTo(o,s,u,s,u,h),this._tmpCtx.bezierCurveTo(u,r,a,r,a,h),this._tmpCtx.bezierCurveTo(a,s,a+this._config.deviceCellWidth/2,s,a+this._config.deviceCellWidth/2,h);break;case 4:let A=0===l?0:l>=t?2*t-l:t-l;0==!(l>=t)||0===A?(this._tmpCtx.setLineDash([Math.round(t),Math.round(t)]),this._tmpCtx.moveTo(o+A,e),this._tmpCtx.lineTo(a,e)):(this._tmpCtx.setLineDash([Math.round(t),Math.round(t)]),this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(o+A,e),this._tmpCtx.moveTo(o+A+t,e),this._tmpCtx.lineTo(a,e)),l=ao(a-o,t,l);break;case 5:let f=.3,d=a-o,g=Math.floor(.6*d),w=Math.floor(f*d);this._tmpCtx.setLineDash([g,w,d-g-w]),this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(a,e);break;default:this._tmpCtx.moveTo(o,e),this._tmpCtx.lineTo(a,e)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!E&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==o){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let i=this._tmpCtx.measureText(o);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in i&&i.actualBoundingBoxDescent>0){this._tmpCtx.save();let i=new Path2D;i.rect(s,e-Math.ceil(t/2),this._config.deviceCellWidth*b,n-e+Math.ceil(t/2)),this._tmpCtx.clip(i),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=v.css,this._tmpCtx.strokeText(o,Q,Q+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(w){let t=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),i=t%2==1?.5:0;this._tmpCtx.lineWidth=t,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(Q,Q+i),this._tmpCtx.lineTo(Q+this._config.deviceCharWidth*b,Q+i),this._tmpCtx.stroke()}if(E||this._tmpCtx.fillText(o,Q,Q+this._config.deviceCharHeight),"_"===o&&!this._config.allowTransparency){let t=Xo(this._tmpCtx.getImageData(Q,Q,this._config.deviceCellWidth,this._config.deviceCellHeight),v,y,k);if(t)for(let i=1;i<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=v.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(o,Q,Q+this._config.deviceCharHeight-i),t=Xo(this._tmpCtx.getImageData(Q,Q,this._config.deviceCellWidth,this._config.deviceCellHeight),v,y,k),t);i++);}if(g){let t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(Q,Q+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(Q+this._config.deviceCharWidth*b,Q+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let x,D=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(x=this._config.allowTransparency?function(t){for(let i=0;i<t.data.length;i+=4)if(t.data[i+3]>0)return!1;return!0}(D):Xo(D,v,y,k),x)return jo;let L,S,_=this._findGlyphBoundingBox(D,this._workBoundingBox,l,M,E,Q);for(;;){if(0===this._activePages.length){let t=this._createNewPage();L=t,S=t.currentRow,S.height=_.size.y;break}L=this._activePages[this._activePages.length-1],S=L.currentRow;for(let t of this._activePages)_.size.y<=t.currentRow.height&&(L=t,S=t.currentRow);for(let t=this._activePages.length-1;t>=0;t--)for(let i of this._activePages[t].fixedRows)i.height<=S.height&&_.size.y<=i.height&&(L=this._activePages[t],S=i);if(_.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Zo(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),L=this._overflowSizePage,S=this._overflowSizePage.currentRow,S.x+_.size.x>=L.canvas.width&&(S.x=0,S.y+=S.height,S.height=0);break}if(S.y+_.size.y>=L.canvas.height||S.height>_.size.y+2){let i=!1;if(L.currentRow.y+L.currentRow.height+_.size.y>=L.canvas.height){let s;for(let t of this._activePages)if(t.currentRow.y+t.currentRow.height+_.size.y<t.canvas.height){s=t;break}if(s)L=s;else if(t.maxAtlasPages&&this._pages.length>=t.maxAtlasPages&&S.y+_.size.y<=L.canvas.height&&S.height>=_.size.y&&S.x+_.size.x<=L.canvas.width)i=!0;else{let t=this._createNewPage();L=t,S=t.currentRow,S.height=_.size.y,i=!0}}i||(L.currentRow.height>0&&L.fixedRows.push(L.currentRow),S={x:0,y:L.currentRow.y+L.currentRow.height,height:_.size.y},L.fixedRows.push(S),L.currentRow={x:0,y:S.y+S.height,height:0})}if(S.x+_.size.x<=L.canvas.width)break;S===L.currentRow?(S.x=0,S.y+=S.height,S.height=0):L.fixedRows.splice(L.fixedRows.indexOf(S),1)}return _.texturePage=this._pages.indexOf(L),_.texturePosition.x=S.x,_.texturePosition.y=S.y,_.texturePositionClipSpace.x=S.x/L.canvas.width,_.texturePositionClipSpace.y=S.y/L.canvas.height,_.sizeClipSpace.x/=L.canvas.width,_.sizeClipSpace.y/=L.canvas.height,S.height=Math.max(S.height,_.size.y),S.x+=_.size.x,L.ctx.putImageData(D,_.texturePosition.x-this._workBoundingBox.left,_.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,_.size.x,_.size.y),L.addGlyph(_),L.version++,_}_findGlyphBoundingBox(t,i,s,e,h,r){i.top=0;let n=e?this._config.deviceCellHeight:this._tmpCanvas.height,o=e?this._config.deviceCellWidth:s,l=!1;for(let s=0;s<n;s++){for(let e=0;e<o;e++)if(0!==t.data[s*this._tmpCanvas.width*4+4*e+3]){i.top=s,l=!0;break}if(l)break}i.left=0,l=!1;for(let s=0;s<r+o;s++){for(let e=0;e<n;e++)if(0!==t.data[e*this._tmpCanvas.width*4+4*s+3]){i.left=s,l=!0;break}if(l)break}i.right=o,l=!1;for(let s=r+o-1;s>=r;s--){for(let e=0;e<n;e++)if(0!==t.data[e*this._tmpCanvas.width*4+4*s+3]){i.right=s,l=!0;break}if(l)break}i.bottom=n,l=!1;for(let s=n-1;s>=0;s--){for(let e=0;e<o;e++)if(0!==t.data[s*this._tmpCanvas.width*4+4*e+3]){i.bottom=s,l=!0;break}if(l)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+r+(e||h?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-i.top+r+(e||h?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Zo=class{constructor(t,i,s){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],s)for(let t of s)this._glyphs.push(...t.glyphs),this._usedPixels+=t._usedPixels;this.canvas=Vo(t,i,i),this.ctx=no(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 Xo(t,i,s,e){let h=i.rgba>>>24,r=i.rgba>>>16&255,n=i.rgba>>>8&255,o=s.rgba>>>16&255,l=s.rgba>>>8&255,a=Math.floor((Math.abs(h-(s.rgba>>>24))+Math.abs(r-o)+Math.abs(n-l))/12),u=!0;for(let i=0;i<t.data.length;i+=4)t.data[i]===h&&t.data[i+1]===r&&t.data[i+2]===n||e&&Math.abs(t.data[i]-h)+Math.abs(t.data[i+1]-r)+Math.abs(t.data[i+2]-n)<a?t.data[i+3]=0:u=!1;return u}function Vo(t,i,s){let e=t.createElement("canvas");return e.width=i,e.height=s,e}function tl(t,i){for(let s=0;s<t.colors.ansi.length;s++)if(t.colors.ansi[s].rgba!==i.colors.ansi[s].rgba)return!1;return t.devicePixelRatio===i.devicePixelRatio&&t.customGlyphs===i.customGlyphs&&t.lineHeight===i.lineHeight&&t.letterSpacing===i.letterSpacing&&t.fontFamily===i.fontFamily&&t.fontSize===i.fontSize&&t.fontWeight===i.fontWeight&&t.fontWeightBold===i.fontWeightBold&&t.allowTransparency===i.allowTransparency&&t.deviceCharWidth===i.deviceCharWidth&&t.deviceCharHeight===i.deviceCharHeight&&t.drawBoldTextInBrightColors===i.drawBoldTextInBrightColors&&t.minimumContrastRatio===i.minimumContrastRatio&&t.colors.foreground.rgba===i.colors.foreground.rgba&&t.colors.background.rgba===i.colors.background.rgba}var il=[];function sl(t,i,s,e,h,r,n,o,l){let a=function(t,i,s,e,h,r,n,o){let l={foreground:r.foreground,background:r.background,cursor:eo,cursorAccent:eo,selectionForeground:eo,selectionBackgroundTransparent:eo,selectionBackgroundOpaque:eo,selectionInactiveBackgroundTransparent:eo,selectionInactiveBackgroundOpaque:eo,overviewRulerBorder:eo,scrollbarSliderBackground:eo,scrollbarSliderHoverBackground:eo,scrollbarSliderActiveBackground:eo,ansi:r.ansi.slice(),contrastCache:r.contrastCache,halfContrastCache:r.halfContrastCache};return{customGlyphs:h.customGlyphs,devicePixelRatio:n,deviceMaxTextureSize:o,letterSpacing:h.letterSpacing,lineHeight:h.lineHeight,deviceCellWidth:t,deviceCellHeight:i,deviceCharWidth:s,deviceCharHeight:e,fontFamily:h.fontFamily,fontSize:h.fontSize,fontWeight:h.fontWeight,fontWeightBold:h.fontWeightBold,allowTransparency:h.allowTransparency,drawBoldTextInBrightColors:h.drawBoldTextInBrightColors,minimumContrastRatio:h.minimumContrastRatio,colors:l}}(e,h,r,n,i,s,o,l);for(let i=0;i<il.length;i++){let s=il[i],e=s.ownedBy.indexOf(t);if(e>=0){if(tl(s.config,a))return s.atlas;1===s.ownedBy.length?(s.atlas.dispose(),il.splice(i,1)):s.ownedBy.splice(e,1);break}}for(let i=0;i<il.length;i++){let s=il[i];if(tl(s.config,a))return s.ownedBy.push(t),s.atlas}let u={atlas:new Yo(document,a,t._core.unicodeService),config:a,ownedBy:[t]};return il.push(u),u.atlas}function el(t){for(let i=0;i<il.length;i++){let s=il[i].ownedBy.indexOf(t);if(-1!==s){1===il[i].ownedBy.length?(il[i].atlas.dispose(),il.splice(i,1)):il[i].ownedBy.splice(s,1);break}}}var hl=600,rl=class{constructor(t,i){this._renderCallback=t,this._coreBrowserService=i,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=hl){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout((()=>{if(this._animationTimeRestarted){let t=hl-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0)return void this._restartInterval(t)}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 t=hl-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(t)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._renderCallback(),this._animationFrame=void 0}))}),hl)}),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 nl(t,i,s){let e=new i.ResizeObserver((i=>{let h=i.find((i=>i.target===t));if(!h)return;if(!("devicePixelContentBoxSize"in h))return e?.disconnect(),void(e=void 0);let r=h.devicePixelContentBoxSize[0].inlineSize,n=h.devicePixelContentBoxSize[0].blockSize;r>0&&n>0&&s(r,n)}));try{e.observe(t,{box:["device-pixel-content-box"]})}catch{e.disconnect(),e=void 0}return Fn((()=>e?.disconnect()))}var ol=class t extends _o{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $o,this.combinedData=""}static fromCharData(i){let s=new t;return s.setFromCharData(i),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(t){return t>65535?String.fromCharCode(55296+((t-=65536)>>10))+String.fromCharCode(t%1024+56320):String.fromCharCode(t)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(2===t[1].length){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let e=t[1].charCodeAt(1);56320<=e&&e<=57343?this.content=1024*(s-55296)+e-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ll=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function al(t,i,s){let e=no(t.createProgram());if(t.attachShader(e,no(ul(t,t.VERTEX_SHADER,i))),t.attachShader(e,no(ul(t,t.FRAGMENT_SHADER,s))),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS))return e;console.error(t.getProgramInfoLog(e)),t.deleteProgram(e)}function ul(t,i,s){let e=no(t.createShader(i));if(t.shaderSource(e,s),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS))return e;console.error(t.getShaderInfoLog(e)),t.deleteShader(e)}var cl,Al=class{constructor(t){this.texture=t,this.version=-1}},fl=11,dl=fl*Float32Array.BYTES_PER_ELEMENT,gl=0,wl=0,pl=0,Cl=class extends Un{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._optionsService=e,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let h=this._gl;void 0===Yo.maxAtlasPages&&(Yo.maxAtlasPages=Math.min(32,no(h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS))),Yo.maxTextureSize=no(h.getParameter(h.MAX_TEXTURE_SIZE))),this._program=no(al(h,"#version 300 es\nlayout (location = 0) in vec2 a_unitquad;\nlayout (location = 1) in vec2 a_cellpos;\nlayout (location = 2) in vec2 a_offset;\nlayout (location = 3) in vec2 a_size;\nlayout (location = 4) in float a_texpage;\nlayout (location = 5) in vec2 a_texcoord;\nlayout (location = 6) in vec2 a_texsize;\n\nuniform mat4 u_projection;\nuniform vec2 u_resolution;\n\nout vec2 v_texcoord;\nflat out int v_texpage;\n\nvoid main() {\n vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_texpage = int(a_texpage);\n v_texcoord = a_texcoord + a_unitquad * a_texsize;\n}",function(t){let i="";for(let s=1;s<t;s++)i+=` else if (v_texpage == ${s}) { outColor = texture(u_texture[${s}], v_texcoord); }`;return`#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${t}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${i}\n}`}(Yo.maxAtlasPages))),this._register(Fn((()=>h.deleteProgram(this._program)))),this._projectionLocation=no(h.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=no(h.getUniformLocation(this._program,"u_resolution")),this._textureLocation=no(h.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=h.createVertexArray(),h.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),n=h.createBuffer();this._register(Fn((()=>h.deleteBuffer(n)))),h.bindBuffer(h.ARRAY_BUFFER,n),h.bufferData(h.ARRAY_BUFFER,r,h.STATIC_DRAW),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let o=new Uint8Array([0,1,2,3]),l=h.createBuffer();this._register(Fn((()=>h.deleteBuffer(l)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,l),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=no(h.createBuffer()),this._register(Fn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,2,h.FLOAT,!1,dl,0),h.vertexAttribDivisor(2,1),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,h.FLOAT,!1,dl,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(3,1),h.enableVertexAttribArray(4),h.vertexAttribPointer(4,1,h.FLOAT,!1,dl,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(4,1),h.enableVertexAttribArray(5),h.vertexAttribPointer(5,2,h.FLOAT,!1,dl,5*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(5,1),h.enableVertexAttribArray(6),h.vertexAttribPointer(6,2,h.FLOAT,!1,dl,7*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(6,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,dl,9*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.useProgram(this._program);let a=new Int32Array(Yo.maxAtlasPages);for(let t=0;t<Yo.maxAtlasPages;t++)a[t]=t;h.uniform1iv(this._textureLocation,a),h.uniformMatrix4fv(this._projectionLocation,!1,ll),this._atlasTextures=[];for(let t=0;t<Yo.maxAtlasPages;t++){let i=new Al(no(h.createTexture()));this._register(Fn((()=>h.deleteTexture(i.texture)))),h.activeTexture(h.TEXTURE0+t),h.bindTexture(h.TEXTURE_2D,i.texture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,h.RGBA,1,1,0,h.RGBA,h.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[t]=i}h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(t,i,s,e,h,r,n,o,l){this._updateCell(this._vertices.attributes,t,i,s,e,h,r,n,o,l)}_updateCell(t,i,s,e,h,r,n,o,l,a){gl=(s*this._terminal.cols+i)*fl,0!==e&&void 0!==e?this._atlas&&(cl=o&&o.length>1?this._atlas.getRasterizedGlyphCombinedChar(o,h,r,n,!1,this._terminal.element):this._atlas.getRasterizedGlyph(e,h,r,n,!1,this._terminal.element),wl=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),h!==a&&cl.offset.x>wl?(t[gl]=-(cl.offset.x-(pl=cl.offset.x-wl))+this._dimensions.device.char.left,t[gl+1]=-cl.offset.y+this._dimensions.device.char.top,t[gl+2]=(cl.size.x-pl)/this._dimensions.device.canvas.width,t[gl+3]=cl.size.y/this._dimensions.device.canvas.height,t[gl+4]=cl.texturePage,t[gl+5]=cl.texturePositionClipSpace.x+pl/this._atlas.pages[cl.texturePage].canvas.width,t[gl+6]=cl.texturePositionClipSpace.y,t[gl+7]=cl.sizeClipSpace.x-pl/this._atlas.pages[cl.texturePage].canvas.width,t[gl+8]=cl.sizeClipSpace.y):(t[gl]=-cl.offset.x+this._dimensions.device.char.left,t[gl+1]=-cl.offset.y+this._dimensions.device.char.top,t[gl+2]=cl.size.x/this._dimensions.device.canvas.width,t[gl+3]=cl.size.y/this._dimensions.device.canvas.height,t[gl+4]=cl.texturePage,t[gl+5]=cl.texturePositionClipSpace.x,t[gl+6]=cl.texturePositionClipSpace.y,t[gl+7]=cl.sizeClipSpace.x,t[gl+8]=cl.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(t,i,s,e){return 1===i&&cl.size.x>Math.ceil(1.5*e)&&void 0!==t&&t>255&&!function(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}(t)&&!oo(t)&&!function(t){return 57344<=t&&t<=63743}(t)}(e,l,0,this._dimensions.device.cell.width)&&(t[gl+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):t.fill(0,gl,gl+fl-1-2)}clear(){let t=this._terminal,i=t.cols*t.rows*fl;this._vertices.count!==i?this._vertices.attributes=new Float32Array(i):this._vertices.attributes.fill(0);let s=0;for(;s<this._vertices.attributesBuffers.length;s++)this._vertices.count!==i?this._vertices.attributesBuffers[s]=new Float32Array(i):this._vertices.attributesBuffers[s].fill(0);this._vertices.count=i,s=0;for(let i=0;i<t.rows;i++)for(let e=0;e<t.cols;e++)this._vertices.attributes[s+9]=e/t.cols,this._vertices.attributes[s+10]=i/t.rows,s+=fl}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 i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let s=this._vertices.attributesBuffers[this._activeBuffer],e=0;for(let i=0;i<t.lineLengths.length;i++){let h=i*this._terminal.cols*fl,r=this._vertices.attributes.subarray(h,h+t.lineLengths[i]*fl);s.set(r,e),e+=r.length}i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,s.subarray(0,e),i.STREAM_DRAW);for(let t=0;t<this._atlas.pages.length;t++)this._atlas.pages[t].version!==this._atlasTextures[t].version&&this._bindAtlasPageTexture(i,this._atlas,t);i.drawElementsInstanced(i.TRIANGLE_STRIP,4,i.UNSIGNED_BYTE,0,e/fl)}setAtlas(t){this._atlas=t;for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(t,i,s){t.activeTexture(t.TEXTURE0+s),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[s].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,i.pages[s].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[s].version=i.pages[s].version}setDimensions(t){this._dimensions=t}},ml=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,i,s,e=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1])return void this.clear();let h=t.buffers.active.ydisp,r=i[1]-h,n=s[1]-h,o=Math.max(r,0),l=Math.min(n,t.rows-1);o>=t.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=e,this.viewportStartRow=r,this.viewportEndRow=n,this.viewportCappedStartRow=o,this.viewportCappedEndRow=l,this.startCol=i[0],this.endCol=s[0])}isCellSelected(t,i,s){return!!this.hasSelection&&(s-=t.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)}},Il=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new ml}resize(t,i){let s=t*i*4;s!==this.cells.length&&(this.cells=new Uint32Array(s),this.lineLengths=new Uint32Array(i))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},vl=8*Float32Array.BYTES_PER_ELEMENT,Bl=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},Ml=0,yl=class extends Un{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._themeService=e,this._vertices=new Bl,this._verticesCursor=new Bl;let h=this._gl;this._program=no(al(h,"#version 300 es\nlayout (location = 0) in vec2 a_position;\nlayout (location = 1) in vec2 a_size;\nlayout (location = 2) in vec4 a_color;\nlayout (location = 3) in vec2 a_unitquad;\n\nuniform mat4 u_projection;\n\nout vec4 v_color;\n\nvoid main() {\n vec2 zeroToOne = a_position + (a_unitquad * a_size);\n gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);\n v_color = a_color;\n}","#version 300 es\nprecision lowp float;\n\nin vec4 v_color;\n\nout vec4 outColor;\n\nvoid main() {\n outColor = v_color;\n}")),this._register(Fn((()=>h.deleteProgram(this._program)))),this._projectionLocation=no(h.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=h.createVertexArray(),h.bindVertexArray(this._vertexArrayObject);let r=new Float32Array([0,0,1,0,0,1,1,1]),n=h.createBuffer();this._register(Fn((()=>h.deleteBuffer(n)))),h.bindBuffer(h.ARRAY_BUFFER,n),h.bufferData(h.ARRAY_BUFFER,r,h.STATIC_DRAW),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let o=new Uint8Array([0,1,2,3]),l=h.createBuffer();this._register(Fn((()=>h.deleteBuffer(l)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,l),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=no(h.createBuffer()),this._register(Fn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,vl,0),h.vertexAttribDivisor(0,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,vl,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,4,h.FLOAT,!1,vl,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(2,1),this._updateCachedColors(e.colors),this._register(this._themeService.onChangeColors((t=>{this._updateCachedColors(t),this._updateViewportRectangle()})))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let i=this._gl;i.useProgram(this._program),i.bindVertexArray(this._vertexArrayObject),i.uniformMatrix4fv(this._projectionLocation,!1,ll),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.bufferData(i.ARRAY_BUFFER,t.attributes,i.DYNAMIC_DRAW),i.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,i.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 i,s,e,h,r,n,o,l,a,u,c,A=this._terminal,f=this._vertices,d=1;for(i=0;i<A.rows;i++){for(e=-1,h=0,r=0,n=!1,s=0;s<A.cols;s++)o=4*(i*A.cols+s),l=t.cells[o+1],a=t.cells[o+2],u=!!(67108864&a),(l!==h||a!==r&&(n||u))&&((0!==h||n&&0!==r)&&(c=8*d++,this._updateRectangle(f,c,r,h,e,s,i)),e=s,h=l,r=a,n=u);(0!==h||n&&0!==r)&&(c=8*d++,this._updateRectangle(f,c,r,h,e,A.cols,i))}f.count=d}updateCursor(t){let i=this._verticesCursor,s=t.cursor;if(!s||"block"===s.style)return void(i.count=0);let e,h=0;("bar"===s.style||"outline"===s.style)&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,s.y*this._dimensions.device.cell.height,"bar"===s.style?s.dpr*s.cursorWidth:s.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===s.style||"outline"===s.style)&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,(s.y+1)*this._dimensions.device.cell.height-s.dpr,s.width*this._dimensions.device.cell.width,s.dpr,this._cursorFloat)),"outline"===s.style&&(e=8*h++,this._addRectangleFloat(i.attributes,e,s.x*this._dimensions.device.cell.width,s.y*this._dimensions.device.cell.height,s.width*this._dimensions.device.cell.width,s.dpr,this._cursorFloat),e=8*h++,this._addRectangleFloat(i.attributes,e,(s.x+s.width)*this._dimensions.device.cell.width-s.dpr,s.y*this._dimensions.device.cell.height,s.dpr,this._dimensions.device.cell.height,this._cursorFloat)),i.count=h}_updateRectangle(t,i,s,e,h,r,n){if(67108864&s)switch(50331648&s){case 16777216:case 33554432:Ml=this._themeService.colors.ansi[255&s].rgba;break;case 50331648:Ml=(16777215&s)<<8;break;default:Ml=this._themeService.colors.foreground.rgba}else switch(50331648&e){case 16777216:case 33554432:Ml=this._themeService.colors.ansi[255&e].rgba;break;case 50331648:Ml=(16777215&e)<<8;break;default:Ml=this._themeService.colors.background.rgba}t.attributes.length<i+4&&(t.attributes=function(t,i){let s=new Float32Array(Math.min(2*t.length,i));for(let i=0;i<t.length;i++)s[i]=t[i];return s}(t.attributes,this._terminal.rows*this._terminal.cols*8)),this._addRectangle(t.attributes,i,h*this._dimensions.device.cell.width,n*this._dimensions.device.cell.height,(r-h)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,(Ml>>24&255)/255,(Ml>>16&255)/255,(Ml>>8&255)/255,1)}_addRectangle(t,i,s,e,h,r,n,o,l,a){t[i]=s/this._dimensions.device.canvas.width,t[i+1]=e/this._dimensions.device.canvas.height,t[i+2]=h/this._dimensions.device.canvas.width,t[i+3]=r/this._dimensions.device.canvas.height,t[i+4]=n,t[i+5]=o,t[i+6]=l,t[i+7]=a}_addRectangleFloat(t,i,s,e,h,r,n){t[i]=s/this._dimensions.device.canvas.width,t[i+1]=e/this._dimensions.device.canvas.height,t[i+2]=h/this._dimensions.device.canvas.width,t[i+3]=r/this._dimensions.device.canvas.height,t[i+4]=n[0],t[i+5]=n[1],t[i+6]=n[2],t[i+7]=n[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(255&t.rgba)/255])}},Ql=class extends Un{constructor(t,i,s,e,h,r,n,o){super(),this._container=i,this._alpha=h,this._coreBrowserService=r,this._optionsService=n,this._themeService=o,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-${s}-layer`),this._canvas.style.zIndex=""+e,this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors((i=>{this._refreshCharAtlas(t,i),this.reset(t)}))),this._register(Fn((()=>{this._canvas.remove()})))}_initCanvas(){this._ctx=no(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,i,s){}handleSelectionChanged(t,i,s,e=!1){}_setTransparency(t,i){if(i===this._alpha)return;let s=this._canvas;this._alpha=i,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,s),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,i){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=sl(t,this._optionsService.rawOptions,i,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,i){this._deviceCellWidth=i.device.cell.width,this._deviceCellHeight=i.device.cell.height,this._deviceCharWidth=i.device.char.width,this._deviceCharHeight=i.device.char.height,this._deviceCharLeft=i.device.char.left,this._deviceCharTop=i.device.char.top,this._canvas.width=i.device.canvas.width,this._canvas.height=i.device.canvas.height,this._canvas.style.width=i.css.canvas.width+"px",this._canvas.style.height=i.css.canvas.height+"px",this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,i,s=1){this._ctx.fillRect(t*this._deviceCellWidth,(i+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,s*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,i,s,e){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,e*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,e*this._deviceCellHeight))}_fillCharTrueColor(t,i,s,e){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=mo,this._clipCell(s,e,i.getWidth()),this._ctx.fillText(i.getChars(),s*this._deviceCellWidth+this._deviceCharLeft,e*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,i,s){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,i*this._deviceCellHeight,s*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,i,s){return`${s?"italic":""} ${i?t.options.fontWeightBold:t.options.fontWeight} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},El=class extends Ql{constructor(t,i,s,e,h,r,n){super(s,t,"link",i,!0,h,r,n),this._register(e.onShowLinkUnderline((t=>this._handleShowLinkUnderline(t)))),this._register(e.onHideLinkUnderline((t=>this._handleHideLinkUnderline(t))))}resize(t,i){super.resize(t,i),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(this._ctx.fillStyle=257===t.fg?this._themeService.colors.background.css:void 0!==t.fg&&function(t){return 16777216==(50331648&t)||33554432==(50331648&t)}(t.fg)?this._themeService.colors.ansi[t.fg].css: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 i=t.y1+1;i<t.y2;i++)this._fillBottomLineAtCells(0,i,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},bl="object"==typeof window?window:globalThis,kl=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ko,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ko,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};kl.INSTANCE=new kl;var xl="object"==typeof navigator?navigator.userAgent:"";if(xl.indexOf("Firefox"),xl.indexOf("AppleWebKit"),!(xl.indexOf("Chrome")>=0)&&xl.indexOf("Safari"),xl.indexOf("Electron/"),xl.indexOf("Android"),"function"==typeof bl.matchMedia){let t=bl.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");bl.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=bl.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Dl,Ll,Sl="en",_l=!1,$l=Sl,Rl=globalThis;typeof Rl.vscode<"u"&&typeof Rl.vscode.process<"u"?Ll=Rl.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Ll=process);var Nl="string"==typeof Ll?.versions?.electron&&"renderer"===Ll?.type;if("object"==typeof Ll){$l=Sl;let t=Ll.env.VSCODE_NLS_CONFIG;if(t)try{$l=JSON.parse(t).resolvedLanguage||Sl}catch{}_l=!0}else"object"!=typeof navigator||Nl?console.error("Unable to resolve platform."):((Dl=navigator.userAgent).indexOf("Windows"),Dl.indexOf("Macintosh"),(Dl.indexOf("Macintosh")>=0||Dl.indexOf("iPad")>=0||Dl.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Dl.indexOf("Linux"),Dl?.indexOf("Mobi"),$l=globalThis._VSCODE_NLS_LANGUAGE||Sl,navigator.language.toLowerCase());var Fl,Hl=_l,Tl=Dl,Ul=$l;(t=>{t.value=function(){return Ul},t.isDefaultVariant=function(){return 2===Ul.length?"en"===Ul:Ul.length>=3&&"e"===Ul[0]&&"n"===Ul[1]&&"-"===Ul[2]},t.isDefault=function(){return"en"===Ul}})(Fl||={});var Gl="function"==typeof Rl.postMessage&&!Rl.importScripts;(()=>{if(Gl){let t=[];Rl.addEventListener("message",(i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,e=t.length;s<e;s++){let e=t[s];if(e.id===i.data.vscodeScheduleAsyncWork)return t.splice(s,1),void e.callback()}}));let i=0}})();var Pl=!!(Tl&&Tl.indexOf("Chrome")>=0);Tl&&Tl.indexOf("Firefox"),!Pl&&Tl&&Tl.indexOf("Safari"),Tl&&Tl.indexOf("Edg/"),Tl&&Tl.indexOf("Android"),"object"==typeof navigator&&navigator,Hl||document.queryCommandSupported&&document.queryCommandSupported("copy");var Jl,Ol=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,i){this._keyCodeToStr[t]=i,this._strToKeyCode[i.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},Wl=new Ol,zl=new Ol,Kl=new Ol;Array(230),(t=>{t.toString=function(t){return Wl.keyCodeToStr(t)},t.fromString=function(t){return Wl.strToKeyCode(t)},t.toUserSettingsUS=function(t){return zl.keyCodeToStr(t)},t.toUserSettingsGeneral=function(t){return Kl.keyCodeToStr(t)},t.fromUserSettings=function(t){return zl.strToKeyCode(t)||Kl.strToKeyCode(t)},t.toElectronAccelerator=function(t){if(t>=98&&t<=113)return null;switch(t){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Wl.keyCodeToStr(t)}})(Jl||={});var ql,jl=Object.freeze((function(t,i){let s=setTimeout(t.bind(i),0);return{dispose(){clearTimeout(s)}}}));(t=>{t.isCancellationToken=function(i){return i===t.None||i===t.Cancelled||i instanceof Zl||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ko.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:jl})})(ql||={});var Yl,Zl=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?jl:(this._emitter||(this._emitter=new Ko),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(t=>{t.settled=async function(t){let i,s=await Promise.all(t.map((t=>t.then((t=>t),(t=>{i||(i=t)})))));if(typeof i<"u")throw i;return s},t.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))}})(Yl||={});var Xl=class t{static fromArray(i){return new t((t=>{t.emitMany(i)}))}static fromPromise(i){return new t((async t=>{t.emitMany(await i)}))}static fromPromises(i){return new t((async t=>{await Promise.all(i.map((async i=>t.emitOne(await i))))}))}static merge(i){return new t((async t=>{await Promise.all(i.map((async i=>{for await(let s of i)t.emitOne(s)})))}))}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new Ko,queueMicrotask((async()=>{let i={emitOne:t=>this.emitOne(t),emitMany:t=>this.emitMany(t),reject:t=>this.reject(t)};try{await Promise.resolve(t(i)),this.resolve()}catch(t){this.reject(t)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}}))}[Symbol.asyncIterator](){let t=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(1===this._state)return{done:!0,value:void 0};await ko.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new t((async t=>{for await(let e of i)t.emitOne(s(e))}))}map(i){return t.map(this,i)}static filter(i,s){return new t((async t=>{for await(let e of i)s(e)&&t.emitOne(e)}))}filter(i){return t.filter(this,i)}static coalesce(i){return t.filter(i,(t=>!!t))}coalesce(){return t.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return t.toPromise(this)}emitOne(t){0===this._state&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){0===this._state&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(t){0===this._state&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Xl.EMPTY=Xl.fromArray([]);var{getWindow:Vl}=function(){let t=new Map,i={window:bl,disposables:new Tn};t.set(bl.vscodeWindowId,i);let s=new Ko,e=new Ko,h=new Ko;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return Un.None;let r=new Tn,n={window:i,disposables:r.add(new Tn)};return t.set(i.vscodeWindowId,n),r.add(Fn((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(ia(i,sa.BEFORE_UNLOAD,(()=>{h.fire(i)}))),s.fire(n),r},getWindows:()=>t.values(),getWindowsCount:()=>t.size,getWindowId:t=>t.vscodeWindowId,hasWindow:i=>t.has(i),getWindowById:function(s,e){return("number"==typeof s?t.get(s):void 0)??(e?i:void 0)},getWindow(t){let i=t;if(i?.ownerDocument?.defaultView)return i.ownerDocument.defaultView.window;let s=t;return s?.view?s.view.window:bl},getDocument:t=>Vl(t).document}}(),ta=class{constructor(t,i,s,e){this._node=t,this._type=i,this._handler=s,this._options=e||!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 ia(t,i,s,e){return new ta(t,i,s,e)}var sa={BEFORE_UNLOAD:"beforeunload"},ea=class extends Un{constructor(t,i,s,e,h,r,n,o,l){if(super(),this._terminal=t,this._characterJoinerService=i,this._charSizeService=s,this._coreBrowserService=e,this._coreService=h,this._decorationService=r,this._optionsService=n,this._themeService=o,this._cursorBlinkStateManager=new Gn,this._charAtlasDisposable=this._register(new Gn),this._observerDisposable=this._register(new Gn),this._model=new Il,this._workCell=new ol,this._workCell2=new ol,this._rectangleRenderer=this._register(new Gn),this._glyphRenderer=this._register(new Gn),this._onChangeTextureAtlas=this._register(new Ko),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Ko),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Ko),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Ko),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Ko),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._gl=this._canvas.getContext("webgl2",{antialias:!1,depth:!1,preserveDrawingBuffer:l}),!this._gl)throw Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors((()=>this._handleColorChange()))),this._cellColorResolver=new Co(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new El(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,n,this._themeService)],this.dimensions={css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}},this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(n.onOptionChange((()=>this._handleOptionsChanged()))),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(ia(this._canvas,"webglcontextlost",(t=>{console.log("webglcontextlost event received"),t.preventDefault(),this._contextRestorationTimeout=setTimeout((()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(t)}),3e3)}))),this._register(ia(this._canvas,"webglcontextrestored",(()=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,el(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()}))),this._observerDisposable.value=nl(this._canvas,this._coreBrowserService.window,((t,i)=>this._setCanvasDevicePixelDimensions(t,i))),this._register(this._coreBrowserService.onWindowChange((t=>{this._observerDisposable.value=nl(this._canvas,t,((t,i)=>this._setCanvasDevicePixelDimensions(t,i)))}))),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Fn((()=>{for(let t of this._renderLayers)t.dispose();this._canvas.parentElement?.removeChild(this._canvas),el(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,i){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let t of this._renderLayers)t.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,i,s){for(let e of this._renderLayers)e.handleSelectionChanged(this._terminal,t,i,s);this._model.selection.update(this._core,t,i,s),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 yl(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Cl(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)return void(this._isAttached=!1);let t=sl(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=Nn(ko.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),ko.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,i){if(!this._isAttached){if(!(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let s of this._renderLayers)s.handleGridChanged(this._terminal,t,i);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,i),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 rl((()=>{this._requestRedrawCursor()}),this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,i){let s,e,h,r,n,o,l,a,u,c,A,f,d,g,w,p=this._core,C=this._workCell,m=0,I=!0;t=ra(t,p.rows-1,0),i=ra(i,p.rows-1,0);let v=this._coreService.decPrivateModes.cursorStyle??p.options.cursorStyle??"block",B=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,M=B-p.buffer.ydisp,y=Math.min(this._terminal.buffer.active.cursorX,p.cols-1),Q=-1,E=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let b=!1;for(e=t;e<=i;e++)for(h=e+p.buffer.ydisp,r=p.buffer.lines.get(h),this._model.lineLengths[e]=0,u=B===h,m=0,n=this._characterJoinerService.getJoinedCharacters(h),g=0;g<p.cols;g++){if(s=this._cellColorResolver.result.bg,r.loadCell(g,C),0===g&&(s=this._cellColorResolver.result.bg),o=!1,I=g>=m,l=g,n.length>0&&g===n[0][0]&&I){a=n.shift();let t=this._model.selection.isCellSelected(this._terminal,a[0],h);for(d=a[0]+1;d<a[1];d++)I&&=t===this._model.selection.isCellSelected(this._terminal,d,h);I&&=!u||y<a[0]||y>=a[1],I?(o=!0,C=new ha(C,r.translateToString(!0,a[0],a[1]),a[1]-a[0]),l=a[1]-1):m=a[1]}if(c=C.getChars(),A=C.getCode(),d=4*(e*p.cols+g),this._cellColorResolver.resolve(C,g,h,this.dimensions.device.cell.width),E&&h===B&&(g===y&&(this._model.cursor={x:y,y:M,width:C.getWidth(),style:this._coreBrowserService.isFocused?v:p.options.cursorInactiveStyle,cursorWidth:p.options.cursorWidth,dpr:this._devicePixelRatio},Q=y+C.getWidth()-1),g>=y&&g<=Q&&(this._coreBrowserService.isFocused&&"block"===v||!1===this._coreBrowserService.isFocused&&"block"===p.options.cursorInactiveStyle)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),0!==A&&(this._model.lineLengths[e]=g+1),(this._model.cells[d]!==A||this._model.cells[d+1]!==this._cellColorResolver.result.bg||this._model.cells[d+2]!==this._cellColorResolver.result.fg||this._model.cells[d+3]!==this._cellColorResolver.result.ext)&&(b=!0,c.length>1&&(A|=2147483648),this._model.cells[d]=A,this._model.cells[d+1]=this._cellColorResolver.result.bg,this._model.cells[d+2]=this._cellColorResolver.result.fg,this._model.cells[d+3]=this._cellColorResolver.result.ext,f=C.getWidth(),this._glyphRenderer.value.updateCell(g,e,A,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,c,f,s),o)){for(C=this._workCell,g++;g<=l;g++)w=4*(e*p.cols+g),this._glyphRenderer.value.updateCell(g,e,0,0,0,0,"",0,0),this._model.cells[w]=0,this._model.cells[w+1]=this._cellColorResolver.result.bg,this._model.cells[w+2]=this._cellColorResolver.result.fg,this._model.cells[w+3]=this._cellColorResolver.result.ext;g--}}b&&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=1===this._optionsService.rawOptions.lineHeight?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,i){this._canvas.width===t&&this._canvas.height===i||(this._canvas.width=t,this._canvas.height=i,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})}},ha=class extends _o{constructor(t,i,s){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function ra(t,i,s=0){return Math.max(Math.min(t,i),s)}var na="di$target",oa="di$dependencies",la=new Map;function aa(t){if(la.has(t))return la.get(t);let i=function(t,s,e){if(3!==arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[na]===i?i[oa].push({id:t,index:s}):(i[oa]=[{id:t,index:s}],i[na]=i)}(i,t,e)};return i._id=t,la.set(t,i),i}aa("BufferService"),aa("CoreMouseService"),aa("CoreService"),aa("CharsetService"),aa("InstantiationService"),aa("LogService");var ua=aa("OptionsService");aa("OscLinkService"),aa("UnicodeService"),aa("DecorationService");var ca={trace:0,debug:1,info:2,warn:3,error:4,off:5},Aa=class extends Un{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=ca[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let i=0;i<t.length;i++)"function"==typeof t[i]&&(t[i]=t[i]())}_log(t,i,s){this._evalLazyOptionalParams(s),t.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...s)}trace(t,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,t,i)}debug(t,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,t,i)}info(t,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,t,i)}warn(t,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,t,i)}error(t,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,t,i)}};Aa=(t=>{for(var i,s=Aa,e=t.length-1;e>=0;e--)(i=t[e])&&(s=i(s)||s);return s})([((t,i)=>(t,s)=>i(t,s,0))(0,ua)]);var fa,da,ga,wa,pa,Ca=class extends Un{constructor(t){if(Kn&&function(){if(!Kn)return 0;let t=Jn.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}()<16){let t={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",t))throw Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new Ko),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Ko),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Ko),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Ko),this.onContextLoss=this._onContextLoss.event}activate(t){let i=t._core;if(!t.element)return void this._register(i.onWillOpen((()=>this.activate(t))));this._terminal=t;let s=i._renderService;this._renderer=this._register(new ea(t,i._characterJoinerService,i._charSizeService,i._coreBrowserService,i.coreService,i._decorationService,i.optionsService,i._themeService,this._preserveDrawingBuffer)),this._register(ko.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(ko.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(ko.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(ko.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),s.setRenderer(this._renderer),this._register(Fn((()=>{if(this._terminal._core._store._isDisposed)return;let i=this._terminal._core._renderService;i.setRenderer(this._terminal._core._createRenderer()),i.handleResize(t.cols,t.rows)})))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},ma=0,Ia=0,va=0,Ba=0;
26
26
  /**
27
27
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
28
28
  * @license MIT
@@ -34,7 +34,7 @@ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
34
34
  * Fabrice Bellard's javascript vt100 for jslinux:
35
35
  * http://bellard.org/jslinux/
36
36
  * Copyright (c) 2011 Fabrice Bellard
37
- */function pl(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Cl(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${pl(t)}${pl(i)}${pl(s)}${pl(e)}`:`#${pl(t)}${pl(i)}${pl(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(ol||={}),(t=>{function i(t,i){return wl=Math.round(255*i),[fl,dl,gl]=ul.toChannels(t.rgba),{css:ol.toCss(fl,dl,gl,wl),rgba:ol.toRgba(fl,dl,gl,wl)}}t.blend=function(t,i){if(1==(wl=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:ol.toCss(fl=h+Math.round(((i.rgba>>24&255)-h)*wl),dl=r+Math.round((s-r)*wl),gl=n+Math.round((e-n)*wl)),rgba:ol.toRgba(fl,dl,gl)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=ul.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return ol.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[fl,dl,gl]=ul.toChannels(i),{css:ol.toCss(fl,dl,gl),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(wl=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(al||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return fl=parseInt(t.slice(1,2).repeat(2),16),dl=parseInt(t.slice(2,3).repeat(2),16),gl=parseInt(t.slice(3,4).repeat(2),16),ol.toColor(fl,dl,gl);case 5:return fl=parseInt(t.slice(1,2).repeat(2),16),dl=parseInt(t.slice(2,3).repeat(2),16),gl=parseInt(t.slice(3,4).repeat(2),16),wl=parseInt(t.slice(4,5).repeat(2),16),ol.toColor(fl,dl,gl,wl);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return ol.toColor(fl=parseInt(e[1]),dl=parseInt(e[2]),gl=parseInt(e[3]),wl=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[fl,dl,gl,wl]=i.getImageData(0,0,1,1).data,255!==wl)throw Error("css.toColor: Unsupported css format");return{rgba:ol.toRgba(fl,dl,gl,wl),css:t}}})(ll||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(cl||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Cl(cl.relativeLuminance2(n,o,a),cl.relativeLuminance2(e,h,r));for(;l<s&&(n>0||o>0||a>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l=Cl(cl.relativeLuminance2(n,o,a),cl.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,a=i>>8&255,l=Cl(cl.relativeLuminance2(n,o,a),cl.relativeLuminance2(e,h,r));for(;l<s&&(n<255||o<255||a<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Cl(cl.relativeLuminance2(n,o,a),cl.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(wl=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return ol.toRgba(fl=h+Math.round(((i>>24&255)-h)*wl),dl=r+Math.round((s-r)*wl),gl=n+Math.round((e-n)*wl))},t.ensureContrastRatio=function(t,e,h){let r=cl.relativeLuminance(t>>8),n=cl.relativeLuminance(e>>8);if(Cl(r,n)<h){if(n<r){let n=i(t,e,h),o=Cl(r,cl.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Cl(r,cl.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=Cl(r,cl.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>Cl(r,cl.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(ul||={});var ml=Object.freeze((()=>{let t=[ll.toColor("#2e3436"),ll.toColor("#cc0000"),ll.toColor("#4e9a06"),ll.toColor("#c4a000"),ll.toColor("#3465a4"),ll.toColor("#75507b"),ll.toColor("#06989a"),ll.toColor("#d3d7cf"),ll.toColor("#555753"),ll.toColor("#ef2929"),ll.toColor("#8ae234"),ll.toColor("#fce94f"),ll.toColor("#729fcf"),ll.toColor("#ad7fa8"),ll.toColor("#34e2e2"),ll.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let s=0;s<216;s++){let e=i[s/36%6|0],h=i[s/6%6|0],r=i[s%6];t.push({css:ol.toCss(e,h,r),rgba:ol.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:ol.toCss(s,s,s),rgba:ol.toRgba(s,s,s)})}return t})());function Il(t,i,s){return Math.max(i,Math.min(t,s))}var vl=class{constructor(t){this._buffer=t}serialize(t,i){let s=this._buffer.getNullCell(),e=this._buffer.getNullCell(),h=s,r=t.start.y,n=t.end.y,o=t.start.x,a=t.end.x;this._beforeSerialize(n-r,r,n);for(let i=r;i<=n;i++){let r=this._buffer.getLine(i);if(r){let n=i===t.end.y?a:r.length;for(let a=i===t.start.y?o:0;a<n;a++){let t=r.getCell(a,h===s?e:s);t?(this._nextCell(t,h,i,a),h=t):console.warn(`Can't get cell at row=${i}, col=${a}`)}}this._rowEnd(i,i===n)}return this._afterSerialize(),this._serializeString(i)}_nextCell(t,i,s,e){}_rowEnd(t,i){}_beforeSerialize(t,i,s){}_afterSerialize(){}_serializeString(t){return""}};function bl(t,i){return t.getFgColorMode()===i.getFgColorMode()&&t.getFgColor()===i.getFgColor()}function Bl(t,i){return t.getBgColorMode()===i.getBgColorMode()&&t.getBgColor()===i.getBgColor()}function Ml(t,i){return t.isInverse()===i.isInverse()&&t.isBold()===i.isBold()&&t.isUnderline()===i.isUnderline()&&t.isOverline()===i.isOverline()&&t.isBlink()===i.isBlink()&&t.isInvisible()===i.isInvisible()&&t.isItalic()===i.isItalic()&&t.isDim()===i.isDim()&&t.isStrikethrough()===i.isStrikethrough()}var yl,El,Ql=class extends vl{constructor(t,i){super(t),this._terminal=i,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,i,s){this._allRows=Array(t),this._lastContentCursorRow=i,this._lastCursorRow=i,this._firstRow=i}_rowEnd(t,i){this._nullCellCount>0&&!Bl(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`[${this._nullCellCount}X`);let s="";if(!i){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let i=this._buffer.getLine(t),e=this._buffer.getLine(t+1);if(e.isWrapped){s="";let h=i.getCell(i.length-1,this._thisRowLastChar),r=i.getCell(i.length-2,this._thisRowLastSecondChar),n=e.getCell(0,this._nextRowFirstChar),o=n.getWidth()>1,a=!1;(n.getChars()&&o?this._nullCellCount<=1:this._nullCellCount<=0)&&((h.getChars()||0===h.getWidth())&&Bl(h,n)&&(a=!0),o&&(r.getChars()||0===r.getWidth())&&Bl(h,n)&&Bl(r,n)&&(a=!0)),a||(s="-".repeat(this._nullCellCount+1),s+="",this._nullCellCount>0&&(s+="",s+=`[${i.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${i.length-this._nullCellCount}D`,s+=""),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}else s="\r\n",this._lastCursorRow=t+1,this._lastCursorCol=0}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(t,i){let s=[],e=!bl(t,i),h=!Bl(t,i),r=!Ml(t,i);if(e||h||r)if(t.isAttributeDefault())i.isAttributeDefault()||s.push(0);else{if(e){let i=t.getFgColor();t.isFgRGB()?s.push(38,2,i>>>16&255,i>>>8&255,255&i):t.isFgPalette()?i>=16?s.push(38,5,i):s.push(8&i?90+(7&i):30+(7&i)):s.push(39)}if(h){let i=t.getBgColor();t.isBgRGB()?s.push(48,2,i>>>16&255,i>>>8&255,255&i):t.isBgPalette()?i>=16?s.push(48,5,i):s.push(8&i?100+(7&i):40+(7&i)):s.push(49)}r&&(t.isInverse()!==i.isInverse()&&s.push(t.isInverse()?7:27),t.isBold()!==i.isBold()&&s.push(t.isBold()?1:22),t.isUnderline()!==i.isUnderline()&&s.push(t.isUnderline()?4:24),t.isOverline()!==i.isOverline()&&s.push(t.isOverline()?53:55),t.isBlink()!==i.isBlink()&&s.push(t.isBlink()?5:25),t.isInvisible()!==i.isInvisible()&&s.push(t.isInvisible()?8:28),t.isItalic()!==i.isItalic()&&s.push(t.isItalic()?3:23),t.isDim()!==i.isDim()&&s.push(t.isDim()?2:22),t.isStrikethrough()!==i.isStrikethrough()&&s.push(t.isStrikethrough()?9:29))}return s}_nextCell(t,i,s,e){if(0===t.getWidth())return;let h=""===t.getChars(),r=this._diffStyle(t,this._cursorStyle);if(h?!Bl(this._cursorStyle,t):r.length>0){this._nullCellCount>0&&(Bl(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=e,this._currentRow+=`[${r.join(";")}m`;let t=this._buffer.getLine(s);void 0!==t&&(t.getCell(e,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=e)}h?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(Bl(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=e+t.getWidth())}_serializeString(t){let i=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(i=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let t=0;t<i;t++)s+=this._allRows[t],t+1<i&&(s+=this._allRowSeparators[t]);if(!t){let t=this._buffer.baseY+this._buffer.cursorY,i=this._buffer.cursorX,e=t=>{t>0?s+=`[${t}C`:t<0&&(s+=`[${-t}D`)};(t!==this._lastCursorRow||i!==this._lastCursorCol)&&((t=>{t>0?s+=`[${t}B`:t<0&&(s+=`[${-t}A`)})(t-this._lastCursorRow),e(i-this._lastCursorCol))}let e=this._diffStyle(this._terminal._core._inputHandler._curAttrData,this._cursorStyle);return e.length>0&&(s+=`[${e.join(";")}m`),s}},kl=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,i,s){let e=i.length,h=void 0===s?e:Il(s+t.rows,0,e);return this._serializeBufferByRange(t,i,{start:e-h,end:e-1},!1)}_serializeBufferByRange(t,i,s,e){return new Ql(i,t).serialize({start:{x:0,y:"number"==typeof s.start?s.start:s.start.line},end:{x:t.cols,y:"number"==typeof s.end?s.end:s.end.line}},e)}_serializeBufferAsHTML(t,i){let s=t.buffer.active,e=new xl(s,t,i),h=i.onlySelection??!1,r=i.range;if(r)return e.serialize({start:{x:r.startCol,y:r.startLine},end:{x:t.cols,y:r.endLine}});if(!h){let h=s.length,r=i.scrollback,n=void 0===r?h:Il(r+t.rows,0,h);return e.serialize({start:{x:0,y:h-n},end:{x:t.cols,y:h-1}})}let n=this._terminal?.getSelectionPosition();return void 0!==n?e.serialize({start:{x:n.start.x,y:n.start.y},end:{x:n.end.x,y:n.end.y}}):""}_serializeModes(t){let i="",s=t.modes;if(s.applicationCursorKeysMode&&(i+="[?1h"),s.applicationKeypadMode&&(i+="[?66h"),s.bracketedPasteMode&&(i+="[?2004h"),s.insertMode&&(i+=""),s.originMode&&(i+="[?6h"),s.reverseWraparoundMode&&(i+="[?45h"),s.sendFocusMode&&(i+="[?1004h"),!1===s.wraparoundMode&&(i+="[?7l"),"none"!==s.mouseTrackingMode)switch(s.mouseTrackingMode){case"x10":i+="[?9h";break;case"vt200":i+="[?1000h";break;case"drag":i+="[?1002h";break;case"any":i+="[?1003h"}return i}serialize(t){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");let i=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);return t?.excludeAltBuffer||"alternate"!==this._terminal.buffer.active.type||(i+="[?1049h"+this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)),t?.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},xl=class extends vl{constructor(t,i,s){super(t),this._terminal=i,this._options=s,this._currentRow="",this._htmlContent="",this._ansiColors=i._core._themeService?i._core._themeService.colors.ansi:ml}_padStart(t,i,s){return s=s??" ",t.length>(i|=0)?t:((i-=t.length)>s.length&&(s+=s.repeat(i/s.length)),s.slice(0,i)+t)}_beforeSerialize(t,i,s){this._htmlContent+="<html><body>\x3c!--StartFragment--\x3e<pre>";let e="#000000",h="#ffffff";this._options.includeGlobalBackground&&(e=this._terminal.options.theme?.foreground??"#ffffff",h=this._terminal.options.theme?.background??"#000000");let r=[];r.push("color: "+e+";"),r.push("background-color: "+h+";"),r.push("font-family: "+this._terminal.options.fontFamily+";"),r.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+r.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre>\x3c!--EndFragment--\x3e</body></html>"}_rowEnd(t,i){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,i){let s=i?t.getFgColor():t.getBgColor();return(i?t.isFgRGB():t.isBgRGB())?"#"+[s>>16&255,s>>8&255,255&s].map((t=>this._padStart(t.toString(16),2,"0"))).join(""):(i?t.isFgPalette():t.isBgPalette())?this._ansiColors[s].css:void 0}_diffStyle(t,i){let s=[],e=!bl(t,i),h=!Bl(t,i),r=!Ml(t,i);if(e||h||r){let i=this._getHexColor(t,!0);i&&s.push("color: "+i+";");let e=this._getHexColor(t,!1);return e&&s.push("background-color: "+e+";"),t.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&s.push("font-weight: bold;"),t.isUnderline()&&t.isOverline()?s.push("text-decoration: overline underline;"):t.isUnderline()?s.push("text-decoration: underline;"):t.isOverline()&&s.push("text-decoration: overline;"),t.isBlink()&&s.push("text-decoration: blink;"),t.isInvisible()&&s.push("visibility: hidden;"),t.isItalic()&&s.push("font-style: italic;"),t.isDim()&&s.push("opacity: 0.5;"),t.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(t,i,s,e){if(0===t.getWidth())return;let h=""===t.getChars(),r=this._diffStyle(t,i);r&&(this._currentRow+=0===r.length?"</span><span>":"</span><span style='"+r.join(" ")+"'>"),this._currentRow+=h?" ":function(t){switch(t){case"&":return"&amp;";case"<":return"&lt;"}return t}(t.getChars())}_serializeString(){return this._htmlContent}},Dl=Object.create,Ll=Object.defineProperty,_l=Object.getOwnPropertyDescriptor,Sl=Object.getOwnPropertyNames,$l=Object.getPrototypeOf,Rl=Object.prototype.hasOwnProperty,Nl=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Fl=(t,i,s)=>(s=null!=t?Dl($l(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of Sl(i))!Rl.call(t,s)&&undefined!==s&&Ll(t,s,{get:()=>i[s],enumerable:!(e=_l(i,s))||e.enumerable});return t})(t&&t.__esModule?s:Ll(s,"default",{value:t,enumerable:!0}),t)),Hl=Nl((t=>{function i(t){return 255&t}function s(t){return t>>>8&255}function e(t){return t>>>16&255}function h(t,i,s,e=255){return((255&e)<<24|(255&s)<<16|(255&i)<<8|255&t)>>>0}function r(t,i,s){return Math.max(t,Math.min(s,i))}function n(t,i,s){return s<0&&(s+=1),s>1&&(s-=1),6*s<1?i+6*(t-i)*s:2*s<1?t:3*s<2?i+(t-i)*(4-6*s):i}function o(t,i,s){return(4278190080|Math.round(s/100*255)<<16|Math.round(i/100*255)<<8|Math.round(t/100*255))>>>0}Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_FOREGROUND=t.DEFAULT_BACKGROUND=t.PALETTE_ANSI_256=t.PALETTE_VT340_GREY=t.PALETTE_VT340_COLOR=t.normalizeHLS=t.normalizeRGB=t.nearestColorIndex=t.fromRGBA8888=t.toRGBA8888=t.alpha=t.blue=t.green=t.red=t.BIG_ENDIAN=void 0,t.BIG_ENDIAN=255===new Uint8Array(new Uint32Array([4278190080]).buffer)[0],t.BIG_ENDIAN&&console.warn("BE platform detected. This version of node-sixel works only on LE properly."),t.red=i,t.green=s,t.blue=e,t.alpha=function(t){return t>>>24&255},t.toRGBA8888=h,t.fromRGBA8888=function(t){return[255&t,t>>8&255,t>>16&255,t>>>24]},t.nearestColorIndex=function(t,h){let r=i(t),n=s(t),o=e(t),a=Number.MAX_SAFE_INTEGER,l=-1;for(let t=0;t<h.length;++t){let i=r-h[t][0],s=n-h[t][1],e=o-h[t][2],c=i*i+s*s+e*e;if(!c)return t;c<a&&(a=c,l=t)}return l},t.normalizeRGB=o,t.normalizeHLS=function(t,i,s){return function(t,i,s){if(!s){let t=Math.round(255*i);return h(t,t,t)}let e=i<.5?i*(1+s):i+s-i*s,o=2*i-e;return h(r(0,255,Math.round(255*n(e,o,t+1/3))),r(0,255,Math.round(255*n(e,o,t))),r(0,255,Math.round(255*n(e,o,t-1/3))))}((t+240)/360,i/100,s/100)},t.PALETTE_VT340_COLOR=new Uint32Array([o(0,0,0),o(20,20,80),o(80,13,13),o(20,80,20),o(80,20,80),o(20,80,80),o(80,80,20),o(53,53,53),o(26,26,26),o(33,33,60),o(60,26,26),o(33,60,33),o(60,33,60),o(33,60,60),o(60,60,33),o(80,80,80)]),t.PALETTE_VT340_GREY=new Uint32Array([o(0,0,0),o(13,13,13),o(26,26,26),o(40,40,40),o(6,6,6),o(20,20,20),o(33,33,33),o(46,46,46),o(0,0,0),o(13,13,13),o(26,26,26),o(40,40,40),o(6,6,6),o(20,20,20),o(33,33,33),o(46,46,46)]),t.PALETTE_ANSI_256=(()=>{let t=[h(0,0,0),h(205,0,0),h(0,205,0),h(205,205,0),h(0,0,238),h(205,0,205),h(0,250,205),h(229,229,229),h(127,127,127),h(255,0,0),h(0,255,0),h(255,255,0),h(92,92,255),h(255,0,255),h(0,255,255),h(255,255,255)],i=[0,95,135,175,215,255];for(let s=0;s<6;++s)for(let e=0;e<6;++e)for(let r=0;r<6;++r)t.push(h(i[s],i[e],i[r]));for(let i=8;i<=238;i+=10)t.push(h(i,i,i));return new Uint32Array(t)})(),t.DEFAULT_BACKGROUND=h(0,0,0,255),t.DEFAULT_FOREGROUND=h(255,255,255,255)})),Ul=Nl((t=>{function i(t){if(typeof Buffer<"u")return Buffer.from(t,"base64");let i=atob(t),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return s}Object.defineProperty(t,"__esModule",{value:!0}),t.InWasm=void 0,t.InWasm=function(t){if(t.d){let s,e,{t:h,s:r,d:n}=t,o=WebAssembly;return 2===h?r?()=>s||(s=i(n)):()=>Promise.resolve(s||(s=i(n))):1===h?r?()=>e||(e=new o.Module(s||(s=i(n)))):()=>e?Promise.resolve(e):o.compile(s||(s=i(n))).then((t=>e=t)):r?t=>new o.Instance(e||(e=new o.Module(s||(s=i(n)))),t):t=>e?o.instantiate(e,t):o.instantiate(s||(s=i(n)),t).then((t=>(e=t.module)&&t.instance))}if(typeof _wasmCtx>"u")throw Error('must run "inwasm"');_wasmCtx.add(t)}})),Tl=Nl((t=>{Object.defineProperty(t,"__esModule",{value:!0});var i=(0,Ul().InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqxAwKuAQEFf0GIKCgCAEGgKGohAUGEKCgCACIAQYAoKAIAQQFrQXxxIgJIBEAgAkGgKGohAyAAQaAoaiEAA0AgAC0AA0ECdCgCgCAgAC0AAkECdCgCgBggAC0AAUECdCgCgBAgAC0AAEECdCgCgAhycnIiBEH///8HSwRAQQEPCyABIAQ2AgAgAUEDaiEBIABBBGoiACADSQ0ACwtBhCggAjYCAEGIKCABQaAoazYCAEEAC/4BAQZ/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQQEhAxAADQFBgCgoAgAhAUGEKCgCACEAC0EBIQMgASAAayIEQQJIDQAgAEGhKGotAABBAnQoAoAQIABBoChqLQAAQQJ0KAKACHIhAQJAIARBAkYEQEEBIQIMAQtBASECIAAtAKIoIgVBPUcEQEECIQIgBUECdCgCgBggAXIhAQsgBEEERw0AIAAtAKMoIgBBPUYNACACQQFqIQIgAEECdCgCgCAgAXIhAQsgAUH///8HSw0AQYgoKAIAQaAoaiABNgIAQYgoQYgoKAIAIAJqIgA2AgAgAEGQKCgCAEchAwsgAwsAdglwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQEFY2xhbmdWMTguMC4wIChodHRwczovL2dpdGh1Yi5jb20vbGx2bS9sbHZtLXByb2plY3QgZDFlNjg1ZGY0NWRjNTk0NGI0M2QyNTQ3ZDAxMzhjZDRhM2VlNGVmZSkALA90YXJnZXRfZmVhdHVyZXMCKw9tdXRhYmxlLWdsb2JhbHMrCHNpZ24tZXh0"}),s=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map((t=>t.charCodeAt(0)))),e=new Uint32Array(1024);e.fill(4278190080);for(let t=0;t<s.length;++t)e[s[t]]=t<<2;for(let t=0;t<s.length;++t)e[256+s[t]]=t>>4|(t<<4&255)<<8;for(let t=0;t<s.length;++t)e[512+s[t]]=t>>2<<8|(t<<6&255)<<16;for(let t=0;t<s.length;++t)e[768+s[t]]=t<<16;var h=new Uint8Array(0);t.default=class{constructor(t){this.keepSize=t}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):h}release(){this._inst&&(this._mem.buffer.byteLength>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(t){let s=this._m32,h=4*(Math.ceil(t/3)+1288);this._inst?this._mem.buffer.byteLength<h&&(this._mem.grow(Math.ceil((h-this._mem.buffer.byteLength)/65536)),s=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(h/65536)}),this._inst=i({env:{memory:this._mem}}),s=new Uint32Array(this._mem.buffer,0),s.set(e,256),this._d=new Uint8Array(this._mem.buffer,5152)),s[1284]=t,s[1283]=4*Math.ceil(t/3),s[1280]=0,s[1281]=0,s[1282]=0,this._m32=s}put(t,i,s){if(!this._inst)return 1;let e=this._m32;return s-i+e[1280]>e[1283]?1:(this._d.set(t.subarray(i,s),e[1280]),e[1280]+=s-i,e[1280]-e[1281]>=131072?this._inst.exports.dec():0)}end(){return this._inst?this._inst.exports.end():1}}})),Gl=Nl((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LIMITS=void 0,t.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:"AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF"}})),Pl=Nl((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsync=t.decode=t.Decoder=t.DecoderAsync=void 0;var i,s=Hl(),e=Gl(),h=function(t){if(typeof Buffer<"u")return Buffer.from(t,"base64");let i=atob(t),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return s}(e.LIMITS.BYTES),r=new Uint32Array,n=class{constructor(){this.bandHandler=()=>1,this.modeHandler=()=>1}handle_band(t){return this.bandHandler(t)}mode_parsed(t){return this.modeHandler(t)}},o={memoryLimit:134217728,sixelColor:s.DEFAULT_FOREGROUND,fillColor:s.DEFAULT_BACKGROUND,palette:s.PALETTE_VT340_COLOR,paletteLimit:e.LIMITS.PALETTE_SIZE,truncate:!0};function a(t){let s=new n,e={env:{handle_band:s.handle_band.bind(s),mode_parsed:s.mode_parsed.bind(s)}};return WebAssembly.instantiate(i||h,e).then((e=>(i=i||e.module,new l(t,e.instance||e,s))))}t.DecoderAsync=a;var l=class{constructor(t,n,a){if(this._PIXEL_OFFSET=e.LIMITS.MAX_WIDTH+4,this._canvas=r,this._bandWidths=[],this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},o,t),this._opts.paletteLimit>e.LIMITS.PALETTE_SIZE)throw Error("DecoderOptions.paletteLimit must not exceed "+e.LIMITS.PALETTE_SIZE);if(n)a.bandHandler=this._handle_band.bind(this),a.modeHandler=this._initCanvas.bind(this);else{let t=i||(i=new WebAssembly.Module(h));n=new WebAssembly.Instance(t,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=n,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),e.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),e.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(s.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(t){if(2===t){let t=this.width*this.height;if(t>this._canvas.length){if(this._opts.memoryLimit&&4*t>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");this._canvas=new Uint32Array(t)}this._maxWidth=this._width}else if(1===t)if(2===this._level){let t=Math.min(this._rasterWidth,e.LIMITS.MAX_WIDTH)*this._rasterHeight;if(t>this._canvas.length){if(this._opts.memoryLimit&&4*t>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");this._canvas=new Uint32Array(t)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(t,i){let s=t+i;if(s>this._canvas.length){if(this._opts.memoryLimit&&4*s>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");let t=new Uint32Array(65536*Math.ceil(s/65536));t.set(this._canvas),this._canvas=t}}_handle_band(t){let i=this._PIXEL_OFFSET,s=this._lastOffset;if(2===this._mode){let e=this.height-this._currentHeight,h=0;for(;h<6&&e>0;)this._canvas.set(this._pSrc.subarray(i*h,i*h+t),s+t*h),h++,e--;this._lastOffset+=t*h,this._currentHeight+=h}else if(1===this._mode){this._realloc(s,6*t),this._maxWidth=Math.max(this._maxWidth,t),this._minWidth=Math.min(this._minWidth,t);for(let e=0;e<6;++e)this._canvas.set(this._pSrc.subarray(i*e,i*e+t),s+t*e);this._bandWidths.push(t),this._lastOffset+=6*t,this._currentHeight+=6}return 0}get width(){return 1!==this._mode?this._width:Math.max(this._maxWidth,this._wasm.current_width())}get height(){return 1!==this._mode?this._height:this._wasm.current_width()?6*this._bandWidths.length+this._wasm.current_height():6*this._bandWidths.length}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(t=this._opts.fillColor,i=this._opts.palette,s=this._opts.paletteLimit,h=this._opts.truncate){this._wasm.init(this._opts.sixelColor,t,s,h?1:0),i&&this._palette.set(i.subarray(0,e.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(t,i=0,s=t.length){let h=i;for(;h<s;){let i=Math.min(s-h,e.LIMITS.CHUNK_SIZE);this._chunk.set(t.subarray(h,h+=i)),this._wasm.decode(0,i)}}decodeString(t,i=0,s=t.length){let h=i;for(;h<s;){let i=Math.min(s-h,e.LIMITS.CHUNK_SIZE);for(let s=0,e=h;s<i;++s,++e)this._chunk[s]=t.charCodeAt(e);h+=i,this._wasm.decode(0,i)}}get data32(){if(0===this._mode||!this.width||!this.height)return r;let t=this._wasm.current_width();if(2===this._mode){let i=this.height-this._currentHeight;if(i>0){let s=this._PIXEL_OFFSET,e=this._lastOffset,h=0;for(;h<6&&i>0;)this._canvas.set(this._pSrc.subarray(s*h,s*h+t),e+t*h),h++,i--;i&&this._canvas.fill(this._fillColor,e+t*h)}return this._canvas.subarray(0,this.width*this.height)}if(1===this._mode){if(this._minWidth===this._maxWidth){let i=!1;if(t)if(t!==this._minWidth)i=!0;else{let i=this._PIXEL_OFFSET,s=this._lastOffset;this._realloc(s,6*t);for(let e=0;e<6;++e)this._canvas.set(this._pSrc.subarray(i*e,i*e+t),s+t*e)}if(!i)return this._canvas.subarray(0,this.width*this.height)}let i=new Uint32Array(this.width*this.height);i.fill(this._fillColor);let s=0,e=0;for(let t=0;t<this._bandWidths.length;++t){let h=this._bandWidths[t];for(let t=0;t<6;++t)i.set(this._canvas.subarray(e,e+=h),s),s+=this.width}if(t){let e=this._PIXEL_OFFSET,h=this._wasm.current_height();for(let r=0;r<h;++r)i.set(this._pSrc.subarray(e*r,e*r+t),s+this.width*r)}return i}return r}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=r,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._wasm.init(s.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};t.Decoder=l,t.decode=function(t,i){let s=new l(i);return s.init(),"string"==typeof t?s.decodeString(t):s.decode(t),{width:s.width,height:s.height,data32:s.data32,data8:s.data8}},t.decodeAsync=async function(t,i){let s=await a(i);return s.init(),"string"==typeof t?s.decodeString(t):s.decode(t),{width:s.width,height:s.height,data32:s.data32,data8:s.data8}}})),Jl=Fl(Hl());
37
+ */function Ma(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ya(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}(t=>{t.toCss=function(t,i,s,e){return void 0!==e?`#${Ma(t)}${Ma(i)}${Ma(s)}${Ma(e)}`:`#${Ma(t)}${Ma(i)}${Ma(s)}`},t.toRgba=function(t,i,s,e=255){return(t<<24|i<<16|s<<8|e)>>>0},t.toColor=function(i,s,e,h){return{css:t.toCss(i,s,e,h),rgba:t.toRgba(i,s,e,h)}}})(fa||={}),(t=>{function i(t,i){return Ba=Math.round(255*i),[ma,Ia,va]=pa.toChannels(t.rgba),{css:fa.toCss(ma,Ia,va,Ba),rgba:fa.toRgba(ma,Ia,va,Ba)}}t.blend=function(t,i){if(1==(Ba=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>16&255,e=i.rgba>>8&255,h=t.rgba>>24&255,r=t.rgba>>16&255,n=t.rgba>>8&255;return{css:fa.toCss(ma=h+Math.round(((i.rgba>>24&255)-h)*Ba),Ia=r+Math.round((s-r)*Ba),va=n+Math.round((e-n)*Ba)),rgba:fa.toRgba(ma,Ia,va)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=pa.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return fa.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[ma,Ia,va]=pa.toChannels(i),{css:fa.toCss(ma,Ia,va),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(Ba=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(da||={}),(t=>{let i,s;try{let t=document.createElement("canvas");t.width=1,t.height=1;let e=t.getContext("2d",{willReadFrequently:!0});e&&(i=e,i.globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}t.toColor=function(t){if(t.match(/#[\da-f]{3,8}/i))switch(t.length){case 4:return ma=parseInt(t.slice(1,2).repeat(2),16),Ia=parseInt(t.slice(2,3).repeat(2),16),va=parseInt(t.slice(3,4).repeat(2),16),fa.toColor(ma,Ia,va);case 5:return ma=parseInt(t.slice(1,2).repeat(2),16),Ia=parseInt(t.slice(2,3).repeat(2),16),va=parseInt(t.slice(3,4).repeat(2),16),Ba=parseInt(t.slice(4,5).repeat(2),16),fa.toColor(ma,Ia,va,Ba);case 7:return{css:t,rgba:(parseInt(t.slice(1),16)<<8|255)>>>0};case 9:return{css:t,rgba:parseInt(t.slice(1),16)>>>0}}let e=t.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(e)return fa.toColor(ma=parseInt(e[1]),Ia=parseInt(e[2]),va=parseInt(e[3]),Ba=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))));if(!i||!s)throw Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[ma,Ia,va,Ba]=i.getImageData(0,0,1,1).data,255!==Ba)throw Error("css.toColor: Unsupported css format");return{rgba:fa.toRgba(ma,Ia,va,Ba),css:t}}})(ga||={}),(t=>{function i(t,i,s){let e=t/255,h=i/255,r=s/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))}t.relativeLuminance=function(t){return i(t>>16&255,t>>8&255,255&t)},t.relativeLuminance2=i})(wa||={}),(t=>{function i(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=ya(wa.relativeLuminance2(n,o,l),wa.relativeLuminance2(e,h,r));for(;a<s&&(n>0||o>0||l>0);)n-=Math.max(0,Math.ceil(.1*n)),o-=Math.max(0,Math.ceil(.1*o)),l-=Math.max(0,Math.ceil(.1*l)),a=ya(wa.relativeLuminance2(n,o,l),wa.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}function s(t,i,s){let e=t>>24&255,h=t>>16&255,r=t>>8&255,n=i>>24&255,o=i>>16&255,l=i>>8&255,a=ya(wa.relativeLuminance2(n,o,l),wa.relativeLuminance2(e,h,r));for(;a<s&&(n<255||o<255||l<255);)n=Math.min(255,n+Math.ceil(.1*(255-n))),o=Math.min(255,o+Math.ceil(.1*(255-o))),l=Math.min(255,l+Math.ceil(.1*(255-l))),a=ya(wa.relativeLuminance2(n,o,l),wa.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}t.blend=function(t,i){if(1==(Ba=(255&i)/255))return i;let s=i>>16&255,e=i>>8&255,h=t>>24&255,r=t>>16&255,n=t>>8&255;return fa.toRgba(ma=h+Math.round(((i>>24&255)-h)*Ba),Ia=r+Math.round((s-r)*Ba),va=n+Math.round((e-n)*Ba))},t.ensureContrastRatio=function(t,e,h){let r=wa.relativeLuminance(t>>8),n=wa.relativeLuminance(e>>8);if(ya(r,n)<h){if(n<r){let n=i(t,e,h),o=ya(r,wa.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ya(r,wa.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=ya(r,wa.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>ya(r,wa.relativeLuminance(s>>8))?o:s}return o}},t.reduceLuminance=i,t.increaseLuminance=s,t.toChannels=function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]}})(pa||={});var Qa=Object.freeze((()=>{let t=[ga.toColor("#2e3436"),ga.toColor("#cc0000"),ga.toColor("#4e9a06"),ga.toColor("#c4a000"),ga.toColor("#3465a4"),ga.toColor("#75507b"),ga.toColor("#06989a"),ga.toColor("#d3d7cf"),ga.toColor("#555753"),ga.toColor("#ef2929"),ga.toColor("#8ae234"),ga.toColor("#fce94f"),ga.toColor("#729fcf"),ga.toColor("#ad7fa8"),ga.toColor("#34e2e2"),ga.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let s=0;s<216;s++){let e=i[s/36%6|0],h=i[s/6%6|0],r=i[s%6];t.push({css:fa.toCss(e,h,r),rgba:fa.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:fa.toCss(s,s,s),rgba:fa.toRgba(s,s,s)})}return t})());function Ea(t,i,s){return Math.max(i,Math.min(t,s))}var ba=class{constructor(t){this._buffer=t}serialize(t,i){let s=this._buffer.getNullCell(),e=this._buffer.getNullCell(),h=s,r=t.start.y,n=t.end.y,o=t.start.x,l=t.end.x;this._beforeSerialize(n-r,r,n);for(let i=r;i<=n;i++){let r=this._buffer.getLine(i);if(r){let n=i===t.end.y?l:r.length;for(let l=i===t.start.y?o:0;l<n;l++){let t=r.getCell(l,h===s?e:s);t?(this._nextCell(t,h,i,l),h=t):console.warn(`Can't get cell at row=${i}, col=${l}`)}}this._rowEnd(i,i===n)}return this._afterSerialize(),this._serializeString(i)}_nextCell(t,i,s,e){}_rowEnd(t,i){}_beforeSerialize(t,i,s){}_afterSerialize(){}_serializeString(t){return""}};function ka(t,i){return t.getFgColorMode()===i.getFgColorMode()&&t.getFgColor()===i.getFgColor()}function xa(t,i){return t.getBgColorMode()===i.getBgColorMode()&&t.getBgColor()===i.getBgColor()}function Da(t,i){return t.isInverse()===i.isInverse()&&t.isBold()===i.isBold()&&t.isUnderline()===i.isUnderline()&&t.isOverline()===i.isOverline()&&t.isBlink()===i.isBlink()&&t.isInvisible()===i.isInvisible()&&t.isItalic()===i.isItalic()&&t.isDim()===i.isDim()&&t.isStrikethrough()===i.isStrikethrough()}var La,Sa,_a=class extends ba{constructor(t,i){super(t),this._terminal=i,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(t,i,s){this._allRows=Array(t),this._lastContentCursorRow=i,this._lastCursorRow=i,this._firstRow=i}_rowEnd(t,i){this._nullCellCount>0&&!xa(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`[${this._nullCellCount}X`);let s="";if(!i){t-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let i=this._buffer.getLine(t),e=this._buffer.getLine(t+1);if(e.isWrapped){s="";let h=i.getCell(i.length-1,this._thisRowLastChar),r=i.getCell(i.length-2,this._thisRowLastSecondChar),n=e.getCell(0,this._nextRowFirstChar),o=n.getWidth()>1,l=!1;(n.getChars()&&o?this._nullCellCount<=1:this._nullCellCount<=0)&&((h.getChars()||0===h.getWidth())&&xa(h,n)&&(l=!0),o&&(r.getChars()||0===r.getWidth())&&xa(h,n)&&xa(r,n)&&(l=!0)),l||(s="-".repeat(this._nullCellCount+1),s+="",this._nullCellCount>0&&(s+="",s+=`[${i.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${i.length-this._nullCellCount}D`,s+=""),this._lastContentCursorRow=t+1,this._lastContentCursorCol=0,this._lastCursorRow=t+1,this._lastCursorCol=0)}else s="\r\n",this._lastCursorRow=t+1,this._lastCursorCol=0}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(t,i){let s=[],e=!ka(t,i),h=!xa(t,i),r=!Da(t,i);if(e||h||r)if(t.isAttributeDefault())i.isAttributeDefault()||s.push(0);else{if(e){let i=t.getFgColor();t.isFgRGB()?s.push(38,2,i>>>16&255,i>>>8&255,255&i):t.isFgPalette()?i>=16?s.push(38,5,i):s.push(8&i?90+(7&i):30+(7&i)):s.push(39)}if(h){let i=t.getBgColor();t.isBgRGB()?s.push(48,2,i>>>16&255,i>>>8&255,255&i):t.isBgPalette()?i>=16?s.push(48,5,i):s.push(8&i?100+(7&i):40+(7&i)):s.push(49)}r&&(t.isInverse()!==i.isInverse()&&s.push(t.isInverse()?7:27),t.isBold()!==i.isBold()&&s.push(t.isBold()?1:22),t.isUnderline()!==i.isUnderline()&&s.push(t.isUnderline()?4:24),t.isOverline()!==i.isOverline()&&s.push(t.isOverline()?53:55),t.isBlink()!==i.isBlink()&&s.push(t.isBlink()?5:25),t.isInvisible()!==i.isInvisible()&&s.push(t.isInvisible()?8:28),t.isItalic()!==i.isItalic()&&s.push(t.isItalic()?3:23),t.isDim()!==i.isDim()&&s.push(t.isDim()?2:22),t.isStrikethrough()!==i.isStrikethrough()&&s.push(t.isStrikethrough()?9:29))}return s}_nextCell(t,i,s,e){if(0===t.getWidth())return;let h=""===t.getChars(),r=this._diffStyle(t,this._cursorStyle);if(h?!xa(this._cursorStyle,t):r.length>0){this._nullCellCount>0&&(xa(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=e,this._currentRow+=`[${r.join(";")}m`;let t=this._buffer.getLine(s);void 0!==t&&(t.getCell(e,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=e)}h?this._nullCellCount+=t.getWidth():(this._nullCellCount>0&&(xa(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`[${this._nullCellCount}X`),this._currentRow+=`[${this._nullCellCount}C`,this._nullCellCount=0),this._currentRow+=t.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=e+t.getWidth())}_serializeString(t){let i=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(i=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let t=0;t<i;t++)s+=this._allRows[t],t+1<i&&(s+=this._allRowSeparators[t]);if(!t){let t=this._buffer.baseY+this._buffer.cursorY,i=this._buffer.cursorX,e=t=>{t>0?s+=`[${t}C`:t<0&&(s+=`[${-t}D`)};(t!==this._lastCursorRow||i!==this._lastCursorCol)&&((t=>{t>0?s+=`[${t}B`:t<0&&(s+=`[${-t}A`)})(t-this._lastCursorRow),e(i-this._lastCursorCol))}let e=this._diffStyle(this._terminal._core._inputHandler._curAttrData,this._cursorStyle);return e.length>0&&(s+=`[${e.join(";")}m`),s}},$a=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,i,s){let e=i.length,h=void 0===s?e:Ea(s+t.rows,0,e);return this._serializeBufferByRange(t,i,{start:e-h,end:e-1},!1)}_serializeBufferByRange(t,i,s,e){return new _a(i,t).serialize({start:{x:0,y:"number"==typeof s.start?s.start:s.start.line},end:{x:t.cols,y:"number"==typeof s.end?s.end:s.end.line}},e)}_serializeBufferAsHTML(t,i){let s=t.buffer.active,e=new Ra(s,t,i),h=i.onlySelection??!1,r=i.range;if(r)return e.serialize({start:{x:r.startCol,y:r.startLine},end:{x:t.cols,y:r.endLine}});if(!h){let h=s.length,r=i.scrollback,n=void 0===r?h:Ea(r+t.rows,0,h);return e.serialize({start:{x:0,y:h-n},end:{x:t.cols,y:h-1}})}let n=this._terminal?.getSelectionPosition();return void 0!==n?e.serialize({start:{x:n.start.x,y:n.start.y},end:{x:n.end.x,y:n.end.y}}):""}_serializeModes(t){let i="",s=t.modes;if(s.applicationCursorKeysMode&&(i+="[?1h"),s.applicationKeypadMode&&(i+="[?66h"),s.bracketedPasteMode&&(i+="[?2004h"),s.insertMode&&(i+=""),s.originMode&&(i+="[?6h"),s.reverseWraparoundMode&&(i+="[?45h"),s.sendFocusMode&&(i+="[?1004h"),!1===s.wraparoundMode&&(i+="[?7l"),"none"!==s.mouseTrackingMode)switch(s.mouseTrackingMode){case"x10":i+="[?9h";break;case"vt200":i+="[?1000h";break;case"drag":i+="[?1002h";break;case"any":i+="[?1003h"}return i}serialize(t){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");let i=t?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,t.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,t?.scrollback);return t?.excludeAltBuffer||"alternate"!==this._terminal.buffer.active.type||(i+="[?1049h"+this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)),t?.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},Ra=class extends ba{constructor(t,i,s){super(t),this._terminal=i,this._options=s,this._currentRow="",this._htmlContent="",this._ansiColors=i._core._themeService?i._core._themeService.colors.ansi:Qa}_padStart(t,i,s){return s=s??" ",t.length>(i|=0)?t:((i-=t.length)>s.length&&(s+=s.repeat(i/s.length)),s.slice(0,i)+t)}_beforeSerialize(t,i,s){this._htmlContent+="<html><body>\x3c!--StartFragment--\x3e<pre>";let e="#000000",h="#ffffff";this._options.includeGlobalBackground&&(e=this._terminal.options.theme?.foreground??"#ffffff",h=this._terminal.options.theme?.background??"#000000");let r=[];r.push("color: "+e+";"),r.push("background-color: "+h+";"),r.push("font-family: "+this._terminal.options.fontFamily+";"),r.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+r.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre>\x3c!--EndFragment--\x3e</body></html>"}_rowEnd(t,i){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(t,i){let s=i?t.getFgColor():t.getBgColor();return(i?t.isFgRGB():t.isBgRGB())?"#"+[s>>16&255,s>>8&255,255&s].map((t=>this._padStart(t.toString(16),2,"0"))).join(""):(i?t.isFgPalette():t.isBgPalette())?this._ansiColors[s].css:void 0}_diffStyle(t,i){let s=[],e=!ka(t,i),h=!xa(t,i),r=!Da(t,i);if(e||h||r){let i=this._getHexColor(t,!0);i&&s.push("color: "+i+";");let e=this._getHexColor(t,!1);return e&&s.push("background-color: "+e+";"),t.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),t.isBold()&&s.push("font-weight: bold;"),t.isUnderline()&&t.isOverline()?s.push("text-decoration: overline underline;"):t.isUnderline()?s.push("text-decoration: underline;"):t.isOverline()&&s.push("text-decoration: overline;"),t.isBlink()&&s.push("text-decoration: blink;"),t.isInvisible()&&s.push("visibility: hidden;"),t.isItalic()&&s.push("font-style: italic;"),t.isDim()&&s.push("opacity: 0.5;"),t.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(t,i,s,e){if(0===t.getWidth())return;let h=""===t.getChars(),r=this._diffStyle(t,i);r&&(this._currentRow+=0===r.length?"</span><span>":"</span><span style='"+r.join(" ")+"'>"),this._currentRow+=h?" ":function(t){switch(t){case"&":return"&amp;";case"<":return"&lt;"}return t}(t.getChars())}_serializeString(){return this._htmlContent}},Na=Object.create,Fa=Object.defineProperty,Ha=Object.getOwnPropertyDescriptor,Ta=Object.getOwnPropertyNames,Ua=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty,Pa=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Ja=(t,i,s)=>(s=null!=t?Na(Ua(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of Ta(i))!Ga.call(t,s)&&undefined!==s&&Fa(t,s,{get:()=>i[s],enumerable:!(e=Ha(i,s))||e.enumerable});return t})(t&&t.__esModule?s:Fa(s,"default",{value:t,enumerable:!0}),t)),Oa=Pa((t=>{function i(t){return 255&t}function s(t){return t>>>8&255}function e(t){return t>>>16&255}function h(t,i,s,e=255){return((255&e)<<24|(255&s)<<16|(255&i)<<8|255&t)>>>0}function r(t,i,s){return Math.max(t,Math.min(s,i))}function n(t,i,s){return s<0&&(s+=1),s>1&&(s-=1),6*s<1?i+6*(t-i)*s:2*s<1?t:3*s<2?i+(t-i)*(4-6*s):i}function o(t,i,s){return(4278190080|Math.round(s/100*255)<<16|Math.round(i/100*255)<<8|Math.round(t/100*255))>>>0}Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_FOREGROUND=t.DEFAULT_BACKGROUND=t.PALETTE_ANSI_256=t.PALETTE_VT340_GREY=t.PALETTE_VT340_COLOR=t.normalizeHLS=t.normalizeRGB=t.nearestColorIndex=t.fromRGBA8888=t.toRGBA8888=t.alpha=t.blue=t.green=t.red=t.BIG_ENDIAN=void 0,t.BIG_ENDIAN=255===new Uint8Array(new Uint32Array([4278190080]).buffer)[0],t.BIG_ENDIAN&&console.warn("BE platform detected. This version of node-sixel works only on LE properly."),t.red=i,t.green=s,t.blue=e,t.alpha=function(t){return t>>>24&255},t.toRGBA8888=h,t.fromRGBA8888=function(t){return[255&t,t>>8&255,t>>16&255,t>>>24]},t.nearestColorIndex=function(t,h){let r=i(t),n=s(t),o=e(t),l=Number.MAX_SAFE_INTEGER,a=-1;for(let t=0;t<h.length;++t){let i=r-h[t][0],s=n-h[t][1],e=o-h[t][2],u=i*i+s*s+e*e;if(!u)return t;u<l&&(l=u,a=t)}return a},t.normalizeRGB=o,t.normalizeHLS=function(t,i,s){return function(t,i,s){if(!s){let t=Math.round(255*i);return h(t,t,t)}let e=i<.5?i*(1+s):i+s-i*s,o=2*i-e;return h(r(0,255,Math.round(255*n(e,o,t+1/3))),r(0,255,Math.round(255*n(e,o,t))),r(0,255,Math.round(255*n(e,o,t-1/3))))}((t+240)/360,i/100,s/100)},t.PALETTE_VT340_COLOR=new Uint32Array([o(0,0,0),o(20,20,80),o(80,13,13),o(20,80,20),o(80,20,80),o(20,80,80),o(80,80,20),o(53,53,53),o(26,26,26),o(33,33,60),o(60,26,26),o(33,60,33),o(60,33,60),o(33,60,60),o(60,60,33),o(80,80,80)]),t.PALETTE_VT340_GREY=new Uint32Array([o(0,0,0),o(13,13,13),o(26,26,26),o(40,40,40),o(6,6,6),o(20,20,20),o(33,33,33),o(46,46,46),o(0,0,0),o(13,13,13),o(26,26,26),o(40,40,40),o(6,6,6),o(20,20,20),o(33,33,33),o(46,46,46)]),t.PALETTE_ANSI_256=(()=>{let t=[h(0,0,0),h(205,0,0),h(0,205,0),h(205,205,0),h(0,0,238),h(205,0,205),h(0,250,205),h(229,229,229),h(127,127,127),h(255,0,0),h(0,255,0),h(255,255,0),h(92,92,255),h(255,0,255),h(0,255,255),h(255,255,255)],i=[0,95,135,175,215,255];for(let s=0;s<6;++s)for(let e=0;e<6;++e)for(let r=0;r<6;++r)t.push(h(i[s],i[e],i[r]));for(let i=8;i<=238;i+=10)t.push(h(i,i,i));return new Uint32Array(t)})(),t.DEFAULT_BACKGROUND=h(0,0,0,255),t.DEFAULT_FOREGROUND=h(255,255,255,255)})),Wa=Pa((t=>{function i(t){if(typeof Buffer<"u")return Buffer.from(t,"base64");let i=atob(t),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return s}Object.defineProperty(t,"__esModule",{value:!0}),t.InWasm=void 0,t.InWasm=function(t){if(t.d){let s,e,{t:h,s:r,d:n}=t,o=WebAssembly;return 2===h?r?()=>s||(s=i(n)):()=>Promise.resolve(s||(s=i(n))):1===h?r?()=>e||(e=new o.Module(s||(s=i(n)))):()=>e?Promise.resolve(e):o.compile(s||(s=i(n))).then((t=>e=t)):r?t=>new o.Instance(e||(e=new o.Module(s||(s=i(n)))),t):t=>e?o.instantiate(e,t):o.instantiate(s||(s=i(n)),t).then((t=>(e=t.module)&&t.instance))}if(typeof _wasmCtx>"u")throw Error('must run "inwasm"');_wasmCtx.add(t)}})),za=Pa((t=>{Object.defineProperty(t,"__esModule",{value:!0});var i=(0,Wa().InWasm)({s:1,t:0,d:"AGFzbQEAAAABBQFgAAF/Ag8BA2VudgZtZW1vcnkCAAEDAwIAAAcNAgNkZWMAAANlbmQAAQqxAwKuAQEFf0GIKCgCAEGgKGohAUGEKCgCACIAQYAoKAIAQQFrQXxxIgJIBEAgAkGgKGohAyAAQaAoaiEAA0AgAC0AA0ECdCgCgCAgAC0AAkECdCgCgBggAC0AAUECdCgCgBAgAC0AAEECdCgCgAhycnIiBEH///8HSwRAQQEPCyABIAQ2AgAgAUEDaiEBIABBBGoiACADSQ0ACwtBhCggAjYCAEGIKCABQaAoazYCAEEAC/4BAQZ/AkBBgCgoAgAiAUGEKCgCACIAa0EFTgRAQQEhAxAADQFBgCgoAgAhAUGEKCgCACEAC0EBIQMgASAAayIEQQJIDQAgAEGhKGotAABBAnQoAoAQIABBoChqLQAAQQJ0KAKACHIhAQJAIARBAkYEQEEBIQIMAQtBASECIAAtAKIoIgVBPUcEQEECIQIgBUECdCgCgBggAXIhAQsgBEEERw0AIAAtAKMoIgBBPUYNACACQQFqIQIgAEECdCgCgCAgAXIhAQsgAUH///8HSw0AQYgoKAIAQaAoaiABNgIAQYgoQYgoKAIAIAJqIgA2AgAgAEGQKCgCAEchAwsgAwsAdglwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQEFY2xhbmdWMTguMC4wIChodHRwczovL2dpdGh1Yi5jb20vbGx2bS9sbHZtLXByb2plY3QgZDFlNjg1ZGY0NWRjNTk0NGI0M2QyNTQ3ZDAxMzhjZDRhM2VlNGVmZSkALA90YXJnZXRfZmVhdHVyZXMCKw9tdXRhYmxlLWdsb2JhbHMrCHNpZ24tZXh0"}),s=new Uint8Array("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").map((t=>t.charCodeAt(0)))),e=new Uint32Array(1024);e.fill(4278190080);for(let t=0;t<s.length;++t)e[s[t]]=t<<2;for(let t=0;t<s.length;++t)e[256+s[t]]=t>>4|(t<<4&255)<<8;for(let t=0;t<s.length;++t)e[512+s[t]]=t>>2<<8|(t<<6&255)<<16;for(let t=0;t<s.length;++t)e[768+s[t]]=t<<16;var h=new Uint8Array(0);t.default=class{constructor(t){this.keepSize=t}get data8(){return this._inst?this._d.subarray(0,this._m32[1282]):h}release(){this._inst&&(this._mem.buffer.byteLength>this.keepSize?this._inst=this._m32=this._d=this._mem=null:(this._m32[1280]=0,this._m32[1281]=0,this._m32[1282]=0))}init(t){let s=this._m32,h=4*(Math.ceil(t/3)+1288);this._inst?this._mem.buffer.byteLength<h&&(this._mem.grow(Math.ceil((h-this._mem.buffer.byteLength)/65536)),s=new Uint32Array(this._mem.buffer,0),this._d=new Uint8Array(this._mem.buffer,5152)):(this._mem=new WebAssembly.Memory({initial:Math.ceil(h/65536)}),this._inst=i({env:{memory:this._mem}}),s=new Uint32Array(this._mem.buffer,0),s.set(e,256),this._d=new Uint8Array(this._mem.buffer,5152)),s[1284]=t,s[1283]=4*Math.ceil(t/3),s[1280]=0,s[1281]=0,s[1282]=0,this._m32=s}put(t,i,s){if(!this._inst)return 1;let e=this._m32;return s-i+e[1280]>e[1283]?1:(this._d.set(t.subarray(i,s),e[1280]),e[1280]+=s-i,e[1280]-e[1281]>=131072?this._inst.exports.dec():0)}end(){return this._inst?this._inst.exports.end():1}}})),Ka=Pa((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LIMITS=void 0,t.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:"AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF"}})),qa=Pa((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsync=t.decode=t.Decoder=t.DecoderAsync=void 0;var i,s=Oa(),e=Ka(),h=function(t){if(typeof Buffer<"u")return Buffer.from(t,"base64");let i=atob(t),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return s}(e.LIMITS.BYTES),r=new Uint32Array,n=class{constructor(){this.bandHandler=()=>1,this.modeHandler=()=>1}handle_band(t){return this.bandHandler(t)}mode_parsed(t){return this.modeHandler(t)}},o={memoryLimit:134217728,sixelColor:s.DEFAULT_FOREGROUND,fillColor:s.DEFAULT_BACKGROUND,palette:s.PALETTE_VT340_COLOR,paletteLimit:e.LIMITS.PALETTE_SIZE,truncate:!0};function l(t){let s=new n,e={env:{handle_band:s.handle_band.bind(s),mode_parsed:s.mode_parsed.bind(s)}};return WebAssembly.instantiate(i||h,e).then((e=>(i=i||e.module,new a(t,e.instance||e,s))))}t.DecoderAsync=l;var a=class{constructor(t,n,l){if(this._PIXEL_OFFSET=e.LIMITS.MAX_WIDTH+4,this._canvas=r,this._bandWidths=[],this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},o,t),this._opts.paletteLimit>e.LIMITS.PALETTE_SIZE)throw Error("DecoderOptions.paletteLimit must not exceed "+e.LIMITS.PALETTE_SIZE);if(n)l.bandHandler=this._handle_band.bind(this),l.modeHandler=this._initCanvas.bind(this);else{let t=i||(i=new WebAssembly.Module(h));n=new WebAssembly.Instance(t,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=n,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),e.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),e.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(s.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(t){if(2===t){let t=this.width*this.height;if(t>this._canvas.length){if(this._opts.memoryLimit&&4*t>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");this._canvas=new Uint32Array(t)}this._maxWidth=this._width}else if(1===t)if(2===this._level){let t=Math.min(this._rasterWidth,e.LIMITS.MAX_WIDTH)*this._rasterHeight;if(t>this._canvas.length){if(this._opts.memoryLimit&&4*t>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");this._canvas=new Uint32Array(t)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536));return 0}_realloc(t,i){let s=t+i;if(s>this._canvas.length){if(this._opts.memoryLimit&&4*s>this._opts.memoryLimit)throw this.release(),Error("image exceeds memory limit");let t=new Uint32Array(65536*Math.ceil(s/65536));t.set(this._canvas),this._canvas=t}}_handle_band(t){let i=this._PIXEL_OFFSET,s=this._lastOffset;if(2===this._mode){let e=this.height-this._currentHeight,h=0;for(;h<6&&e>0;)this._canvas.set(this._pSrc.subarray(i*h,i*h+t),s+t*h),h++,e--;this._lastOffset+=t*h,this._currentHeight+=h}else if(1===this._mode){this._realloc(s,6*t),this._maxWidth=Math.max(this._maxWidth,t),this._minWidth=Math.min(this._minWidth,t);for(let e=0;e<6;++e)this._canvas.set(this._pSrc.subarray(i*e,i*e+t),s+t*e);this._bandWidths.push(t),this._lastOffset+=6*t,this._currentHeight+=6}return 0}get width(){return 1!==this._mode?this._width:Math.max(this._maxWidth,this._wasm.current_width())}get height(){return 1!==this._mode?this._height:this._wasm.current_width()?6*this._bandWidths.length+this._wasm.current_height():6*this._bandWidths.length}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(t=this._opts.fillColor,i=this._opts.palette,s=this._opts.paletteLimit,h=this._opts.truncate){this._wasm.init(this._opts.sixelColor,t,s,h?1:0),i&&this._palette.set(i.subarray(0,e.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(t,i=0,s=t.length){let h=i;for(;h<s;){let i=Math.min(s-h,e.LIMITS.CHUNK_SIZE);this._chunk.set(t.subarray(h,h+=i)),this._wasm.decode(0,i)}}decodeString(t,i=0,s=t.length){let h=i;for(;h<s;){let i=Math.min(s-h,e.LIMITS.CHUNK_SIZE);for(let s=0,e=h;s<i;++s,++e)this._chunk[s]=t.charCodeAt(e);h+=i,this._wasm.decode(0,i)}}get data32(){if(0===this._mode||!this.width||!this.height)return r;let t=this._wasm.current_width();if(2===this._mode){let i=this.height-this._currentHeight;if(i>0){let s=this._PIXEL_OFFSET,e=this._lastOffset,h=0;for(;h<6&&i>0;)this._canvas.set(this._pSrc.subarray(s*h,s*h+t),e+t*h),h++,i--;i&&this._canvas.fill(this._fillColor,e+t*h)}return this._canvas.subarray(0,this.width*this.height)}if(1===this._mode){if(this._minWidth===this._maxWidth){let i=!1;if(t)if(t!==this._minWidth)i=!0;else{let i=this._PIXEL_OFFSET,s=this._lastOffset;this._realloc(s,6*t);for(let e=0;e<6;++e)this._canvas.set(this._pSrc.subarray(i*e,i*e+t),s+t*e)}if(!i)return this._canvas.subarray(0,this.width*this.height)}let i=new Uint32Array(this.width*this.height);i.fill(this._fillColor);let s=0,e=0;for(let t=0;t<this._bandWidths.length;++t){let h=this._bandWidths[t];for(let t=0;t<6;++t)i.set(this._canvas.subarray(e,e+=h),s),s+=this.width}if(t){let e=this._PIXEL_OFFSET,h=this._wasm.current_height();for(let r=0;r<h;++r)i.set(this._pSrc.subarray(e*r,e*r+t),s+this.width*r)}return i}return r}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=r,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=e.LIMITS.MAX_WIDTH,this._wasm.init(s.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};t.Decoder=a,t.decode=function(t,i){let s=new a(i);return s.init(),"string"==typeof t?s.decodeString(t):s.decode(t),{width:s.width,height:s.height,data32:s.data32,data8:s.data8}},t.decodeAsync=async function(t,i){let s=await l(i);return s.init(),"string"==typeof t?s.decodeString(t):s.decode(t),{width:s.width,height:s.height,data32:s.data32,data8:s.data8}}})),ja=Ja(Oa());
38
38
  /**
39
39
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
40
40
  * @license MIT
@@ -46,4 +46,4 @@ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
46
46
  * Fabrice Bellard's javascript vt100 for jslinux:
47
47
  * http://bellard.org/jslinux/
48
48
  * Copyright (c) 2011 Fabrice Bellard
49
- */function Ol(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(yl||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(El||={});var Wl=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(El.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Wl.DISABLE_DISPOSED_WARNING=!1;var zl=Wl,ql=class{constructor(){this._store=new zl}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};ql.None=Object.freeze({dispose(){}});var Kl=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}},jl=class t extends ql{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new Kl),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Ol((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,a=Math.ceil(o.width/r),l=i%a*r,c=Math.floor(i/a)*n,u=s*r,A=e*n,f=h*r+l>o.width?o.width-l:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(l),Math.floor(c),Math.ceil(f),Math.ceil(d),Math.floor(u),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,a=Math.floor(s/n)*h,l=e+o>r.width?r.width-o:e,c=a+h>r.height?r.height-a:h,u=t.createCanvas(this.document,l,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(a),Math.floor(l),Math.floor(c),0,0,Math.floor(l),Math.floor(c)),u):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,Jl.toRGBA8888)(0,0,0),a=(0,Jl.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=a}h.putImageData(r,0,0);let l=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,l,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<l;t+=s)c.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},Yl={width:7,height:14},Zl=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},Xl=new Zl,Vl=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,a=r.x,l=r.y,c=a,u=0;this._opts.sixelScrolling||(r.x=0,r.y=0,c=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(c+e>=n);++e)this._writeToCell(i,c+e,h,t*s+e),u++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=c}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=c:(r.x=a,r.y=l);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:u,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||Xl,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,a=s,l=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||Xl)&&e.imageId===r&&e.tileId===o+l;)l++;s--,n?n.actual&&this._renderer.draw(n,o,a,t,l):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(a,t,l),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||Xl,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let a=Math.min(t.cols,n-i.tileId%n+e),l=i.tileId;for(let t=e+1;t<a;++t)this._writeToCell(s,t,h,++l),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=jl.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new Zl(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new Zl(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},tc=Fl(Tl());function ic(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function sc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw Error("illegal char");i=10*i+t[s]-48}return i}function ec(t){let i=ic(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var hc={inline:sc,size:sc,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(ic(t),"base64");let i=atob(ic(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:ec,height:ec,preserveAspectRatio:sc},rc=[70,105,108,101],nc=1024,oc=class{constructor(){this.state=0,this._buffer=new Uint32Array(nc),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<4;++t)if(r[t]!==rc[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=nc)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=nc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ic(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=hc[this._key]?hc[this._key](i):i}catch{return!1}return!0}return!1}},ac={mime:"unsupported",width:0,height:0},lc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},cc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new oc,this._header=lc,this._dec=new tc.default(4194304),this._metrics=ac}reset(){}start(){this._aborted=!1,this._header=lc,this._metrics=ac,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},lc,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return ac;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?ac:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=jl.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||Yl.width,e=this._renderer.dimensions?.css.cell.height||Yl.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},uc=Fl(Hl()),Ac=Fl(Pl()),fc=uc.PALETTE_ANSI_256;fc.set(uc.PALETTE_VT340_COLOR);var dc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Ac.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:fc,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,fc,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=gc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=gc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn("SIXEL: error while decoding image - "+t),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=jl.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function gc(t){return uc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var wc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},pc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},wc,t),this._defaultOpts=Object.assign({},wc,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new jl(t),this._storage=new Vl(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new dc(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new cc(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=Yl;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};class Cc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Ec.unregister(this),t}free(){const t=this.__destroy_into_raw();Kc.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_authenticate(this.__wbg_ptr,e,h,r,jc,Tc(s)?4294967297:s>>>0)}connect(){Kc.channel_connect(this.__wbg_ptr)}disconnect(){Kc.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==Kc.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==Kc.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc;var o=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);const a=Kc.channel_new(e,h,r,n,o,jc);return this.__wbg_ptr=a>>>0,Ec.register(this,this.__wbg_ptr,this),this}on_connection_close(t){Kc.channel_on_connection_close(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_error(t){Kc.channel_on_connection_error(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_message(t){Kc.channel_on_connection_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_open(t){Kc.channel_on_connection_open(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_protocol_message(t){Kc.channel_on_protocol_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}open_sftp_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_chunk(this.__wbg_ptr,r,jc,i,s,e,Tc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc,n=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,jc,Tc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=function(t){const i=(0,Kc.__wbindgen_export)(1*t.length,1)>>>0;return Rc().set(t,i/1),jc=t.length,i}(r);Kc.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,jc,Tc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),c=jc,u=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,jc,h,r,Tc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e,h,r){const n=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_terminal_resize(this.__wbg_ptr,n,jc,i,s,e,h,r)}send_ssh_tunnel_data(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,jc)}start_heartbeat(t){Kc.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){Kc.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(Cc.prototype[Symbol.dispose]=Cc.prototype.free);const mc=Object.freeze({Generic:0,0:"Generic",Authentication:10,10:"Authentication",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Ic(){const t={__proto__:null,__wbg_Error_2e59b1b37a9a34c3:function(t,i){return Qc(Error(Sc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Pc(Nc(i)+"",Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57:function(t,i){const s=Pc(xc(Nc(i)),Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_914df97fcfa788f2:function(t,i){const s=Nc(i),e="string"==typeof s?s:void 0;var h=Tc(e)?0:Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;_c().setInt32(t+4,r,!0),_c().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_81fc77679af83bc6:function(t,i){throw Error(Sc(t,i))},__wbg__wbg_cb_unref_3c3b4f651835fbcb:function(t){Nc(t)._wbg_cb_unref()},__wbg_call_7f2987183bb62793:function(){return Fc((function(t,i){return Qc(Nc(t).call(Nc(i)))}),arguments)},__wbg_call_d578befcc3145dee:function(){return Fc((function(t,i,s){return Qc(Nc(t).call(Nc(i),Nc(s)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return Qc(clearInterval(Jc(t)))},__wbg_close_f181fdc02ee236e6:function(){return Fc((function(t){Nc(t).close()}),arguments)},__wbg_data_60b50110c5bd9349:function(t){return Qc(Nc(t).data)},__wbg_from_741da0f916ab74aa:function(t){return Qc(Array.from(Nc(t)))},__wbg_info_38afa9e6e86ac5a5:function(t,i){console.info(Sc(t,i))},__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a:function(t){let i;try{i=Nc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_0c32cb8543c8e4c8:function(t){return Nc(t).length},__wbg_new_4f9fafbb3909af72:function(){return Qc({})},__wbg_new_a560378ea1240b14:function(t){return Qc(new Uint8Array(Nc(t)))},__wbg_new_f3c9df4f38f3f798:function(){return Qc([])},__wbg_new_with_str_sequence_e6b5bb982fdcf253:function(){return Fc((function(t,i,s){return Qc(new WebSocket(Sc(t,i),Nc(s)))}),arguments)},__wbg_prototypesetcall_3e05eb9545565046:function(t,i,s){Uint8Array.prototype.set.call(Dc(t,i),Nc(s))},__wbg_push_6bdbc990be5ac37b:function(t,i){return Nc(t).push(Nc(i))},__wbg_readyState_631d9f7c37e595d7:function(t){return Nc(t).readyState},__wbg_send_64dd480ad0d86a31:function(){return Fc((function(t,i,s){Nc(t).send(Dc(i,s))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return Fc((function(t,i){return Qc(setInterval(Nc(t),i))}),arguments)},__wbg_set_6be42768c690e380:function(t,i,s){Nc(t)[Jc(i)]=Jc(s)},__wbg_set_6c60b2e8ad0e9383:function(t,i,s){Nc(t)[i>>>0]=Jc(s)},__wbg_set_binaryType_95c0a0f7586a3903:function(t,i){Nc(t).binaryType=yc[i]},__wbg_set_onclose_47cce56c686db4fb:function(t,i){Nc(t).onclose=Nc(i)},__wbg_set_onerror_3db8bc3e52b2b10b:function(t,i){Nc(t).onerror=Nc(i)},__wbg_set_onmessage_45bd33b110c54f5b:function(t,i){Nc(t).onmessage=Nc(i)},__wbg_set_onopen_7ffeb01f8a628209:function(t,i){Nc(t).onopen=Nc(i)},__wbg_warn_d8fb60272adc4bb8:function(t,i){console.warn(Sc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Qc(Gc(t,i,bc))},__wbindgen_cast_0000000000000002:function(t,i){return Qc(Gc(t,i,Bc))},__wbindgen_cast_0000000000000003:function(t,i){return Qc(Gc(t,i,Mc))},__wbindgen_cast_0000000000000004:function(t,i){return Qc(Gc(t,i,vc))},__wbindgen_cast_0000000000000005:function(t){return Qc(t)},__wbindgen_cast_0000000000000006:function(t,i){return Qc(Dc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Qc(Sc(t,i))},__wbindgen_cast_0000000000000008:function(t){return Qc(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Qc(Nc(t))},__wbindgen_object_drop_ref:function(t){Jc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function vc(t,i){Kc.__wasm_bindgen_func_elem_42(t,i)}function bc(t,i,s){Kc.__wasm_bindgen_func_elem_39(t,i,Qc(s))}function Bc(t,i,s){Kc.__wasm_bindgen_func_elem_39_1(t,i,Qc(s))}function Mc(t,i,s){Kc.__wasm_bindgen_func_elem_39_2(t,i,Qc(s))}const yc=["blob","arraybuffer"],Ec="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbg_channel_free(t>>>0,1)));function Qc(t){Uc===Hc.length&&Hc.push(Hc.length+1);const i=Uc;return Uc=Hc[i],Hc[i]=t,i}const kc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbindgen_export4(t.a,t.b)));function xc(t){const i=typeof t;if("number"==i||"boolean"==i||null==t)return""+t;if("string"==i)return`"${t}"`;if("symbol"==i){const i=t.description;return null==i?"Symbol":`Symbol(${i})`}if("function"==i){const i=t.name;return"string"==typeof i&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){const i=t.length;let s="[";i>0&&(s+=xc(t[0]));for(let e=1;e<i;e++)s+=", "+xc(t[e]);return s+="]",s}const s=/\[object ([^\]]+)\]/.exec(toString.call(t));let e;if(!(s&&s.length>1))return toString.call(t);if(e=s[1],"Object"==e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:e}function Dc(t,i){return t>>>=0,Rc().subarray(t/1,t/1+i)}let Lc=null;function _c(){return(null===Lc||!0===Lc.buffer.detached||void 0===Lc.buffer.detached&&Lc.buffer!==Kc.memory.buffer)&&(Lc=new DataView(Kc.memory.buffer)),Lc}function Sc(t,i){return function(t,i){return zc+=i,zc>=Wc&&(Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Oc.decode(),zc=i),Oc.decode(Rc().subarray(t,t+i))}(t>>>=0,i)}let $c=null;function Rc(){return null!==$c&&0!==$c.byteLength||($c=new Uint8Array(Kc.memory.buffer)),$c}function Nc(t){return Hc[t]}function Fc(t,i){try{return t.apply(this,i)}catch(t){Kc.__wbindgen_export3(Qc(t))}}let Hc=Array(1024).fill(void 0);Hc.push(void 0,null,!0,!1);let Uc=Hc.length;function Tc(t){return null==t}function Gc(t,i,s){const e={a:t,b:i,cnt:1},h=(...t)=>{e.cnt++;const i=e.a;e.a=0;try{return s(i,e.b,...t)}finally{e.a=i,h._wbg_cb_unref()}};return h._wbg_cb_unref=()=>{0==--e.cnt&&(Kc.__wbindgen_export4(e.a,e.b),e.a=0,kc.unregister(e))},kc.register(h,e,e),h}function Pc(t,i,s){if(void 0===s){const s=qc.encode(t),e=i(s.length,1)>>>0;return Rc().subarray(e,e+s.length).set(s),jc=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Rc();let n=0;for(;n<e;n++){const i=t.charCodeAt(n);if(i>127)break;r[h+n]=i}if(n!==e){0!==n&&(t=t.slice(n)),h=s(h,e,e=n+3*t.length,1)>>>0;const i=Rc().subarray(h+n,h+e);n+=qc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return jc=n,h}function Jc(t){const i=Nc(t);return function(t){t<1028||(Hc[t]=Uc,Uc=t)}(t),i}let Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Oc.decode();const Wc=2146435072;let zc=0;const qc=new TextEncoder;"encodeInto"in qc||(qc.encodeInto=function(t,i){const s=qc.encode(t);return i.set(s),{read:t.length,written:s.length}});let Kc,jc=0;var Yc,Zc;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(Yc||(Yc={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(Zc||(Zc={}));const Xc=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=e(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=Yc.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return this}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await async function(t){if(void 0!==Kc)return Kc;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const i=Ic();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,i){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,i)}catch(i){if(!t.ok||!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw i;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,i)}{const s=await WebAssembly.instantiate(t,i);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,i);return function(t){return Kc=t.exports,Lc=null,$c=null,Kc}(s)}(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeDebounceHandle&&(clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=void 0),this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}is_terminal_open(){return!!(this.connected&&this.containerEl&&this.terminal.element)}fit_terminal_safely(){if(this.fitAddon&&this.is_terminal_open())try{this.fitAddon.fit()}catch(t){console.warn("Skipping terminal fit before renderer is ready:",t)}}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new dr(this.terminalOptions),this.fitAddon=new gr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new vr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new In,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new kl,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new pc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Al,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([Zc.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([Zc.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([Zc.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case"Error":this.handle_error(i);break;case"AuthSuccess":this.handle_auth_success(i);break;case"TunnelOpened":this.handle_tunnel_opened(i);break;case"TunnelClosed":this.handle_tunnel_closed(i);break;case"TunnelData":this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fit_terminal_safely();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case mc.Generic:case mc.Authentication:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus(),this.usernameBuffer="",this.passwordBuffer="";break;case mc.RequiresUsername:this.terminal.reset(),this.inputMode=Yc.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case mc.RequiresPassword:this.terminal.reset(),this.inputMode=Yc.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fit_terminal_safely(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.connected=!0,this.fit_terminal_safely(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fit_terminal_safely(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case Yc.Username:this.handle_username_input(t);break;case Yc.Password:this.handle_password_input(t);break;case Yc.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return h(r,{key:"e56bf0b0f8825571a341588cfc4c99432d056eb6"},h("div",{key:"91e2d8d168fac1c488059ba0b42da089d0b2bf30",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}"}},[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function Vc(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),Xc))}))}Vc();const tu=Xc,iu=Vc;export{tu as PhirepassTerminal,iu as defineCustomElement}
49
+ */function Ya(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(La||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Sa||={});var Za=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(Sa.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(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(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Za.DISABLE_DISPOSED_WARNING=!1;var Xa=Za,Va=class{constructor(){this._store=new Xa}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};Va.None=Object.freeze({dispose(){}});var tu=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}},iu=class t extends Va{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new tu),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Ya((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,l=Math.ceil(o.width/r),a=i%l*r,u=Math.floor(i/l)*n,c=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=u+n>o.height?o.height-u:n;this._ctx.drawImage(o,Math.floor(a),Math.floor(u),Math.ceil(f),Math.ceil(d),Math.floor(c),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,u=l+h>r.height?r.height-l:h,c=t.createCanvas(this.document,a,u),A=c.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(u),0,0,Math.floor(a),Math.floor(u)),c):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,ja.toRGBA8888)(0,0,0),l=(0,ja.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=l}h.putImageData(r,0,0);let a=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,a,i);let u=this._placeholder.getContext("2d",{alpha:!1});if(u){for(let t=0;t<a;t+=s)u.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},su={width:7,height:14},eu=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},hu=new eu,ru=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=su);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=su);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,l=r.x,a=r.y,u=l,c=0;this._opts.sixelScrolling||(r.x=0,r.y=0,u=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(u+e>=n);++e)this._writeToCell(i,u+e,h,t*s+e),c++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=u}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=u:(r.x=l,r.y=a);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:c,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||hu,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,l=s,a=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||hu)&&e.imageId===r&&e.tileId===o+a;)a++;s--,n?n.actual&&this._renderer.draw(n,o,l,t,a):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(l,t,a),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||hu,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let l=Math.min(t.cols,n-i.tileId%n+e),a=i.tileId;for(let t=e+1;t<l;++t)this._writeToCell(s,t,h,++a),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||hu;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=iu.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||hu;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new eu(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new eu(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},nu=Ja(za());function ou(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function lu(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw Error("illegal char");i=10*i+t[s]-48}return i}function au(t){let i=ou(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var uu={inline:lu,size:lu,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(ou(t),"base64");let i=atob(ou(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:au,height:au,preserveAspectRatio:lu},cu=[70,105,108,101],Au=1024,fu=class{constructor(){this.state=0,this._buffer=new Uint32Array(Au),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<4;++t)if(r[t]!==cu[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=Au)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=Au)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ou(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=uu[this._key]?uu[this._key](i):i}catch{return!1}return!0}return!1}},du={mime:"unsupported",width:0,height:0},gu={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},wu=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new fu,this._header=gu,this._dec=new nu.default(4194304),this._metrics=du}reset(){}start(){this._aborted=!1,this._header=gu,this._metrics=du,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},gu,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return du;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?du:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=iu.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||su.width,e=this._renderer.dimensions?.css.cell.height||su.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},pu=Ja(Oa()),Cu=Ja(qa()),mu=pu.PALETTE_ANSI_256;mu.set(pu.PALETTE_VT340_COLOR);var Iu=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Cu.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:mu,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,mu,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=vu(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,pu.toRGBA8888)(...i)}else s=vu(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=vu(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,pu.toRGBA8888)(...i)}else s=vu(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn("SIXEL: error while decoding image - "+t),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=iu.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function vu(t){return pu.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var Bu={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},Mu=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},Bu,t),this._defaultOpts=Object.assign({},Bu,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new iu(t),this._storage=new ru(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new Iu(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new wu(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=su;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};const yu=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=e(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=n.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return this}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await o(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeDebounceHandle&&(clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=void 0),this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}is_terminal_open(){return!!(this.connected&&this.containerEl&&this.terminal.element)}fit_terminal_safely(){if(this.fitAddon&&this.is_terminal_open())try{this.fitAddon.fit()}catch(t){console.warn("Skipping terminal fit before renderer is ready:",t)}}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new Ir(this.terminalOptions),this.fitAddon=new vr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new br,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new En,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new $a,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new Mu(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Ca,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new l(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new l(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([a.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([a.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([a.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case u.Error:this.handle_error(i);break;case u.AuthSuccess:this.handle_auth_success(i);break;case u.TunnelOpened:this.handle_tunnel_opened(i);break;case u.TunnelClosed:this.handle_tunnel_closed(i);break;case u.TunnelData:this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fit_terminal_safely();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case c.Generic:case c.Authentication:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus(),this.usernameBuffer="",this.passwordBuffer="";break;case c.RequiresUsername:case c.RequiresUsernamePassword:this.terminal.reset(),this.inputMode=n.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case c.RequiresPassword:this.terminal.reset(),this.inputMode=n.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=n.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=n.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fit_terminal_safely(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=n.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.connected=!0,this.fit_terminal_safely(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fit_terminal_safely(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case n.Username:this.handle_username_input(t);break;case n.Password:this.handle_password_input(t);break;case n.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=n.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=n.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return h(r,{key:"274fd3f8db8cb3f48bd956ba40d5aacb8ec15e1f"},h("div",{key:"644c586e190c63651d9e521793611a83d372d0ad",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}"}},[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function Qu(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),yu))}))}Qu();const Eu=yu,bu=Qu;export{Eu as PhirepassTerminal,bu as defineCustomElement}