phirepass-widgets 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/phirepass-terminal.cjs.entry.js +2 -1
- package/dist/collection/components/phirepass-terminal/phirepass-terminal.js +2 -1
- package/dist/components/phirepass-terminal.js +3 -3
- package/dist/esm/phirepass-terminal.entry.js +2 -1
- package/dist/phirepass-widgets/{p-13e452ab.entry.js → p-4d9374b4.entry.js} +4 -4
- package/dist/phirepass-widgets/phirepass-widgets.esm.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import{r as t,g as i,h as s,H as e}from"./p-BZOTLEeX.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 h=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=(t,i,s,e)=>{for(var n,o=e>1?void 0:e?r(i,s):i,a=t.length-1;a>=0;a--)(n=t[a])&&(o=(e?n(i,s,o):n(o))||o);return e&&o&&h(i,s,o),o},o=(t,i)=>(s,e)=>i(s,e,t),a="Terminal input",l=()=>a,c="Too much output to announce, navigate to rows manually to read",u=()=>c;function A(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 f(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 d(t,i,s,e,h){f(t,i,s),h&&e.rightClickSelect(t),i.value=e.selectionText,i.select()}function g(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function w(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 p=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}},C=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}},m=" ",I=class t{constructor(){this.fg=0,this.bg=0,this.extended=new v}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}},v=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}},B=class t extends I{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new v,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?g(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()]}},b="di$target",M="di$dependencies",y=new Map;function E(t){if(y.has(t))return y.get(t);let i=function(t,s,e){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[b]===i?i[M].push({id:t,index:s}):(i[M]=[{id:t,index:s}],i[b]=i)}(i,t,e)};return i._id=t,y.set(t,i),i}var Q=E("BufferService"),k=E("CoreMouseService"),x=E("CoreService"),D=E("CharsetService"),L=E("InstantiationService"),_=E("LogService"),S=E("OptionsService"),$=E("OscLinkService"),R=E("UnicodeService"),N=E("DecorationService"),F=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 B,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):H(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 H(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")}}F=n([o(0,Q),o(1,S),o(2,$)],F);var T=E("CharSizeService"),U=E("CoreBrowserService"),P=E("MouseService"),G=E("RenderService"),J=E("SelectionService"),O=E("CharacterJoinerService"),W=E("ThemeService"),q=E("LinkProviderService"),z=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?tt.isErrorNoTelemetry(t)?new tt(t.message+"\n\n"+t.stack):new 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 K(t){(function(t){return t instanceof V||t instanceof Error&&t.name===X&&t.message===X})(t)||z.onUnexpectedError(t)}var j,Y,Z,X="Canceled",V=class extends Error{constructor(){super(X),this.name=this.message}},tt=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}},it=class t extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,t.prototype)}};function st(t,i=0){return t[t.length-(1+i)]}function et(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function ht(t){if(Z.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 rt(t){return{dispose:et((()=>{t()}))}}(Y=j||={}).isLessThan=function(t){return t<0},Y.isLessThanOrEqual=function(t){return t<=0},Y.isGreaterThan=function(t){return t>0},Y.isNeitherLessOrGreaterThan=function(t){return 0===t},Y.greaterThan=1,Y.lessThan=-1,Y.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(Z||={});var nt=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{ht(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};nt.DISABLE_DISPOSED_WARNING=!1;var ot=nt,at=class{constructor(){this._store=new ot}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};at.None=Object.freeze({dispose(){}});var lt=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}},ct="object"==typeof window?window:globalThis,ut=class t{constructor(i){this.element=i,this.next=t.Undefined,this.prev=t.Undefined}};ut.Undefined=new ut(void 0);var At,ft=ut,dt=class{constructor(){this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ft.Undefined}clear(){let t=this._first;for(;t!==ft.Undefined;){let i=t.next;t.prev=ft.Undefined,t.next=ft.Undefined,t=i}this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,i){let s=new ft(t);if(this._first===ft.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!==ft.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==ft.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==ft.Undefined&&t.next!==ft.Undefined){let i=t.prev;i.next=t.next,t.next.prev=i}else t.prev===ft.Undefined&&t.next===ft.Undefined?(this._first=ft.Undefined,this._last=ft.Undefined):t.next===ft.Undefined?(this._last=this._last.prev,this._last.next=ft.Undefined):t.prev===ft.Undefined&&(this._first=this._first.next,this._first.prev=ft.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==ft.Undefined;)yield t.element,t=t.next}},gt=globalThis.performance&&"function"==typeof globalThis.performance.now,wt=class t{static create(i){return new t(i)}constructor(t){this._now=gt&&!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 Et({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 Et(A);return n?.add(f),f.event}t.None=()=>at.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 rt((()=>ht(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 Et({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 Et({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 Et({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 Et;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 Et({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 ot?e.add(o):Array.isArray(e)&&e.push(o),o}}})(At||={});var pt=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 wt,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}}};pt.all=new Set,pt._idPool=0;var Ct=pt,mt=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}};mt._idPool=1;var It=mt,vt=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.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}},bt=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Mt=0,yt=class{constructor(t){this.value=t,this.id=Mt++}},Et=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new It(t?.onListenerError??K,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Ct(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 bt(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||K)(s),at.None}if(this._disposed)return at.None;i&&(t=t.bind(i));let e,h=new yt(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=vt.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof yt?(this._deliveryQueue??=new Qt,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=rt((()=>{e?.(),this._removeListener(h)}));return s instanceof ot?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)),new 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||K;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 yt)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}},Qt=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}},kt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Et,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Et,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}};kt.INSTANCE=new kt;var xt=kt,Dt="object"==typeof navigator?navigator.userAgent:"",Lt=Dt.indexOf("Firefox")>=0,_t=Dt.indexOf("AppleWebKit")>=0,St=Dt.indexOf("Chrome")>=0,$t=!St&&Dt.indexOf("Safari")>=0;if(Dt.indexOf("Electron/"),Dt.indexOf("Android"),"function"==typeof ct.matchMedia){let t=ct.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");ct.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=ct.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Rt,Nt,Ft="en",Ht=!1,Tt=!1,Ut=!1,Pt=!1,Gt=Ft,Jt=globalThis;typeof Jt.vscode<"u"&&typeof Jt.vscode.process<"u"?Nt=Jt.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Nt=process);var Ot="string"==typeof Nt?.versions?.electron&&"renderer"===Nt?.type;if("object"==typeof Nt){Ht="win32"===Nt.platform,Tt="darwin"===Nt.platform,Ut="linux"===Nt.platform,Gt=Ft;let t=Nt.env.VSCODE_NLS_CONFIG;if(t)try{Gt=JSON.parse(t).resolvedLanguage||Ft}catch{}Pt=!0}else"object"!=typeof navigator||Ot?console.error("Unable to resolve platform."):(Ht=(Rt=navigator.userAgent).indexOf("Windows")>=0,Tt=Rt.indexOf("Macintosh")>=0,(Rt.indexOf("Macintosh")>=0||Rt.indexOf("iPad")>=0||Rt.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Ut=Rt.indexOf("Linux")>=0,Rt?.indexOf("Mobi"),Gt=globalThis._VSCODE_NLS_LANGUAGE||Ft,navigator.language.toLowerCase());var Wt,qt,zt=Ht,Kt=Tt,jt=Ut,Yt=Pt,Zt=Rt,Xt=Gt;(qt=Wt||={}).value=function(){return Xt},qt.isDefaultVariant=function(){return 2===Xt.length?"en"===Xt:Xt.length>=3&&"e"===Xt[0]&&"n"===Xt[1]&&"-"===Xt[2]},qt.isDefault=function(){return"en"===Xt};var Vt="function"==typeof Jt.postMessage&&!Jt.importScripts;(()=>{if(Vt){let t=[];Jt.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=new 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 new 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(Lt)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(_t){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(St){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?Lt&&!Kt?-t.deltaY/3:-t.deltaY:-t.deltaY/40),typeof i.wheelDeltaX<"u"?this.deltaX=$t&&zt?-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?Lt&&!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 vi||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:At.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ci})})(di||={});var mi,Ii,vi=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 Et),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 it("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout((()=>{this._token=-1,t()}),i)}setIfNotSet(t,i){if(this._isDisposed)throw new it("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 it("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let e=s.setInterval((()=>{t()}),i);this.disposable=rt((()=>{s.clearInterval(e),this.disposable=void 0}))}dispose(){this.cancel(),this.isDisposed=!0}};(Ii=mi||={}).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},Ii.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))};var Mi=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 Et,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 At.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())}};Mi.EMPTY=Mi.fromArray([]);var{getWindow:yi,getWindowId:Ei,onDidRegisterWindow:Qi}=function(){let t=new Map,i={window:ct,disposables:new ot};t.set(ct.vscodeWindowId,i);let s=new Et,e=new Et,h=new Et;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return at.None;let r=new ot,n={window:i,disposables:r.add(new ot)};return t.set(i.vscodeWindowId,n),r.add(rt((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(xi(i,$i.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:ct},getDocument:t=>yi(t).document}}(),ki=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 xi(t,i,s,e){return new ki(t,i,s,e)}var Di,Li=function(t,i,s,e){return xi(t,i,s,e)},_i=class extends bi{constructor(t){super(),this.defaultTarget=t&&yi(t)}cancelAndSet(t,i,s){return super.cancelAndSet(t,i,s??this.defaultTarget)}},Si=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){K(t)}}static sort(t,i){return i.priority-t.priority}};!function(){let t=new Map,i=new Map,s=new Map,e=new Map;Di=(h,r,n=0)=>{let o=Ei(h),a=new Si(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(Si.sort),r.shift().execute();e.set(h,!1)})(o)))),a}}();var $i={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"},Ri=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=Ni(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=Ni(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=Ni(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=Ni(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=Ni(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=Ni(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=Ni(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=Ni(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=Ni(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=Ni(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=Ni(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=Ni(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=Ni(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=Ni(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 Ni(t){return"number"==typeof t?`${t}px`:t}function Fi(t){return new Ri(t)}var Hi,Ti,Ui=class{constructor(){this._hooks=new ot,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(rt((()=>{try{t.releasePointerCapture(i)}catch{}})))}catch{r=yi(t)}this._hooks.add(xi(r,$i.POINTER_MOVE,(t=>{t.buttons===s?(t.preventDefault(),this._pointerMoveCallback(t)):this.stopMonitoring(!0)}))),this._hooks.add(xi(r,$i.POINTER_UP,(()=>this.stopMonitoring(!0))))}};(Ti=Hi||={}).Tap="-xterm-gesturetap",Ti.Change="-xterm-gesturechange",Ti.Start="-xterm-gesturestart",Ti.End="-xterm-gesturesend",Ti.Contextmenu="-xterm-gesturecontextmenu";var Pi=class t extends at{constructor(){super(),this.dispatched=!1,this.targets=new dt,this.ignoreTargets=new dt,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(At.runAndSubscribe(Qi,(({window:t,disposables:i})=>{i.add(xi(t.document,"touchstart",(t=>this.onTouchStart(t)),{passive:!1})),i.add(xi(t.document,"touchend",(i=>this.onTouchEnd(t,i)))),i.add(xi(t.document,"touchmove",(t=>this.onTouchMove(t)),{passive:!1}))}),{window:ct,disposables:this._store}))}static addTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),rt(t.INSTANCE.targets.push(i))):at.None}static ignoreTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),rt(t.INSTANCE.ignoreTargets.push(i))):at.None}static isTouchDevice(){return"ontouchstart"in ct||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(Hi.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(String(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-st(o.rollingPageX))<30&&Math.abs(o.initialPageY-st(o.rollingPageY))<30){let t=this.newGestureEvent(Hi.Tap,o.initialTarget);t.pageX=st(o.rollingPageX),t.pageY=st(o.rollingPageY),this.dispatchEvent(t)}else if(a>=t.HOLD_DELAY&&Math.abs(o.initialPageX-st(o.rollingPageX))<30&&Math.abs(o.initialPageY-st(o.rollingPageY))<30){let t=this.newGestureEvent(Hi.Contextmenu,o.initialTarget);t.pageX=st(o.rollingPageX),t.pageY=st(o.rollingPageY),this.dispatchEvent(t)}else if(1===h){let t=st(o.rollingPageX),s=st(o.rollingPageY),h=st(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(Hi.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===Hi.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===Hi.Change||i.type===Hi.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=Di(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(Hi.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(String(e.identifier))){console.warn("end of an UNKNOWN touch",e);continue}let h=this.activeTouches[e.identifier],r=this.newGestureEvent(Hi.Change,h.initialTarget);r.translationX=e.pageX-st(h.rollingPageX),r.translationY=e.pageY-st(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)}};Pi.SCROLL_FRICTION=-.005,Pi.HOLD_DELAY=700,Pi.CLEAR_TAP_COUNT_TIME=400,n([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 new 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]}}],Pi,"isTouchDevice",1);var Gi=Pi,Ji=class extends at{onclick(t,i){this._register(xi(t,$i.CLICK,(s=>i(new wi(yi(t),s)))))}onmousedown(t,i){this._register(xi(t,$i.MOUSE_DOWN,(s=>i(new wi(yi(t),s)))))}onmouseover(t,i){this._register(xi(t,$i.MOUSE_OVER,(s=>i(new wi(yi(t),s)))))}onmouseleave(t,i){this._register(xi(t,$i.MOUSE_LEAVE,(s=>i(new wi(yi(t),s)))))}onkeydown(t,i){this._register(xi(t,$i.KEY_DOWN,(t=>i(new ui(t)))))}onkeyup(t,i){this._register(xi(t,$i.KEY_UP,(t=>i(new ui(t)))))}oninput(t,i){this._register(xi(t,$i.INPUT,i))}onblur(t,i){this._register(xi(t,$i.BLUR,i))}onfocus(t,i){this._register(xi(t,$i.FOCUS,i))}onchange(t,i){this._register(xi(t,$i.CHANGE,i))}ignoreGesture(t){return Gi.ignoreTarget(t)}},Oi=class extends Ji{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 Ui),this._register(Li(this.bgDomNode,$i.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._register(Li(this.domNode,$i.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._pointerdownRepeatTimer=this._register(new _i),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,yi(t))}),200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(()=>{}),(()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()})),t.preventDefault())}},Wi=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}}},qi=class extends at{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new Wi(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 ji(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=ji.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 Ki(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 ji=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))}}(Ki(t,e),Ki(h,i),.33)}return Ki(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)}},Yi=class extends at{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":"")))}},Zi=class extends Ji{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 Yi(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ui),this._shouldRender=!0,this.domNode=Fi(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(xi(this.domNode.domNode,$i.POINTER_DOWN,(t=>this._domNodePointerDown(t))))}_createArrow(t){let i=this._register(new Oi(t));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(t,i,s,e){this.slider=Fi(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(xi(this.slider.domNode,$i.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=yi(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),r=Math.abs(h-s);if(zt&&r>140)return void this._setDesiredScrollPositionNow(e.getScrollPosition());let n=this._sliderPointerPosition(t)-i;this._setDesiredScrollPositionNow(e.getDesiredScrollPositionFromDelta(n))}),(()=>{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()}},Xi=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}},Vi=class extends Zi{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Xi(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 new 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}},ts=class extends Zi{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Xi(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 new 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}},is=class{constructor(t,i,s){this.timestamp=t,this.deltaX=i,this.deltaY=s,this.score=0}},ss=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(St){let i=yi(t.browserEvent),s=xt.INSTANCE.getZoomFactor(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let e=null,h=new is(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),l=Math.max(e,r),c=Math.max(h,n);l%o==0&&c%a==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ss.INSTANCE=new ss;var es=ss,hs=class extends Ji{constructor(t,i,s){super(),this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Et),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 ts(this._scrollable,this._options,e)),this._horizontalScrollbar=this._register(new Vi(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=Fi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Fi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Fi(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=ht(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){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ht(this._mouseWheelToDispose),t)){let t=t=>{this._onMouseWheel(new pi(t))};this._mouseWheelToDispose.push(xi(this._listenOnDomNode,$i.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let i=es.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,i=r.scrollTop-(t<0?Math.floor(t):Math.ceil(t));this._verticalScrollbar.writeScrollPosition(n,i)}if(h){let t=50*h,i=r.scrollLeft-(t<0?Math.floor(t):Math.ceil(t));this._horizontalScrollbar.writeScrollPosition(n,i)}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 new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),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)}},rs=class extends hs{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()}},ns=class extends at{constructor(t,i,s,e,h,r,n,o){super(),this._bufferService=s,this._optionsService=n,this._renderService=o,this._onRequestScrollLines=this._register(new Et),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let a=this._register(new qi({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:t=>Di(e.window,t)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",(()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)}))),this._scrollableElement=this._register(new rs(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(At.runAndSubscribe(r.onChangeColors,(()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css}))),t.appendChild(this._scrollableElement.getDomNode()),this._register(rt((()=>this._scrollableElement.getDomNode().remove()))),this._styleElement=e.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(rt((()=>this._styleElement.remove()))),this._register(At.runAndSubscribe(r.onChangeColors,(()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}",".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}};ns=n([o(2,Q),o(3,U),o(4,k),o(5,W),o(6,S),o(7,G)],ns);var os=class extends at{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(rt((()=>{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()}};os=n([o(1,Q),o(2,U),o(3,N),o(4,G)],os);var as,ls,cs,us=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)}},As={full:0,left:0,center:0,right:0},fs={full:0,left:0,center:0,right:0},ds={full:0,left:0,center:0,right:0},gs=class extends at{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 us,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(rt((()=>this._canvas?.remove())));let a=this._canvas.getContext("2d");if(!a)throw new 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);fs.full=this._canvas.width,fs.left=t,fs.center=i,fs.right=t,this._refreshDrawHeightConstants(),ds.full=1,ds.left=1,ds.center=1+fs.left,ds.right=1+fs.left+fs.center}_refreshDrawHeightConstants(){As.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);As.left=t,As.center=t,As.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.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(ds[t.position||"full"],Math.round(t.startBufferLine/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)-As[t.position||"full"]/2),fs[t.position||"full"],Math.round((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)+As[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})))}};gs=n([o(2,Q),o(3,N),o(4,G),o(5,S),o(6,W),o(7,U)],gs),(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=""})(ls||={}),(cs||={}).ST=`${as.ESC}\\`;var ws=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=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,e=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=e+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let h=this._compositionView.getBoundingClientRect();this._textarea.style.left=e+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(h.width,1)+"px",this._textarea.style.height=Math.max(h.height,1)+"px",this._textarea.style.lineHeight=h.height+"px"}t||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};ws=n([o(2,Q),o(3,S),o(4,x),o(5,G)],ws);var ps,Cs,ms,Is,vs,Bs=0,bs=0,Ms=0,ys=0,Es={css:"#00000000",rgba:0};function Qs(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ks(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?`#${Qs(t)}${Qs(i)}${Qs(s)}${Qs(e)}`:`#${Qs(t)}${Qs(i)}${Qs(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)}}})(ps||={}),(t=>{function i(t,i){return ys=Math.round(255*i),[Bs,bs,Ms]=vs.toChannels(t.rgba),{css:ps.toCss(Bs,bs,Ms,ys),rgba:ps.toRgba(Bs,bs,Ms,ys)}}t.blend=function(t,i){if(1==(ys=(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 Bs=h+Math.round(((i.rgba>>24&255)-h)*ys),bs=r+Math.round((s-r)*ys),Ms=n+Math.round((e-n)*ys),{css:ps.toCss(Bs,bs,Ms),rgba:ps.toRgba(Bs,bs,Ms)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=vs.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return ps.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Bs,bs,Ms]=vs.toChannels(i),{css:ps.toCss(Bs,bs,Ms),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(ys=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Cs||={}),(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 Bs=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),Ms=parseInt(t.slice(3,4).repeat(2),16),ps.toColor(Bs,bs,Ms);case 5:return Bs=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),Ms=parseInt(t.slice(3,4).repeat(2),16),ys=parseInt(t.slice(4,5).repeat(2),16),ps.toColor(Bs,bs,Ms,ys);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 Bs=parseInt(e[1]),bs=parseInt(e[2]),Ms=parseInt(e[3]),ys=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),ps.toColor(Bs,bs,Ms,ys);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Bs,bs,Ms,ys]=i.getImageData(0,0,1,1).data,255!==ys)throw new Error("css.toColor: Unsupported css format");return{rgba:ps.toRgba(Bs,bs,Ms,ys),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})(Is||={}),(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=ks(Is.relativeLuminance2(n,o,a),Is.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=ks(Is.relativeLuminance2(n,o,a),Is.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=ks(Is.relativeLuminance2(n,o,a),Is.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=ks(Is.relativeLuminance2(n,o,a),Is.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(ys=(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 Bs=h+Math.round(((i>>24&255)-h)*ys),bs=r+Math.round((s-r)*ys),Ms=n+Math.round((e-n)*ys),ps.toRgba(Bs,bs,Ms)},t.ensureContrastRatio=function(t,e,h){let r=Is.relativeLuminance(t>>8),n=Is.relativeLuminance(e>>8);if(ks(r,n)<h){if(n<r){let n=i(t,e,h),o=ks(r,Is.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ks(r,Is.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=ks(r,Is.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>ks(r,Is.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]}})(vs||={});var xs=class extends I{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 new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ds=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new B}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++)Ds._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}};Ds=n([o(0,Q)],Ds);var Ls=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 B,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,v=0,B=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 xs(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,T=!1;this._decorationService.forEachDecorationAtCell(L,i,void 0,(()=>{T=!0}));let U=R.getChars()||m;if(" "===U&&(R.isUnderline()||R.isOverline())&&(U=" "),Q=d*o-a.get(U,R.isBold(),R.isItalic()),g){if(w&&(N&&E||!N&&!E&&R.bg===v)&&(N&&E&&f.selectionForeground||R.fg===B)&&R.extended.ext===b&&H===M&&Q===y&&!F&&!_&&!T&&S){R.isInvisible()?p+=m:p+=U,w++;continue}w&&(g.textContent=p),g=this._document.createElement("span"),w=0,p=""}else g=this._document.createElement("span");if(v=R.bg,B=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()?m:R.getChars()||m,R.isUnderline()&&(x.push(`xterm-underline-${R.extended.underlineStyle}`)," "===p&&(p=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${I.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 P=R.getFgColor(),G=R.getFgColorMode(),J=R.getBgColor(),O=R.getBgColorMode(),W=!!R.isInverse();if(W){let t=P;P=J,J=t;let i=G;G=O,O=i}let q,z,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,q=t.backgroundColorRGB),t.foregroundColorRGB&&(G=50331648,P=t.foregroundColorRGB.rgba>>8&16777215,z=t.foregroundColorRGB),j="top"===t.options.layer)})),!j&&N&&(q=this._coreBrowserService.isFocused?f.selectionBackgroundOpaque:f.selectionInactiveBackgroundOpaque,J=q.rgba>>8&16777215,O=50331648,j=!0,f.selectionForeground&&(G=50331648,P=f.selectionForeground.rgba>>8&16777215,z=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=ps.toColor(J>>16,J>>8&255,255&J),this._addStyle(g,`background-color:#${_s((J>>>0).toString(16),"0",6)}`);break;default:W?(K=f.foreground,x.push("xterm-bg-257")):K=f.background}switch(q||R.isDim()&&(q=Cs.multiplyOpacity(K,.5)),G){case 16777216:case 33554432:R.isBold()&&P<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(P+=8),this._applyMinimumContrast(g,K,f.ansi[P],R,q,void 0)||x.push(`xterm-fg-${P}`);break;case 50331648:let t=ps.toColor(P>>16&255,P>>8&255,255&P);this._applyMinimumContrast(g,K,t,R,q,z)||this._addStyle(g,`color:#${_s(P.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,K,f.foreground,R,q,z)||W&&x.push("xterm-fg-257")}x.length&&(g.className=x.join(" "),x.length=0),F||_||T||!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 57508<=t&&t<=57558}(n=e.getCode())||function(t){return 9472<=t&&t<=9631}(n))return!1;var n;let o,a=this._getContrastCache(e);if(!h&&!r&&(o=a.getColor(i.rgba,s.rgba)),void 0===o){let t=this._optionsService.rawOptions.minimumContrastRatio/(e.isDim()?2:1);o=Cs.ensureContrastRatio(h||i,r||s,t),a.setColor((h||i).rgba,(r||s).rgba,o??null)}return!!o&&(this._addStyle(t,`color:${o.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 _s(t,i,s){for(;t.length<s;)t=i+t;return t}Ls=n([o(1,O),o(2,S),o(3,U),o(4,x),o(5,N),o(6,W)],Ls);var Ss=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)}},Rs="xterm-dom-renderer-owner-",Ns="xterm-rows",Fs="xterm-fg-",Hs="xterm-bg-",Ts="xterm-focus",Us="xterm-selection",Ps=1,Gs=class extends at{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=Ps++,this._rowElements=[],this._selectionRenderModel=new $s,this.onRequestRedraw=this._register(new Et).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ns),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(Us),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(Ls,document),this._element.classList.add(Rs+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(rt((()=>{this._element.classList.remove(Rs+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new Ss(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} .${Ns} 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} .${Ns} { 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} .${Ns} .xterm-dim { color: ${Cs.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} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${h} 1s step-end infinite;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${Us} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Us} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Us} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[s,e]of t.ansi.entries())i+=`${this._terminalSelector} .${Fs}${s} { color: ${e.css}; }${this._terminalSelector} .${Fs}${s}.xterm-dim { color: ${Cs.multiplyOpacity(e,.5).css}; }${this._terminalSelector} .${Hs}${s} { background-color: ${e.css}; }`;i+=`${this._terminalSelector} .${Fs}257 { color: ${Cs.opaque(t.background).css}; }${this._terminalSelector} .${Fs}257.xterm-dim { color: ${Cs.multiplyOpacity(Cs.opaque(t.background),.5).css}; }${this._terminalSelector} .${Hs}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(Ts),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ts),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`.${Rs}${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),h=Math.min(h,this._bufferService.cols);let o=this._bufferService.buffer,a=o.ybase+o.y,l=Math.min(o.x,h-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))}}};Gs=n([o(7,L),o(8,T),o(9,S),o(10,Q),o(11,x),o(12,U),o(13,W)],Gs);var Js=class extends at{constructor(t,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Et),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new qs(this._optionsService))}catch{this._measureStrategy=this._register(new Ws(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())}};Js=n([o(2,S)],Js);var Os=class extends at{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)}},Ws=class extends Os{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}},qs=class extends Os{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 new 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 at{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 Ks(this._window)),this._onDprChange=this._register(new Et),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Et),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange((t=>this._screenDprMonitor.setWindow(t)))),this._register(At.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(xi(this._textarea,"focus",(()=>this._isFocused=!0))),this._register(xi(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}},Ks=class extends at{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new lt),this._onDprChange=this._register(new Et),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt((()=>this.clearListener())))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=xi(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)}},js=class extends at{constructor(){super(),this.linkProviders=[],this._register(rt((()=>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 Ys(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 Zs=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=Ys(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=Ys(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])}}};Zs=n([o(0,G),o(1,T)],Zs);var Xs=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=[]}},Vs={};((t,i)=>{for(var s in i)h(t,s,{get:i[s],enumerable:!0})})(Vs,{getSafariVersion:()=>ne,isChromeOS:()=>Ae,isFirefox:()=>ee,isIpad:()=>ae,isIphone:()=>le,isLegacyEdge:()=>he,isLinux:()=>ue,isMac:()=>oe,isNode:()=>te,isSafari:()=>re,isWindows:()=>ce});var te=typeof process<"u"&&"title"in process,ie=te?"node":navigator.userAgent,se=te?"node":navigator.platform,ee=ie.includes("Firefox"),he=ie.includes("Edge"),re=/^((?!chrome|android).)*safari/i.test(ie);function ne(){if(!re)return 0;let t=ie.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}var oe=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(se),ae="iPad"===se,le="iPhone"===se,ce=["Windows","Win16","Win32","WinCE"].includes(se),ue=se.indexOf("Linux")>=0,Ae=/\bCrOS\b/.test(ie),fe=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()}},de=!te&&"requestIdleCallback"in window?class extends fe{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends fe{_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())}}},ge=class{constructor(){this._queue=new de}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},we=class extends at{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 lt),this._pausedResizeTask=new ge,this._observerDisposable=this._register(new lt),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 Et),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Et),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Et),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Et),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Xs(((t,i)=>this._renderRows(t,i)),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new pe(this._coreBrowserService,this._coreService,(()=>this._fullRefresh())),this._register(rt((()=>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=rt((()=>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);t=Math.min(t,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(t,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start: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()}};we=n([o(2,S),o(3,T),o(4,x),o(5,N),o(6,Q),o(7,U),o(8,W)],we);var pe=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 Ce(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"===Ie(t,i)?-1:1;s.buffer.lines.get(h+r*n)?.isWrapped&&e++}return e}(t,i,s);return be(n,Be(Ie(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 Ie(t,i){return t>i?"A":"B"}function ve(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 Be(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 Me=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 ye(t,i){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return i*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Ee=new RegExp(" ","g"),Qe=class extends at{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 B,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Et),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Et),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Et),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Et),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 Me(this._bufferService),this._activeSelectionMode=0,this._register(rt((()=>{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(Ee," "))).join(ce?"\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()))),ue&&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=ye(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=Ys(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 oe?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&&!(oe&&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===Ce(i,e,h,r).length?"":be(ve(t,i,t,i-me(i,h),!1,h).length,Be("D",r))}(r,n,0,i,s,e)+Ce(n,i,s,e)+function(t,i,s,e,h,r){let n;n=Ce(i,e,h,r).length>0?e-me(e,h):i;let o=e,a=function(t,i,s,e,h,r){let n;return n=Ce(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(ve(t,n,s,o,"C"===a,h).length,Be(a,r))}(r,n,t,i,s,e);if(n===i)return h=r>t?"D":"C",be(Math.abs(r-t),Be(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 be(a,Be(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=ye(s,this._bufferService.cols)}};Qe=n([o(3,Q),o(4,x),o(5,P),o(6,S),o(7,G),o(8,U)],Qe);var ke=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={}}},xe=class{constructor(){this._color=new ke,this._css=new ke}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()}},De=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:ps.toCss(e,h,r),rgba:ps.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:ps.toCss(s,s,s),rgba:ps.toRgba(s,s,s)})}return t})()),Le=ms.toColor("#ffffff"),_e=ms.toColor("#000000"),Se=ms.toColor("#ffffff"),$e=_e,Re={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ne=Le,Fe=class extends at{constructor(t){super(),this._optionsService=t,this._contrastCache=new xe,this._halfContrastCache=new xe,this._onChangeColors=this._register(new Et),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Le,background:_e,cursor:Se,cursorAccent:$e,selectionForeground:void 0,selectionBackgroundTransparent:Re,selectionBackgroundOpaque:Cs.blend(_e,Re),selectionInactiveBackgroundTransparent:Re,selectionInactiveBackgroundOpaque:Cs.blend(_e,Re),scrollbarSliderBackground:Cs.opacity(Le,.2),scrollbarSliderHoverBackground:Cs.opacity(Le,.4),scrollbarSliderActiveBackground:Cs.opacity(Le,.5),overviewRulerBorder:Le,ansi:De.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this._register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}get colors(){return this._colors}_setTheme(t={}){let i=this._colors;if(i.foreground=He(t.foreground,Le),i.background=He(t.background,_e),i.cursor=Cs.blend(i.background,He(t.cursor,Se)),i.cursorAccent=Cs.blend(i.background,He(t.cursorAccent,$e)),i.selectionBackgroundTransparent=He(t.selectionBackground,Re),i.selectionBackgroundOpaque=Cs.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=He(t.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=Cs.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=t.selectionForeground?He(t.selectionForeground,Es):void 0,i.selectionForeground===Es&&(i.selectionForeground=void 0),Cs.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=Cs.opacity(i.selectionBackgroundTransparent,.3)),Cs.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=Cs.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=He(t.scrollbarSliderBackground,Cs.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=He(t.scrollbarSliderHoverBackground,Cs.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=He(t.scrollbarSliderActiveBackground,Cs.opacity(i.foreground,.5)),i.overviewRulerBorder=He(t.overviewRulerBorder,Ne),i.ansi=De.slice(),i.ansi[0]=He(t.black,De[0]),i.ansi[1]=He(t.red,De[1]),i.ansi[2]=He(t.green,De[2]),i.ansi[3]=He(t.yellow,De[3]),i.ansi[4]=He(t.blue,De[4]),i.ansi[5]=He(t.magenta,De[5]),i.ansi[6]=He(t.cyan,De[6]),i.ansi[7]=He(t.white,De[7]),i.ansi[8]=He(t.brightBlack,De[8]),i.ansi[9]=He(t.brightRed,De[9]),i.ansi[10]=He(t.brightGreen,De[10]),i.ansi[11]=He(t.brightYellow,De[11]),i.ansi[12]=He(t.brightBlue,De[12]),i.ansi[13]=He(t.brightMagenta,De[13]),i.ansi[14]=He(t.brightCyan,De[14]),i.ansi[15]=He(t.brightWhite,De[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]=He(t.extendedAnsi[e],De[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 He(t,i){if(void 0!==t)try{return ms.toColor(t)}catch{}return i}Fe=n([o(0,S)],Fe);var Te=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)}},Ue=class{constructor(){this._services=new Te,this._services.set(L,this)}setService(t,i){this._services.set(t,i)}getService(t){return this._services.get(t)}createInstance(t,...i){let s=(h=t,h[M]||[]).sort(((t,i)=>t.index-i.index)),e=[];var h;for(let i of s){let s=this._services.get(i.id);if(!s)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${i.id._id}.`);e.push(s)}let r=s.length>0?s[0].index:i.length;if(i.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${i.length} static arguments`);return new t(...i,...e)}},Pe={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ge=class extends at{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=Pe[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)}};Ge=n([o(0,S)],Ge);var Je=class extends at{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Et),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Et),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Et),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let i=new 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 new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(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 new Error("start argument out of range");if(t+s<0)throw new 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}},Oe=Object.freeze(new I),We=0,qe=class t{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*t);let e=i||B.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?g(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?g(2097151&i):""}isProtected(t){return 536870912&this._data[3*t+2]}loadCell(t,i){return i.content=this._data[0+(We=3*t)],i.fg=this._data[We+1],i.bg=this._data[We+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]+=g(i):2097151&e?(this._combined[t]=g(2097151&e)+g(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 B;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 B;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?g(s):m;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)=>Ke(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=Ke(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 Ke(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 je=class t{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=t._nextId++,this._onDispose=this.register(new Et),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ht(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};je._nextId=1;var Ye=je,Ze={},Xe=Ze.B;Ze[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:"≥","{":"π","|":"≠","}":"£","~":"·"},Ze.A={"#":"£"},Ze.B=void 0,Ze[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},Ze.C=Ze[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Ze.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},Ze.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},Ze.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},Ze.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},Ze.E=Ze[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},Ze.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},Ze.H=Ze[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Ze["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ve=4294967295,th=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=Oe.clone(),this.savedCharset=Xe,this.markers=[],this._nullCell=B.fromCharData([0,"",1,0]),this._whitespaceCell=B.fromCharData([0,m,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new de,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Je(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 v),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 v),this._whitespaceCell}getBlankLine(t,i){return new qe(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>Ve?Ve:i}fillViewportRows(t){if(0===this.lines.length){void 0===t&&(t=Oe);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 Je(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,i){let s=this.getNullCell(Oe),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 qe(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 qe(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=Ke(c,u,i),f=1,d=0;for(;f<c.length;){let t=Ke(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(Oe),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(Oe),h=s;for(;h-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new qe(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(Oe),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=ze(a,this._cols,t),A=u.length-a.length;l=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+A):Math.max(0,this.lines.length-this.lines.maxLength+A);let f=[];for(let t=0;t<A;t++){let t=this.getBlankLine(Oe,!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=Ke(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 Ye(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)}},ih=class extends at{constructor(t,i){super(),this._optionsService=t,this._bufferService=i,this._onBufferActivate=this._register(new Et),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 th(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new th(!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)}},sh=class extends at{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Et),this.onResize=this._onResize.event,this._onScroll=this._register(new Et),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 ih(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))}};sh=n([o(0,S)],sh);var eh={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:oe,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},hh=["normal","bold","100","200","300","400","500","600","700","800","900"],rh=class extends at{constructor(t){super(),this._onOptionChange=this._register(new Et),this.onOptionChange=this._onOptionChange.event;let i={...eh};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(rt((()=>{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 eh))throw new Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,i)=>{if(!(t in eh))throw new 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=eh[t]),"block"!==(s=i)&&"underline"!==s&&"bar"!==s)throw new Error(`"${i}" is not a valid value for ${t}`);break;case"wordSeparator":i||(i=eh[t]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=hh.includes(i)?i:eh[t];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new 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 new Error(`${t} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw new Error(`${t} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}var s;return i}};function nh(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]&&nh(t[e],i-1);return s}var oh=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}),lh=class extends at{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 Et),this.onData=this._onData.event,this._onUserInput=this._register(new Et),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Et),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Et),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=nh(oh),this.decPrivateModes=nh(ah)}reset(){this.modes=nh(oh),this.decPrivateModes=nh(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))}};lh=n([o(0,Q),o(1,_),o(2,S)],lh);var ch={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 uh(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 Ah=String.fromCharCode,fh={DEFAULT:t=>{let i=[uh(t,!1)+32,t.col+32,t.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`[M${Ah(i[0])}${Ah(i[1])}${Ah(i[2])}`},SGR:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${uh(t,!0)};${t.col};${t.row}${i}`},SGR_PIXELS:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${uh(t,!0)};${t.x};${t.y}${i}`}},dh=class extends at{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 Et),this.onProtocolChange=this._onProtocolChange.event;for(let t of Object.keys(ch))this.addProtocol(t,ch[t]);for(let t of Object.keys(fh))this.addEncoding(t,fh[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 new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,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)}};dh=n([o(0,Q),o(1,x),o(2,S)],dh);var gh,wh=[[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]],ph=[[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]],Ch=class{constructor(){if(this.version="6",!gh){(gh=new Uint8Array(65536)).fill(1),gh[0]=0,gh.fill(0,1,32),gh.fill(0,127,160),gh.fill(2,4352,4448),gh[9001]=2,gh[9002]=2,gh.fill(2,11904,42192),gh[12351]=1,gh.fill(2,44032,55204),gh.fill(2,63744,64256),gh.fill(2,65040,65050),gh.fill(2,65072,65136),gh.fill(2,65280,65377),gh.fill(2,65504,65511);for(let t=0;t<wh.length;++t)gh.fill(0,wh[t][0],wh[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?gh[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,ph)?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 Et,this.onChange=this._onChange.event;let t=new Ch;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 new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(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)}},Ih=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 vh(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 Bh=2147483647,bh=class t{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>256)throw new 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 new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Bh?Bh: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 new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Bh?Bh: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,Bh):t}},Mh=[],yh=class{constructor(){this._state=0,this._active=Mh,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=Mh}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=Mh,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Mh,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",w(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=Mh,this._id=-1,this._state=0}}},Eh=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+=w(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}},Qh=[],kh=class{constructor(){this._handlers=Object.create(null),this._active=Qh,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Qh}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=Qh,this._ident=0}hook(t,i){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Qh,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",w(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=Qh,this._ident=0}},xh=new bh;xh.addParam(0);var Dh=class{constructor(t){this._handler=t,this._data="",this._params=xh,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():xh,this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=w(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=xh,this._data="",this._hitLimit=!1,t)));return this._params=xh,this._data="",this._hitLimit=!1,i}},Lh=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}},_h=160,Sh=function(){let t=new Lh(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(_h,0,2,0),t.add(_h,8,5,8),t.add(_h,6,0,6),t.add(_h,11,0,11),t.add(_h,13,13,13),t}(),$h=class extends at{constructor(t=Sh){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(rt((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this._register(new yh),this._dcsParser=this._register(new kh),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 new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new 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 new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=e}}if(1!==t.final.length)throw new Error("final must be a single byte");let e=t.final.charCodeAt(0);if(i[0]>e||e>i[1])throw new 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,new 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:_h)],r>>4){case 2:for(let e=s+1;;++e){if(e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){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<_h){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<_h){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}}},Rh=/^([\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})$/,Nh=/^[\da-f]+$/;function Fh(t){if(!t)return;let i=t.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let t=Rh.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),Nh.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 Hh(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 Th(t,i=16){let[s,e,h]=t;return`rgb:${Hh(s,i)}/${Hh(e,i)}/${Hh(h,i)}`}var Uh={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ph=131072;function Gh(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 Jh=0,Oh=class extends at{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 p,this._utf8Decoder=new C,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Oe.clone(),this._eraseAttrDataInternal=Oe.clone(),this._onRequestBell=this._register(new Et),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Et),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Et),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Et),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Et),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Et),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Et),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Et),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Et),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Et),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Et),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Et),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 Wh(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(ls.IND,(()=>this.index())),this._parser.setExecuteHandler(ls.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(ls.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new Eh((t=>(this.setTitle(t),this.setIconName(t),!0)))),this._parser.registerOscHandler(1,new Eh((t=>this.setIconName(t)))),this._parser.registerOscHandler(2,new Eh((t=>this.setTitle(t)))),this._parser.registerOscHandler(4,new Eh((t=>this.setOrReportIndexedColor(t)))),this._parser.registerOscHandler(8,new Eh((t=>this.setHyperlink(t)))),this._parser.registerOscHandler(10,new Eh((t=>this.setOrReportFgColor(t)))),this._parser.registerOscHandler(11,new Eh((t=>this.setOrReportBgColor(t)))),this._parser.registerOscHandler(12,new Eh((t=>this.setOrReportCursorColor(t)))),this._parser.registerOscHandler(104,new Eh((t=>this.restoreIndexedColor(t)))),this._parser.registerOscHandler(110,new Eh((t=>this.restoreFgColor(t)))),this._parser.registerOscHandler(111,new Eh((t=>this.restoreBgColor(t)))),this._parser.registerOscHandler(112,new Eh((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 Ze)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 Dh(((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>Ph&&(r=this._parseStack.position+Ph)}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<Ph&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Ph))),n||this._dirtyRowTracker.clearRange(),t.length>Ph)for(let i=r;i<t.length;i+=Ph){let r=i+Ph<t.length?i+Ph: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=mh.extractWidth(i);let s=mh.extractShouldJoin(i),d=s?mh.extractWidth(A):0;if(A=i,n&&this._onA11yChar.fire(g(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 qe&&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=>!Gh(t.params[0],this._optionsService.rawOptions.windowOptions)||i(t))}registerDcsHandler(t,i){return this._parser.registerDcsHandler(t,new Dh(i))}registerEscHandler(t,i){return this._parser.registerEscHandler(t,i)}registerOscHandler(t,i){return this._parser.registerOscHandler(t,new Eh(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(Oe));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 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(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,Xe),this._charsetService.setgCharset(1,Xe),this._charsetService.setgCharset(2,Xe),this._charsetService.setgCharset(3,Xe);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(`${as.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|=I.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=Oe.fg,t.bg=Oe.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&Oe.fg):49===i?(e.bg&=-67108864,e.bg|=16777215&Oe.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&Oe.fg,e.bg&=-67108864,e.bg|=16777215&Oe.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=Oe.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(!Gh(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(qh(s))if("?"===e)i.push({type:0,index:s});else{let t=Fh(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=Fh(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]);qh(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,Xe),!0}selectCharset(t){return 2!==t.length?(this.selectDefaultCharset(),!0):("/"===t[0]||this._charsetService.setgCharset(Uh[t[0]],Ze[t[1]]||Xe),!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=Oe.clone(),this._eraseAttrDataInternal=Oe.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 B;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)}},Wh=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&&(Jh=t,t=i,i=Jh),t<this.start&&(this.start=t),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function qh(t){return 0<=t&&t<256}Wh=n([o(0,Q)],Wh);var zh=class extends at{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 Et),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 new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=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()}},Kh=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)))}};Kh=n([o(0,Q)],Kh);var jh=!1,Yh=class extends at{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new lt),this._onBinary=this._register(new Et),this.onBinary=this._onBinary.event,this._onData=this._register(new Et),this.onData=this._onData.event,this._onLineFeed=this._register(new Et),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Et),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Et),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Et),this._instantiationService=new Ue,this.optionsService=this._register(new rh(t)),this._instantiationService.setService(S,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sh)),this._instantiationService.setService(Q,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ge)),this._instantiationService.setService(_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(lh)),this._instantiationService.setService(x,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(dh)),this._instantiationService.setService(k,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(mh)),this._instantiationService.setService(R,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Ih),this._instantiationService.setService(D,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Kh),this._instantiationService.setService($,this._oscLinkService),this._inputHandler=this._register(new Oh(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(At.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(At.forward(this._bufferService.onResize,this._onResize)),this._register(At.forward(this.coreService.onData,this._onData)),this._register(At.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(At.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Et),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&&!jh&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jh=!0),this._writeBuffer.writeSync(t,i)}input(t,i=!0){this.coreService.triggerDataEvent(t,i)}resize(t,i){isNaN(t)||isNaN(i)||(t=Math.max(t,2),i=Math.max(i,1),this._bufferService.resize(t,i))}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(vh.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(()=>(vh(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=rt((()=>{for(let i of t)i.dispose()}))}}},Zh={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:["'",'"']},Xh=0,Vh=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new de,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new de,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=new 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===(Xh=this._search(i))||this._getKey(this._array[Xh])!==i)return!1;do{if(this._array[Xh]===t)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue((()=>this._flushDeleted())),this._deletedIndices.push(Xh),!0}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort(((t,i)=>t-i)),i=0,s=new 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&&!((Xh=this._search(t))<0||Xh>=this._array.length)&&this._getKey(this._array[Xh])===t)do{yield this._array[Xh]}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===t)}forEachByKey(t,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((Xh=this._search(t))<0||Xh>=this._array.length)&&this._getKey(this._array[Xh])===t)do{i(this._array[Xh])}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===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}},tr=0,ir=0,sr=class extends at{constructor(){super(),this._decorations=new Vh((t=>t?.marker.line)),this._onDecorationRegistered=this._register(new Et),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Et),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt((()=>this.reset())))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let i=new er(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=>{ir=(tr=i.options.x??0)+(i.options.width??1),t>=tr&&t<ir&&(!s||(i.options.layer??"bottom")===s)&&e(i)}))}},er=class extends ot{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Et),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Et),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()}},hr=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)}},rr=class extends at{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 hr(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize((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(xi(h,"selectionchange",(()=>this._handleSelectionChange()))),this._register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRowsDimensions(),this._refreshRows(),this._register(rt((()=>{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+=u())))}_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.toString();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).toString(),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 new 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})`)}};rr=n([o(1,L),o(2,U),o(3,G)],rr);var nr=class extends at{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 Et),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Et),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rt((()=>{ht(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(xi(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this._register(xi(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(xi(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(xi(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);var s,e;i&&this._mouseDownLink&&(s=this._mouseDownLink.link).text===(e=this._currentLink.link).text&&s.range.start.x===e.range.start.x&&s.range.start.y===e.range.start.y&&s.range.end.x===e.range.end.x&&s.range.end.y===e.range.end.y&&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,ht(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}}};nr=n([o(1,P),o(2,G),o(3,Q),o(4,q)],nr);var or=class extends Yh{constructor(t={}){super(t),this._linkifier=this._register(new lt),this.browser=Vs,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new lt),this._onCursorMove=this._register(new Et),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Et),this.onKey=this._onKey.event,this._onRender=this._register(new Et),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Et),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Et),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Et),this.onBell=this._onBell.event,this._onFocus=this._register(new Et),this._onBlur=this._register(new Et),this._onA11yCharEmitter=this._register(new Et),this._onA11yTabEmitter=this._register(new Et),this._onWillOpen=this._register(new Et),this._setup(),this._decorationService=this._instantiationService.createInstance(sr),this._instantiationService.setService(N,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(js),this._instantiationService.setService(q,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(F)),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(At.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(At.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(At.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(At.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize((t=>this._afterResize(t.cols,t.rows)))),this._register(rt((()=>{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=Cs.toColorRGB("ansi"===t?this._themeService.colors.ansi[i.index]:this._themeService.colors[t]);this.coreService.triggerDataEvent(`${as.ESC}]${s};${Th(e)}${cs.ST}`);break;case 1:if("ansi"===t)this._themeService.modifyColors((t=>t.ansi[i.index]=ps.toColor(...i.color)));else{let s=t;this._themeService.modifyColors((t=>t[s]=ps.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(rr,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(xi(this.element,"copy",(t=>{var i;this.hasSelection()&&((i=t).clipboardData&&i.clipboardData.setData("text/plain",this._selectionService.selectionText),i.preventDefault())})));let t=t=>function(t,i,s,e){t.stopPropagation(),t.clipboardData&&A(t.clipboardData.getData("text/plain"),i,s,e)}(t,this.textarea,this.coreService,this.optionsService);this._register(xi(this.textarea,"paste",t)),this._register(xi(this.element,"paste",t)),this._register(ee?xi(this.element,"mousedown",(t=>{2===t.button&&d(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):xi(this.element,"contextmenu",(t=>{d(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),ue&&this._register(xi(this.element,"auxclick",(t=>{1===t.button&&f(t,this.textarea,this.screenElement)})))}_bindKeys(){this._register(xi(this.textarea,"keyup",(t=>this._keyUp(t)),!0)),this._register(xi(this.textarea,"keydown",(t=>this._keyDown(t)),!0)),this._register(xi(this.textarea,"keypress",(t=>this._keyPress(t)),!0)),this._register(xi(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this._register(xi(this.textarea,"compositionupdate",(t=>this._compositionHelper.compositionupdate(t)))),this._register(xi(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this._register(xi(this.textarea,"input",(t=>this._inputEvent(t)),!0)),this._register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(t){if(!t)throw new 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(xi(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",l()),Ae||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(U,this._coreBrowserService),this._register(xi(this.textarea,"focus",(t=>this._handleTextAreaFocus(t)))),this._register(xi(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Js,this._document,this._helperContainer),this._instantiationService.setService(T,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fe),this._instantiationService.setService(W,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ds),this._instantiationService.setService(O,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(we,this.rows,this.screenElement)),this._instantiationService.setService(G,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(ws,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Zs),this._instantiationService.setService(P,this._mouseService);let e=this._linkifier.value=this._register(this._instantiationService.createInstance(nr,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(ns,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(Qe,this.element,this.screenElement,e)),this._instantiationService.setService(J,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(At.any(this._onScroll.event,this._inputHandler.onScroll)((()=>{this._selectionService.refresh(),this._viewport?.queueSync()}))),this._register(this._instantiationService.createInstance(os,this.screenElement)),this._register(xi(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(rr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",(t=>this._handleScreenReaderModeOptionChange(t)))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",(t=>{!this._overviewRulerRenderer&&t&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gs,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(xi(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(xi(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){A(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 new 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 new 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=Zh[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){var i;this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(t))&&(16===(i=t).keyCode||17===i.keyCode||18===i.keyCode||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(Oe));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 new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(i,1)}},lr=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 B)}translateToString(t,i,s){return this._line.translateToString(t,i,s)}},cr=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 lr(i)}getNullCell(){return new B}},ur=class extends at{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Et),this.onBufferChange=this._onBufferChange.event,this._normal=new cr(this._core.buffers.normal,"normal"),this._alternate=new cr(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Ar=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)}},fr=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}},dr=["cols","rows"],gr=0,wr=class extends at{constructor(t){super(),this._core=this._register(new or(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(dr.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Ar(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fr(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 ur(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 l()},set promptLabel(t){a=t},get tooMuchOutput(){return u()},set tooMuchOutput(t){c=t}}}_verifyIntegers(...t){for(gr of t)if(gr===1/0||isNaN(gr)||gr%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(gr of t)if(gr&&(gr===1/0||isNaN(gr)||gr%1!=0||gr<0))throw new Error("This API only accepts positive integers")}},pr=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))}}},Cr=class{constructor(t,i,s,e={}){this._terminal=t,this._regex=i,this._handler=s,this._options=e}provideLinks(t,i){let s=Ir.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 Ir=class t{static computeLink(i,s,e,h){let r,n=new 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(!mr(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]}},vr=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Br(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=Br,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options;this._linkProvider=this._terminal.registerLinkProvider(new Cr(this._terminal,i.urlRegex||vr,this._handler,i))}dispose(){this._linkProvider?.dispose()}},Mr=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?Lr.isErrorNoTelemetry(t)?new Lr(t.message+"\n\n"+t.stack):new 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 h=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=(t,i,s,e)=>{for(var n,o=e>1?void 0:e?r(i,s):i,l=t.length-1;l>=0;l--)(n=t[l])&&(o=(e?n(i,s,o):n(o))||o);return e&&o&&h(i,s,o),o},o=(t,i)=>(s,e)=>i(s,e,t),l="Terminal input",a=()=>l,c="Too much output to announce, navigate to rows manually to read",u=()=>c;function A(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 f(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 d(t,i,s,e,h){f(t,i,s),h&&e.rightClickSelect(t),i.value=e.selectionText,i.select()}function g(t){return t>65535?(t-=65536,String.fromCharCode(55296+(t>>10))+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function w(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 p=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}},C=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,c=l-n;for(;a<c;){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 c=s-4,u=a;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(l=(31&e)<<6|63&h,l<128){u--;continue}i[o++]=l}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(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(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(l=(7&e)<<18|(63&h)<<12|(63&r)<<6|63&n,l<65536||l>1114111)continue;i[o++]=l}}return o}},m=" ",I=class t{constructor(){this.fg=0,this.bg=0,this.extended=new v}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}},v=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}},B=class t extends I{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new v,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?g(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()]}},b="di$target",M="di$dependencies",y=new Map;function E(t){if(y.has(t))return y.get(t);let i=function(t,s,e){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[b]===i?i[M].push({id:t,index:s}):(i[M]=[{id:t,index:s}],i[b]=i)}(i,t,e)};return i._id=t,y.set(t,i),i}var Q=E("BufferService"),k=E("CoreMouseService"),x=E("CoreService"),D=E("CharsetService"),L=E("InstantiationService"),_=E("LogService"),S=E("OptionsService"),$=E("OscLinkService"),R=E("UnicodeService"),N=E("DecorationService"),F=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 B,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):H(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 H(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")}}F=n([o(0,Q),o(1,S),o(2,$)],F);var T=E("CharSizeService"),U=E("CoreBrowserService"),P=E("MouseService"),G=E("RenderService"),J=E("SelectionService"),O=E("CharacterJoinerService"),W=E("ThemeService"),z=E("LinkProviderService"),q=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?tt.isErrorNoTelemetry(t)?new tt(t.message+"\n\n"+t.stack):new 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 K(t){(function(t){return t instanceof V||t instanceof Error&&t.name===X&&t.message===X})(t)||q.onUnexpectedError(t)}var j,Y,Z,X="Canceled",V=class extends Error{constructor(){super(X),this.name=this.message}},tt=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}},it=class t extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,t.prototype)}};function st(t,i=0){return t[t.length-(1+i)]}function et(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function ht(t){if(Z.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 rt(t){return{dispose:et((()=>{t()}))}}(Y=j||={}).isLessThan=function(t){return t<0},Y.isLessThanOrEqual=function(t){return t<=0},Y.isGreaterThan=function(t){return t>0},Y.isNeitherLessOrGreaterThan=function(t){return 0===t},Y.greaterThan=1,Y.lessThan=-1,Y.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(Z||={});var nt=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{ht(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};nt.DISABLE_DISPOSED_WARNING=!1;var ot=nt,lt=class{constructor(){this._store=new ot}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};lt.None=Object.freeze({dispose(){}});var at=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}},ct="object"==typeof window?window:globalThis,ut=class t{constructor(i){this.element=i,this.next=t.Undefined,this.prev=t.Undefined}};ut.Undefined=new ut(void 0);var At,ft=ut,dt=class{constructor(){this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ft.Undefined}clear(){let t=this._first;for(;t!==ft.Undefined;){let i=t.next;t.prev=ft.Undefined,t.next=ft.Undefined,t=i}this._first=ft.Undefined,this._last=ft.Undefined,this._size=0}unshift(t){return this._insert(t,!1)}push(t){return this._insert(t,!0)}_insert(t,i){let s=new ft(t);if(this._first===ft.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!==ft.Undefined){let t=this._first.element;return this._remove(this._first),t}}pop(){if(this._last!==ft.Undefined){let t=this._last.element;return this._remove(this._last),t}}_remove(t){if(t.prev!==ft.Undefined&&t.next!==ft.Undefined){let i=t.prev;i.next=t.next,t.next.prev=i}else t.prev===ft.Undefined&&t.next===ft.Undefined?(this._first=ft.Undefined,this._last=ft.Undefined):t.next===ft.Undefined?(this._last=this._last.prev,this._last.next=ft.Undefined):t.prev===ft.Undefined&&(this._first=this._first.next,this._first.prev=ft.Undefined);this._size-=1}*[Symbol.iterator](){let t=this._first;for(;t!==ft.Undefined;)yield t.element,t=t.next}},gt=globalThis.performance&&"function"==typeof globalThis.performance.now,wt=class t{static create(i){return new t(i)}constructor(t){this._now=gt&&!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 Et({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,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),c=()=>{let t=l;l=void 0,a=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(c,s)):void 0===a&&(a=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new Et(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 rt((()=>ht(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 Et({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 Et({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 Et({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 Et;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 Et({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 ot?e.add(o):Array.isArray(e)&&e.push(o),o}}})(At||={});var pt=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 wt,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}}};pt.all=new Set,pt._idPool=0;var Ct=pt,mt=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}};mt._idPool=1;var It=mt,vt=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.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}},bt=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Mt=0,yt=class{constructor(t){this.value=t,this.id=Mt++}},Et=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new It(t?.onListenerError??K,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Ct(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 bt(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||K)(s),lt.None}if(this._disposed)return lt.None;i&&(t=t.bind(i));let e,h=new yt(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=vt.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof yt?(this._deliveryQueue??=new Qt,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=rt((()=>{e?.(),this._removeListener(h)}));return s instanceof ot?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)),new 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||K;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 yt)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}},Qt=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}},kt=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Et,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Et,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}};kt.INSTANCE=new kt;var xt=kt,Dt="object"==typeof navigator?navigator.userAgent:"",Lt=Dt.indexOf("Firefox")>=0,_t=Dt.indexOf("AppleWebKit")>=0,St=Dt.indexOf("Chrome")>=0,$t=!St&&Dt.indexOf("Safari")>=0;if(Dt.indexOf("Electron/"),Dt.indexOf("Android"),"function"==typeof ct.matchMedia){let t=ct.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");ct.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=ct.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var Rt,Nt,Ft="en",Ht=!1,Tt=!1,Ut=!1,Pt=!1,Gt=Ft,Jt=globalThis;typeof Jt.vscode<"u"&&typeof Jt.vscode.process<"u"?Nt=Jt.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Nt=process);var Ot="string"==typeof Nt?.versions?.electron&&"renderer"===Nt?.type;if("object"==typeof Nt){Ht="win32"===Nt.platform,Tt="darwin"===Nt.platform,Ut="linux"===Nt.platform,Gt=Ft;let t=Nt.env.VSCODE_NLS_CONFIG;if(t)try{Gt=JSON.parse(t).resolvedLanguage||Ft}catch{}Pt=!0}else"object"!=typeof navigator||Ot?console.error("Unable to resolve platform."):(Ht=(Rt=navigator.userAgent).indexOf("Windows")>=0,Tt=Rt.indexOf("Macintosh")>=0,(Rt.indexOf("Macintosh")>=0||Rt.indexOf("iPad")>=0||Rt.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,Ut=Rt.indexOf("Linux")>=0,Rt?.indexOf("Mobi"),Gt=globalThis._VSCODE_NLS_LANGUAGE||Ft,navigator.language.toLowerCase());var Wt,zt,qt=Ht,Kt=Tt,jt=Ut,Yt=Pt,Zt=Rt,Xt=Gt;(zt=Wt||={}).value=function(){return Xt},zt.isDefaultVariant=function(){return 2===Xt.length?"en"===Xt:Xt.length>=3&&"e"===Xt[0]&&"n"===Xt[1]&&"-"===Xt[2]},zt.isDefault=function(){return"en"===Xt};var Vt="function"==typeof Jt.postMessage&&!Jt.importScripts;(()=>{if(Vt){let t=[];Jt.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=new 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 li([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},li=class{constructor(t){if(0===t.length)throw new 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}},ai=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(Lt)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(_t){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|=ai),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(St){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?Lt&&!Kt?-t.deltaY/3:-t.deltaY:-t.deltaY/40),typeof i.wheelDeltaX<"u"?this.deltaX=$t&&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?Lt&&!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 vi||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:At.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ci})})(di||={});var mi,Ii,vi=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 Et),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 it("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout((()=>{this._token=-1,t()}),i)}setIfNotSet(t,i){if(this._isDisposed)throw new it("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 it("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let e=s.setInterval((()=>{t()}),i);this.disposable=rt((()=>{s.clearInterval(e),this.disposable=void 0}))}dispose(){this.cancel(),this.isDisposed=!0}};(Ii=mi||={}).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},Ii.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))};var Mi=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 Et,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 At.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())}};Mi.EMPTY=Mi.fromArray([]);var{getWindow:yi,getWindowId:Ei,onDidRegisterWindow:Qi}=function(){let t=new Map,i={window:ct,disposables:new ot};t.set(ct.vscodeWindowId,i);let s=new Et,e=new Et,h=new Et;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return lt.None;let r=new ot,n={window:i,disposables:r.add(new ot)};return t.set(i.vscodeWindowId,n),r.add(rt((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(xi(i,$i.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:ct},getDocument:t=>yi(t).document}}(),ki=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 xi(t,i,s,e){return new ki(t,i,s,e)}var Di,Li=function(t,i,s,e){return xi(t,i,s,e)},_i=class extends bi{constructor(t){super(),this.defaultTarget=t&&yi(t)}cancelAndSet(t,i,s){return super.cancelAndSet(t,i,s??this.defaultTarget)}},Si=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){K(t)}}static sort(t,i){return i.priority-t.priority}};!function(){let t=new Map,i=new Map,s=new Map,e=new Map;Di=(h,r,n=0)=>{let o=Ei(h),l=new Si(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(Si.sort),r.shift().execute();e.set(h,!1)})(o)))),l}}();var $i={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"},Ri=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=Ni(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=Ni(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=Ni(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=Ni(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=Ni(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=Ni(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=Ni(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=Ni(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=Ni(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=Ni(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=Ni(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=Ni(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=Ni(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=Ni(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 Ni(t){return"number"==typeof t?`${t}px`:t}function Fi(t){return new Ri(t)}var Hi,Ti,Ui=class{constructor(){this._hooks=new ot,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(rt((()=>{try{t.releasePointerCapture(i)}catch{}})))}catch{r=yi(t)}this._hooks.add(xi(r,$i.POINTER_MOVE,(t=>{t.buttons===s?(t.preventDefault(),this._pointerMoveCallback(t)):this.stopMonitoring(!0)}))),this._hooks.add(xi(r,$i.POINTER_UP,(()=>this.stopMonitoring(!0))))}};(Ti=Hi||={}).Tap="-xterm-gesturetap",Ti.Change="-xterm-gesturechange",Ti.Start="-xterm-gesturestart",Ti.End="-xterm-gesturesend",Ti.Contextmenu="-xterm-gesturecontextmenu";var Pi=class t extends lt{constructor(){super(),this.dispatched=!1,this.targets=new dt,this.ignoreTargets=new dt,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(At.runAndSubscribe(Qi,(({window:t,disposables:i})=>{i.add(xi(t.document,"touchstart",(t=>this.onTouchStart(t)),{passive:!1})),i.add(xi(t.document,"touchend",(i=>this.onTouchEnd(t,i)))),i.add(xi(t.document,"touchmove",(t=>this.onTouchMove(t)),{passive:!1}))}),{window:ct,disposables:this._store}))}static addTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),rt(t.INSTANCE.targets.push(i))):lt.None}static ignoreTarget(i){return t.isTouchDevice()?(t.INSTANCE||(t.INSTANCE=new t),rt(t.INSTANCE.ignoreTargets.push(i))):lt.None}static isTouchDevice(){return"ontouchstart"in ct||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(Hi.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(String(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-st(o.rollingPageX))<30&&Math.abs(o.initialPageY-st(o.rollingPageY))<30){let t=this.newGestureEvent(Hi.Tap,o.initialTarget);t.pageX=st(o.rollingPageX),t.pageY=st(o.rollingPageY),this.dispatchEvent(t)}else if(l>=t.HOLD_DELAY&&Math.abs(o.initialPageX-st(o.rollingPageX))<30&&Math.abs(o.initialPageY-st(o.rollingPageY))<30){let t=this.newGestureEvent(Hi.Contextmenu,o.initialTarget);t.pageX=st(o.rollingPageX),t.pageY=st(o.rollingPageY),this.dispatchEvent(t)}else if(1===h){let t=st(o.rollingPageX),s=st(o.rollingPageY),h=st(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(Hi.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===Hi.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===Hi.Change||i.type===Hi.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=Di(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=l*o*u);let g=this.newGestureEvent(Hi.Change);g.translationX=A,g.translationY=f,s.forEach((t=>t.dispatchEvent(g))),d||this.inertia(i,s,c,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(String(e.identifier))){console.warn("end of an UNKNOWN touch",e);continue}let h=this.activeTouches[e.identifier],r=this.newGestureEvent(Hi.Change,h.initialTarget);r.translationX=e.pageX-st(h.rollingPageX),r.translationY=e.pageY-st(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)}};Pi.SCROLL_FRICTION=-.005,Pi.HOLD_DELAY=700,Pi.CLEAR_TAP_COUNT_TIME=400,n([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 new 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]}}],Pi,"isTouchDevice",1);var Gi=Pi,Ji=class extends lt{onclick(t,i){this._register(xi(t,$i.CLICK,(s=>i(new wi(yi(t),s)))))}onmousedown(t,i){this._register(xi(t,$i.MOUSE_DOWN,(s=>i(new wi(yi(t),s)))))}onmouseover(t,i){this._register(xi(t,$i.MOUSE_OVER,(s=>i(new wi(yi(t),s)))))}onmouseleave(t,i){this._register(xi(t,$i.MOUSE_LEAVE,(s=>i(new wi(yi(t),s)))))}onkeydown(t,i){this._register(xi(t,$i.KEY_DOWN,(t=>i(new ui(t)))))}onkeyup(t,i){this._register(xi(t,$i.KEY_UP,(t=>i(new ui(t)))))}oninput(t,i){this._register(xi(t,$i.INPUT,i))}onblur(t,i){this._register(xi(t,$i.BLUR,i))}onfocus(t,i){this._register(xi(t,$i.FOCUS,i))}onchange(t,i){this._register(xi(t,$i.CHANGE,i))}ignoreGesture(t){return Gi.ignoreTarget(t)}},Oi=class extends Ji{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 Ui),this._register(Li(this.bgDomNode,$i.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._register(Li(this.domNode,$i.POINTER_DOWN,(t=>this._arrowPointerDown(t)))),this._pointerdownRepeatTimer=this._register(new _i),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,yi(t))}),200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,(()=>{}),(()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()})),t.preventDefault())}},Wi=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}}},zi=class extends lt{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new Wi(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 ji(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=ji.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)))}},qi=class{constructor(t,i,s){this.scrollLeft=t,this.scrollTop=i,this.isDone=s}};function Ki(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 ji=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))}}(Ki(t,e),Ki(h,i),.33)}return Ki(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 qi(t,s,!1)}return new qi(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)}},Yi=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 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":"")))}},Zi=class extends Ji{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 Yi(t.visibility,"visible scrollbar "+t.extraScrollbarClassName,"invisible scrollbar "+t.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ui),this._shouldRender=!0,this.domNode=Fi(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(xi(this.domNode.domNode,$i.POINTER_DOWN,(t=>this._domNodePointerDown(t))))}_createArrow(t){let i=this._register(new Oi(t));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(t,i,s,e){this.slider=Fi(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(xi(this.slider.domNode,$i.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=yi(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),r=Math.abs(h-s);if(qt&&r>140)return void this._setDesiredScrollPositionNow(e.getScrollPosition());let n=this._sliderPointerPosition(t)-i;this._setDesiredScrollPositionNow(e.getDesiredScrollPositionFromDelta(n))}),(()=>{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()}},Xi=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),c=h*a;return{computedAvailableSize:Math.round(r),computedIsNeeded:o,computedSliderSize:Math.round(l),computedSliderRatio:a,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}},Vi=class extends Zi{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Xi(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 new 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}},ts=class extends Zi{constructor(t,i,s){let e=t.getScrollDimensions(),h=t.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new Xi(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 new 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}},is=class{constructor(t,i,s){this.timestamp=t,this.deltaX=i,this.deltaY=s,this.score=0}},ss=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(St){let i=yi(t.browserEvent),s=xt.INSTANCE.getZoomFactor(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let e=null,h=new is(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),a=Math.max(e,r),c=Math.max(h,n);a%o==0&&c%l==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ss.INSTANCE=new ss;var es=ss,hs=class extends Ji{constructor(t,i,s){super(),this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Et),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 ts(this._scrollable,this._options,e)),this._horizontalScrollbar=this._register(new Vi(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=Fi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Fi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Fi(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=ht(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){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=ht(this._mouseWheelToDispose),t)){let t=t=>{this._onMouseWheel(new pi(t))};this._mouseWheelToDispose.push(xi(this._listenOnDomNode,$i.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(t){if(t.browserEvent?.defaultPrevented)return;let i=es.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,i=r.scrollTop-(t<0?Math.floor(t):Math.ceil(t));this._verticalScrollbar.writeScrollPosition(n,i)}if(h){let t=50*h,i=r.scrollLeft-(t<0?Math.floor(t):Math.ceil(t));this._horizontalScrollbar.writeScrollPosition(n,i)}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 new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let t=this._scrollable.getCurrentScrollPosition(),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)}},rs=class extends hs{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()}},ns=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 Et),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let l=this._register(new zi({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:t=>Di(e.window,t)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",(()=>{l.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)}))),this._scrollableElement=this._register(new rs(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(At.runAndSubscribe(r.onChangeColors,(()=>{this._scrollableElement.getDomNode().style.backgroundColor=r.colors.background.css}))),t.appendChild(this._scrollableElement.getDomNode()),this._register(rt((()=>this._scrollableElement.getDomNode().remove()))),this._styleElement=e.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(rt((()=>this._styleElement.remove()))),this._register(At.runAndSubscribe(r.onChangeColors,(()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${r.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${r.colors.scrollbarSliderHoverBackground.css};`,"}",".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}};ns=n([o(2,Q),o(3,U),o(4,k),o(5,W),o(6,S),o(7,G)],ns);var os=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(rt((()=>{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()}};os=n([o(1,Q),o(2,U),o(3,N),o(4,G)],os);var ls,as,cs,us=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)}},As={full:0,left:0,center:0,right:0},fs={full:0,left:0,center:0,right:0},ds={full:0,left:0,center:0,right:0},gs=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 us,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(rt((()=>this._canvas?.remove())));let l=this._canvas.getContext("2d");if(!l)throw new 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);fs.full=this._canvas.width,fs.left=t,fs.center=i,fs.right=t,this._refreshDrawHeightConstants(),ds.full=1,ds.left=1,ds.center=1+fs.left,ds.right=1+fs.left+fs.center}_refreshDrawHeightConstants(){As.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);As.left=t,As.center=t,As.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*As.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(ds[t.position||"full"],Math.round(t.startBufferLine/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)-As[t.position||"full"]/2),fs[t.position||"full"],Math.round((t.endBufferLine-t.startBufferLine)/this._bufferService.buffers.active.lines.length*(this._canvas.height-1)+As[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})))}};gs=n([o(2,Q),o(3,N),o(4,G),o(5,S),o(6,W),o(7,U)],gs),(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=""})(ls||={}),(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=""})(as||={}),(cs||={}).ST=`${ls.ESC}\\`;var ws=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(`${ls.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=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,e=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=e+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let h=this._compositionView.getBoundingClientRect();this._textarea.style.left=e+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(h.width,1)+"px",this._textarea.style.height=Math.max(h.height,1)+"px",this._textarea.style.lineHeight=h.height+"px"}t||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};ws=n([o(2,Q),o(3,S),o(4,x),o(5,G)],ws);var ps,Cs,ms,Is,vs,Bs=0,bs=0,Ms=0,ys=0,Es={css:"#00000000",rgba:0};function Qs(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ks(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?`#${Qs(t)}${Qs(i)}${Qs(s)}${Qs(e)}`:`#${Qs(t)}${Qs(i)}${Qs(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)}}})(ps||={}),(t=>{function i(t,i){return ys=Math.round(255*i),[Bs,bs,Ms]=vs.toChannels(t.rgba),{css:ps.toCss(Bs,bs,Ms,ys),rgba:ps.toRgba(Bs,bs,Ms,ys)}}t.blend=function(t,i){if(1==(ys=(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 Bs=h+Math.round(((i.rgba>>24&255)-h)*ys),bs=r+Math.round((s-r)*ys),Ms=n+Math.round((e-n)*ys),{css:ps.toCss(Bs,bs,Ms),rgba:ps.toRgba(Bs,bs,Ms)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=vs.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return ps.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Bs,bs,Ms]=vs.toChannels(i),{css:ps.toCss(Bs,bs,Ms),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(ys=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Cs||={}),(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 Bs=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),Ms=parseInt(t.slice(3,4).repeat(2),16),ps.toColor(Bs,bs,Ms);case 5:return Bs=parseInt(t.slice(1,2).repeat(2),16),bs=parseInt(t.slice(2,3).repeat(2),16),Ms=parseInt(t.slice(3,4).repeat(2),16),ys=parseInt(t.slice(4,5).repeat(2),16),ps.toColor(Bs,bs,Ms,ys);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 Bs=parseInt(e[1]),bs=parseInt(e[2]),Ms=parseInt(e[3]),ys=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),ps.toColor(Bs,bs,Ms,ys);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Bs,bs,Ms,ys]=i.getImageData(0,0,1,1).data,255!==ys)throw new Error("css.toColor: Unsupported css format");return{rgba:ps.toRgba(Bs,bs,Ms,ys),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})(Is||={}),(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=ks(Is.relativeLuminance2(n,o,l),Is.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=ks(Is.relativeLuminance2(n,o,l),Is.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=ks(Is.relativeLuminance2(n,o,l),Is.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=ks(Is.relativeLuminance2(n,o,l),Is.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}t.blend=function(t,i){if(1==(ys=(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 Bs=h+Math.round(((i>>24&255)-h)*ys),bs=r+Math.round((s-r)*ys),Ms=n+Math.round((e-n)*ys),ps.toRgba(Bs,bs,Ms)},t.ensureContrastRatio=function(t,e,h){let r=Is.relativeLuminance(t>>8),n=Is.relativeLuminance(e>>8);if(ks(r,n)<h){if(n<r){let n=i(t,e,h),o=ks(r,Is.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ks(r,Is.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=ks(r,Is.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>ks(r,Is.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]}})(vs||={});var xs=class extends I{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 new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ds=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new B}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++)Ds._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}};Ds=n([o(0,Q)],Ds);var Ls=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 B,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,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,v=0,B=0,b=0,M=!1,y=0,E=!1,Q=0,k=0,x=[],D=-1!==a&&-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 xs(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>=a&&L<=c,T=!1;this._decorationService.forEachDecorationAtCell(L,i,void 0,(()=>{T=!0}));let U=R.getChars()||m;if(" "===U&&(R.isUnderline()||R.isOverline())&&(U=" "),Q=d*o-l.get(U,R.isBold(),R.isItalic()),g){if(w&&(N&&E||!N&&!E&&R.bg===v)&&(N&&E&&f.selectionForeground||R.fg===B)&&R.extended.ext===b&&H===M&&Q===y&&!F&&!_&&!T&&S){R.isInvisible()?p+=m:p+=U,w++;continue}w&&(g.textContent=p),g=this._document.createElement("span"),w=0,p=""}else g=this._document.createElement("span");if(v=R.bg,B=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()?m:R.getChars()||m,R.isUnderline()&&(x.push(`xterm-underline-${R.extended.underlineStyle}`)," "===p&&(p=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${I.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 P=R.getFgColor(),G=R.getFgColorMode(),J=R.getBgColor(),O=R.getBgColorMode(),W=!!R.isInverse();if(W){let t=P;P=J,J=t;let i=G;G=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&&(G=50331648,P=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&&(G=50331648,P=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=ps.toColor(J>>16,J>>8&255,255&J),this._addStyle(g,`background-color:#${_s((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=Cs.multiplyOpacity(K,.5)),G){case 16777216:case 33554432:R.isBold()&&P<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(P+=8),this._applyMinimumContrast(g,K,f.ansi[P],R,z,void 0)||x.push(`xterm-fg-${P}`);break;case 50331648:let t=ps.toColor(P>>16&255,P>>8&255,255&P);this._applyMinimumContrast(g,K,t,R,z,q)||this._addStyle(g,`color:#${_s(P.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||_||T||!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 57508<=t&&t<=57558}(n=e.getCode())||function(t){return 9472<=t&&t<=9631}(n))return!1;var n;let o,l=this._getContrastCache(e);if(!h&&!r&&(o=l.getColor(i.rgba,s.rgba)),void 0===o){let t=this._optionsService.rawOptions.minimumContrastRatio/(e.isDim()?2:1);o=Cs.ensureContrastRatio(h||i,r||s,t),l.setColor((h||i).rgba,(r||s).rgba,o??null)}return!!o&&(this._addStyle(t,`color:${o.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 _s(t,i,s){for(;t.length<s;)t=i+t;return t}Ls=n([o(1,O),o(2,S),o(3,U),o(4,x),o(5,N),o(6,W)],Ls);var Ss=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),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)}},Rs="xterm-dom-renderer-owner-",Ns="xterm-rows",Fs="xterm-fg-",Hs="xterm-bg-",Ts="xterm-focus",Us="xterm-selection",Ps=1,Gs=class extends lt{constructor(t,i,s,e,h,r,n,o,l,a,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=l,this._optionsService=a,this._bufferService=c,this._coreService=u,this._coreBrowserService=A,this._themeService=f,this._terminalClass=Ps++,this._rowElements=[],this._selectionRenderModel=new $s,this.onRequestRedraw=this._register(new Et).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ns),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(Us),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(Ls,document),this._element.classList.add(Rs+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(rt((()=>{this._element.classList.remove(Rs+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new Ss(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} .${Ns} 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} .${Ns} { 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} .${Ns} .xterm-dim { color: ${Cs.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} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${e} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${Ts} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${h} 1s step-end infinite;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block { background-color: ${t.cursor.css}; color: ${t.cursorAccent.css};}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${t.cursor.css} !important; color: ${t.cursorAccent.css} !important;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${t.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${t.cursor.css} inset;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${t.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,i+=`${this._terminalSelector} .${Us} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Us} div { position: absolute; background-color: ${t.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Us} div { position: absolute; background-color: ${t.selectionInactiveBackgroundOpaque.css};}`;for(let[s,e]of t.ansi.entries())i+=`${this._terminalSelector} .${Fs}${s} { color: ${e.css}; }${this._terminalSelector} .${Fs}${s}.xterm-dim { color: ${Cs.multiplyOpacity(e,.5).css}; }${this._terminalSelector} .${Hs}${s} { background-color: ${e.css}; }`;i+=`${this._terminalSelector} .${Fs}257 { color: ${Cs.opaque(t.background).css}; }${this._terminalSelector} .${Fs}257.xterm-dim { color: ${Cs.multiplyOpacity(Cs.opaque(t.background),.5).css}; }${this._terminalSelector} .${Hs}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(Ts),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ts),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`.${Rs}${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),h=Math.min(h,this._bufferService.cols);let o=this._bufferService.buffer,l=o.ybase+o.y,a=Math.min(o.x,h-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===l,u,A,a,c,this.dimensions.css.cell.width,this._widthCache,r?n===s?t:0:-1,r?(n===e?i:h)-1:-1))}}};Gs=n([o(7,L),o(8,T),o(9,S),o(10,Q),o(11,x),o(12,U),o(13,W)],Gs);var Js=class extends lt{constructor(t,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Et),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new zs(this._optionsService))}catch{this._measureStrategy=this._register(new Ws(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())}};Js=n([o(2,S)],Js);var Os=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)}},Ws=class extends Os{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}},zs=class extends Os{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 new 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}},qs=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 Ks(this._window)),this._onDprChange=this._register(new Et),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Et),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange((t=>this._screenDprMonitor.setWindow(t)))),this._register(At.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(xi(this._textarea,"focus",(()=>this._isFocused=!0))),this._register(xi(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}},Ks=class extends lt{constructor(t){super(),this._parentWindow=t,this._windowResizeListener=this._register(new at),this._onDprChange=this._register(new Et),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rt((()=>this.clearListener())))}setWindow(t){this._parentWindow=t,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=xi(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)}},js=class extends lt{constructor(){super(),this.linkProviders=[],this._register(rt((()=>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 Ys(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 Zs=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=Ys(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=Ys(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])}}};Zs=n([o(0,G),o(1,T)],Zs);var Xs=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=[]}},Vs={};((t,i)=>{for(var s in i)h(t,s,{get:i[s],enumerable:!0})})(Vs,{getSafariVersion:()=>ne,isChromeOS:()=>Ae,isFirefox:()=>ee,isIpad:()=>le,isIphone:()=>ae,isLegacyEdge:()=>he,isLinux:()=>ue,isMac:()=>oe,isNode:()=>te,isSafari:()=>re,isWindows:()=>ce});var te=typeof process<"u"&&"title"in process,ie=te?"node":navigator.userAgent,se=te?"node":navigator.platform,ee=ie.includes("Firefox"),he=ie.includes("Edge"),re=/^((?!chrome|android).)*safari/i.test(ie);function ne(){if(!re)return 0;let t=ie.match(/Version\/(\d+)/);return null===t||t.length<2?0:parseInt(t[1])}var oe=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(se),le="iPad"===se,ae="iPhone"===se,ce=["Windows","Win16","Win32","WinCE"].includes(se),ue=se.indexOf("Linux")>=0,Ae=/\bCrOS\b/.test(ie),fe=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()}},de=!te&&"requestIdleCallback"in window?class extends fe{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends fe{_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())}}},ge=class{constructor(){this._queue=new de}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},we=class extends lt{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 at),this._pausedResizeTask=new ge,this._observerDisposable=this._register(new at),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 Et),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Et),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Et),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Et),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Xs(((t,i)=>this._renderRows(t,i)),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new pe(this._coreBrowserService,this._coreService,(()=>this._fullRefresh())),this._register(rt((()=>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=rt((()=>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);t=Math.min(t,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(t,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start: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()}};we=n([o(2,S),o(3,T),o(4,x),o(5,N),o(6,Q),o(7,U),o(8,W)],we);var pe=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 Ce(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"===Ie(t,i)?-1:1;s.buffer.lines.get(h+r*n)?.isWrapped&&e++}return e}(t,i,s);return be(n,Be(Ie(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 Ie(t,i){return t>i?"A":"B"}function ve(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 Be(t,i){return ls.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 Me=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 ye(t,i){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return i*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var Ee=new RegExp(" ","g"),Qe=class extends lt{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 B,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Et),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Et),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Et),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Et),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 Me(this._bufferService),this._activeSelectionMode=0,this._register(rt((()=>{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(Ee," "))).join(ce?"\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()))),ue&&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=ye(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=Ys(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 oe?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&&!(oe&&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===Ce(i,e,h,r).length?"":be(ve(t,i,t,i-me(i,h),!1,h).length,Be("D",r))}(r,n,0,i,s,e)+Ce(n,i,s,e)+function(t,i,s,e,h,r){let n;n=Ce(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=Ce(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(ve(t,n,s,o,"C"===l,h).length,Be(l,r))}(r,n,t,i,s,e);if(n===i)return h=r>t?"D":"C",be(Math.abs(r-t),Be(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,Be(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,c=0,u=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)&&(c++,i--),2===r.getWidth(s)&&(u++,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()?(c++,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()?(u++,s++):t>1&&(f+=t-1,l+=t-1),l++,s++}}l++;let d=o+a-c+A,g=Math.min(this._bufferService.cols,l-o+c+u-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=ye(s,this._bufferService.cols)}};Qe=n([o(3,Q),o(4,x),o(5,P),o(6,S),o(7,G),o(8,U)],Qe);var ke=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={}}},xe=class{constructor(){this._color=new ke,this._css=new ke}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()}},De=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:ps.toCss(e,h,r),rgba:ps.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:ps.toCss(s,s,s),rgba:ps.toRgba(s,s,s)})}return t})()),Le=ms.toColor("#ffffff"),_e=ms.toColor("#000000"),Se=ms.toColor("#ffffff"),$e=_e,Re={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ne=Le,Fe=class extends lt{constructor(t){super(),this._optionsService=t,this._contrastCache=new xe,this._halfContrastCache=new xe,this._onChangeColors=this._register(new Et),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Le,background:_e,cursor:Se,cursorAccent:$e,selectionForeground:void 0,selectionBackgroundTransparent:Re,selectionBackgroundOpaque:Cs.blend(_e,Re),selectionInactiveBackgroundTransparent:Re,selectionInactiveBackgroundOpaque:Cs.blend(_e,Re),scrollbarSliderBackground:Cs.opacity(Le,.2),scrollbarSliderHoverBackground:Cs.opacity(Le,.4),scrollbarSliderActiveBackground:Cs.opacity(Le,.5),overviewRulerBorder:Le,ansi:De.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this._register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}get colors(){return this._colors}_setTheme(t={}){let i=this._colors;if(i.foreground=He(t.foreground,Le),i.background=He(t.background,_e),i.cursor=Cs.blend(i.background,He(t.cursor,Se)),i.cursorAccent=Cs.blend(i.background,He(t.cursorAccent,$e)),i.selectionBackgroundTransparent=He(t.selectionBackground,Re),i.selectionBackgroundOpaque=Cs.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=He(t.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=Cs.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=t.selectionForeground?He(t.selectionForeground,Es):void 0,i.selectionForeground===Es&&(i.selectionForeground=void 0),Cs.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=Cs.opacity(i.selectionBackgroundTransparent,.3)),Cs.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=Cs.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=He(t.scrollbarSliderBackground,Cs.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=He(t.scrollbarSliderHoverBackground,Cs.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=He(t.scrollbarSliderActiveBackground,Cs.opacity(i.foreground,.5)),i.overviewRulerBorder=He(t.overviewRulerBorder,Ne),i.ansi=De.slice(),i.ansi[0]=He(t.black,De[0]),i.ansi[1]=He(t.red,De[1]),i.ansi[2]=He(t.green,De[2]),i.ansi[3]=He(t.yellow,De[3]),i.ansi[4]=He(t.blue,De[4]),i.ansi[5]=He(t.magenta,De[5]),i.ansi[6]=He(t.cyan,De[6]),i.ansi[7]=He(t.white,De[7]),i.ansi[8]=He(t.brightBlack,De[8]),i.ansi[9]=He(t.brightRed,De[9]),i.ansi[10]=He(t.brightGreen,De[10]),i.ansi[11]=He(t.brightYellow,De[11]),i.ansi[12]=He(t.brightBlue,De[12]),i.ansi[13]=He(t.brightMagenta,De[13]),i.ansi[14]=He(t.brightCyan,De[14]),i.ansi[15]=He(t.brightWhite,De[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]=He(t.extendedAnsi[e],De[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 He(t,i){if(void 0!==t)try{return ms.toColor(t)}catch{}return i}Fe=n([o(0,S)],Fe);var Te=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)}},Ue=class{constructor(){this._services=new Te,this._services.set(L,this)}setService(t,i){this._services.set(t,i)}getService(t){return this._services.get(t)}createInstance(t,...i){let s=(h=t,h[M]||[]).sort(((t,i)=>t.index-i.index)),e=[];var h;for(let i of s){let s=this._services.get(i.id);if(!s)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${i.id._id}.`);e.push(s)}let r=s.length>0?s[0].index:i.length;if(i.length!==r)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${r+1} conflicts with ${i.length} static arguments`);return new t(...i,...e)}},Pe={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ge=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=Pe[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)}};Ge=n([o(0,S)],Ge);var Je=class extends lt{constructor(t){super(),this._maxLength=t,this.onDeleteEmitter=this._register(new Et),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Et),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Et),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(t){if(this._maxLength===t)return;let i=new 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 new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(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 new Error("start argument out of range");if(t+s<0)throw new 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}},Oe=Object.freeze(new I),We=0,ze=class t{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*t);let e=i||B.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?g(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?g(2097151&i):""}isProtected(t){return 536870912&this._data[3*t+2]}loadCell(t,i){return i.content=this._data[0+(We=3*t)],i.fg=this._data[We+1],i.bg=this._data[We+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]+=g(i):2097151&e?(this._combined[t]=g(2097151&e)+g(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 B;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 B;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?g(s):m;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 qe(t,i,s){let e=[],h=t.map(((s,e)=>Ke(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=Ke(t,n,i);r>l&&(r-=l,n++);let a=2===t[n].getWidth(r-1);a&&r--;let c=a?s-1:s;e.push(c),o+=c}return e}function Ke(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 je=class t{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=t._nextId++,this._onDispose=this.register(new Et),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ht(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};je._nextId=1;var Ye=je,Ze={},Xe=Ze.B;Ze[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:"≥","{":"π","|":"≠","}":"£","~":"·"},Ze.A={"#":"£"},Ze.B=void 0,Ze[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},Ze.C=Ze[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Ze.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},Ze.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},Ze.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},Ze.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},Ze.E=Ze[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},Ze.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},Ze.H=Ze[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},Ze["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ve=4294967295,th=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=Oe.clone(),this.savedCharset=Xe,this.markers=[],this._nullCell=B.fromCharData([0,"",1,0]),this._whitespaceCell=B.fromCharData([0,m,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new de,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Je(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 v),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 v),this._whitespaceCell}getBlankLine(t,i){return new ze(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>Ve?Ve:i}fillViewportRows(t){if(0===this.lines.length){void 0===t&&(t=Oe);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 Je(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,i){let s=this.getNullCell(Oe),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 ze(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 ze(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 c=[t.get(o)];for(;l<t.length&&a.isWrapped;)c.push(a),a=t.get(++l);if(!r&&e>=o&&e<l){o+=c.length-1;continue}let u=0,A=Ke(c,u,i),f=1,d=0;for(;f<c.length;){let t=Ke(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(Oe),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(Oe),h=s;for(;h-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new ze(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(Oe),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,c=l[l.length-1].getTrimmedLength(),u=qe(l,this._cols,t),A=u.length-l.length;a=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+A):Math.max(0,this.lines.length-this.lines.maxLength+A);let f=[];for(let t=0;t<A;t++){let t=this.getBlankLine(Oe,!0);f.push(t)}f.length>0&&(h.push({start:n+l.length+r,newLines:f}),r+=f.length),l.push(...f);let d=u.length-1,g=u[d];0===g&&(d--,g=u[d]);let w=l.length-A-1,p=c;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=u[d]),p-=t,0===p&&(w--,p=Ke(l,Math.max(w,0),this._cols))}for(let i=0;i<l.length;i++)u[i]<t&&l[i].setCell(u[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 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 Ye(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)}},ih=class extends lt{constructor(t,i){super(),this._optionsService=t,this._bufferService=i,this._onBufferActivate=this._register(new Et),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 th(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new th(!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)}},sh=class extends lt{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new Et),this.onResize=this._onResize.event,this._onScroll=this._register(new Et),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 ih(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))}};sh=n([o(0,S)],sh);var eh={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:oe,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},hh=["normal","bold","100","200","300","400","500","600","700","800","900"],rh=class extends lt{constructor(t){super(),this._onOptionChange=this._register(new Et),this.onOptionChange=this._onOptionChange.event;let i={...eh};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(rt((()=>{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 eh))throw new Error(`No option with key "${t}"`);return this.rawOptions[t]},i=(t,i)=>{if(!(t in eh))throw new 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=eh[t]),"block"!==(s=i)&&"underline"!==s&&"bar"!==s)throw new Error(`"${i}" is not a valid value for ${t}`);break;case"wordSeparator":i||(i=eh[t]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=hh.includes(i)?i:eh[t];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw new 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 new Error(`${t} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw new Error(`${t} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw new Error(`${t} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}var s;return i}};function nh(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]&&nh(t[e],i-1);return s}var oh=Object.freeze({insertMode:!1}),lh=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ah=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 Et),this.onData=this._onData.event,this._onUserInput=this._register(new Et),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Et),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Et),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=nh(oh),this.decPrivateModes=nh(lh)}reset(){this.modes=nh(oh),this.decPrivateModes=nh(lh)}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))}};ah=n([o(0,Q),o(1,_),o(2,S)],ah);var ch={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 uh(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 Ah=String.fromCharCode,fh={DEFAULT:t=>{let i=[uh(t,!1)+32,t.col+32,t.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`[M${Ah(i[0])}${Ah(i[1])}${Ah(i[2])}`},SGR:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${uh(t,!0)};${t.col};${t.row}${i}`},SGR_PIXELS:t=>{let i=0===t.action&&4!==t.button?"m":"M";return`[<${uh(t,!0)};${t.x};${t.y}${i}`}},dh=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 Et),this.onProtocolChange=this._onProtocolChange.event;for(let t of Object.keys(ch))this.addProtocol(t,ch[t]);for(let t of Object.keys(fh))this.addEncoding(t,fh[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 new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,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)}};dh=n([o(0,Q),o(1,x),o(2,S)],dh);var gh,wh=[[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]],ph=[[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]],Ch=class{constructor(){if(this.version="6",!gh){(gh=new Uint8Array(65536)).fill(1),gh[0]=0,gh.fill(0,1,32),gh.fill(0,127,160),gh.fill(2,4352,4448),gh[9001]=2,gh[9002]=2,gh.fill(2,11904,42192),gh[12351]=1,gh.fill(2,44032,55204),gh.fill(2,63744,64256),gh.fill(2,65040,65050),gh.fill(2,65072,65136),gh.fill(2,65280,65377),gh.fill(2,65504,65511);for(let t=0;t<wh.length;++t)gh.fill(0,wh[t][0],wh[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?gh[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,ph)?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 Et,this.onChange=this._onChange.event;let t=new Ch;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 new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(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)}},Ih=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 vh(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 Bh=2147483647,bh=class t{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>256)throw new 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 new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Bh?Bh: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 new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Bh?Bh: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,Bh):t}},Mh=[],yh=class{constructor(){this._state=0,this._active=Mh,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=Mh}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=Mh,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Mh,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",w(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=Mh,this._id=-1,this._state=0}}},Eh=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+=w(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}},Qh=[],kh=class{constructor(){this._handlers=Object.create(null),this._active=Qh,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Qh}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=Qh,this._ident=0}hook(t,i){if(this.reset(),this._ident=t,this._active=this._handlers[t]||Qh,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",w(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=Qh,this._ident=0}},xh=new bh;xh.addParam(0);var Dh=class{constructor(t){this._handler=t,this._data="",this._params=xh,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():xh,this._data="",this._hitLimit=!1}put(t,i,s){this._hitLimit||(this._data+=w(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=xh,this._data="",this._hitLimit=!1,t)));return this._params=xh,this._data="",this._hitLimit=!1,i}},Lh=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}},_h=160,Sh=function(){let t=new Lh(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(_h,0,2,0),t.add(_h,8,5,8),t.add(_h,6,0,6),t.add(_h,11,0,11),t.add(_h,13,13,13),t}(),$h=class extends lt{constructor(t=Sh){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(rt((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this._register(new yh),this._dcsParser=this._register(new kh),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 new Error("only one byte as prefix supported");if(s=t.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(t.intermediates){if(t.intermediates.length>2)throw new 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 new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=e}}if(1!==t.final.length)throw new Error("final must be a single byte");let e=t.final.charCodeAt(0);if(i[0]>e||e>i[1])throw new 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,new 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:_h)],r>>4){case 2:for(let e=s+1;;++e){if(e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){this._printHandler(t,s,e),s=e-1;break}if(++e>=i||(h=t[e])<32||h>126&&h<_h){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<_h){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<_h){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}}},Rh=/^([\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})$/,Nh=/^[\da-f]+$/;function Fh(t){if(!t)return;let i=t.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let t=Rh.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),Nh.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 Hh(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 Th(t,i=16){let[s,e,h]=t;return`rgb:${Hh(s,i)}/${Hh(e,i)}/${Hh(h,i)}`}var Uh={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ph=131072;function Gh(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 Jh=0,Oh=class extends lt{constructor(t,i,s,e,h,r,n,o,l=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=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new p,this._utf8Decoder=new C,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Oe.clone(),this._eraseAttrDataInternal=Oe.clone(),this._onRequestBell=this._register(new Et),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Et),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Et),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Et),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Et),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Et),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Et),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Et),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Et),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Et),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Et),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Et),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Et),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 Wh(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(ls.BEL,(()=>this.bell())),this._parser.setExecuteHandler(ls.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(ls.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(ls.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(ls.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(ls.BS,(()=>this.backspace())),this._parser.setExecuteHandler(ls.HT,(()=>this.tab())),this._parser.setExecuteHandler(ls.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(ls.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(as.IND,(()=>this.index())),this._parser.setExecuteHandler(as.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(as.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new Eh((t=>(this.setTitle(t),this.setIconName(t),!0)))),this._parser.registerOscHandler(1,new Eh((t=>this.setIconName(t)))),this._parser.registerOscHandler(2,new Eh((t=>this.setTitle(t)))),this._parser.registerOscHandler(4,new Eh((t=>this.setOrReportIndexedColor(t)))),this._parser.registerOscHandler(8,new Eh((t=>this.setHyperlink(t)))),this._parser.registerOscHandler(10,new Eh((t=>this.setOrReportFgColor(t)))),this._parser.registerOscHandler(11,new Eh((t=>this.setOrReportBgColor(t)))),this._parser.registerOscHandler(12,new Eh((t=>this.setOrReportCursorColor(t)))),this._parser.registerOscHandler(104,new Eh((t=>this.restoreIndexedColor(t)))),this._parser.registerOscHandler(110,new Eh((t=>this.restoreFgColor(t)))),this._parser.registerOscHandler(111,new Eh((t=>this.restoreBgColor(t)))),this._parser.registerOscHandler(112,new Eh((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 Ze)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 Dh(((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>Ph&&(r=this._parseStack.position+Ph)}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<Ph&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Ph))),n||this._dirtyRowTracker.clearRange(),t.length>Ph)for(let i=r;i<t.length;i+=Ph){let r=i+Ph<t.length?i+Ph: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,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=mh.extractWidth(i);let s=mh.extractShouldJoin(i),d=s?mh.extractWidth(A):0;if(A=i,n&&this._onA11yChar.fire(g(e)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+h-d>o)if(l){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 ze&&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(a&&(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=>!Gh(t.params[0],this._optionsService.rawOptions.windowOptions)||i(t))}registerDcsHandler(t,i){return this._parser.registerDcsHandler(t,new Dh(i))}registerEscHandler(t,i){return this._parser.registerEscHandler(t,i)}registerOscHandler(t,i){return this._parser.registerOscHandler(t,new Eh(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(Oe));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(ls.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ls.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ls.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ls.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ls.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,Xe),this._charsetService.setgCharset(1,Xe),this._charsetService.setgCharset(2,Xe),this._charsetService.setgCharset(3,Xe);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:c}=o,u=this._optionsService.rawOptions,A=t=>t?1:2,f=t.params[0];return((t,s)=>(n.triggerDataEvent(`${ls.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===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(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(a===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|=I.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=Oe.fg,t.bg=Oe.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&Oe.fg):49===i?(e.bg&=-67108864,e.bg|=16777215&Oe.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&Oe.fg,e.bg&=-67108864,e.bg|=16777215&Oe.bg):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${ls.ESC}[0n`);break;case 6:this._coreService.triggerDataEvent(`${ls.ESC}[${this._activeBuffer.y+1};${this._activeBuffer.x+1}R`)}return!0}deviceStatusPrivate(t){return 6===t.params[0]&&this._coreService.triggerDataEvent(`${ls.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=Oe.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(!Gh(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(`${ls.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(zh(s))if("?"===e)i.push({type:0,index:s});else{let t=Fh(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=Fh(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]);zh(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,Xe),!0}selectCharset(t){return 2!==t.length?(this.selectDefaultCharset(),!0):("/"===t[0]||this._charsetService.setgCharset(Uh[t[0]],Ze[t[1]]||Xe),!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=Oe.clone(),this._eraseAttrDataInternal=Oe.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 B;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(`${ls.ESC}${t}${ls.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)}},Wh=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&&(Jh=t,t=i,i=Jh),t<this.start&&(this.start=t),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function zh(t){return 0<=t&&t<256}Wh=n([o(0,Q)],Wh);var qh=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 Et),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 new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=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()}},Kh=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)))}};Kh=n([o(0,Q)],Kh);var jh=!1,Yh=class extends lt{constructor(t){super(),this._windowsWrappingHeuristics=this._register(new at),this._onBinary=this._register(new Et),this.onBinary=this._onBinary.event,this._onData=this._register(new Et),this.onData=this._onData.event,this._onLineFeed=this._register(new Et),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Et),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Et),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Et),this._instantiationService=new Ue,this.optionsService=this._register(new rh(t)),this._instantiationService.setService(S,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(sh)),this._instantiationService.setService(Q,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ge)),this._instantiationService.setService(_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ah)),this._instantiationService.setService(x,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(dh)),this._instantiationService.setService(k,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(mh)),this._instantiationService.setService(R,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Ih),this._instantiationService.setService(D,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Kh),this._instantiationService.setService($,this._oscLinkService),this._inputHandler=this._register(new Oh(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(At.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(At.forward(this._bufferService.onResize,this._onResize)),this._register(At.forward(this.coreService.onData,this._onData)),this._register(At.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 qh(((t,i)=>this._inputHandler.parse(t,i)))),this._register(At.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Et),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&&!jh&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jh=!0),this._writeBuffer.writeSync(t,i)}input(t,i=!0){this.coreService.triggerDataEvent(t,i)}resize(t,i){isNaN(t)||isNaN(i)||(t=Math.max(t,2),i=Math.max(i,1),this._bufferService.resize(t,i))}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(vh.bind(null,this._bufferService))),t.push(this.registerCsiHandler({final:"H"},(()=>(vh(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=rt((()=>{for(let i of t)i.dispose()}))}}},Zh={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:["'",'"']},Xh=0,Vh=class{constructor(t){this._getKey=t,this._array=[],this._insertedValues=[],this._flushInsertedTask=new de,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new de,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=new 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===(Xh=this._search(i))||this._getKey(this._array[Xh])!==i)return!1;do{if(this._array[Xh]===t)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue((()=>this._flushDeleted())),this._deletedIndices.push(Xh),!0}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===i);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let t=this._deletedIndices.sort(((t,i)=>t-i)),i=0,s=new 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&&!((Xh=this._search(t))<0||Xh>=this._array.length)&&this._getKey(this._array[Xh])===t)do{yield this._array[Xh]}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===t)}forEachByKey(t,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((Xh=this._search(t))<0||Xh>=this._array.length)&&this._getKey(this._array[Xh])===t)do{i(this._array[Xh])}while(++Xh<this._array.length&&this._getKey(this._array[Xh])===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}},tr=0,ir=0,sr=class extends lt{constructor(){super(),this._decorations=new Vh((t=>t?.marker.line)),this._onDecorationRegistered=this._register(new Et),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Et),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rt((()=>this.reset())))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let i=new er(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=>{ir=(tr=i.options.x??0)+(i.options.width??1),t>=tr&&t<ir&&(!s||(i.options.layer??"bottom")===s)&&e(i)}))}},er=class extends ot{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new Et),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Et),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()}},hr=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)}},rr=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 hr(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize((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(xi(h,"selectionchange",(()=>this._handleSelectionChange()))),this._register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRowsDimensions(),this._refreshRows(),this._register(rt((()=>{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+=u())))}_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.toString();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).toString(),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 new 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})`)}};rr=n([o(1,L),o(2,U),o(3,G)],rr);var nr=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 Et),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Et),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rt((()=>{ht(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(xi(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this._register(xi(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(xi(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(xi(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);var s,e;i&&this._mouseDownLink&&(s=this._mouseDownLink.link).text===(e=this._currentLink.link).text&&s.range.start.x===e.range.start.x&&s.range.start.y===e.range.start.y&&s.range.end.x===e.range.end.x&&s.range.end.y===e.range.end.y&&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,ht(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}}};nr=n([o(1,P),o(2,G),o(3,Q),o(4,z)],nr);var or=class extends Yh{constructor(t={}){super(t),this._linkifier=this._register(new at),this.browser=Vs,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new at),this._onCursorMove=this._register(new Et),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Et),this.onKey=this._onKey.event,this._onRender=this._register(new Et),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Et),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Et),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Et),this.onBell=this._onBell.event,this._onFocus=this._register(new Et),this._onBlur=this._register(new Et),this._onA11yCharEmitter=this._register(new Et),this._onA11yTabEmitter=this._register(new Et),this._onWillOpen=this._register(new Et),this._setup(),this._decorationService=this._instantiationService.createInstance(sr),this._instantiationService.setService(N,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(js),this._instantiationService.setService(z,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(F)),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(At.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(At.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(At.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(At.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize((t=>this._afterResize(t.cols,t.rows)))),this._register(rt((()=>{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=Cs.toColorRGB("ansi"===t?this._themeService.colors.ansi[i.index]:this._themeService.colors[t]);this.coreService.triggerDataEvent(`${ls.ESC}]${s};${Th(e)}${cs.ST}`);break;case 1:if("ansi"===t)this._themeService.modifyColors((t=>t.ansi[i.index]=ps.toColor(...i.color)));else{let s=t;this._themeService.modifyColors((t=>t[s]=ps.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(rr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(t){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ls.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(ls.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(xi(this.element,"copy",(t=>{var i;this.hasSelection()&&((i=t).clipboardData&&i.clipboardData.setData("text/plain",this._selectionService.selectionText),i.preventDefault())})));let t=t=>function(t,i,s,e){t.stopPropagation(),t.clipboardData&&A(t.clipboardData.getData("text/plain"),i,s,e)}(t,this.textarea,this.coreService,this.optionsService);this._register(xi(this.textarea,"paste",t)),this._register(xi(this.element,"paste",t)),this._register(ee?xi(this.element,"mousedown",(t=>{2===t.button&&d(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):xi(this.element,"contextmenu",(t=>{d(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),ue&&this._register(xi(this.element,"auxclick",(t=>{1===t.button&&f(t,this.textarea,this.screenElement)})))}_bindKeys(){this._register(xi(this.textarea,"keyup",(t=>this._keyUp(t)),!0)),this._register(xi(this.textarea,"keydown",(t=>this._keyDown(t)),!0)),this._register(xi(this.textarea,"keypress",(t=>this._keyPress(t)),!0)),this._register(xi(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this._register(xi(this.textarea,"compositionupdate",(t=>this._compositionHelper.compositionupdate(t)))),this._register(xi(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this._register(xi(this.textarea,"input",(t=>this._inputEvent(t)),!0)),this._register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(t){if(!t)throw new 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(xi(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",a()),Ae||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(qs,this.textarea,t.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(U,this._coreBrowserService),this._register(xi(this.textarea,"focus",(t=>this._handleTextAreaFocus(t)))),this._register(xi(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Js,this._document,this._helperContainer),this._instantiationService.setService(T,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fe),this._instantiationService.setService(W,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ds),this._instantiationService.setService(O,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(we,this.rows,this.screenElement)),this._instantiationService.setService(G,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(ws,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Zs),this._instantiationService.setService(P,this._mouseService);let e=this._linkifier.value=this._register(this._instantiationService.createInstance(nr,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(ns,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(Qe,this.element,this.screenElement,e)),this._instantiationService.setService(J,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(At.any(this._onScroll.event,this._inputHandler.onScroll)((()=>{this._selectionService.refresh(),this._viewport?.queueSync()}))),this._register(this._instantiationService.createInstance(os,this.screenElement)),this._register(xi(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(rr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",(t=>this._handleScreenReaderModeOptionChange(t)))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",(t=>{!this._overviewRulerRenderer&&t&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gs,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Gs,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(xi(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(xi(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(ls.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){A(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 new 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 new 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?ls.ESC+"OA":ls.ESC+"[A":"UIKeyInputLeftArrow"===t.key?h.key=i?ls.ESC+"OD":ls.ESC+"[D":"UIKeyInputRightArrow"===t.key?h.key=i?ls.ESC+"OC":ls.ESC+"[C":"UIKeyInputDownArrow"===t.key&&(h.key=i?ls.ESC+"OB":ls.ESC+"[B");break;case 8:h.key=t.ctrlKey?"\b":ls.DEL,t.altKey&&(h.key=ls.ESC+h.key);break;case 9:if(t.shiftKey){h.key=ls.ESC+"[Z";break}h.key=ls.HT,h.cancel=!0;break;case 13:h.key=t.altKey?ls.ESC+ls.CR:ls.CR,h.cancel=!0;break;case 27:h.key=ls.ESC,t.altKey&&(h.key=ls.ESC+ls.ESC),h.cancel=!0;break;case 37:if(t.metaKey)break;h.key=r?ls.ESC+"[1;"+(r+1)+"D":i?ls.ESC+"OD":ls.ESC+"[D";break;case 39:if(t.metaKey)break;h.key=r?ls.ESC+"[1;"+(r+1)+"C":i?ls.ESC+"OC":ls.ESC+"[C";break;case 38:if(t.metaKey)break;h.key=r?ls.ESC+"[1;"+(r+1)+"A":i?ls.ESC+"OA":ls.ESC+"[A";break;case 40:if(t.metaKey)break;h.key=r?ls.ESC+"[1;"+(r+1)+"B":i?ls.ESC+"OB":ls.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(h.key=ls.ESC+"[2~");break;case 46:h.key=r?ls.ESC+"[3;"+(r+1)+"~":ls.ESC+"[3~";break;case 36:h.key=r?ls.ESC+"[1;"+(r+1)+"H":i?ls.ESC+"OH":ls.ESC+"[H";break;case 35:h.key=r?ls.ESC+"[1;"+(r+1)+"F":i?ls.ESC+"OF":ls.ESC+"[F";break;case 33:t.shiftKey?h.type=2:h.key=t.ctrlKey?ls.ESC+"[5;"+(r+1)+"~":ls.ESC+"[5~";break;case 34:t.shiftKey?h.type=3:h.key=t.ctrlKey?ls.ESC+"[6;"+(r+1)+"~":ls.ESC+"[6~";break;case 112:h.key=r?ls.ESC+"[1;"+(r+1)+"P":ls.ESC+"OP";break;case 113:h.key=r?ls.ESC+"[1;"+(r+1)+"Q":ls.ESC+"OQ";break;case 114:h.key=r?ls.ESC+"[1;"+(r+1)+"R":ls.ESC+"OR";break;case 115:h.key=r?ls.ESC+"[1;"+(r+1)+"S":ls.ESC+"OS";break;case 116:h.key=r?ls.ESC+"[15;"+(r+1)+"~":ls.ESC+"[15~";break;case 117:h.key=r?ls.ESC+"[17;"+(r+1)+"~":ls.ESC+"[17~";break;case 118:h.key=r?ls.ESC+"[18;"+(r+1)+"~":ls.ESC+"[18~";break;case 119:h.key=r?ls.ESC+"[19;"+(r+1)+"~":ls.ESC+"[19~";break;case 120:h.key=r?ls.ESC+"[20;"+(r+1)+"~":ls.ESC+"[20~";break;case 121:h.key=r?ls.ESC+"[21;"+(r+1)+"~":ls.ESC+"[21~";break;case 122:h.key=r?ls.ESC+"[23;"+(r+1)+"~":ls.ESC+"[23~";break;case 123:h.key=r?ls.ESC+"[24;"+(r+1)+"~":ls.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=ls.US),"@"===t.key&&(h.key=ls.NUL)):65===t.keyCode&&(h.type=1);else{let i=Zh[t.keyCode]?.[t.shiftKey?1:0];if(i)h.key=ls.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=ls.ESC+i}else if(32===t.keyCode)h.key=ls.ESC+(t.ctrlKey?ls.NUL:" ");else if("Dead"===t.key&&t.code.startsWith("Key")){let i=t.code.slice(3,4);t.shiftKey||(i=i.toLowerCase()),h.key=ls.ESC+i,h.cancel=!0}}else t.keyCode>=65&&t.keyCode<=90?h.key=String.fromCharCode(t.keyCode-64):32===t.keyCode?h.key=ls.NUL:t.keyCode>=51&&t.keyCode<=55?h.key=String.fromCharCode(t.keyCode-51+27):56===t.keyCode?h.key=ls.DEL:219===t.keyCode?h.key=ls.ESC:220===t.keyCode?h.key=ls.FS:221===t.keyCode&&(h.key=ls.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===ls.ETX||s.key===ls.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){var i;this._keyDownSeen=!1,(!this._customKeyEventHandler||!1!==this._customKeyEventHandler(t))&&(16===(i=t).keyCode||17===i.keyCode||18===i.keyCode||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(Oe));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(ls.ESC+"[I"):this.coreService.triggerDataEvent(ls.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(`${ls.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(`${ls.ESC}[6;${e};${s}t`)}}cancel(t,i){if(this.options.cancelEvents||i)return t.preventDefault(),t.stopPropagation(),!1}},lr=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 new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(i,1)}},ar=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 B)}translateToString(t,i,s){return this._line.translateToString(t,i,s)}},cr=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 ar(i)}getNullCell(){return new B}},ur=class extends lt{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new Et),this.onBufferChange=this._onBufferChange.event,this._normal=new cr(this._core.buffers.normal,"normal"),this._alternate=new cr(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Ar=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)}},fr=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}},dr=["cols","rows"],gr=0,wr=class extends lt{constructor(t){super(),this._core=this._register(new or(t)),this._addonManager=this._register(new lr),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(dr.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Ar(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new fr(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 ur(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 a()},set promptLabel(t){l=t},get tooMuchOutput(){return u()},set tooMuchOutput(t){c=t}}}_verifyIntegers(...t){for(gr of t)if(gr===1/0||isNaN(gr)||gr%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(gr of t)if(gr&&(gr===1/0||isNaN(gr)||gr%1!=0||gr<0))throw new Error("This API only accepts positive integers")}},pr=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")),c=e-(n+o);return{cols:Math.max(2,Math.floor((h-(l+a)-i)/t.css.cell.width)),rows:Math.max(1,Math.floor(c/t.css.cell.height))}}},Cr=class{constructor(t,i,s,e={}){this._terminal=t,this._regex=i,this._handler=s,this._options=e}provideLinks(t,i){let s=Ir.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 Ir=class t{static computeLink(i,s,e,h){let r,n=new RegExp(s.source,(s.flags||"")+"g"),[o,l]=t._getWindowedLineStrings(i-1,e),a=o.join(""),c=[];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&&c.push({range:{start:{x:n+1,y:s+1},end:{x:a,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]}},vr=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Br(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=Br,i={}){this._handler=t,this._options=i}activate(t){this._terminal=t;let i=this._options;this._linkProvider=this._terminal.registerLinkProvider(new Cr(this._terminal,i.urlRegex||vr,this._handler,i))}dispose(){this._linkProvider?.dispose()}},Mr=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?Lr.isErrorNoTelemetry(t)?new Lr(t.message+"\n\n"+t.stack):new 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{r as t,g as i,h as s,H as e}from"./p-BZOTLEeX.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 yr(t){(function(t){return t instanceof Dr||t instanceof Error&&t.name===xr&&t.message===xr})(t)||Mr.onUnexpectedError(t)}var Er,Qr,kr,xr="Canceled",Dr=class extends Error{constructor(){super(xr),this.name=this.message}},Lr=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 _r(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function Sr(t){if(Qr.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 $r(...t){return Rr((()=>Sr(t)))}function Rr(t){return{dispose:_r((()=>{t()}))}}(kr=Er||={}).isLessThan=function(t){return t<0},kr.isLessThanOrEqual=function(t){return t<=0},kr.isGreaterThan=function(t){return t>0},kr.isNeitherLessOrGreaterThan=function(t){return 0===t},kr.greaterThan=1,kr.lessThan=-1,kr.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(Qr||={});var Nr=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{Sr(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Nr.DISABLE_DISPOSED_WARNING=!1;var Fr=Nr,Hr=class{constructor(){this._store=new Fr}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Hr.None=Object.freeze({dispose(){}});var Tr,Ur=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}},Pr=globalThis.performance&&"function"==typeof globalThis.performance.now,Gr=class t{static create(i){return new t(i)}constructor(t){this._now=Pr&&!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 Vr({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 Vr(A);return n?.add(f),f.event}t.None=()=>Hr.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=$r(...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 Vr({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 Vr({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 Vr({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 Vr;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 Vr({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 Fr?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Tr||={});var Jr=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 Gr,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}}};Jr.all=new Set,Jr._idPool=0;var Or=Jr,Wr=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 jr(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}};Wr._idPool=1;var qr,zr=Wr,Kr=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},jr=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Yr=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Zr=0,Xr=class{constructor(t){this.value=t,this.id=Zr++}},Vr=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new zr(t?.onListenerError??yr,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Or(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 Yr(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||yr)(s),Hr.None}if(this._disposed)return Hr.None;i&&(t=t.bind(i));let e,h=new Xr(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Kr.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof Xr?(this._deliveryQueue??=new tn,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Rr((()=>{e?.(),this._removeListener(h)}));return s instanceof Fr?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)),new 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||yr;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 Xr)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}},tn=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}},sn=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 rn||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Tr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sn})})(qr||={});var en,hn,rn=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?sn:(this._emitter||(this._emitter=new Vr),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},nn="en",on=nn,an=globalThis;typeof an.vscode<"u"&&typeof an.vscode.process<"u"?hn=an.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(hn=process);var ln="string"==typeof hn?.versions?.electron&&"renderer"===hn?.type;if("object"==typeof hn){on=nn;let t=hn.env.VSCODE_NLS_CONFIG;if(t)try{on=JSON.parse(t).resolvedLanguage||nn}catch{}}else"object"!=typeof navigator||ln?console.error("Unable to resolve platform."):((en=navigator.userAgent).indexOf("Windows"),en.indexOf("Macintosh"),(en.indexOf("Macintosh")>=0||en.indexOf("iPad")>=0||en.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,en.indexOf("Linux"),en?.indexOf("Mobi"),on=globalThis._VSCODE_NLS_LANGUAGE||nn,navigator.language.toLowerCase());var cn,un=en,An=on;(t=>{t.value=function(){return An},t.isDefaultVariant=function(){return 2===An.length?"en"===An:An.length>=3&&"e"===An[0]&&"n"===An[1]&&"-"===An[2]},t.isDefault=function(){return"en"===An}})(cn||={});var fn="function"==typeof an.postMessage&&!an.importScripts;(()=>{if(fn){let t=[];an.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 dn,gn,wn=!!(un&&un.indexOf("Chrome")>=0);function pn(t,i=0){let s=setTimeout((()=>{t()}),i);return Rr((()=>{clearTimeout(s)}))}un&&un.indexOf("Firefox"),!wn&&un&&un.indexOf("Safari"),un&&un.indexOf("Edg/"),un&&un.indexOf("Android"),(gn=dn||={}).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},gn.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))};var Cn=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 Vr,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 Tr.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())}};Cn.EMPTY=Cn.fromArray([]);var mn=class extends Hr{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Ur),this._linesCacheDisposables=this._register(new Ur),this._register(Rr((()=>this._destroyLinesCache())))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=$r(this._terminal.onLineFeed((()=>this._destroyLinesCache())),this._terminal.onCursorMove((()=>this._destroyLinesCache())),this._terminal.onResize((()=>this._destroyLinesCache())))),this._linesCacheTimeout.value=pn((()=>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]}},In=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}},vn=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 new 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}},Bn=class extends Hr{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Rr((()=>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(){Sr(s)}}}clearHighlightDecorations(){Sr(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((()=>Sr(t)))),o.push(h)}}return 0===o.length?void 0:o}},bn=class extends Hr{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Vr)}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()}},Mn=class extends Hr{constructor(t){super(),this._highlightTimeout=this._register(new Ur),this._lineCache=this._register(new Ur),this._state=new In,this._resultTracker=this._register(new bn),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new mn(t),this._engine=new vn(t,this._lineCache.value),this._decorationManager=new Bn(t),this._register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this._register(this._terminal.onResize((()=>this._updateMatches()))),this._register(Rr((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=pn((()=>{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 new 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 new 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 new 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}},yn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?_n.isErrorNoTelemetry(t)?new _n(t.message+"\n\n"+t.stack):new 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 En(t){(function(t){return t instanceof Ln||t instanceof Error&&t.name===Dn&&t.message===Dn})(t)||yn.onUnexpectedError(t)}var Qn,kn,xn,Dn="Canceled",Ln=class extends Error{constructor(){super(Dn),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 Sn(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function $n(t){if(xn.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 Rn(...t){return Nn((()=>$n(t)))}function Nn(t){return{dispose:Sn((()=>{t()}))}}(kn=Qn||={}).isLessThan=function(t){return t<0},kn.isLessThanOrEqual=function(t){return t<=0},kn.isGreaterThan=function(t){return t>0},kn.isNeitherLessOrGreaterThan=function(t){return 0===t},kn.greaterThan=1,kn.lessThan=-1,kn.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(xn||={});var Fn=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{$n(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Fn.DISABLE_DISPOSED_WARNING=!1;var Hn=Fn,Tn=class{constructor(){this._store=new Hn}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Tn.None=Object.freeze({dispose(){}});var Un=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,Gn=Pn?"node":navigator.userAgent,Jn=Pn?"node":navigator.platform,On=Gn.includes("Firefox"),Wn=Gn.includes("Edge"),qn=/^((?!chrome|android).)*safari/i.test(Gn);Jn.indexOf("Linux");var zn,Kn,jn,Yn,Zn,Xn=0,Vn=0,to=0,io=0,so={css:"#00000000",rgba:0};function eo(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ho(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}function ro(t){if(!t)throw new Error("value must not be falsy");return t}function no(t){return 57508<=t&&t<=57558}function oo(t){return no(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?`#${eo(t)}${eo(i)}${eo(s)}${eo(e)}`:`#${eo(t)}${eo(i)}${eo(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)}}})(zn||={}),(t=>{function i(t,i){return io=Math.round(255*i),[Xn,Vn,to]=Zn.toChannels(t.rgba),{css:zn.toCss(Xn,Vn,to,io),rgba:zn.toRgba(Xn,Vn,to,io)}}t.blend=function(t,i){if(1==(io=(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 Xn=h+Math.round(((i.rgba>>24&255)-h)*io),Vn=r+Math.round((s-r)*io),to=n+Math.round((e-n)*io),{css:zn.toCss(Xn,Vn,to),rgba:zn.toRgba(Xn,Vn,to)}},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 zn.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Xn,Vn,to]=Zn.toChannels(i),{css:zn.toCss(Xn,Vn,to),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(io=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Kn||={}),(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 Xn=parseInt(t.slice(1,2).repeat(2),16),Vn=parseInt(t.slice(2,3).repeat(2),16),to=parseInt(t.slice(3,4).repeat(2),16),zn.toColor(Xn,Vn,to);case 5:return Xn=parseInt(t.slice(1,2).repeat(2),16),Vn=parseInt(t.slice(2,3).repeat(2),16),to=parseInt(t.slice(3,4).repeat(2),16),io=parseInt(t.slice(4,5).repeat(2),16),zn.toColor(Xn,Vn,to,io);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 Xn=parseInt(e[1]),Vn=parseInt(e[2]),to=parseInt(e[3]),io=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),zn.toColor(Xn,Vn,to,io);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Xn,Vn,to,io]=i.getImageData(0,0,1,1).data,255!==io)throw new Error("css.toColor: Unsupported css format");return{rgba:zn.toRgba(Xn,Vn,to,io),css:t}}})(jn||={}),(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})(Yn||={}),(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=ho(Yn.relativeLuminance2(n,o,a),Yn.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=ho(Yn.relativeLuminance2(n,o,a),Yn.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=ho(Yn.relativeLuminance2(n,o,a),Yn.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=ho(Yn.relativeLuminance2(n,o,a),Yn.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(io=(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 Xn=h+Math.round(((i>>24&255)-h)*io),Vn=r+Math.round((s-r)*io),to=n+Math.round((e-n)*io),zn.toRgba(Xn,Vn,to)},t.ensureContrastRatio=function(t,e,h){let r=Yn.relativeLuminance(t>>8),n=Yn.relativeLuminance(e>>8);if(ho(r,n)<h){if(n<r){let n=i(t,e,h),o=ho(r,Yn.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ho(r,Yn.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=ho(r,Yn.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>ho(r,Yn.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 lo,co=0,uo=0,Ao=!1,fo=!1,go=!1,wo=0,po=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,uo=0,co=0,fo=!1,Ao=!1,go=!1,lo=this._themeService.colors,wo=0,0!==t.getCode()&&4===t.extended.underlineStyle){let t=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));wo=i*e%(2*Math.round(t))}if(this._decorationService.forEachDecorationAtCell(i,s,"bottom",(t=>{t.backgroundColorRGB&&(uo=t.backgroundColorRGB.rgba>>8&16777215,fo=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,Ao=!0)})),go=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:uo=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:uo=(16777215&this.result.fg)<<8|255;break;default:uo=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:uo=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:uo=(16777215&this.result.bg)<<8|255}uo=Zn.blend(uo,4294967040&(this._coreBrowserService.isFocused?lo.selectionBackgroundOpaque:lo.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else uo=(this._coreBrowserService.isFocused?lo.selectionBackgroundOpaque:lo.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(fo=!0,lo.selectionForeground&&(co=lo.selectionForeground.rgba>>8&16777215,Ao=!0),oo(t.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))co=(this._coreBrowserService.isFocused?lo.selectionBackgroundOpaque:lo.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=Zn.blend(co,4294967040&(this._coreBrowserService.isFocused?lo.selectionBackgroundOpaque:lo.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Ao=!0}}this._decorationService.forEachDecorationAtCell(i,s,"top",(t=>{t.backgroundColorRGB&&(uo=t.backgroundColorRGB.rgba>>8&16777215,fo=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,Ao=!0)})),fo&&(uo=go?-16777216&t.bg&-134217729|uo|50331648:-16777216&t.bg|uo|50331648),Ao&&(co=-16777216&t.fg&-67108865|co|50331648),67108864&this.result.fg&&(fo&&!Ao&&(co=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&lo.background.rgba>>8|50331648,Ao=!0),!fo&&Ao&&(uo=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&lo.foreground.rgba>>8|50331648,fo=!0)),lo=void 0,this.result.bg=fo?uo:this.result.bg,this.result.fg=Ao?co:this.result.fg,this.result.ext&=536870911,this.result.ext|=wo<<29&3758096384}},Co=On||Wn?"bottom":"ideographic",mo={"▀":[{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}]},Io={"░":[[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]]},vo={"─":{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`}},Bo={"":{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}};Bo[""]=Bo[""],Bo[""]=Bo[""];var bo=new Map;function Mo(t,i,s=0){return Math.max(Math.min(t,i),s)}var yo={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 Eo(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 new 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 Qo,ko=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={}}},xo=class{constructor(){this._data=new ko}set(t,i,s,e,h){this._data.get(t,i)||this._data.set(t,i,new ko),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()}},Do=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()}},Lo=!Pn&&"requestIdleCallback"in window?class extends Do{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends Do{_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 So}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}},So=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}},$o=globalThis.performance&&"function"==typeof globalThis.performance.now,Ro=class t{static create(i){return new t(i)}constructor(t){this._now=$o&&!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 qo({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 qo(A);return n?.add(f),f.event}t.None=()=>Tn.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=Rn(...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 qo({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 qo({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 qo({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 qo;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 qo({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 Hn?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Qo||={});var No=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 Ro,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}}};No.all=new Set,No._idPool=0;var Fo=No,Ho=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 Go(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}};Ho._idPool=1;var To,Uo=Ho,Po=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Go=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Jo=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Oo=0,Wo=class{constructor(t){this.value=t,this.id=Oo++}},qo=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Uo(t?.onListenerError??En,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Fo(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 Jo(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||En)(s),Tn.None}if(this._disposed)return Tn.None;i&&(t=t.bind(i));let e,h=new Wo(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 Wo?(this._deliveryQueue??=new zo,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Nn((()=>{e?.(),this._removeListener(h)}));return s instanceof Hn?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)),new 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||En;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 Wo)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}},zo=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}},Ko={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}},jo=class t{constructor(t,i,s){this._document=t,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new xo,this._cacheMapCombined=new xo,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new _o,this._textureSize=512,this._onAddTextureAtlasCanvas=new qo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new qo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Xo(t,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=ro(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 Lo;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 Yo(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 Yo(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(To=t.get(i,s,e,h))||(To=this._drawToCache(i,s,e,h,r,n),t.set(i,s,e,h,To)),To}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,i,s,e){if(this._config.allowTransparency)return so;let h;switch(t){case 16777216:case 33554432:h=this._getColorFromAnsiIndex(i);break;case 50331648:let t=_o.toColorRGB(i);h=zn.toColor(t[0],t[1],t[2]);break;default:h=s?Kn.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(h=Kn.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=_o.toColorRGB(r);c=zn.toColor(t[0],t[1],t[2]);break;default:c=n?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(c=Kn.opaque(c)),o&&(c=Kn.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=zn.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 Ko;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=Co;let B=1===o.length&&no(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,oo(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=mo[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=Io[i];if(l)return function(t,i,s,e,h,r){let n=bo.get(i);n||(n=new Map,bo.set(i,n));let o=t.fillStyle;if("string"!=typeof o)throw new 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=ro(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 new 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=ro(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=vo[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=yo[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,Eo(l,h,r,s,e,!0,n))}t.stroke(),t.closePath()}}(t,c,s,e,h,r,o),!0;let u=Bo[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=yo[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,Eo(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(${_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=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=ao(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=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),i=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=t,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(y,y+Math.floor(this._config.deviceCharHeight/2)-i),this._tmpCtx.lineTo(y+this._config.deviceCharWidth*Q,y+Math.floor(this._config.deviceCharHeight/2)-i),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 Ko;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 Yo(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)}}}},Yo=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=Xo(t,i,i),this.ctx=ro(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 Xo(t,i,s){let e=t.createElement("canvas");return e.width=i,e.height=s,e}function Vo(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 ta=[];function ia(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:so,cursorAccent:so,selectionForeground:so,selectionBackgroundTransparent:so,selectionBackgroundOpaque:so,selectionInactiveBackgroundTransparent:so,selectionInactiveBackgroundOpaque:so,overviewRulerBorder:so,scrollbarSliderBackground:so,scrollbarSliderHoverBackground:so,scrollbarSliderActiveBackground:so,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<ta.length;i++){let s=ta[i],e=s.ownedBy.indexOf(t);if(e>=0){if(Vo(s.config,l))return s.atlas;1===s.ownedBy.length?(s.atlas.dispose(),ta.splice(i,1)):s.ownedBy.splice(e,1);break}}for(let i=0;i<ta.length;i++){let s=ta[i];if(Vo(s.config,l))return s.ownedBy.push(t),s.atlas}let c={atlas:new jo(document,l,t._core.unicodeService),config:l,ownedBy:[t]};return ta.push(c),c.atlas}function sa(t){for(let i=0;i<ta.length;i++){let s=ta[i].ownedBy.indexOf(t);if(-1!==s){1===ta[i].ownedBy.length?(ta[i].atlas.dispose(),ta.splice(i,1)):ta[i].ownedBy.splice(s,1);break}}}var ea=600,ha=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=ea){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout((()=>{if(this._animationTimeRestarted){let t=ea-(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=ea-(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}))}),ea)}),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 ra(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 Nn((()=>e?.disconnect()))}var na=class t extends _o{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new So,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?(t-=65536,String.fromCharCode(55296+(t>>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()]}},oa=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function aa(t,i,s){let e=ro(t.createProgram());if(t.attachShader(e,ro(la(t,t.VERTEX_SHADER,i))),t.attachShader(e,ro(la(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 la(t,i,s){let e=ro(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 ca,ua=class{constructor(t){this.texture=t,this.version=-1}},Aa=11,fa=Aa*Float32Array.BYTES_PER_ELEMENT,da=0,ga=0,wa=0,pa=class extends Tn{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===jo.maxAtlasPages&&(jo.maxAtlasPages=Math.min(32,ro(h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS))),jo.maxTextureSize=ro(h.getParameter(h.MAX_TEXTURE_SIZE))),this._program=ro(aa(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}`}(jo.maxAtlasPages))),this._register(Nn((()=>h.deleteProgram(this._program)))),this._projectionLocation=ro(h.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=ro(h.getUniformLocation(this._program,"u_resolution")),this._textureLocation=ro(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(Nn((()=>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(Nn((()=>h.deleteBuffer(a)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,a),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=ro(h.createBuffer()),this._register(Nn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,2,h.FLOAT,!1,fa,0),h.vertexAttribDivisor(2,1),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,h.FLOAT,!1,fa,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(3,1),h.enableVertexAttribArray(4),h.vertexAttribPointer(4,1,h.FLOAT,!1,fa,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(4,1),h.enableVertexAttribArray(5),h.vertexAttribPointer(5,2,h.FLOAT,!1,fa,5*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(5,1),h.enableVertexAttribArray(6),h.vertexAttribPointer(6,2,h.FLOAT,!1,fa,7*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(6,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,fa,9*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.useProgram(this._program);let l=new Int32Array(jo.maxAtlasPages);for(let t=0;t<jo.maxAtlasPages;t++)l[t]=t;h.uniform1iv(this._textureLocation,l),h.uniformMatrix4fv(this._projectionLocation,!1,oa),this._atlasTextures=[];for(let t=0;t<jo.maxAtlasPages;t++){let i=new ua(ro(h.createTexture()));this._register(Nn((()=>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){da=(s*this._terminal.cols+i)*Aa,0!==e&&void 0!==e?this._atlas&&(ca=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),ga=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),h!==l&&ca.offset.x>ga?(t[da]=-(ca.offset.x-(wa=ca.offset.x-ga))+this._dimensions.device.char.left,t[da+1]=-ca.offset.y+this._dimensions.device.char.top,t[da+2]=(ca.size.x-wa)/this._dimensions.device.canvas.width,t[da+3]=ca.size.y/this._dimensions.device.canvas.height,t[da+4]=ca.texturePage,t[da+5]=ca.texturePositionClipSpace.x+wa/this._atlas.pages[ca.texturePage].canvas.width,t[da+6]=ca.texturePositionClipSpace.y,t[da+7]=ca.sizeClipSpace.x-wa/this._atlas.pages[ca.texturePage].canvas.width,t[da+8]=ca.sizeClipSpace.y):(t[da]=-ca.offset.x+this._dimensions.device.char.left,t[da+1]=-ca.offset.y+this._dimensions.device.char.top,t[da+2]=ca.size.x/this._dimensions.device.canvas.width,t[da+3]=ca.size.y/this._dimensions.device.canvas.height,t[da+4]=ca.texturePage,t[da+5]=ca.texturePositionClipSpace.x,t[da+6]=ca.texturePositionClipSpace.y,t[da+7]=ca.sizeClipSpace.x,t[da+8]=ca.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(t,i,s,e){return 1===i&&ca.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)&&!no(t)&&!function(t){return 57344<=t&&t<=63743}(t)}(e,a,0,this._dimensions.device.cell.width)&&(t[da+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):t.fill(0,da,da+Aa-1-2)}clear(){let t=this._terminal,i=t.cols*t.rows*Aa;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+=Aa}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*Aa,r=this._vertices.attributes.subarray(h,h+t.lineLengths[i]*Aa);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/Aa)}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}},Ca=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)}},ma=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new Ca}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)}},Ia=8*Float32Array.BYTES_PER_ELEMENT,va=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},Ba=0,ba=class extends Tn{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._themeService=e,this._vertices=new va,this._verticesCursor=new va;let h=this._gl;this._program=ro(aa(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(Nn((()=>h.deleteProgram(this._program)))),this._projectionLocation=ro(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(Nn((()=>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(Nn((()=>h.deleteBuffer(a)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,a),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=ro(h.createBuffer()),this._register(Nn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,Ia,0),h.vertexAttribDivisor(0,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,Ia,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,4,h.FLOAT,!1,Ia,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,oa),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:Ba=this._themeService.colors.ansi[255&s].rgba;break;case 50331648:Ba=(16777215&s)<<8;break;default:Ba=this._themeService.colors.foreground.rgba}else switch(50331648&e){case 16777216:case 33554432:Ba=this._themeService.colors.ansi[255&e].rgba;break;case 50331648:Ba=(16777215&e)<<8;break;default:Ba=this._themeService.colors.background.rgba}t.attributes.length<i+4&&(t.attributes=function(t,i){let s=Math.min(2*t.length,i),e=new Float32Array(s);for(let i=0;i<t.length;i++)e[i]=t[i];return e}(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,(Ba>>24&255)/255,(Ba>>16&255)/255,(Ba>>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 Tn{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.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors((i=>{this._refreshCharAtlas(t,i),this.reset(t)}))),this._register(Nn((()=>{this._canvas.remove()})))}_initCanvas(){this._ctx=ro(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=ia(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=Co,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}`}},ya=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()}},Ea="object"==typeof window?window:globalThis,Qa=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new qo,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new qo,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}};Qa.INSTANCE=new Qa;var ka="object"==typeof navigator?navigator.userAgent:"";if(ka.indexOf("Firefox"),ka.indexOf("AppleWebKit"),!(ka.indexOf("Chrome")>=0)&&ka.indexOf("Safari"),ka.indexOf("Electron/"),ka.indexOf("Android"),"function"==typeof Ea.matchMedia){let t=Ea.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");Ea.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=Ea.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var xa,Da,La="en",_a=!1,Sa=La,$a=globalThis;typeof $a.vscode<"u"&&typeof $a.vscode.process<"u"?Da=$a.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Da=process);var Ra="string"==typeof Da?.versions?.electron&&"renderer"===Da?.type;if("object"==typeof Da){Sa=La;let t=Da.env.VSCODE_NLS_CONFIG;if(t)try{Sa=JSON.parse(t).resolvedLanguage||La}catch{}_a=!0}else"object"!=typeof navigator||Ra?console.error("Unable to resolve platform."):((xa=navigator.userAgent).indexOf("Windows"),xa.indexOf("Macintosh"),(xa.indexOf("Macintosh")>=0||xa.indexOf("iPad")>=0||xa.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,xa.indexOf("Linux"),xa?.indexOf("Mobi"),Sa=globalThis._VSCODE_NLS_LANGUAGE||La,navigator.language.toLowerCase());var Na,Fa=_a,Ha=xa,Ta=Sa;(t=>{t.value=function(){return Ta},t.isDefaultVariant=function(){return 2===Ta.length?"en"===Ta:Ta.length>=3&&"e"===Ta[0]&&"n"===Ta[1]&&"-"===Ta[2]},t.isDefault=function(){return"en"===Ta}})(Na||={});var Ua="function"==typeof $a.postMessage&&!$a.importScripts;(()=>{if(Ua){let t=[];$a.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 Pa=!!(Ha&&Ha.indexOf("Chrome")>=0);Ha&&Ha.indexOf("Firefox"),!Pa&&Ha&&Ha.indexOf("Safari"),Ha&&Ha.indexOf("Edg/"),Ha&&Ha.indexOf("Android"),"object"==typeof navigator&&navigator,Fa||document.queryCommandSupported&&document.queryCommandSupported("copy");var Ga,Ja,Oa=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}},Wa=new Oa,qa=new Oa,za=new Oa;new Array(230),(Ja=Ga||={}).toString=function(t){return Wa.keyCodeToStr(t)},Ja.fromString=function(t){return Wa.strToKeyCode(t)},Ja.toUserSettingsUS=function(t){return qa.keyCodeToStr(t)},Ja.toUserSettingsGeneral=function(t){return za.keyCodeToStr(t)},Ja.fromUserSettings=function(t){return qa.strToKeyCode(t)||za.strToKeyCode(t)},Ja.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 Wa.keyCodeToStr(t)};var Ka,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 Za||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Qo.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ja})})(Ka||={});var Ya,Za=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 qo),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)}}))}})(Ya||={});var Xa=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 qo,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 Qo.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())}};Xa.EMPTY=Xa.fromArray([]);var{getWindow:Va}=function(){let t=new Map,i={window:Ea,disposables:new Hn};t.set(Ea.vscodeWindowId,i);let s=new qo,e=new qo,h=new qo;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return Tn.None;let r=new Hn,n={window:i,disposables:r.add(new Hn)};return t.set(i.vscodeWindowId,n),r.add(Nn((()=>{t.delete(i.vscodeWindowId),e.fire(i)}))),r.add(il(i,sl.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:Ea},getDocument:t=>Va(t).document}}(),tl=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 il(t,i,s,e){return new tl(t,i,s,e)}var sl={BEFORE_UNLOAD:"beforeunload"},el=class extends Tn{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 Un,this._charAtlasDisposable=this._register(new Un),this._observerDisposable=this._register(new Un),this._model=new ma,this._workCell=new na,this._workCell2=new na,this._rectangleRenderer=this._register(new Un),this._glyphRenderer=this._register(new Un),this._onChangeTextureAtlas=this._register(new qo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new qo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new qo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new qo),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new qo),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 new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors((()=>this._handleColorChange()))),this._cellColorResolver=new po(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new ya(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(il(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(il(this._canvas,"webglcontextrestored",(()=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,sa(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()}))),this._observerDisposable.value=ra(this._canvas,this._coreBrowserService.window,((t,i)=>this._setCanvasDevicePixelDimensions(t,i))),this._register(this._coreBrowserService.onWindowChange((t=>{this._observerDisposable.value=ra(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(Nn((()=>{for(let t of this._renderLayers)t.dispose();this._canvas.parentElement?.removeChild(this._canvas),sa(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 ba(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new pa(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=ia(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=Rn(Qo.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Qo.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 ha((()=>{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=rl(t,p.rows-1,0),i=rl(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 hl(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})}},hl=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 new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function rl(t,i,s=0){return Math.max(Math.min(t,i),s)}var nl="di$target",ol="di$dependencies",al=new Map;function ll(t){if(al.has(t))return al.get(t);let i=function(t,s,e){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(t,i,s){i[nl]===i?i[ol].push({id:t,index:s}):(i[ol]=[{id:t,index:s}],i[nl]=i)}(i,t,e)};return i._id=t,al.set(t,i),i}ll("BufferService"),ll("CoreMouseService"),ll("CoreService"),ll("CharsetService"),ll("InstantiationService"),ll("LogService");var cl=ll("OptionsService");ll("OscLinkService"),ll("UnicodeService"),ll("DecorationService");var ul={trace:0,debug:1,info:2,warn:3,error:4,off:5},Al=class extends Tn{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=ul[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)}};Al=(t=>{for(var i,s=Al,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,cl)]);var fl,dl,gl,wl,pl,Cl=class extends Tn{constructor(t){if(qn&&function(){if(!qn)return 0;let t=Gn.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 new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new qo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new qo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new qo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new qo),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 el(t,i._characterJoinerService,i._charSizeService,i._coreBrowserService,i.coreService,i._decorationService,i.optionsService,i._themeService,this._preserveDrawingBuffer)),this._register(Qo.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Qo.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Qo.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Qo.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),s.setRenderer(this._renderer),this._register(Nn((()=>{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()}},ml=0,Il=0,vl=0,Bl=0;
|
|
25
|
+
*/function yr(t){(function(t){return t instanceof Dr||t instanceof Error&&t.name===xr&&t.message===xr})(t)||Mr.onUnexpectedError(t)}var Er,Qr,kr,xr="Canceled",Dr=class extends Error{constructor(){super(xr),this.name=this.message}},Lr=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 _r(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function Sr(t){if(Qr.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 $r(...t){return Rr((()=>Sr(t)))}function Rr(t){return{dispose:_r((()=>{t()}))}}(kr=Er||={}).isLessThan=function(t){return t<0},kr.isLessThanOrEqual=function(t){return t<=0},kr.isGreaterThan=function(t){return t>0},kr.isNeitherLessOrGreaterThan=function(t){return 0===t},kr.greaterThan=1,kr.lessThan=-1,kr.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(Qr||={});var Nr=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{Sr(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Nr.DISABLE_DISPOSED_WARNING=!1;var Fr=Nr,Hr=class{constructor(){this._store=new Fr}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Hr.None=Object.freeze({dispose(){}});var Tr,Ur=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}},Pr=globalThis.performance&&"function"==typeof globalThis.performance.now,Gr=class t{static create(i){return new t(i)}constructor(t){this._now=Pr&&!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 Vr({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,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),c=()=>{let t=l;l=void 0,a=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(c,s)):void 0===a&&(a=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new Vr(A);return n?.add(f),f.event}t.None=()=>Hr.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=$r(...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 Vr({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 Vr({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 Vr({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 Vr;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 Vr({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 Fr?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Tr||={});var Jr=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 Gr,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}}};Jr.all=new Set,Jr._idPool=0;var Or=Jr,Wr=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 jr(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}};Wr._idPool=1;var zr,qr=Wr,Kr=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},jr=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Yr=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Zr=0,Xr=class{constructor(t){this.value=t,this.id=Zr++}},Vr=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new qr(t?.onListenerError??yr,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Or(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 Yr(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||yr)(s),Hr.None}if(this._disposed)return Hr.None;i&&(t=t.bind(i));let e,h=new Xr(t);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=Kr.create(),e=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof Xr?(this._deliveryQueue??=new tn,this._listeners=[this._listeners,h]):this._listeners.push(h):(this._options?.onWillAddFirstListener?.(this),this._listeners=h,this._options?.onDidAddFirstListener?.(this)),this._size++;let r=Rr((()=>{e?.(),this._removeListener(h)}));return s instanceof Fr?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)),new 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||yr;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 Xr)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}},tn=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}},sn=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 rn||!(!i||"object"!=typeof i)&&"boolean"==typeof i.isCancellationRequested&&"function"==typeof i.onCancellationRequested},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Tr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sn})})(zr||={});var en,hn,rn=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?sn:(this._emitter||(this._emitter=new Vr),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},nn="en",on=nn,ln=globalThis;typeof ln.vscode<"u"&&typeof ln.vscode.process<"u"?hn=ln.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(hn=process);var an="string"==typeof hn?.versions?.electron&&"renderer"===hn?.type;if("object"==typeof hn){on=nn;let t=hn.env.VSCODE_NLS_CONFIG;if(t)try{on=JSON.parse(t).resolvedLanguage||nn}catch{}}else"object"!=typeof navigator||an?console.error("Unable to resolve platform."):((en=navigator.userAgent).indexOf("Windows"),en.indexOf("Macintosh"),(en.indexOf("Macintosh")>=0||en.indexOf("iPad")>=0||en.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,en.indexOf("Linux"),en?.indexOf("Mobi"),on=globalThis._VSCODE_NLS_LANGUAGE||nn,navigator.language.toLowerCase());var cn,un=en,An=on;(t=>{t.value=function(){return An},t.isDefaultVariant=function(){return 2===An.length?"en"===An:An.length>=3&&"e"===An[0]&&"n"===An[1]&&"-"===An[2]},t.isDefault=function(){return"en"===An}})(cn||={});var fn="function"==typeof ln.postMessage&&!ln.importScripts;(()=>{if(fn){let t=[];ln.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 dn,gn,wn=!!(un&&un.indexOf("Chrome")>=0);function pn(t,i=0){let s=setTimeout((()=>{t()}),i);return Rr((()=>{clearTimeout(s)}))}un&&un.indexOf("Firefox"),!wn&&un&&un.indexOf("Safari"),un&&un.indexOf("Edg/"),un&&un.indexOf("Android"),(gn=dn||={}).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},gn.withAsyncBody=function(t){return new Promise((async(i,s)=>{try{await t(i,s)}catch(t){s(t)}}))};var Cn=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 Vr,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 Tr.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())}};Cn.EMPTY=Cn.fromArray([]);var mn=class extends Hr{constructor(t){super(),this._terminal=t,this._linesCacheTimeout=this._register(new Ur),this._linesCacheDisposables=this._register(new Ur),this._register(Rr((()=>this._destroyLinesCache())))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=$r(this._terminal.onLineFeed((()=>this._destroyLinesCache())),this._terminal.onCursorMove((()=>this._destroyLinesCache())),this._terminal.onResize((()=>this._destroyLinesCache())))),this._linesCacheTimeout.value=pn((()=>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]}},In=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}},vn=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 new 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),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,a));)A=h.lastIndex-i[0].length,h.lastIndex-=(t=i[0]).length-1;else i=h.exec(u.slice(a)),i&&i[0].length>0&&(A=a+(h.lastIndex-i[0].length),t=i[0])}else e?a-c.length>=0&&(A=u.lastIndexOf(c,a-c.length)):A=u.indexOf(c,a);if(A>=0){if(s.wholeWord&&!this._isWholeWord(A,u,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}},Bn=class extends Hr{constructor(t){super(),this._terminal=t,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Rr((()=>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(){Sr(s)}}}clearHighlightDecorations(){Sr(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((()=>Sr(t)))),o.push(h)}}return 0===o.length?void 0:o}},bn=class extends Hr{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Vr)}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()}},Mn=class extends Hr{constructor(t){super(),this._highlightTimeout=this._register(new Ur),this._lineCache=this._register(new Ur),this._state=new In,this._resultTracker=this._register(new bn),this._highlightLimit=t?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(t){this._terminal=t,this._lineCache.value=new mn(t),this._engine=new vn(t,this._lineCache.value),this._decorationManager=new Bn(t),this._register(this._terminal.onWriteParsed((()=>this._updateMatches()))),this._register(this._terminal.onResize((()=>this._updateMatches()))),this._register(Rr((()=>this.clearDecorations())))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=pn((()=>{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 new 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 new 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 new 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}},yn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout((()=>{throw t.stack?_n.isErrorNoTelemetry(t)?new _n(t.message+"\n\n"+t.stack):new 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 En(t){(function(t){return t instanceof Ln||t instanceof Error&&t.name===Dn&&t.message===Dn})(t)||yn.onUnexpectedError(t)}var Qn,kn,xn,Dn="Canceled",Ln=class extends Error{constructor(){super(Dn),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 Sn(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}function $n(t){if(xn.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 Rn(...t){return Nn((()=>$n(t)))}function Nn(t){return{dispose:Sn((()=>{t()}))}}(kn=Qn||={}).isLessThan=function(t){return t<0},kn.isLessThanOrEqual=function(t){return t<=0},kn.isGreaterThan=function(t){return t>0},kn.isNeitherLessOrGreaterThan=function(t){return 0===t},kn.greaterThan=1,kn.lessThan=-1,kn.neitherLessOrGreaterThan=0,(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=Number.POSITIVE_INFINITY){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)}})(xn||={});var Fn=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{$n(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Fn.DISABLE_DISPOSED_WARNING=!1;var Hn=Fn,Tn=class{constructor(){this._store=new Hn}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Tn.None=Object.freeze({dispose(){}});var Un=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,Gn=Pn?"node":navigator.userAgent,Jn=Pn?"node":navigator.platform,On=Gn.includes("Firefox"),Wn=Gn.includes("Edge"),zn=/^((?!chrome|android).)*safari/i.test(Gn);Jn.indexOf("Linux");var qn,Kn,jn,Yn,Zn,Xn=0,Vn=0,to=0,io=0,so={css:"#00000000",rgba:0};function eo(t){let i=t.toString(16);return i.length<2?"0"+i:i}function ho(t,i){return t<i?(i+.05)/(t+.05):(t+.05)/(i+.05)}function ro(t){if(!t)throw new Error("value must not be falsy");return t}function no(t){return 57508<=t&&t<=57558}function oo(t){return no(t)||function(t){return 9472<=t&&t<=9631}(t)}function lo(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?`#${eo(t)}${eo(i)}${eo(s)}${eo(e)}`:`#${eo(t)}${eo(i)}${eo(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 io=Math.round(255*i),[Xn,Vn,to]=Zn.toChannels(t.rgba),{css:qn.toCss(Xn,Vn,to,io),rgba:qn.toRgba(Xn,Vn,to,io)}}t.blend=function(t,i){if(1==(io=(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 Xn=h+Math.round(((i.rgba>>24&255)-h)*io),Vn=r+Math.round((s-r)*io),to=n+Math.round((e-n)*io),{css:qn.toCss(Xn,Vn,to),rgba:qn.toRgba(Xn,Vn,to)}},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 qn.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[Xn,Vn,to]=Zn.toChannels(i),{css:qn.toCss(Xn,Vn,to),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(io=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(Kn||={}),(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 Xn=parseInt(t.slice(1,2).repeat(2),16),Vn=parseInt(t.slice(2,3).repeat(2),16),to=parseInt(t.slice(3,4).repeat(2),16),qn.toColor(Xn,Vn,to);case 5:return Xn=parseInt(t.slice(1,2).repeat(2),16),Vn=parseInt(t.slice(2,3).repeat(2),16),to=parseInt(t.slice(3,4).repeat(2),16),io=parseInt(t.slice(4,5).repeat(2),16),qn.toColor(Xn,Vn,to,io);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 Xn=parseInt(e[1]),Vn=parseInt(e[2]),to=parseInt(e[3]),io=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),qn.toColor(Xn,Vn,to,io);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[Xn,Vn,to,io]=i.getImageData(0,0,1,1).data,255!==io)throw new Error("css.toColor: Unsupported css format");return{rgba:qn.toRgba(Xn,Vn,to,io),css:t}}})(jn||={}),(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})(Yn||={}),(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=ho(Yn.relativeLuminance2(n,o,l),Yn.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=ho(Yn.relativeLuminance2(n,o,l),Yn.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=ho(Yn.relativeLuminance2(n,o,l),Yn.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=ho(Yn.relativeLuminance2(n,o,l),Yn.relativeLuminance2(e,h,r));return(n<<24|o<<16|l<<8|255)>>>0}t.blend=function(t,i){if(1==(io=(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 Xn=h+Math.round(((i>>24&255)-h)*io),Vn=r+Math.round((s-r)*io),to=n+Math.round((e-n)*io),qn.toRgba(Xn,Vn,to)},t.ensureContrastRatio=function(t,e,h){let r=Yn.relativeLuminance(t>>8),n=Yn.relativeLuminance(e>>8);if(ho(r,n)<h){if(n<r){let n=i(t,e,h),o=ho(r,Yn.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>ho(r,Yn.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=ho(r,Yn.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>ho(r,Yn.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 ao,co=0,uo=0,Ao=!1,fo=!1,go=!1,wo=0,po=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,uo=0,co=0,fo=!1,Ao=!1,go=!1,ao=this._themeService.colors,wo=0,0!==t.getCode()&&4===t.extended.underlineStyle){let t=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));wo=i*e%(2*Math.round(t))}if(this._decorationService.forEachDecorationAtCell(i,s,"bottom",(t=>{t.backgroundColorRGB&&(uo=t.backgroundColorRGB.rgba>>8&16777215,fo=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,Ao=!0)})),go=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:uo=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:uo=(16777215&this.result.fg)<<8|255;break;default:uo=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:uo=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:uo=(16777215&this.result.bg)<<8|255}uo=Zn.blend(uo,4294967040&(this._coreBrowserService.isFocused?ao.selectionBackgroundOpaque:ao.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else uo=(this._coreBrowserService.isFocused?ao.selectionBackgroundOpaque:ao.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(fo=!0,ao.selectionForeground&&(co=ao.selectionForeground.rgba>>8&16777215,Ao=!0),oo(t.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))co=(this._coreBrowserService.isFocused?ao.selectionBackgroundOpaque:ao.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=Zn.blend(co,4294967040&(this._coreBrowserService.isFocused?ao.selectionBackgroundOpaque:ao.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Ao=!0}}this._decorationService.forEachDecorationAtCell(i,s,"top",(t=>{t.backgroundColorRGB&&(uo=t.backgroundColorRGB.rgba>>8&16777215,fo=!0),t.foregroundColorRGB&&(co=t.foregroundColorRGB.rgba>>8&16777215,Ao=!0)})),fo&&(uo=go?-16777216&t.bg&-134217729|uo|50331648:-16777216&t.bg|uo|50331648),Ao&&(co=-16777216&t.fg&-67108865|co|50331648),67108864&this.result.fg&&(fo&&!Ao&&(co=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&ao.background.rgba>>8|50331648,Ao=!0),!fo&&Ao&&(uo=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&ao.foreground.rgba>>8|50331648,fo=!0)),ao=void 0,this.result.bg=fo?uo:this.result.bg,this.result.fg=Ao?co:this.result.fg,this.result.ext&=536870911,this.result.ext|=wo<<29&3758096384}},Co=On||Wn?"bottom":"ideographic",mo={"▀":[{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}]},Io={"░":[[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]]},vo={"─":{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`}},Bo={"":{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}};Bo[""]=Bo[""],Bo[""]=Bo[""];var bo=new Map;function Mo(t,i,s=0){return Math.max(Math.min(t,i),s)}var yo={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 Eo(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 new 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]=Mo(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]=Mo(Math.round(a[t]+.5)-.5,s,0)),a[t]+=h;return a}var Qo,ko=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={}}},xo=class{constructor(){this._data=new ko}set(t,i,s,e,h){this._data.get(t,i)||this._data.set(t,i,new ko),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()}},Do=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()}},Lo=!Pn&&"requestIdleCallback"in window?class extends Do{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}}:class extends Do{_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 So}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}},So=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}},$o=globalThis.performance&&"function"==typeof globalThis.performance.now,Ro=class t{static create(i){return new t(i)}constructor(t){this._now=$o&&!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 zo({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,c,u=0,A={leakWarningThreshold:r,onWillAddFirstListener(){o=t((t=>{u++,l=i(l,t),e&&!a&&(f.fire(l),l=void 0),c=()=>{let t=l;l=void 0,a=void 0,(!e||u>1)&&f.fire(t),u=0},"number"==typeof s?(clearTimeout(a),a=setTimeout(c,s)):void 0===a&&(a=0,queueMicrotask(c))}))},onWillRemoveListener(){h&&u>0&&c?.()},onDidRemoveLastListener(){c=void 0,o.dispose()}},f=new zo(A);return n?.add(f),f.event}t.None=()=>Tn.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=Rn(...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 zo({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 zo({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 zo({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 zo;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 zo({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 Hn?e.add(o):Array.isArray(e)&&e.push(o),o}}})(Qo||={});var No=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 Ro,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}}};No.all=new Set,No._idPool=0;var Fo=No,Ho=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 Go(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}};Ho._idPool=1;var To,Uo=Ho,Po=class t{constructor(t){this.value=t}static create(){let i=new Error;return new t(i.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},Go=class extends Error{constructor(t,i){super(t),this.name="ListenerLeakError",this.stack=i}},Jo=class extends Error{constructor(t,i){super(t),this.name="ListenerRefusalError",this.stack=i}},Oo=0,Wo=class{constructor(t){this.value=t,this.id=Oo++}},zo=class{constructor(t){this._size=0,this._options=t,this._leakageMon=this._options?.leakWarningThreshold?new Uo(t?.onListenerError??En,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new Fo(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 Jo(`${t}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||En)(s),Tn.None}if(this._disposed)return Tn.None;i&&(t=t.bind(i));let e,h=new Wo(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 Wo?(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=Nn((()=>{e?.(),this._removeListener(h)}));return s instanceof Hn?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)),new 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||En;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 Wo)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}},Ko={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}},jo=class t{constructor(t,i,s){this._document=t,this._config=i,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new xo,this._cacheMapCombined=new xo,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new _o,this._textureSize=512,this._onAddTextureAtlasCanvas=new zo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new zo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Xo(t,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=ro(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 Lo;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 Yo(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 Yo(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(To=t.get(i,s,e,h))||(To=this._drawToCache(i,s,e,h,r,n),t.set(i,s,e,h,To)),To}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,i,s,e){if(this._config.allowTransparency)return so;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?Kn.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(h=Kn.opaque(h)),h}_getForegroundColor(t,i,s,e,h,r,n,o,l,a){let c,u=this._getMinimumContrastColor(t,i,s,e,h,r,n,l,o,a);if(u)return u;switch(h){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&r<8&&(r+=8),c=this._getColorFromAnsiIndex(r);break;case 50331648:let t=_o.toColorRGB(r);c=qn.toColor(t[0],t[1],t[2]);break;default:c=n?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(c=Kn.opaque(c)),o&&(c=Kn.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,l,a){if(1===this._config.minimumContrastRatio||a)return;let c=this._getContrastCache(l),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/(l?2:1));if(!d)return void c.setColor(t,e,null);let g=qn.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 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 Ko;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=Co;let B=1===o.length&&no(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,oo(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 l=mo[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=Io[i];if(a)return function(t,i,s,e,h,r){let n=bo.get(i);n||(n=new Map,bo.set(i,n));let o=t.fillStyle;if("string"!=typeof o)throw new 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,c,u,A=ro(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),c=parseInt(o.slice(5,7),16),u=o.length>7&&parseInt(o.slice(7,9),16)||1;else{if(!o.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${o}" when drawing pattern glyph`);[r,a,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]=a,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),l=ro(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 c=vo[i];if(c)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=yo[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,Eo(a,h,r,s,e,!0,n))}t.stroke(),t.closePath()}}(t,c,s,e,h,r,o),!0;let u=Bo[i];return!!u&&(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],c=yo[l];if(!c){console.error(`Could not find drawing instructions for "${l}"`);continue}let u=n.substring(1).split(",");!u[0]||!u[1]||c(t,Eo(u,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,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(${_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=y,e=Math.ceil(y+this._config.deviceCharHeight)-i-(r?2*t:0),h=e+t,n=e+2*t,l=this._workAttributeData.getUnderlineVariantOffset();for(let r=0;r<Q;r++){this._tmpCtx.save();let o=s+r*this._config.deviceCellWidth,a=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(a,e),this._tmpCtx.moveTo(o,n),this._tmpCtx.lineTo(a,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,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=lo(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*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=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),i=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=t,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(y,y+Math.floor(this._config.deviceCharHeight/2)-i),this._tmpCtx.lineTo(y+this._config.deviceCharWidth*Q,y+Math.floor(this._config.deviceCharHeight/2)-i),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 Ko;let L,_,S=this._findGlyphBoundingBox(D,this._workBoundingBox,l,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 Yo(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,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)}}}},Yo=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=Xo(t,i,i),this.ctx=ro(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,l=s.rgba>>>8&255,a=Math.floor((Math.abs(h-(s.rgba>>>24))+Math.abs(r-o)+Math.abs(n-l))/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)<a?t.data[i+3]=0:c=!1;return c}function Xo(t,i,s){let e=t.createElement("canvas");return e.width=i,e.height=s,e}function Vo(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 tl=[];function il(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:so,cursorAccent:so,selectionForeground:so,selectionBackgroundTransparent:so,selectionBackgroundOpaque:so,selectionInactiveBackgroundTransparent:so,selectionInactiveBackgroundOpaque:so,overviewRulerBorder:so,scrollbarSliderBackground:so,scrollbarSliderHoverBackground:so,scrollbarSliderActiveBackground:so,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<tl.length;i++){let s=tl[i],e=s.ownedBy.indexOf(t);if(e>=0){if(Vo(s.config,a))return s.atlas;1===s.ownedBy.length?(s.atlas.dispose(),tl.splice(i,1)):s.ownedBy.splice(e,1);break}}for(let i=0;i<tl.length;i++){let s=tl[i];if(Vo(s.config,a))return s.ownedBy.push(t),s.atlas}let c={atlas:new jo(document,a,t._core.unicodeService),config:a,ownedBy:[t]};return tl.push(c),c.atlas}function sl(t){for(let i=0;i<tl.length;i++){let s=tl[i].ownedBy.indexOf(t);if(-1!==s){1===tl[i].ownedBy.length?(tl[i].atlas.dispose(),tl.splice(i,1)):tl[i].ownedBy.splice(s,1);break}}}var el=600,hl=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=el){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout((()=>{if(this._animationTimeRestarted){let t=el-(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=el-(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}))}),el)}),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 rl(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 Nn((()=>e?.disconnect()))}var nl=class t extends _o{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new So,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?(t-=65536,String.fromCharCode(55296+(t>>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()]}},ol=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function ll(t,i,s){let e=ro(t.createProgram());if(t.attachShader(e,ro(al(t,t.VERTEX_SHADER,i))),t.attachShader(e,ro(al(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 al(t,i,s){let e=ro(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,ul=class{constructor(t){this.texture=t,this.version=-1}},Al=11,fl=Al*Float32Array.BYTES_PER_ELEMENT,dl=0,gl=0,wl=0,pl=class extends Tn{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===jo.maxAtlasPages&&(jo.maxAtlasPages=Math.min(32,ro(h.getParameter(h.MAX_TEXTURE_IMAGE_UNITS))),jo.maxTextureSize=ro(h.getParameter(h.MAX_TEXTURE_SIZE))),this._program=ro(ll(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}`}(jo.maxAtlasPages))),this._register(Nn((()=>h.deleteProgram(this._program)))),this._projectionLocation=ro(h.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=ro(h.getUniformLocation(this._program,"u_resolution")),this._textureLocation=ro(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(Nn((()=>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(Nn((()=>h.deleteBuffer(l)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,l),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=ro(h.createBuffer()),this._register(Nn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,2,h.FLOAT,!1,fl,0),h.vertexAttribDivisor(2,1),h.enableVertexAttribArray(3),h.vertexAttribPointer(3,2,h.FLOAT,!1,fl,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(3,1),h.enableVertexAttribArray(4),h.vertexAttribPointer(4,1,h.FLOAT,!1,fl,4*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(4,1),h.enableVertexAttribArray(5),h.vertexAttribPointer(5,2,h.FLOAT,!1,fl,5*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(5,1),h.enableVertexAttribArray(6),h.vertexAttribPointer(6,2,h.FLOAT,!1,fl,7*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(6,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,fl,9*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.useProgram(this._program);let a=new Int32Array(jo.maxAtlasPages);for(let t=0;t<jo.maxAtlasPages;t++)a[t]=t;h.uniform1iv(this._textureLocation,a),h.uniformMatrix4fv(this._projectionLocation,!1,ol),this._atlasTextures=[];for(let t=0;t<jo.maxAtlasPages;t++){let i=new ul(ro(h.createTexture()));this._register(Nn((()=>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){dl=(s*this._terminal.cols+i)*Al,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),gl=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),h!==a&&cl.offset.x>gl?(t[dl]=-(cl.offset.x-(wl=cl.offset.x-gl))+this._dimensions.device.char.left,t[dl+1]=-cl.offset.y+this._dimensions.device.char.top,t[dl+2]=(cl.size.x-wl)/this._dimensions.device.canvas.width,t[dl+3]=cl.size.y/this._dimensions.device.canvas.height,t[dl+4]=cl.texturePage,t[dl+5]=cl.texturePositionClipSpace.x+wl/this._atlas.pages[cl.texturePage].canvas.width,t[dl+6]=cl.texturePositionClipSpace.y,t[dl+7]=cl.sizeClipSpace.x-wl/this._atlas.pages[cl.texturePage].canvas.width,t[dl+8]=cl.sizeClipSpace.y):(t[dl]=-cl.offset.x+this._dimensions.device.char.left,t[dl+1]=-cl.offset.y+this._dimensions.device.char.top,t[dl+2]=cl.size.x/this._dimensions.device.canvas.width,t[dl+3]=cl.size.y/this._dimensions.device.canvas.height,t[dl+4]=cl.texturePage,t[dl+5]=cl.texturePositionClipSpace.x,t[dl+6]=cl.texturePositionClipSpace.y,t[dl+7]=cl.sizeClipSpace.x,t[dl+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)&&!no(t)&&!function(t){return 57344<=t&&t<=63743}(t)}(e,l,0,this._dimensions.device.cell.width)&&(t[dl+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):t.fill(0,dl,dl+Al-1-2)}clear(){let t=this._terminal,i=t.cols*t.rows*Al;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+=Al}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*Al,r=this._vertices.attributes.subarray(h,h+t.lineLengths[i]*Al);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/Al)}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}},Cl=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)}},ml=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new Cl}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)}},Il=8*Float32Array.BYTES_PER_ELEMENT,vl=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},Bl=0,bl=class extends Tn{constructor(t,i,s,e){super(),this._terminal=t,this._gl=i,this._dimensions=s,this._themeService=e,this._vertices=new vl,this._verticesCursor=new vl;let h=this._gl;this._program=ro(ll(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(Nn((()=>h.deleteProgram(this._program)))),this._projectionLocation=ro(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(Nn((()=>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(Nn((()=>h.deleteBuffer(l)))),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,l),h.bufferData(h.ELEMENT_ARRAY_BUFFER,o,h.STATIC_DRAW),this._attributesBuffer=ro(h.createBuffer()),this._register(Nn((()=>h.deleteBuffer(this._attributesBuffer)))),h.bindBuffer(h.ARRAY_BUFFER,this._attributesBuffer),h.enableVertexAttribArray(0),h.vertexAttribPointer(0,2,h.FLOAT,!1,Il,0),h.vertexAttribDivisor(0,1),h.enableVertexAttribArray(1),h.vertexAttribPointer(1,2,h.FLOAT,!1,Il,2*Float32Array.BYTES_PER_ELEMENT),h.vertexAttribDivisor(1,1),h.enableVertexAttribArray(2),h.vertexAttribPointer(2,4,h.FLOAT,!1,Il,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,ol),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,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),l=t.cells[o+1],a=t.cells[o+2],c=!!(67108864&a),(l!==h||a!==r&&(n||c))&&((0!==h||n&&0!==r)&&(u=8*d++,this._updateRectangle(f,u,r,h,e,s,i)),e=s,h=l,r=a,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:Bl=this._themeService.colors.ansi[255&s].rgba;break;case 50331648:Bl=(16777215&s)<<8;break;default:Bl=this._themeService.colors.foreground.rgba}else switch(50331648&e){case 16777216:case 33554432:Bl=this._themeService.colors.ansi[255&e].rgba;break;case 50331648:Bl=(16777215&e)<<8;break;default:Bl=this._themeService.colors.background.rgba}t.attributes.length<i+4&&(t.attributes=function(t,i){let s=Math.min(2*t.length,i),e=new Float32Array(s);for(let i=0;i<t.length;i++)e[i]=t[i];return e}(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,(Bl>>24&255)/255,(Bl>>16&255)/255,(Bl>>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])}},Ml=class extends Tn{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.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors((i=>{this._refreshCharAtlas(t,i),this.reset(t)}))),this._register(Nn((()=>{this._canvas.remove()})))}_initCanvas(){this._ctx=ro(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=il(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=Co,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}`}},yl=class extends Ml{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()}},El="object"==typeof window?window:globalThis,Ql=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new zo,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new zo,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}};Ql.INSTANCE=new Ql;var kl="object"==typeof navigator?navigator.userAgent:"";if(kl.indexOf("Firefox"),kl.indexOf("AppleWebKit"),!(kl.indexOf("Chrome")>=0)&&kl.indexOf("Safari"),kl.indexOf("Electron/"),kl.indexOf("Android"),"function"==typeof El.matchMedia){let t=El.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)");El.matchMedia("(display-mode: fullscreen)"),function(t,i){"string"==typeof i&&(i=El.matchMedia(i)),i.addEventListener("change",(({})=>{}))}(0,t)}var xl,Dl,Ll="en",_l=!1,Sl=Ll,$l=globalThis;typeof $l.vscode<"u"&&typeof $l.vscode.process<"u"?Dl=$l.vscode.process:typeof process<"u"&&"string"==typeof process?.versions?.node&&(Dl=process);var Rl="string"==typeof Dl?.versions?.electron&&"renderer"===Dl?.type;if("object"==typeof Dl){Sl=Ll;let t=Dl.env.VSCODE_NLS_CONFIG;if(t)try{Sl=JSON.parse(t).resolvedLanguage||Ll}catch{}_l=!0}else"object"!=typeof navigator||Rl?console.error("Unable to resolve platform."):((xl=navigator.userAgent).indexOf("Windows"),xl.indexOf("Macintosh"),(xl.indexOf("Macintosh")>=0||xl.indexOf("iPad")>=0||xl.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator,xl.indexOf("Linux"),xl?.indexOf("Mobi"),Sl=globalThis._VSCODE_NLS_LANGUAGE||Ll,navigator.language.toLowerCase());var Nl,Fl=_l,Hl=xl,Tl=Sl;(t=>{t.value=function(){return Tl},t.isDefaultVariant=function(){return 2===Tl.length?"en"===Tl:Tl.length>=3&&"e"===Tl[0]&&"n"===Tl[1]&&"-"===Tl[2]},t.isDefault=function(){return"en"===Tl}})(Nl||={});var Ul="function"==typeof $l.postMessage&&!$l.importScripts;(()=>{if(Ul){let t=[];$l.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=!!(Hl&&Hl.indexOf("Chrome")>=0);Hl&&Hl.indexOf("Firefox"),!Pl&&Hl&&Hl.indexOf("Safari"),Hl&&Hl.indexOf("Edg/"),Hl&&Hl.indexOf("Android"),"object"==typeof navigator&&navigator,Fl||document.queryCommandSupported&&document.queryCommandSupported("copy");var Gl,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,ql=new Ol;new Array(230),(Jl=Gl||={}).toString=function(t){return Wl.keyCodeToStr(t)},Jl.fromString=function(t){return Wl.strToKeyCode(t)},Jl.toUserSettingsUS=function(t){return zl.keyCodeToStr(t)},Jl.toUserSettingsGeneral=function(t){return ql.keyCodeToStr(t)},Jl.fromUserSettings=function(t){return zl.strToKeyCode(t)||ql.strToKeyCode(t)},Jl.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)};var Kl,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:Qo.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:jl})})(Kl||={});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 zo),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 zo,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 Qo.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:El,disposables:new Hn};t.set(El.vscodeWindowId,i);let s=new zo,e=new zo,h=new zo;return{onDidRegisterWindow:s.event,onWillUnregisterWindow:h.event,onDidUnregisterWindow:e.event,registerWindow(i){if(t.has(i.vscodeWindowId))return Tn.None;let r=new Hn,n={window:i,disposables:r.add(new Hn)};return t.set(i.vscodeWindowId,n),r.add(Nn((()=>{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:El},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 Tn{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 Un,this._charAtlasDisposable=this._register(new Un),this._observerDisposable=this._register(new Un),this._model=new ml,this._workCell=new nl,this._workCell2=new nl,this._rectangleRenderer=this._register(new Un),this._glyphRenderer=this._register(new Un),this._onChangeTextureAtlas=this._register(new zo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new zo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new zo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new zo),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new zo),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 new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors((()=>this._handleColorChange()))),this._cellColorResolver=new po(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new yl(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,sl(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()}))),this._observerDisposable.value=rl(this._canvas,this._coreBrowserService.window,((t,i)=>this._setCanvasDevicePixelDimensions(t,i))),this._register(this._coreBrowserService.onWindowChange((t=>{this._observerDisposable.value=rl(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(Nn((()=>{for(let t of this._renderLayers)t.dispose();this._canvas.parentElement?.removeChild(this._canvas),sl(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 bl(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new pl(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=il(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=Rn(Qo.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Qo.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 hl((()=>{this._requestRedrawCursor()}),this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,i){let s,e,h,r,n,o,l,a,c,u,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,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,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&&=!c||M<a[0]||M>=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(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<=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--}}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})}},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 new 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 new 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 ca=aa("OptionsService");aa("OscLinkService"),aa("UnicodeService"),aa("DecorationService");var ua={trace:0,debug:1,info:2,warn:3,error:4,off:5},Aa=class extends Tn{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=ua[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,ca)]);var fa,da,ga,wa,pa,Ca=class extends Tn{constructor(t){if(zn&&function(){if(!zn)return 0;let t=Gn.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 new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new zo),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new zo),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new zo),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new zo),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(Qo.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Qo.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Qo.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Qo.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),s.setRenderer(this._renderer),this._register(Nn((()=>{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{r as t,g as i,h as s,H as e}from"./p-BZOTLEeX.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 bl(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Ml(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?`#${bl(t)}${bl(i)}${bl(s)}${bl(e)}`:`#${bl(t)}${bl(i)}${bl(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)}}})(fl||={}),(t=>{function i(t,i){return Bl=Math.round(255*i),[ml,Il,vl]=pl.toChannels(t.rgba),{css:fl.toCss(ml,Il,vl,Bl),rgba:fl.toRgba(ml,Il,vl,Bl)}}t.blend=function(t,i){if(1==(Bl=(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 ml=h+Math.round(((i.rgba>>24&255)-h)*Bl),Il=r+Math.round((s-r)*Bl),vl=n+Math.round((e-n)*Bl),{css:fl.toCss(ml,Il,vl),rgba:fl.toRgba(ml,Il,vl)}},t.isOpaque=function(t){return!(255&~t.rgba)},t.ensureContrastRatio=function(t,i,s){let e=pl.ensureContrastRatio(t.rgba,i.rgba,s);if(e)return fl.toColor(e>>24&255,e>>16&255,e>>8&255)},t.opaque=function(t){let i=(255|t.rgba)>>>0;return[ml,Il,vl]=pl.toChannels(i),{css:fl.toCss(ml,Il,vl),rgba:i}},t.opacity=i,t.multiplyOpacity=function(t,s){return i(t,(Bl=255&t.rgba)*s/255)},t.toColorRGB=function(t){return[t.rgba>>24&255,t.rgba>>16&255,t.rgba>>8&255]}})(dl||={}),(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 ml=parseInt(t.slice(1,2).repeat(2),16),Il=parseInt(t.slice(2,3).repeat(2),16),vl=parseInt(t.slice(3,4).repeat(2),16),fl.toColor(ml,Il,vl);case 5:return ml=parseInt(t.slice(1,2).repeat(2),16),Il=parseInt(t.slice(2,3).repeat(2),16),vl=parseInt(t.slice(3,4).repeat(2),16),Bl=parseInt(t.slice(4,5).repeat(2),16),fl.toColor(ml,Il,vl,Bl);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 ml=parseInt(e[1]),Il=parseInt(e[2]),vl=parseInt(e[3]),Bl=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),fl.toColor(ml,Il,vl,Bl);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new Error("css.toColor: Unsupported css format");if(i.fillRect(0,0,1,1),[ml,Il,vl,Bl]=i.getImageData(0,0,1,1).data,255!==Bl)throw new Error("css.toColor: Unsupported css format");return{rgba:fl.toRgba(ml,Il,vl,Bl),css:t}}})(gl||={}),(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})(wl||={}),(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=Ml(wl.relativeLuminance2(n,o,a),wl.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=Ml(wl.relativeLuminance2(n,o,a),wl.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=Ml(wl.relativeLuminance2(n,o,a),wl.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=Ml(wl.relativeLuminance2(n,o,a),wl.relativeLuminance2(e,h,r));return(n<<24|o<<16|a<<8|255)>>>0}t.blend=function(t,i){if(1==(Bl=(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 ml=h+Math.round(((i>>24&255)-h)*Bl),Il=r+Math.round((s-r)*Bl),vl=n+Math.round((e-n)*Bl),fl.toRgba(ml,Il,vl)},t.ensureContrastRatio=function(t,e,h){let r=wl.relativeLuminance(t>>8),n=wl.relativeLuminance(e>>8);if(Ml(r,n)<h){if(n<r){let n=i(t,e,h),o=Ml(r,wl.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Ml(r,wl.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),a=Ml(r,wl.relativeLuminance(o>>8));if(a<h){let s=i(t,e,h);return a>Ml(r,wl.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]}})(pl||={});var yl=Object.freeze((()=>{let t=[gl.toColor("#2e3436"),gl.toColor("#cc0000"),gl.toColor("#4e9a06"),gl.toColor("#c4a000"),gl.toColor("#3465a4"),gl.toColor("#75507b"),gl.toColor("#06989a"),gl.toColor("#d3d7cf"),gl.toColor("#555753"),gl.toColor("#ef2929"),gl.toColor("#8ae234"),gl.toColor("#fce94f"),gl.toColor("#729fcf"),gl.toColor("#ad7fa8"),gl.toColor("#34e2e2"),gl.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:fl.toCss(e,h,r),rgba:fl.toRgba(e,h,r)})}for(let i=0;i<24;i++){let s=8+10*i;t.push({css:fl.toCss(s,s,s),rgba:fl.toRgba(s,s,s)})}return t})());function El(t,i,s){return Math.max(i,Math.min(t,s))}var Ql=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 kl(t,i){return t.getFgColorMode()===i.getFgColorMode()&&t.getFgColor()===i.getFgColor()}function xl(t,i){return t.getBgColorMode()===i.getBgColorMode()&&t.getBgColor()===i.getBgColor()}function Dl(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 Ll,_l,Sl=class extends Ql{constructor(t,i){super(t),this._terminal=i,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,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=new Array(t),this._lastContentCursorRow=i,this._lastCursorRow=i,this._firstRow=i}_rowEnd(t,i){this._nullCellCount>0&&!xl(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())&&xl(h,n)&&(a=!0),o&&(r.getChars()||0===r.getWidth())&&xl(h,n)&&xl(r,n)&&(a=!0)),a||(s="-".repeat(this._nullCellCount+1),s+="[1D[1X",this._nullCellCount>0&&(s+="[A",s+=`[${i.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${i.length-this._nullCellCount}D`,s+="[B"),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=!kl(t,i),h=!xl(t,i),r=!Dl(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?!xl(this._cursorStyle,t):r.length>0){this._nullCellCount>0&&(xl(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&&(xl(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,h=t=>{t>0?s+=`[${t}C`:t<0&&(s+=`[${-t}D`)};(t!==this._lastCursorRow||i!==this._lastCursorCol)&&((e=t-this._lastCursorRow)>0?s+=`[${e}B`:e<0&&(s+=`[${-e}A`),h(i-this._lastCursorCol))}var e;let h=this._diffStyle(this._terminal._core._inputHandler._curAttrData,this._cursorStyle);return h.length>0&&(s+=`[${h.join(";")}m`),s}},$l=class{activate(t){this._terminal=t}_serializeBufferByScrollback(t,i,s){let e=i.length,h=void 0===s?e:El(s+t.rows,0,e);return this._serializeBufferByRange(t,i,{start:e-h,end:e-1},!1)}_serializeBufferByRange(t,i,s,e){return new Sl(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 Rl(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:El(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+="[4h"),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 new 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[H${this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)}`),t?.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},Rl=class extends Ql{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:yl}_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=!kl(t,i),h=!xl(t,i),r=!Dl(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"&";case"<":return"<"}return t}(t.getChars())}_serializeString(){return this._htmlContent}},Nl=Object.create,Fl=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Tl=Object.getOwnPropertyNames,Ul=Object.getPrototypeOf,Pl=Object.prototype.hasOwnProperty,Gl=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Jl=(t,i,s)=>(s=null!=t?Nl(Ul(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of Tl(i))!Pl.call(t,s)&&undefined!==s&&Fl(t,s,{get:()=>i[s],enumerable:!(e=Hl(i,s))||e.enumerable});return t})(t&&t.__esModule?s:Fl(s,"default",{value:t,enumerable:!0}),t)),Ol=Gl((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)})),Wl=Gl((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 new Error('must run "inwasm"');_wasmCtx.add(t)}})),ql=Gl((t=>{Object.defineProperty(t,"__esModule",{value:!0});var i=(0,Wl().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}}})),zl=Gl((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"}})),Kl=Gl((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsync=t.decode=t.Decoder=t.DecoderAsync=void 0;var i,s=Ol(),e=zl(),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 new 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(),new 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(),new 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(),new 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=Jl(Ol());
|
|
37
|
+
*/function ba(t){let i=t.toString(16);return i.length<2?"0"+i:i}function Ma(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?`#${ba(t)}${ba(i)}${ba(s)}${ba(e)}`:`#${ba(t)}${ba(i)}${ba(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 ma=h+Math.round(((i.rgba>>24&255)-h)*Ba),Ia=r+Math.round((s-r)*Ba),va=n+Math.round((e-n)*Ba),{css:fa.toCss(ma,Ia,va),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 ma=parseInt(e[1]),Ia=parseInt(e[2]),va=parseInt(e[3]),Ba=Math.round(255*(void 0===e[5]?1:parseFloat(e[5]))),fa.toColor(ma,Ia,va,Ba);if(!i||!s)throw new Error("css.toColor: Unsupported css format");if(i.fillStyle=s,i.fillStyle=t,"string"!=typeof i.fillStyle)throw new 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 new 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=Ma(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=Ma(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=Ma(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=Ma(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 ma=h+Math.round(((i>>24&255)-h)*Ba),Ia=r+Math.round((s-r)*Ba),va=n+Math.round((e-n)*Ba),fa.toRgba(ma,Ia,va)},t.ensureContrastRatio=function(t,e,h){let r=wa.relativeLuminance(t>>8),n=wa.relativeLuminance(e>>8);if(Ma(r,n)<h){if(n<r){let n=i(t,e,h),o=Ma(r,wa.relativeLuminance(n>>8));if(o<h){let i=s(t,e,h);return o>Ma(r,wa.relativeLuminance(i>>8))?n:i}return n}let o=s(t,e,h),l=Ma(r,wa.relativeLuminance(o>>8));if(l<h){let s=i(t,e,h);return l>Ma(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 ya=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 Qa=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,_a,Sa=class extends Qa{constructor(t,i){super(t),this._terminal=i,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,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=new 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+="[1D[1X",this._nullCellCount>0&&(s+="[A",s+=`[${i.length-this._nullCellCount}C`,s+=`[${this._nullCellCount}X`,s+=`[${i.length-this._nullCellCount}D`,s+="[B"),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,h=t=>{t>0?s+=`[${t}C`:t<0&&(s+=`[${-t}D`)};(t!==this._lastCursorRow||i!==this._lastCursorCol)&&((e=t-this._lastCursorRow)>0?s+=`[${e}B`:e<0&&(s+=`[${-e}A`),h(i-this._lastCursorCol))}var e;let h=this._diffStyle(this._terminal._core._inputHandler._curAttrData,this._cursorStyle);return h.length>0&&(s+=`[${h.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 Sa(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+="[4h"),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 new 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[H${this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0)}`),t?.excludeModes||(i+=this._serializeModes(this._terminal)),i}serializeAsHTML(t){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,t||{})}dispose(){}},Ra=class extends Qa{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:ya}_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"&";case"<":return"<"}return t}(t.getChars())}_serializeString(){return this._htmlContent}},Na=Object.create,Fa=Object.defineProperty,Ha=Object.getOwnPropertyDescriptor,Ta=Object.getOwnPropertyNames,Ua=Object.getPrototypeOf,Pa=Object.prototype.hasOwnProperty,Ga=(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))!Pa.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=Ga((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],c=i*i+s*s+e*e;if(!c)return t;c<l&&(l=c,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=Ga((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 new Error('must run "inwasm"');_wasmCtx.add(t)}})),za=Ga((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}}})),qa=Ga((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"}})),Ka=Ga((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeAsync=t.decode=t.Decoder=t.DecoderAsync=void 0;var i,s=Oa(),e=qa(),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 new 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(),new 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(),new 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(),new 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{r as t,g as i,h as s,H as e}from"./p-BZOTLEeX.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 Yl(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})(Ll||={}),(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=Number.POSITIVE_INFINITY){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)}})(_l||={});var Zl=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(_l.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 new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Zl.DISABLE_DISPOSED_WARNING=!1;var Xl=Zl,Vl=class{constructor(){this._store=new Xl}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Vl.None=Object.freeze({dispose(){}});var tc=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}},ic=class t extends Vl{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new tc),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:Yl((()=>{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}},sc={width:7,height:14},ec=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}},hc=new ec,rc=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=sc);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=sc);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]||hc,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]||hc)&&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]||hc,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]||hc;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=ic.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]||hc;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 ec(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new ec(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)}},nc=Jl(ql());function oc(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function ac(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function lc(t){let i=oc(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var cc={inline:ac,size:ac,name:function(t){if(typeof Buffer<"u")return Buffer.from(oc(t),"base64").toString();let i=atob(oc(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:lc,height:lc,preserveAspectRatio:ac},uc=[70,105,108,101],Ac=1024,fc=class{constructor(){this.state=0,this._buffer=new Uint32Array(Ac),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<uc.length;++t)if(r[t]!==uc[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>=Ac)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>=Ac)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=oc(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]=cc[this._key]?cc[this._key](i):i}catch{return!1}return!0}return!1}},dc={mime:"unsupported",width:0,height:0},gc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},wc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new fc,this._header=gc,this._dec=new nc.default(4194304),this._metrics=dc}reset(){}start(){this._aborted=!1,this._header=gc,this._metrics=dc,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({},gc,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 dc;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]?dc:{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=ic.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||sc.width,e=this._renderer.dimensions?.css.cell.height||sc.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}},pc=Jl(Ol()),Cc=Jl(Kl()),mc=pc.PALETTE_ANSI_256;mc.set(pc.PALETTE_VT340_COLOR);var Ic=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Cc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:mc,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,mc,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=vc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,pc.toRGBA8888)(...i)}else s=vc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=vc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,pc.toRGBA8888)(...i)}else s=vc(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=ic.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 vc(t){return pc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var Bc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},bc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},Bc,t),this._defaultOpts=Object.assign({},Bc,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 ic(t),this._storage=new rc(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 Ic(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 wc(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=sc;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 Mc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_c.unregister(this),t}free(){const t=this.__destroy_into_raw();tu.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_authenticate(this.__wbg_ptr,e,h,r,iu,qc(s)?4294967297:s>>>0)}connect(){tu.channel_connect(this.__wbg_ptr)}disconnect(){tu.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==tu.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==tu.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu;var o=qc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);const a=tu.channel_new(e,h,r,n,o,iu);return this.__wbg_ptr=a>>>0,_c.register(this,this.__wbg_ptr,this),this}on_connection_close(t){tu.channel_on_connection_close(this.__wbg_ptr,qc(t)?0:Sc(t))}on_connection_error(t){tu.channel_on_connection_error(this.__wbg_ptr,qc(t)?0:Sc(t))}on_connection_message(t){tu.channel_on_connection_message(this.__wbg_ptr,qc(t)?0:Sc(t))}on_connection_open(t){tu.channel_on_connection_open(this.__wbg_ptr,qc(t)?0:Sc(t))}on_protocol_message(t){tu.channel_on_protocol_message(this.__wbg_ptr,qc(t)?0:Sc(t))}open_sftp_tunnel(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;var n=qc(i)?0:Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),o=iu,a=qc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,iu,qc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;var n=qc(i)?0:Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),o=iu,a=qc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,iu,qc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu,o=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),a=iu,l=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,iu,qc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_download_chunk(this.__wbg_ptr,r,iu,i,s,e,qc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu,o=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),a=iu,l=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,iu,qc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu,n=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,iu,qc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),a=iu,l=function(t){const i=(0,tu.__wbindgen_export)(1*t.length,1)>>>0;return Pc().set(t,i/1),iu=t.length,i}(r);tu.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,iu,qc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),a=iu,l=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),c=iu,u=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,iu,h,r,qc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_ssh_terminal_resize(this.__wbg_ptr,h,iu,i,s,e)}send_ssh_tunnel_data(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,iu)}start_heartbeat(t){tu.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){tu.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(Mc.prototype[Symbol.dispose]=Mc.prototype.free);const yc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Ec(){const t={__proto__:null,__wbg_Error_83742b46f01ce22d:function(t,i){return Sc(Error(Tc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Kc(String(Gc(i)),tu.__wbindgen_export,tu.__wbindgen_export2),e=iu;Hc().setInt32(t+4,e,!0),Hc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_5398f5bb970e0daa:function(t,i){const s=Kc(Rc(Gc(i)),tu.__wbindgen_export,tu.__wbindgen_export2),e=iu;Hc().setInt32(t+4,e,!0),Hc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_395e606bd0ee4427:function(t,i){const s=Gc(i),e="string"==typeof s?s:void 0;var h=qc(e)?0:Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;Hc().setInt32(t+4,r,!0),Hc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_6ddd609b62940d55:function(t,i){throw new Error(Tc(t,i))},__wbg__wbg_cb_unref_6b5b6b8576d35cb1:function(t){Gc(t)._wbg_cb_unref()},__wbg_call_2d781c1f4d5c0ef8:function(){return Jc((function(t,i,s){return Sc(Gc(t).call(Gc(i),Gc(s)))}),arguments)},__wbg_call_e133b57c9155d22c:function(){return Jc((function(t,i){return Sc(Gc(t).call(Gc(i)))}),arguments)},__wbg_clearInterval_16e8cbbce92291d0:function(t){return Sc(clearInterval(jc(t)))},__wbg_close_af26905c832a88cb:function(){return Jc((function(t){Gc(t).close()}),arguments)},__wbg_data_a3d9ff9cdd801002:function(t){return Sc(Gc(t).data)},__wbg_from_4bdf88943703fd48:function(t){return Sc(Array.from(Gc(t)))},__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6:function(t){let i;try{i=Gc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_ea16607d7b61445b:function(t){return Gc(t).length},__wbg_new_5f486cdf45a04d78:function(t){return Sc(new Uint8Array(Gc(t)))},__wbg_new_a70fbab9066b301f:function(){return Sc(new Array)},__wbg_new_ab79df5bd7c26067:function(){return Sc(new Object)},__wbg_new_with_str_299114bdb2430303:function(){return Jc((function(t,i,s,e){return Sc(new WebSocket(Tc(t,i),Tc(s,e)))}),arguments)},__wbg_prototypesetcall_d62e5099504357e6:function(t,i,s){Uint8Array.prototype.set.call(Nc(t,i),Gc(s))},__wbg_readyState_1f1e7f1bdf9f4d42:function(t){return Gc(t).readyState},__wbg_send_d31a693c975dea74:function(){return Jc((function(t,i,s){Gc(t).send(Nc(i,s))}),arguments)},__wbg_setInterval_84b64f01452a246e:function(){return Jc((function(t,i){return Sc(setInterval(Gc(t),i))}),arguments)},__wbg_set_282384002438957f:function(t,i,s){Gc(t)[i>>>0]=jc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Gc(t)[jc(i)]=jc(s)},__wbg_set_binaryType_3dcf8281ec100a8f:function(t,i){Gc(t).binaryType=Lc[i]},__wbg_set_onclose_8da801226bdd7a7b:function(t,i){Gc(t).onclose=Gc(i)},__wbg_set_onerror_901ca711f94a5bbb:function(t,i){Gc(t).onerror=Gc(i)},__wbg_set_onmessage_6f80ab771bf151aa:function(t,i){Gc(t).onmessage=Gc(i)},__wbg_set_onopen_34e3e24cf9337ddd:function(t,i){Gc(t).onopen=Gc(i)},__wbg_warn_1bf034bfadbf0dc0:function(t,i){console.warn(Tc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Sc(zc(t,i,tu.__wasm_bindgen_func_elem_37,kc))},__wbindgen_cast_0000000000000002:function(t,i){return Sc(zc(t,i,tu.__wasm_bindgen_func_elem_37,xc))},__wbindgen_cast_0000000000000003:function(t,i){return Sc(zc(t,i,tu.__wasm_bindgen_func_elem_37,Dc))},__wbindgen_cast_0000000000000004:function(t,i){return Sc(zc(t,i,tu.__wasm_bindgen_func_elem_37,Qc))},__wbindgen_cast_0000000000000005:function(t){return Sc(t)},__wbindgen_cast_0000000000000006:function(t,i){return Sc(Nc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Sc(Tc(t,i))},__wbindgen_cast_0000000000000008:function(t){return Sc(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Sc(Gc(t))},__wbindgen_object_drop_ref:function(t){jc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function Qc(t,i){tu.__wasm_bindgen_func_elem_42(t,i)}function kc(t,i,s){tu.__wasm_bindgen_func_elem_38(t,i,Sc(s))}function xc(t,i,s){tu.__wasm_bindgen_func_elem_38_1(t,i,Sc(s))}function Dc(t,i,s){tu.__wasm_bindgen_func_elem_38_2(t,i,Sc(s))}const Lc=["blob","arraybuffer"],_c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>tu.__wbg_channel_free(t>>>0,1)));function Sc(t){Wc===Oc.length&&Oc.push(Oc.length+1);const i=Wc;return Wc=Oc[i],Oc[i]=t,i}const $c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>t.dtor(t.a,t.b)));function Rc(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+=Rc(t[0]));for(let e=1;e<i;e++)s+=", "+Rc(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 Nc(t,i){return t>>>=0,Pc().subarray(t/1,t/1+i)}let Fc=null;function Hc(){return(null===Fc||!0===Fc.buffer.detached||void 0===Fc.buffer.detached&&Fc.buffer!==tu.memory.buffer)&&(Fc=new DataView(tu.memory.buffer)),Fc}function Tc(t,i){return function(t,i){return Xc+=i,Xc>=Zc&&(Yc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Yc.decode(),Xc=i),Yc.decode(Pc().subarray(t,t+i))}(t>>>=0,i)}let Uc=null;function Pc(){return null!==Uc&&0!==Uc.byteLength||(Uc=new Uint8Array(tu.memory.buffer)),Uc}function Gc(t){return Oc[t]}function Jc(t,i){try{return t.apply(this,i)}catch(t){tu.__wbindgen_export3(Sc(t))}}let Oc=new Array(1024).fill(void 0);Oc.push(void 0,null,!0,!1);let Wc=Oc.length;function qc(t){return null==t}function zc(t,i,s,e){const h={a:t,b:i,cnt:1,dtor:s},r=(...t)=>{h.cnt++;const i=h.a;h.a=0;try{return e(i,h.b,...t)}finally{h.a=i,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--h.cnt&&(h.dtor(h.a,h.b),h.a=0,$c.unregister(h))},$c.register(r,h,h),r}function Kc(t,i,s){if(void 0===s){const s=Vc.encode(t),e=i(s.length,1)>>>0;return Pc().subarray(e,e+s.length).set(s),iu=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Pc();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=Pc().subarray(h+n,h+e);n+=Vc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return iu=n,h}function jc(t){const i=Gc(t);return function(t){t<1028||(Oc[t]=Wc,Wc=t)}(t),i}let Yc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Yc.decode();const Zc=2146435072;let Xc=0;const Vc=new TextEncoder;"encodeInto"in Vc||(Vc.encodeInto=function(t,i){const s=Vc.encode(t);return i.set(s),{read:t.length,written:s.length}});let tu,iu=0;var su;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(su||(su={}));const eu=class{constructor(i){t(this,i)}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=su.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 i(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)}createWebSocketEndpoint(){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(){console.log("PhirepassTerminal connected to DOM"),await async function(t){if(void 0!==tu)return tu;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=Ec();("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 tu=t.exports,Fc=null,Uc=null,tu}(s)}(),console.log("PhirepassChannel module initialized"),this.setup_terminal(),console.log("Terminal setup complete"),this.open_comms(),console.log("Comms opened"),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.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new wr(this.terminalOptions),this.fitAddon=new pr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new br,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new Mn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new $l,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new bc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Cl,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}this.fitAddon.fit()}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new Mc(`${this.createWebSocketEndpoint()}/api/web/ws`,this.nodeId,this.serverId):new Mc(`${this.createWebSocketEndpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.terminal.reset()})),this.channel.on_connection_error((t=>{console.error(">> connection 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.handleAuthSuccess(i);break;case"TunnelOpened":this.session_id=i.sid,this.terminal.reset(),this.send_ssh_terminal_resize();break;case"TunnelClosed":this.handleTunnelClosed();break;case"TunnelData":this.terminal.write(new Uint8Array(i.data));break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.channel||!this.channel.is_connected()||!this.session_id)return;const t=this.terminal?.cols??0,i=this.terminal?.rows??0;if(!(t<=0||i<=0))try{this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i)}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 yc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case yc.RequiresUsername:this.terminal.reset(),this.inputMode=su.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case yc.RequiresPassword:this.terminal.reset(),this.inputMode=su.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=su.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=su.Default,this.clear_creds_buffer()}handleAuthSuccess(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handleTunnelClosed(){this.session_id=void 0,this.inputMode=su.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed.")}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.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handleTerminalData.bind(this)),this.channel.connect(),this.setupResizeObserver(),this.connected=!0,console.log("Terminal connected and ready"))}setupResizeObserver(){this.resizeObserver=new ResizeObserver((()=>{this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.el)}handleTerminalData(t){switch(this.inputMode){case su.Username:this.handleUsernameInput(t);break;case su.Password:this.handlePasswordInput(t);break;case su.Default:this.send_ssh_data(t)}}handleUsernameInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitUsername()):""===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")))}submitUsername(){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=su.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handlePasswordInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitPassword()):""===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")))}submitPassword(){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=su.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return s(e,{key:"16372280bf650813e7aae4e28fae8b761b87a096"},s("div",{key:"5a387d5d9d0772510ded9b50c764ab4ae4b14abc",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};eu.style=".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%}:host #ccc{width:inherit;height:inherit}:host #ccc .terminal{height:inherit}:host #ccc .terminal .xterm-scrollable-element{height:inherit}";export{eu as phirepass_terminal}
|
|
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=Number.POSITIVE_INFINITY){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)}})(_a||={});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(_a.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 new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};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 new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Va.None=Object.freeze({dispose(){}});var tc=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}},ic=class t extends Va{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new tc),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,c=Math.floor(i/l)*n,u=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(a),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,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,c=l+h>r.height?r.height-l:h,u=t.createCanvas(this.document,a,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(c),0,0,Math.floor(a),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,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 c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<a;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}},sc={width:7,height:14},ec=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}},hc=new ec,rc=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=sc);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=sc);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,c=l,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=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: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]||hc,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]||hc)&&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]||hc,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]||hc;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=ic.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]||hc;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 ec(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new ec(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)}},nc=Ja(za());function oc(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function lc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function ac(t){let i=oc(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var cc={inline:lc,size:lc,name:function(t){if(typeof Buffer<"u")return Buffer.from(oc(t),"base64").toString();let i=atob(oc(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:ac,height:ac,preserveAspectRatio:lc},uc=[70,105,108,101],Ac=1024,fc=class{constructor(){this.state=0,this._buffer=new Uint32Array(Ac),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<uc.length;++t)if(r[t]!==uc[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>=Ac)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>=Ac)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=oc(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]=cc[this._key]?cc[this._key](i):i}catch{return!1}return!0}return!1}},dc={mime:"unsupported",width:0,height:0},gc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},wc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new fc,this._header=gc,this._dec=new nc.default(4194304),this._metrics=dc}reset(){}start(){this._aborted=!1,this._header=gc,this._metrics=dc,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({},gc,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 dc;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]?dc:{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=ic.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||sc.width,e=this._renderer.dimensions?.css.cell.height||sc.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}},pc=Ja(Oa()),Cc=Ja(Ka()),mc=pc.PALETTE_ANSI_256;mc.set(pc.PALETTE_VT340_COLOR);var Ic=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Cc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:mc,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,mc,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=vc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,pc.toRGBA8888)(...i)}else s=vc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=vc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,pc.toRGBA8888)(...i)}else s=vc(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=ic.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 vc(t){return pc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var Bc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},bc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},Bc,t),this._defaultOpts=Object.assign({},Bc,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 ic(t),this._storage=new rc(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 Ic(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 wc(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=sc;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 Mc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_c.unregister(this),t}free(){const t=this.__destroy_into_raw();tu.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_authenticate(this.__wbg_ptr,e,h,r,iu,zc(s)?4294967297:s>>>0)}connect(){tu.channel_connect(this.__wbg_ptr)}disconnect(){tu.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==tu.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==tu.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu;var o=zc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);const l=tu.channel_new(e,h,r,n,o,iu);return this.__wbg_ptr=l>>>0,_c.register(this,this.__wbg_ptr,this),this}on_connection_close(t){tu.channel_on_connection_close(this.__wbg_ptr,zc(t)?0:Sc(t))}on_connection_error(t){tu.channel_on_connection_error(this.__wbg_ptr,zc(t)?0:Sc(t))}on_connection_message(t){tu.channel_on_connection_message(this.__wbg_ptr,zc(t)?0:Sc(t))}on_connection_open(t){tu.channel_on_connection_open(this.__wbg_ptr,zc(t)?0:Sc(t))}on_protocol_message(t){tu.channel_on_protocol_message(this.__wbg_ptr,zc(t)?0:Sc(t))}open_sftp_tunnel(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;var n=zc(i)?0:Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),o=iu,l=zc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,l,iu,zc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;var n=zc(i)?0:Kc(i,tu.__wbindgen_export,tu.__wbindgen_export2),o=iu,l=zc(s)?0:Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,l,iu,zc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu,o=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),l=iu,a=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,l,a,iu,zc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_download_chunk(this.__wbg_ptr,r,iu,i,s,e,zc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),n=iu,o=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),l=iu,a=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,l,a,iu,zc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu,n=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,iu,zc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),l=iu,a=function(t){const i=(0,tu.__wbindgen_export)(1*t.length,1)>>>0;return Pc().set(t,i/1),iu=t.length,i}(r);tu.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,l,i,s,e,h,a,iu,zc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),l=iu,a=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2),c=iu,u=Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_sftp_upload_start(this.__wbg_ptr,o,l,i,a,c,u,iu,h,r,zc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e){const h=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_ssh_terminal_resize(this.__wbg_ptr,h,iu,i,s,e)}send_ssh_tunnel_data(t,i,s){const e=Kc(t,tu.__wbindgen_export,tu.__wbindgen_export2),h=iu,r=Kc(s,tu.__wbindgen_export,tu.__wbindgen_export2);tu.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,iu)}start_heartbeat(t){tu.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){tu.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(Mc.prototype[Symbol.dispose]=Mc.prototype.free);const yc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Ec(){const t={__proto__:null,__wbg_Error_83742b46f01ce22d:function(t,i){return Sc(Error(Tc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Kc(String(Gc(i)),tu.__wbindgen_export,tu.__wbindgen_export2),e=iu;Hc().setInt32(t+4,e,!0),Hc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_5398f5bb970e0daa:function(t,i){const s=Kc(Rc(Gc(i)),tu.__wbindgen_export,tu.__wbindgen_export2),e=iu;Hc().setInt32(t+4,e,!0),Hc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_395e606bd0ee4427:function(t,i){const s=Gc(i),e="string"==typeof s?s:void 0;var h=zc(e)?0:Kc(e,tu.__wbindgen_export,tu.__wbindgen_export2),r=iu;Hc().setInt32(t+4,r,!0),Hc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_6ddd609b62940d55:function(t,i){throw new Error(Tc(t,i))},__wbg__wbg_cb_unref_6b5b6b8576d35cb1:function(t){Gc(t)._wbg_cb_unref()},__wbg_call_2d781c1f4d5c0ef8:function(){return Jc((function(t,i,s){return Sc(Gc(t).call(Gc(i),Gc(s)))}),arguments)},__wbg_call_e133b57c9155d22c:function(){return Jc((function(t,i){return Sc(Gc(t).call(Gc(i)))}),arguments)},__wbg_clearInterval_16e8cbbce92291d0:function(t){return Sc(clearInterval(jc(t)))},__wbg_close_af26905c832a88cb:function(){return Jc((function(t){Gc(t).close()}),arguments)},__wbg_data_a3d9ff9cdd801002:function(t){return Sc(Gc(t).data)},__wbg_from_4bdf88943703fd48:function(t){return Sc(Array.from(Gc(t)))},__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6:function(t){let i;try{i=Gc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_ea16607d7b61445b:function(t){return Gc(t).length},__wbg_new_5f486cdf45a04d78:function(t){return Sc(new Uint8Array(Gc(t)))},__wbg_new_a70fbab9066b301f:function(){return Sc(new Array)},__wbg_new_ab79df5bd7c26067:function(){return Sc(new Object)},__wbg_new_with_str_299114bdb2430303:function(){return Jc((function(t,i,s,e){return Sc(new WebSocket(Tc(t,i),Tc(s,e)))}),arguments)},__wbg_prototypesetcall_d62e5099504357e6:function(t,i,s){Uint8Array.prototype.set.call(Nc(t,i),Gc(s))},__wbg_readyState_1f1e7f1bdf9f4d42:function(t){return Gc(t).readyState},__wbg_send_d31a693c975dea74:function(){return Jc((function(t,i,s){Gc(t).send(Nc(i,s))}),arguments)},__wbg_setInterval_84b64f01452a246e:function(){return Jc((function(t,i){return Sc(setInterval(Gc(t),i))}),arguments)},__wbg_set_282384002438957f:function(t,i,s){Gc(t)[i>>>0]=jc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Gc(t)[jc(i)]=jc(s)},__wbg_set_binaryType_3dcf8281ec100a8f:function(t,i){Gc(t).binaryType=Lc[i]},__wbg_set_onclose_8da801226bdd7a7b:function(t,i){Gc(t).onclose=Gc(i)},__wbg_set_onerror_901ca711f94a5bbb:function(t,i){Gc(t).onerror=Gc(i)},__wbg_set_onmessage_6f80ab771bf151aa:function(t,i){Gc(t).onmessage=Gc(i)},__wbg_set_onopen_34e3e24cf9337ddd:function(t,i){Gc(t).onopen=Gc(i)},__wbg_warn_1bf034bfadbf0dc0:function(t,i){console.warn(Tc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Sc(qc(t,i,tu.__wasm_bindgen_func_elem_37,kc))},__wbindgen_cast_0000000000000002:function(t,i){return Sc(qc(t,i,tu.__wasm_bindgen_func_elem_37,xc))},__wbindgen_cast_0000000000000003:function(t,i){return Sc(qc(t,i,tu.__wasm_bindgen_func_elem_37,Dc))},__wbindgen_cast_0000000000000004:function(t,i){return Sc(qc(t,i,tu.__wasm_bindgen_func_elem_37,Qc))},__wbindgen_cast_0000000000000005:function(t){return Sc(t)},__wbindgen_cast_0000000000000006:function(t,i){return Sc(Nc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Sc(Tc(t,i))},__wbindgen_cast_0000000000000008:function(t){return Sc(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Sc(Gc(t))},__wbindgen_object_drop_ref:function(t){jc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function Qc(t,i){tu.__wasm_bindgen_func_elem_42(t,i)}function kc(t,i,s){tu.__wasm_bindgen_func_elem_38(t,i,Sc(s))}function xc(t,i,s){tu.__wasm_bindgen_func_elem_38_1(t,i,Sc(s))}function Dc(t,i,s){tu.__wasm_bindgen_func_elem_38_2(t,i,Sc(s))}const Lc=["blob","arraybuffer"],_c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>tu.__wbg_channel_free(t>>>0,1)));function Sc(t){Wc===Oc.length&&Oc.push(Oc.length+1);const i=Wc;return Wc=Oc[i],Oc[i]=t,i}const $c="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>t.dtor(t.a,t.b)));function Rc(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+=Rc(t[0]));for(let e=1;e<i;e++)s+=", "+Rc(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 Nc(t,i){return t>>>=0,Pc().subarray(t/1,t/1+i)}let Fc=null;function Hc(){return(null===Fc||!0===Fc.buffer.detached||void 0===Fc.buffer.detached&&Fc.buffer!==tu.memory.buffer)&&(Fc=new DataView(tu.memory.buffer)),Fc}function Tc(t,i){return function(t,i){return Xc+=i,Xc>=Zc&&(Yc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Yc.decode(),Xc=i),Yc.decode(Pc().subarray(t,t+i))}(t>>>=0,i)}let Uc=null;function Pc(){return null!==Uc&&0!==Uc.byteLength||(Uc=new Uint8Array(tu.memory.buffer)),Uc}function Gc(t){return Oc[t]}function Jc(t,i){try{return t.apply(this,i)}catch(t){tu.__wbindgen_export3(Sc(t))}}let Oc=new Array(1024).fill(void 0);Oc.push(void 0,null,!0,!1);let Wc=Oc.length;function zc(t){return null==t}function qc(t,i,s,e){const h={a:t,b:i,cnt:1,dtor:s},r=(...t)=>{h.cnt++;const i=h.a;h.a=0;try{return e(i,h.b,...t)}finally{h.a=i,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--h.cnt&&(h.dtor(h.a,h.b),h.a=0,$c.unregister(h))},$c.register(r,h,h),r}function Kc(t,i,s){if(void 0===s){const s=Vc.encode(t),e=i(s.length,1)>>>0;return Pc().subarray(e,e+s.length).set(s),iu=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Pc();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=Pc().subarray(h+n,h+e);n+=Vc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return iu=n,h}function jc(t){const i=Gc(t);return function(t){t<1028||(Oc[t]=Wc,Wc=t)}(t),i}let Yc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Yc.decode();const Zc=2146435072;let Xc=0;const Vc=new TextEncoder;"encodeInto"in Vc||(Vc.encodeInto=function(t,i){const s=Vc.encode(t);return i.set(s),{read:t.length,written:s.length}});let tu,iu=0;var su;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(su||(su={}));const eu=class{constructor(i){t(this,i)}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=su.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 i(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)}createWebSocketEndpoint(){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(){console.log("PhirepassTerminal connected to DOM"),await async function(t){if(void 0!==tu)return tu;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=Ec();("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 tu=t.exports,Fc=null,Uc=null,tu}(s)}(),console.log("PhirepassChannel module initialized"),this.setup_terminal(),console.log("Terminal setup complete"),this.open_comms(),console.log("Comms opened"),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.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new wr(this.terminalOptions),this.fitAddon=new pr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new br,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new Mn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new $a,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new bc(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)}this.fitAddon.fit()}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new Mc(`${this.createWebSocketEndpoint()}/api/web/ws`,this.nodeId,this.serverId):new Mc(`${this.createWebSocketEndpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.terminal.reset()})),this.channel.on_connection_error((t=>{console.error(">> connection 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.handleAuthSuccess(i);break;case"TunnelOpened":this.session_id=i.sid,this.terminal.reset(),this.send_ssh_terminal_resize();break;case"TunnelClosed":this.handleTunnelClosed();break;case"TunnelData":this.terminal.write(new Uint8Array(i.data));break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.channel||!this.channel.is_connected()||!this.session_id)return;const t=this.terminal?.cols??0,i=this.terminal?.rows??0;if(!(t<=0||i<=0))try{console.log(`Sending terminal resize: cols=${t}, rows=${i}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i)}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 yc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case yc.RequiresUsername:this.terminal.reset(),this.inputMode=su.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case yc.RequiresPassword:this.terminal.reset(),this.inputMode=su.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=su.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=su.Default,this.clear_creds_buffer()}handleAuthSuccess(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handleTunnelClosed(){this.session_id=void 0,this.inputMode=su.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed.")}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.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handleTerminalData.bind(this)),this.channel.connect(),this.setupResizeObserver(),this.connected=!0,console.log("Terminal connected and ready"))}setupResizeObserver(){this.resizeObserver=new ResizeObserver((()=>{this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.el)}handleTerminalData(t){switch(this.inputMode){case su.Username:this.handleUsernameInput(t);break;case su.Password:this.handlePasswordInput(t);break;case su.Default:this.send_ssh_data(t)}}handleUsernameInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitUsername()):""===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")))}submitUsername(){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=su.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handlePasswordInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitPassword()):""===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")))}submitPassword(){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=su.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return s(e,{key:"19ac1ed6ebba15249ad4cbcc8b824508eef08d26"},s("div",{key:"779492472d585c808ec2e96a3adae67df09c58a5",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};eu.style=".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%}:host #ccc{width:inherit;height:inherit}:host #ccc .terminal{height:inherit}:host #ccc .terminal .xterm-scrollable-element{height:inherit}";export{eu as phirepass_terminal}
|