paneful 0.9.15 → 0.9.16

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Paneful
2
2
 
3
- A fast, GPU-accelerated terminal multiplexer that runs in your browser or as a native macOS app. Split panes, organize projects, sync with your editor, and detect AI agents and dev servers automatically. One `npm install`, no config.
3
+ A fast, GPU-accelerated terminal manager with split panes, project organization, editor sync, and automatic AI agent and dev server detection. Runs as a native macOS app or in the browser. One `npm install`, no config.
4
4
 
5
5
  **Website:** [paneful.dev](https://paneful.dev)
6
6
 
@@ -97,10 +97,13 @@ A folder picker dialog lets you choose the install location (defaults to `/Appli
97
97
 
98
98
  Install the [Paneful extension](https://marketplace.visualstudio.com/items?itemName=kplates.paneful-vscode) from the VS Code Marketplace. Works with VS Code, Cursor, and other VS Code-based editors.
99
99
 
100
- **Commands** (via Command Palette):
100
+ **Commands** (via Command Palette or right-click context menu):
101
101
 
102
102
  - **Paneful: Spawn project** — Creates or activates a Paneful project for the current workspace folder.
103
103
  - **Paneful: Send open file paths** — Sends all open editor file paths to the focused Paneful terminal.
104
+ - **Paneful: Send current file path** — Sends the active editor's file path.
105
+ - **Paneful: Send selection** — Sends selected text with file path and line numbers.
106
+ - **Paneful: Send path** — Sends a file or folder path from the explorer.
104
107
 
105
108
  ### Updating
106
109
 
@@ -59,7 +59,7 @@ var e,t,i,r,s,n,o,a,l;function h(e){return e&&e.__esModule&&Object.prototype.has
59
59
  * Fabrice Bellard's javascript vt100 for jslinux:
60
60
  * http://bellard.org/jslinux/
61
61
  * Copyright (c) 2011 Fabrice Bellard
62
- */function Vm(e){(function(e){return e instanceof Jm||e instanceof Error&&e.name===Ym&&e.message===Ym})(e)||qm.onUnexpectedError(e)}var Ym="Canceled";var Gm,Xm,Qm,Jm=class extends Error{constructor(){super(Ym),this.name=this.message}},Zm=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function ey(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function ty(e){if(Qm.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(sp){t.push(sp)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function iy(...e){return ry(()=>ty(e))}function ry(e){return{dispose:ey(()=>{e()})}}(Xm=Gm||(Gm={})).isLessThan=function(e){return e<0},Xm.isLessThanOrEqual=function(e){return e<=0},Xm.isGreaterThan=function(e){return e>0},Xm.isNeitherLessOrGreaterThan=function(e){return 0===e},Xm.greaterThan=1,Xm.lessThan=-1,Xm.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(Qm||(Qm={}));var sy=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{ty(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};sy.DISABLE_DISPOSED_WARNING=!1;var ny=sy,oy=class{constructor(){this._store=new ny,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};oy.None=Object.freeze({dispose(){}});var ay,ly=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},hy=globalThis.performance&&"function"==typeof globalThis.performance.now,cy=class e{static create(t){return new e(t)}constructor(e){this._now=hy&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new Sy({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,h,c,u=0,d=new Sy({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!h&&(d.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){s&&u>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>oy.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>{let s=iy(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(s,r)}},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new Sy({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Sy({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Sy({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Sy;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Sy(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof ny?r.add(a):Array.isArray(r)&&r.push(a),a}}})(ay||(ay={}));var uy=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cy,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};uy.all=new Set,uy._idPool=0;var dy=uy,fy=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new vy(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};fy._idPool=1;var _y,py=fy,gy=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},vy=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},my=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},yy=0,by=class{constructor(e){this.value=e,this.id=yy++}},Sy=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new py((null==e?void 0:e.onListenerError)??Vm,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new dy(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new my(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||Vm)(i),oy.None}if(this._disposed)return oy.None;t&&(e=e.bind(t));let l,h=new by(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=gy.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof by?(this._deliveryQueue??(this._deliveryQueue=new wy),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=ry(()=>{null==l||l(),this._removeListener(h)});return i instanceof ny?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||Vm;if(r)try{e.value(t)}catch(h_){r(h_)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof by)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},wy=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},xy=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Ly||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ay.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:xy})})(_y||(_y={}));var Cy,ky,Ly=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?xy:(this._emitter||(this._emitter=new Sy),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ey="en",My=Ey,Ry=globalThis;typeof Ry.vscode<"u"&&typeof Ry.vscode.process<"u"?ky=Ry.vscode.process:typeof process<"u"&&"string"==typeof(null==(r=null==process?void 0:process.versions)?void 0:r.node)&&(ky=process);var Ty="string"==typeof(null==(s=null==ky?void 0:ky.versions)?void 0:s.electron)&&"renderer"===(null==ky?void 0:ky.type);if("object"==typeof ky){ky.platform,ky.platform,"linux"===ky.platform&&!!ky.env.SNAP&&ky.env.SNAP_REVISION,!!ky.env.CI||ky.env.BUILD_ARTIFACTSTAGINGDIRECTORY,My=Ey;let e=ky.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,My=t.resolvedLanguage||Ey,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||Ty?console.error("Unable to resolve platform."):((Cy=navigator.userAgent).indexOf("Windows"),Cy.indexOf("Macintosh"),(Cy.indexOf("Macintosh")>=0||Cy.indexOf("iPad")>=0||Cy.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Cy.indexOf("Linux")>=0,null==Cy||Cy.indexOf("Mobi"),My=globalThis._VSCODE_NLS_LANGUAGE||Ey,navigator.language.toLowerCase());var Py,Dy=Cy,By=My;(e=>{e.value=function(){return By},e.isDefaultVariant=function(){return 2===By.length?"en"===By:By.length>=3&&("e"===By[0]&&"n"===By[1]&&"-"===By[2])},e.isDefault=function(){return"en"===By}})(Py||(Py={}));var Ay="function"==typeof Ry.postMessage&&!Ry.importScripts;(()=>{if(Ay){let e=[];Ry.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),Ry.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Ny,Iy,Oy=!!(Dy&&Dy.indexOf("Chrome")>=0);function zy(e,t=0,i){let r=setTimeout(()=>{e()},t);return ry(()=>{clearTimeout(r)})}Dy&&Dy.indexOf("Firefox"),!Oy&&Dy&&Dy.indexOf("Safari"),Dy&&Dy.indexOf("Edg/"),Dy&&Dy.indexOf("Android"),(Iy=Ny||(Ny={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},Iy.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(vt){i(vt)}})};var Fy=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Sy,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(h_){this.reject(h_)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await ay.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Fy.EMPTY=Fy.fromArray([]);var jy=class extends oy{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new ly),this._linesCacheDisposables=this._register(new ly),this._register(ry(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=iy(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=zy(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let r=[],s=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(r.push(l),!a)break;s.push(s[s.length-1]+l.length),e++,n=o}return[r.join(""),s]}},Wy=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Hy=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,r){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let s={startRow:t,startCol:i},n=this._findInLine(e,s,r);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(s.startRow=o,s.startCol=0,n=this._findInLine(e,s,r),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,n=0;r&&(i===e?(s=r.end.x,n=r.end.y):(s=r.start.x,n=r.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:s},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&r&&(o.startRow=r.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:s,startCol:n};if(r&&(l.startRow=s=r.start.y,l.startCol=n=r.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=s=r.end.y,l.startCol=n=r.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=s-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=s&&(l.startRow=h,a=this._findInLine(e,l,t,o),!a);h--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},r=!1){var s;let n=t.startRow,o=t.startCol;if(null==(s=this._terminal.buffer.active.getLine(n))?void 0:s.isWrapped)return r?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,h]=a,c=this._bufferColsToStringOffset(n,o),u=e,d=l;i.regex||(u=i.caseSensitive?e:e.toLowerCase(),d=i.caseSensitive?l:l.toLowerCase());let f=-1;if(i.regex){let t,s=RegExp(u,i.caseSensitive?"g":"gi");if(r)for(;t=s.exec(d.slice(0,c));)f=s.lastIndex-t[0].length,e=t[0],s.lastIndex-=e.length-1;else t=s.exec(d.slice(c)),t&&t[0].length>0&&(f=c+(s.lastIndex-t[0].length),e=t[0])}else r?c-u.length>=0&&(f=d.lastIndexOf(u,c-u.length)):f=d.indexOf(u,c);if(f>=0){if(i.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<h.length-1&&f>=h[t+1];)t++;let r=t;for(;r<h.length-1&&f+e.length>=h[r+1];)r++;let s=f-h[t],o=f+e.length-h[r],a=this._stringLengthToBufferSize(n+t,s);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+r,o)-a+this._terminal.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let r=0;r<t;r++){let e=i.getCell(r);if(!e)break;let s=e.getChars();s.length>1&&(t-=s.length-1);let n=i.getCell(r+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,r=0,s=this._terminal.buffer.active.getLine(i);for(;t>0&&s;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=s.getCell(e);if(!t)break;t.getWidth()&&(r+=0===t.getCode()?1:t.getChars().length)}if(i++,s=this._terminal.buffer.active.getLine(i),s&&!s.isWrapped)break;t-=this._terminal.cols}return r}},$y=class extends oy{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ry(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){ty(i)}}}clearHighlightDecorations(){ty(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let r=[],s=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-s,n);r.push([o,s,e]),s=0,n-=e,o++}let a=[];for(let l of r){let e=this._terminal.registerMarker(l[0]),r=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(r){let s=[];s.push(e),s.push(r.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),s.push(r.onDispose(()=>ty(s))),a.push(r)}}return 0===a.length?void 0:a}},Uy=class extends oy{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Sy)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Ky=class extends oy{constructor(e){super(),this._highlightTimeout=this._register(new ly),this._lineCache=this._register(new ly),this._state=new Wy,this._resultTracker=this._register(new Uy),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new jy(e),this._engine=new Hy(e,this._lineCache.value),this._decorationManager=new $y(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ry(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=zy(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,r=[],s=this._engine.find(e,0,0,t);for(;s&&((null==i?void 0:i.row)!==s.row||(null==i?void 0:i.col)!==s.col)&&!(r.length>=this._highlightLimit);)i=s,r.push(i),s=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(r,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(r,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},qy=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Jy.isErrorNoTelemetry(e)?new Jy(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Vy(e){(function(e){return e instanceof Qy||e instanceof Error&&e.name===Yy&&e.message===Yy})(e)||qy.onUnexpectedError(e)}var Yy="Canceled";var Gy,Xy,Qy=class extends Error{constructor(){super(Yy),this.name=this.message}},Jy=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function Zy(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function eb(e){if(Xy.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(sp){t.push(sp)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function tb(...e){return ib(()=>eb(e))}function ib(e){return{dispose:Zy(()=>{e()})}}(e=>{e.isLessThan=function(e){return e<0},e.isLessThanOrEqual=function(e){return e<=0},e.isGreaterThan=function(e){return e>0},e.isNeitherLessOrGreaterThan=function(e){return 0===e},e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Gy||(Gy={})),(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(Xy||(Xy={}));var rb=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{eb(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};rb.DISABLE_DISPOSED_WARNING=!1;var sb=rb,nb=class{constructor(){this._store=new sb,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};nb.None=Object.freeze({dispose(){}});var ob=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ab=typeof process<"u"&&"title"in process,lb=ab?"node":navigator.userAgent,hb=ab?"node":navigator.platform,cb=lb.includes("Firefox"),ub=lb.includes("Edge"),db=/^((?!chrome|android).)*safari/i.test(lb);hb.indexOf("Linux");var fb,_b,pb,gb,vb,mb=0,yb=0,bb=0,Sb=0,wb={css:"#00000000",rgba:0};function xb(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Cb(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function kb(e){if(!e)throw new Error("value must not be falsy");return e}function Lb(e){return 57508<=e&&e<=57558}function Eb(e){return Lb(e)||function(e){return 9472<=e&&e<=9631}(e)}function Mb(e,t,i=0){return(e-(2*Math.round(t)-i))%(2*Math.round(t))}(e=>{e.toCss=function(e,t,i,r){return void 0!==r?`#${xb(e)}${xb(t)}${xb(i)}${xb(r)}`:`#${xb(e)}${xb(t)}${xb(i)}`},e.toRgba=function(e,t,i,r=255){return(e<<24|t<<16|i<<8|r)>>>0},e.toColor=function(t,i,r,s){return{css:e.toCss(t,i,r,s),rgba:e.toRgba(t,i,r,s)}}})(fb||(fb={})),(e=>{function t(e,t){return Sb=Math.round(255*t),[mb,yb,bb]=vb.toChannels(e.rgba),{css:fb.toCss(mb,yb,bb,Sb),rgba:fb.toRgba(mb,yb,bb,Sb)}}e.blend=function(e,t){if(1===(Sb=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,r=t.rgba>>16&255,s=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return mb=n+Math.round((i-n)*Sb),yb=o+Math.round((r-o)*Sb),bb=a+Math.round((s-a)*Sb),{css:fb.toCss(mb,yb,bb),rgba:fb.toRgba(mb,yb,bb)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let r=vb.ensureContrastRatio(e.rgba,t.rgba,i);if(r)return fb.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[mb,yb,bb]=vb.toChannels(t),{css:fb.toCss(mb,yb,bb),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(Sb=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(_b||(_b={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return mb=parseInt(e.slice(1,2).repeat(2),16),yb=parseInt(e.slice(2,3).repeat(2),16),bb=parseInt(e.slice(3,4).repeat(2),16),fb.toColor(mb,yb,bb);case 5:return mb=parseInt(e.slice(1,2).repeat(2),16),yb=parseInt(e.slice(2,3).repeat(2),16),bb=parseInt(e.slice(3,4).repeat(2),16),Sb=parseInt(e.slice(4,5).repeat(2),16),fb.toColor(mb,yb,bb,Sb);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return mb=parseInt(r[1]),yb=parseInt(r[2]),bb=parseInt(r[3]),Sb=Math.round(255*(void 0===r[5]?1:parseFloat(r[5]))),fb.toColor(mb,yb,bb,Sb);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[mb,yb,bb,Sb]=t.getImageData(0,0,1,1).data,255!==Sb)throw new Error("css.toColor: Unsupported css format");return{rgba:fb.toRgba(mb,yb,bb,Sb),css:e}}})(pb||(pb={})),(e=>{function t(e,t,i){let r=e/255,s=t/255,n=i/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(gb||(gb={})),(e=>{function t(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));for(;h<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));for(;h<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(Sb=(255&t)/255))return t;let i=t>>24&255,r=t>>16&255,s=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return mb=n+Math.round((i-n)*Sb),yb=o+Math.round((r-o)*Sb),bb=a+Math.round((s-a)*Sb),fb.toRgba(mb,yb,bb)},e.ensureContrastRatio=function(e,r,s){let n=gb.relativeLuminance(e>>8),o=gb.relativeLuminance(r>>8);if(Cb(n,o)<s){if(o<n){let o=t(e,r,s),a=Cb(n,gb.relativeLuminance(o>>8));if(a<s){let t=i(e,r,s);return a>Cb(n,gb.relativeLuminance(t>>8))?o:t}return o}let a=i(e,r,s),l=Cb(n,gb.relativeLuminance(a>>8));if(l<s){let i=t(e,r,s);return l>Cb(n,gb.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(vb||(vb={}));var Rb,Tb=0,Pb=0,Db=!1,Bb=!1,Ab=!1,Nb=0,Ib=class{constructor(e,t,i,r,s,n){this._terminal=e,this._optionService=t,this._selectionRenderModel=i,this._decorationService=r,this._coreBrowserService=s,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(e,t,i,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=268435456&e.bg?e.extended.ext:0,Pb=0,Tb=0,Bb=!1,Db=!1,Ab=!1,Rb=this._themeService.colors,Nb=0,0!==e.getCode()&&4===e.extended.underlineStyle){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Nb=t*r%(2*Math.round(e))}if(this._decorationService.forEachDecorationAtCell(t,i,"bottom",e=>{e.backgroundColorRGB&&(Pb=e.backgroundColorRGB.rgba>>8&16777215,Bb=!0),e.foregroundColorRGB&&(Tb=e.foregroundColorRGB.rgba>>8&16777215,Db=!0)}),Ab=this._selectionRenderModel.isCellSelected(this._terminal,t,i)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:Pb=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:Pb=(16777215&this.result.fg)<<8|255;break;default:Pb=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:Pb=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:Pb=(16777215&this.result.bg)<<8|255}Pb=vb.blend(Pb,4294967040&(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else Pb=(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Bb=!0,Rb.selectionForeground&&(Tb=Rb.selectionForeground.rgba>>8&16777215,Db=!0),Eb(e.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))Tb=(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:Tb=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:Tb=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:Tb=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:Tb=(16777215&this.result.fg)<<8|255;break;default:Tb=this._themeService.colors.foreground.rgba}Tb=vb.blend(Tb,4294967040&(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Db=!0}}this._decorationService.forEachDecorationAtCell(t,i,"top",e=>{e.backgroundColorRGB&&(Pb=e.backgroundColorRGB.rgba>>8&16777215,Bb=!0),e.foregroundColorRGB&&(Tb=e.foregroundColorRGB.rgba>>8&16777215,Db=!0)}),Bb&&(Pb=Ab?-16777216&e.bg&-134217729|Pb|50331648:-16777216&e.bg|Pb|50331648),Db&&(Tb=-16777216&e.fg&-67108865|Tb|50331648),67108864&this.result.fg&&(Bb&&!Db&&(Tb=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&Rb.background.rgba>>8|50331648,Db=!0),!Bb&&Db&&(Pb=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&Rb.foreground.rgba>>8|50331648,Bb=!0)),Rb=void 0,this.result.bg=Bb?Pb:this.result.bg,this.result.fg=Db?Tb:this.result.fg,this.result.ext&=536870911,this.result.ext|=Nb<<29&3758096384}},Ob=cb||ub?"bottom":"ideographic",zb={"▀":[{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}]},Fb={"░":[[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]]},jb={"─":{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:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},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:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},Wb={"":{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}};function Hb(e,t,i,r,s,n,o,a){let l=zb[t];if(l)return function(e,t,i,r,s,n){for(let o=0;o<t.length;o++){let a=t[o],l=s/8,h=n/8;e.fillRect(i+a.x*l,r+a.y*h,a.w*l,a.h*h)}}(e,l,i,r,s,n),!0;let h=Fb[t];if(h)return function(e,t,i,r,s,n){let o=$b.get(t);o||(o=new Map,$b.set(t,o));let a=e.fillStyle;if("string"!=typeof a)throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let i=t[0].length,r=t.length,s=e.canvas.ownerDocument.createElement("canvas");s.width=i,s.height=r;let n,h,c,u,d=kb(s.getContext("2d")),f=new ImageData(i,r);if(a.startsWith("#"))n=parseInt(a.slice(1,3),16),h=parseInt(a.slice(3,5),16),c=parseInt(a.slice(5,7),16),u=a.length>7&&parseInt(a.slice(7,9),16)||1;else{if(!a.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);[n,h,c,u]=a.substring(5,a.length-1).split(",").map(e=>parseFloat(e))}for(let e=0;e<r;e++)for(let r=0;r<i;r++)f.data[4*(e*i+r)]=n,f.data[4*(e*i+r)+1]=h,f.data[4*(e*i+r)+2]=c,f.data[4*(e*i+r)+3]=t[e][r]*(255*u);d.putImageData(f,0,0),l=kb(e.createPattern(s,null)),o.set(a,l)}e.fillStyle=l,e.fillRect(i,r,s,n)}(e,h,i,r,s,n),!0;let c=jb[t];if(c)return function(e,t,i,r,s,n,o){e.strokeStyle=e.fillStyle;for(let[a,l]of Object.entries(t)){let t;if(e.beginPath(),e.lineWidth=o*Number.parseInt(a),"function"==typeof l){t=l(.15,.15/n*s)}else t=l;for(let a of t.split(" ")){let t=a[0],l=Kb[t];if(!l){console.error(`Could not find drawing instructions for "${t}"`);continue}let h=a.substring(1).split(",");!h[0]||!h[1]||l(e,qb(h,s,n,i,r,!0,o))}e.stroke(),e.closePath()}}(e,c,i,r,s,n,a),!0;let u=Wb[t];return!!u&&(function(e,t,i,r,s,n,o,a){let l=new Path2D;l.rect(i,r,s,n),e.clip(l),e.beginPath();let h=o/12;e.lineWidth=a*h;for(let c of t.d.split(" ")){let o=c[0],l=Kb[o];if(!l){console.error(`Could not find drawing instructions for "${o}"`);continue}let u=c.substring(1).split(",");!u[0]||!u[1]||l(e,qb(u,s,n,i,r,!1,a,(t.leftPadding??0)*(h/2),(t.rightPadding??0)*(h/2)))}1===t.type?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}(e,u,i,r,s,n,o,a),!0)}Wb[""]=Wb[""],Wb[""]=Wb[""];var $b=new Map;function Ub(e,t,i=0){return Math.max(Math.min(e,t),i)}var Kb={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function qb(e,t,i,r,s,n,o,a=0,l=0){let h=e.map(e=>parseFloat(e)||parseInt(e));if(h.length<2)throw new Error("Too few arguments for instruction");for(let c=0;c<h.length;c+=2)h[c]*=t-a*o-l*o,n&&0!==h[c]&&(h[c]=Ub(Math.round(h[c]+.5)-.5,t,0)),h[c]+=r+a*o;for(let c=1;c<h.length;c+=2)h[c]*=i,n&&0!==h[c]&&(h[c]=Ub(Math.round(h[c]+.5)-.5,i,0)),h[c]+=s;return h}var Vb,Yb=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Gb=class{constructor(){this._data=new Yb}set(e,t,i,r,s){this._data.get(e,t)||this._data.set(e,t,new Yb),this._data.get(e,t).set(i,r,s)}get(e,t,i,r){var s;return null==(s=this._data.get(e,t))?void 0:s.get(i,r)}clear(){this._data.clear()}},Xb=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),s=e.timeRemaining(),1.5*i>s)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=s}this.clear()}},Qb=!ab&&"requestIdleCallback"in window?class extends Xb{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends Xb{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Jb=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Zb}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Zb=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},eS=globalThis.performance&&"function"==typeof globalThis.performance.now,tS=class e{static create(t){return new e(t)}constructor(e){this._now=eS&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new dS({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,h,c,u=0,d=new dS({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!h&&(d.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){s&&u>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>nb.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(tb(...e.map(e=>e(e=>t.call(i,e)))),r)},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new dS({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new dS({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new dS({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new dS;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new dS(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof sb?r.add(a):Array.isArray(r)&&r.push(a),a}}})(Vb||(Vb={}));var iS=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new tS,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};iS.all=new Set,iS._idPool=0;var rS=iS,sS=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new lS(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};sS._idPool=1;var nS,oS=sS,aS=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},lS=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},hS=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},cS=0,uS=class{constructor(e){this.value=e,this.id=cS++}},dS=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new oS((null==e?void 0:e.onListenerError)??Vy,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new rS(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new hS(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||Vy)(i),nb.None}if(this._disposed)return nb.None;t&&(e=e.bind(t));let l,h=new uS(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=aS.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof uS?(this._deliveryQueue??(this._deliveryQueue=new fS),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=ib(()=>{null==l||l(),this._removeListener(h)});return i instanceof sb?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||Vy;if(r)try{e.value(t)}catch(s){r(s)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof uS)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},fS=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_S={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}},pS=class e{constructor(e,t,i){this._document=e,this._config=t,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new Gb,this._cacheMapCombined=new Gb,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Jb,this._textureSize=512,this._onAddTextureAtlasCanvas=new dS,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new dS,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=mS(e,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=kb(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Qb;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>2*t.canvas.width<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width!==e.canvas.width?t.canvas.width-e.canvas.width:t.percentageUsed-e.percentageUsed),i=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)i=e,r=t[e].canvas.width;else if(e-i===3)break;let s=t.slice(i,i+4),n=s.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-s.length,a=this._mergePages(s,o);a.version++;for(let e=n.length-1;e>=0;e--)this._deletePage(n[e]);this.pages.push(a),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(a.canvas)}let t=new gS(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let i=2*e[0].canvas.width,r=new gS(this._document,i,e);for(let[s,n]of e.entries()){let e=s*n.canvas.width%i,o=Math.floor(s/2)*n.canvas.height;r.ctx.drawImage(n.canvas,e,o);for(let r of n.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/i,r.sizeClipSpace.y=r.size.y/i,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/i,r.texturePositionClipSpace.y=r.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(n.canvas);let a=this._activePages.indexOf(n);-1!==a&&this._activePages.splice(a,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMapCombined,e,t,i,r,s,n)}getRasterizedGlyph(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMap,e,t,i,r,s,n)}_getFromCacheMap(e,t,i,r,s,n,o){return(nS=e.get(t,i,r,s))||(nS=this._drawToCache(t,i,r,s,n,o),e.set(t,i,r,s,nS)),nS}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,i,r){if(this._config.allowTransparency)return wb;let s;switch(e){case 16777216:case 33554432:s=this._getColorFromAnsiIndex(t);break;case 50331648:let e=Jb.toColorRGB(t);s=fb.toColor(e[0],e[1],e[2]);break;default:s=i?_b.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(s=_b.opaque(s)),s}_getForegroundColor(e,t,i,r,s,n,o,a,l,h){let c,u=this._getMinimumContrastColor(e,t,i,r,s,n,o,l,a,h);if(u)return u;switch(s){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&n<8&&(n+=8),c=this._getColorFromAnsiIndex(n);break;case 50331648:let e=Jb.toColorRGB(n);c=fb.toColor(e[0],e[1],e[2]);break;default:c=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(c=_b.opaque(c)),a&&(c=_b.multiplyOpacity(c,.5)),c}_resolveBackgroundRgba(e,t,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,i,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,i,r,s,n,o,a,l,h){if(1===this._config.minimumContrastRatio||h)return;let c=this._getContrastCache(l),u=c.getColor(e,r);if(void 0!==u)return u||void 0;let d=this._resolveBackgroundRgba(t,i,o),f=this._resolveForegroundRgba(s,n,o,a),_=vb.ensureContrastRatio(d,f,this._config.minimumContrastRatio/(l?2:1));if(!_)return void c.setColor(e,r,null);let p=fb.toColor(_>>24&255,_>>16&255,_>>8&255);return c.setColor(e,r,p),p}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,i,r,s,n,o){let a="number"==typeof t?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let h=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,this._workAttributeData.isInvisible())return _S;let c=!!this._workAttributeData.isBold(),u=!!this._workAttributeData.isInverse(),d=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),_=!!this._workAttributeData.isUnderline(),p=!!this._workAttributeData.isStrikethrough(),g=!!this._workAttributeData.isOverline(),v=this._workAttributeData.getFgColor(),m=this._workAttributeData.getFgColorMode(),y=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(u){let e=v;v=y,y=e;let t=m;m=b,b=t}let S=this._getBackgroundColor(b,y,u,d);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=S.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let w=c?this._config.fontWeightBold:this._config.fontWeight,x=f?"italic":"";this._tmpCtx.font=`${x} ${w} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=Ob;let C=1===a.length&&Lb(a.charCodeAt(0)),k=1===a.length&&function(e){return 57520<=e&&e<=57527}(a.charCodeAt(0)),L=this._getForegroundColor(i,b,y,r,m,v,u,d,c,Eb(a.charCodeAt(0)));this._tmpCtx.fillStyle=L.css;let E=k?0:4,M=!1;!1!==this._config.customGlyphs&&(M=Hb(this._tmpCtx,a,E,E,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let R,T=!C;if(R="number"==typeof t?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),_){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())T=!1,this._tmpCtx.strokeStyle=`rgb(${Jb.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{T=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let i=E,r=Math.ceil(E+this._config.deviceCharHeight)-t-(n?2*e:0),s=r+e,o=r+2*e,l=this._workAttributeData.getUnderlineVariantOffset();for(let n=0;n<R;n++){this._tmpCtx.save();let a=i+n*this._config.deviceCellWidth,h=i+(n+1)*this._config.deviceCellWidth,c=a+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r),this._tmpCtx.moveTo(a,o),this._tmpCtx.lineTo(h,o);break;case 3:let i=e<=1?o:Math.ceil(E+this._config.deviceCharHeight-e/2)-t,n=e<=1?r:Math.ceil(E+this._config.deviceCharHeight+e/2)-t,u=new Path2D;u.rect(a,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(u),this._tmpCtx.moveTo(a-this._config.deviceCellWidth/2,s),this._tmpCtx.bezierCurveTo(a-this._config.deviceCellWidth/2,n,a,n,a,s),this._tmpCtx.bezierCurveTo(a,i,c,i,c,s),this._tmpCtx.bezierCurveTo(c,n,h,n,h,s),this._tmpCtx.bezierCurveTo(h,i,h+this._config.deviceCellWidth/2,i,h+this._config.deviceCellWidth/2,s);break;case 4:let d=0===l?0:l>=e?2*e-l:e-l;!1==!(l>=e)||0===d?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a+d,r),this._tmpCtx.lineTo(h,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(a+d,r),this._tmpCtx.moveTo(a+d+e,r),this._tmpCtx.lineTo(h,r)),l=Mb(h-a,e,l);break;case 5:let f=.6,_=.3,p=h-a,g=Math.floor(f*p),v=Math.floor(_*p),m=p-g-v;this._tmpCtx.setLineDash([g,v,m]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r);break;default:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!M&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==a){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let t=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(i,r-Math.ceil(e/2),this._config.deviceCellWidth*R,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=S.css,this._tmpCtx.strokeText(a,E,E+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*R,E+t),this._tmpCtx.stroke()}if(M||this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight),"_"===a&&!this._config.allowTransparency){let e=vS(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),S,L,T);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=S.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight-t),e=vS(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),S,L,T),e);t++);}if(p){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*R,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let P,D=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(P=this._config.allowTransparency?function(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}(D):vS(D,S,L,T),P)return _S;let B,A,N=this._findGlyphBoundingBox(D,this._workBoundingBox,l,k,M,E);for(;;){if(0===this._activePages.length){let e=this._createNewPage();B=e,A=e.currentRow,A.height=N.size.y;break}B=this._activePages[this._activePages.length-1],A=B.currentRow;for(let e of this._activePages)N.size.y<=e.currentRow.height&&(B=e,A=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=A.height&&N.size.y<=t.height&&(B=this._activePages[e],A=t);if(N.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new gS(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),B=this._overflowSizePage,A=this._overflowSizePage.currentRow,A.x+N.size.x>=B.canvas.width&&(A.x=0,A.y+=A.height,A.height=0);break}if(A.y+N.size.y>=B.canvas.height||A.height>N.size.y+2){let t=!1;if(B.currentRow.y+B.currentRow.height+N.size.y>=B.canvas.height){let i;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+N.size.y<e.canvas.height){i=e;break}if(i)B=i;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&A.y+N.size.y<=B.canvas.height&&A.height>=N.size.y&&A.x+N.size.x<=B.canvas.width)t=!0;else{let e=this._createNewPage();B=e,A=e.currentRow,A.height=N.size.y,t=!0}}t||(B.currentRow.height>0&&B.fixedRows.push(B.currentRow),A={x:0,y:B.currentRow.y+B.currentRow.height,height:N.size.y},B.fixedRows.push(A),B.currentRow={x:0,y:A.y+A.height,height:0})}if(A.x+N.size.x<=B.canvas.width)break;A===B.currentRow?(A.x=0,A.y+=A.height,A.height=0):B.fixedRows.splice(B.fixedRows.indexOf(A),1)}return N.texturePage=this._pages.indexOf(B),N.texturePosition.x=A.x,N.texturePosition.y=A.y,N.texturePositionClipSpace.x=A.x/B.canvas.width,N.texturePositionClipSpace.y=A.y/B.canvas.height,N.sizeClipSpace.x/=B.canvas.width,N.sizeClipSpace.y/=B.canvas.height,A.height=Math.max(A.height,N.size.y),A.x+=N.size.x,B.ctx.putImageData(D,N.texturePosition.x-this._workBoundingBox.left,N.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,N.size.x,N.size.y),B.addGlyph(N),B.version++,N}_findGlyphBoundingBox(e,t,i,r,s,n){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,a=r?this._config.deviceCellWidth:i,l=!1;for(let h=0;h<o;h++){for(let i=0;i<a;i++){let r=h*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.top=h,l=!0;break}}if(l)break}t.left=0,l=!1;for(let h=0;h<n+a;h++){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*h+3;if(0!==e.data[r]){t.left=h,l=!0;break}}if(l)break}t.right=a,l=!1;for(let h=n+a-1;h>=n;h--){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*h+3;if(0!==e.data[r]){t.right=h,l=!0;break}}if(l)break}t.bottom=o,l=!1;for(let h=o-1;h>=0;h--){for(let i=0;i<a;i++){let r=h*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.bottom=h,l=!0;break}}if(l)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+n+(r||s?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+n+(r||s?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},gS=class{constructor(e,t,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let r of i)this._glyphs.push(...r.glyphs),this._usedPixels+=r._usedPixels;this.canvas=mS(e,t,t),this.ctx=kb(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.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 vS(e,t,i,r){let s=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,h=i.rgba>>>8&255,c=Math.floor((Math.abs(s-a)+Math.abs(n-l)+Math.abs(o-h))/12),u=!0;for(let d=0;d<e.data.length;d+=4)e.data[d]===s&&e.data[d+1]===n&&e.data[d+2]===o||r&&Math.abs(e.data[d]-s)+Math.abs(e.data[d+1]-n)+Math.abs(e.data[d+2]-o)<c?e.data[d+3]=0:u=!1;return u}function mS(e,t,i){let r=e.createElement("canvas");return r.width=t,r.height=i,r}function yS(e,t){for(let i=0;i<e.colors.ansi.length;i++)if(e.colors.ansi[i].rgba!==t.colors.ansi[i].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}var bS=[];function SS(e,t,i,r,s,n,o,a,l){let h=function(e,t,i,r,s,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:wb,cursorAccent:wb,selectionForeground:wb,selectionBackgroundTransparent:wb,selectionBackgroundOpaque:wb,selectionInactiveBackgroundTransparent:wb,selectionInactiveBackgroundOpaque:wb,overviewRulerBorder:wb,scrollbarSliderBackground:wb,scrollbarSliderHoverBackground:wb,scrollbarSliderActiveBackground:wb,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:a,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:i,deviceCharHeight:r,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:l}}(r,s,n,o,t,i,a,l);for(let d=0;d<bS.length;d++){let t=bS[d],i=t.ownedBy.indexOf(e);if(i>=0){if(yS(t.config,h))return t.atlas;1===t.ownedBy.length?(t.atlas.dispose(),bS.splice(d,1)):t.ownedBy.splice(i,1);break}}for(let d=0;d<bS.length;d++){let t=bS[d];if(yS(t.config,h))return t.ownedBy.push(e),t.atlas}let c=e._core,u={atlas:new pS(document,h,c.unicodeService),config:h,ownedBy:[e]};return bS.push(u),u.atlas}function wS(e){for(let t=0;t<bS.length;t++){let i=bS[t].ownedBy.indexOf(e);if(-1!==i){1===bS[t].ownedBy.length?(bS[t].atlas.dispose(),bS.splice(t,1)):bS[t].ownedBy.splice(i,1);break}}}var xS=600,CS=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,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(e=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=xS-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0)return void this._restartInterval(e)}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=xS-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(e)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},xS)},e)}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 kS(e,t,i){let r=new t.ResizeObserver(t=>{let s=t.find(t=>t.target===e);if(!s)return;if(!("devicePixelContentBoxSize"in s))return null==r||r.disconnect(),void(r=void 0);let n=s.devicePixelContentBoxSize[0].inlineSize,o=s.devicePixelContentBoxSize[0].blockSize;n>0&&o>0&&i(n,o)});try{r.observe(e,{box:["device-pixel-content-box"]})}catch{r.disconnect(),r=void 0}return ib(()=>null==r?void 0:r.disconnect())}var LS=class e extends Jb{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Zb,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ES=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function MS(e,t,i){let r=kb(e.createProgram());if(e.attachShader(r,kb(RS(e,e.VERTEX_SHADER,t))),e.attachShader(r,kb(RS(e,e.FRAGMENT_SHADER,i))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function RS(e,t,i){let r=kb(e.createShader(t));if(e.shaderSource(r,i),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}var TS=class{constructor(e){this.texture=e,this.version=-1}};var PS,DS=11,BS=DS*Float32Array.BYTES_PER_ELEMENT,AS=0,NS=0,IS=0,OS=class extends nb{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._optionsService=r,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;void 0===pS.maxAtlasPages&&(pS.maxAtlasPages=Math.min(32,kb(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),pS.maxTextureSize=kb(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=kb(MS(s,"#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(e){let t="";for(let i=1;i<e;i++)t+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${e}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${t}\n}`}(pS.maxAtlasPages))),this._register(ib(()=>s.deleteProgram(this._program))),this._projectionLocation=kb(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=kb(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=kb(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(ib(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(ib(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=kb(s.createBuffer()),this._register(ib(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,BS,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,BS,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,BS,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,BS,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,BS,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,BS,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let h=new Int32Array(pS.maxAtlasPages);for(let c=0;c<pS.maxAtlasPages;c++)h[c]=c;s.uniform1iv(this._textureLocation,h),s.uniformMatrix4fv(this._projectionLocation,!1,ES),this._atlasTextures=[];for(let c=0;c<pS.maxAtlasPages;c++){let e=new TS(kb(s.createTexture()));this._register(ib(()=>s.deleteTexture(e.texture))),s.activeTexture(s.TEXTURE0+c),s.bindTexture(s.TEXTURE_2D,e.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[c]=e}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,i,r,s,n,o,a,l){this._updateCell(this._vertices.attributes,e,t,i,r,s,n,o,a,l)}_updateCell(e,t,i,r,s,n,o,a,l,h){AS=(i*this._terminal.cols+t)*DS,0!==r&&void 0!==r?this._atlas&&(PS=a&&a.length>1?this._atlas.getRasterizedGlyphCombinedChar(a,s,n,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,s,n,o,!1,this._terminal.element),NS=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==h&&PS.offset.x>NS?(IS=PS.offset.x-NS,e[AS]=-(PS.offset.x-IS)+this._dimensions.device.char.left,e[AS+1]=-PS.offset.y+this._dimensions.device.char.top,e[AS+2]=(PS.size.x-IS)/this._dimensions.device.canvas.width,e[AS+3]=PS.size.y/this._dimensions.device.canvas.height,e[AS+4]=PS.texturePage,e[AS+5]=PS.texturePositionClipSpace.x+IS/this._atlas.pages[PS.texturePage].canvas.width,e[AS+6]=PS.texturePositionClipSpace.y,e[AS+7]=PS.sizeClipSpace.x-IS/this._atlas.pages[PS.texturePage].canvas.width,e[AS+8]=PS.sizeClipSpace.y):(e[AS]=-PS.offset.x+this._dimensions.device.char.left,e[AS+1]=-PS.offset.y+this._dimensions.device.char.top,e[AS+2]=PS.size.x/this._dimensions.device.canvas.width,e[AS+3]=PS.size.y/this._dimensions.device.canvas.height,e[AS+4]=PS.texturePage,e[AS+5]=PS.texturePositionClipSpace.x,e[AS+6]=PS.texturePositionClipSpace.y,e[AS+7]=PS.sizeClipSpace.x,e[AS+8]=PS.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(e,t,i,r){return 1===t&&i>Math.ceil(1.5*r)&&void 0!==e&&e>255&&!function(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}(e)&&!Lb(e)&&!function(e){return 57344<=e&&e<=63743}(e)}(r,l,PS.size.x,this._dimensions.device.cell.width)&&(e[AS+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):e.fill(0,AS,AS+DS-1-2)}clear(){let e=this._terminal,t=e.cols*e.rows*DS;this._vertices.count!==t?this._vertices.attributes=new Float32Array(t):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==t?this._vertices.attributesBuffers[i]=new Float32Array(t):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=t,i=0;for(let r=0;r<e.rows;r++)for(let t=0;t<e.cols;t++)this._vertices.attributes[i+9]=t/e.cols,this._vertices.attributes[i+10]=r/e.rows,i+=DS}handleResize(){let e=this._gl;e.useProgram(this._program),e.viewport(0,0,e.canvas.width,e.canvas.height),e.uniform2f(this._resolutionLocation,e.canvas.width,e.canvas.height),this.clear()}render(e){if(!this._atlas)return;let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],r=0;for(let s=0;s<e.lineLengths.length;s++){let t=s*this._terminal.cols*DS,n=this._vertices.attributes.subarray(t,t+e.lineLengths[s]*DS);i.set(n,r),r+=n.length}t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,i.subarray(0,r),t.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(t,this._atlas,s);t.drawElementsInstanced(t.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,r/DS)}setAtlas(e){this._atlas=e;for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(e,t,i){e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,this._atlasTextures[i].texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.pages[i].canvas),e.generateMipmap(e.TEXTURE_2D),this._atlasTextures[i].version=t.pages[i].version}setDimensions(e){this._dimensions=e}},zS=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1])return void this.clear();let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0])}isCellSelected(e,t,i){return!!this.hasSelection&&(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol)}};var FS=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new zS}resize(e,t){let i=e*t*4;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},jS=8*Float32Array.BYTES_PER_ELEMENT,WS=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},HS=0,$S=0,US=0,KS=0,qS=0,VS=0,YS=0,GS=class extends nb{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._themeService=r,this._vertices=new WS,this._verticesCursor=new WS;let s=this._gl;this._program=kb(MS(s,"#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(ib(()=>s.deleteProgram(this._program))),this._projectionLocation=kb(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(ib(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(ib(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=kb(s.createBuffer()),this._register(ib(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,jS,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,jS,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,jS,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,ES),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.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(e){let t,i,r,s,n,o,a,l,h,c,u,d=this._terminal,f=this._vertices,_=1;for(t=0;t<d.rows;t++){for(r=-1,s=0,n=0,o=!1,i=0;i<d.cols;i++)a=4*(t*d.cols+i),l=e.cells[a+1],h=e.cells[a+2],c=!!(67108864&h),(l!==s||h!==n&&(o||c))&&((0!==s||o&&0!==n)&&(u=8*_++,this._updateRectangle(f,u,n,s,r,i,t)),r=i,s=l,n=h,o=c);(0!==s||o&&0!==n)&&(u=8*_++,this._updateRectangle(f,u,n,s,r,d.cols,t))}f.count=_}updateCursor(e){let t=this._verticesCursor,i=e.cursor;if(!i||"block"===i.style)return void(t.count=0);let r,s=0;("bar"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,"bar"===i.style?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),"outline"===i.style&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),r=8*s++,this._addRectangleFloat(t.attributes,r,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=s}_updateRectangle(e,t,i,r,s,n,o){if(67108864&i)switch(50331648&i){case 16777216:case 33554432:HS=this._themeService.colors.ansi[255&i].rgba;break;case 50331648:HS=(16777215&i)<<8;break;default:HS=this._themeService.colors.foreground.rgba}else switch(50331648&r){case 16777216:case 33554432:HS=this._themeService.colors.ansi[255&r].rgba;break;case 50331648:HS=(16777215&r)<<8;break;default:HS=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=function(e,t){let i=Math.min(2*e.length,t),r=new Float32Array(i);for(let s=0;s<e.length;s++)r[s]=e[s];return r}(e.attributes,this._terminal.rows*this._terminal.cols*8)),$S=s*this._dimensions.device.cell.width,US=o*this._dimensions.device.cell.height,KS=(HS>>24&255)/255,qS=(HS>>16&255)/255,VS=(HS>>8&255)/255,YS=1,this._addRectangle(e.attributes,t,$S,US,(n-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,KS,qS,VS,YS)}_addRectangle(e,t,i,r,s,n,o,a,l,h){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=n/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=a,e[t+6]=l,e[t+7]=h}_addRectangleFloat(e,t,i,r,s,n,o){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=n/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(255&e.rgba)/255])}},XS=class extends nb{constructor(e,t,i,r,s,n,o,a){super(),this._container=t,this._alpha=s,this._coreBrowserService=n,this._optionsService=o,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(ib(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=kb(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,i){}handleSelectionChanged(e,t,i,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let i=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=SS(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,i=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,i,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,i,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=Ob,this._clipCell(i,r,t.getWidth()),this._ctx.fillText(t.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,i){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,i){return`${i?"italic":""} ${t?e.options.fontWeightBold:e.options.fontWeight} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},QS=class extends XS{constructor(e,t,i,r,s,n,o){super(i,e,"link",t,!0,s,n,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(257===e.fg?this._ctx.fillStyle=this._themeService.colors.background.css:void 0!==e.fg&&function(e){return 16777216==(50331648&e)||33554432==(50331648&e)}(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},JS="object"==typeof window?window:globalThis,ZS=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new dS,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new dS,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};ZS.INSTANCE=new ZS;var ew=ZS;ew.INSTANCE.onDidChangeZoomLevel,ew.INSTANCE.onDidChangeFullscreen;var tw="object"==typeof navigator?navigator.userAgent:"";tw.indexOf("Firefox"),tw.indexOf("AppleWebKit"),!(tw.indexOf("Chrome")>=0)&&tw.indexOf("Safari"),tw.indexOf("Electron/"),tw.indexOf("Android");var iw=!1;if("function"==typeof JS.matchMedia){let e=JS.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=JS.matchMedia("(display-mode: fullscreen)");iw=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(JS,e,({matches:e})=>{iw&&t.matches||(iw=e)})}var rw,sw,nw="en",ow=!1,aw=nw,lw=globalThis;typeof lw.vscode<"u"&&typeof lw.vscode.process<"u"?sw=lw.vscode.process:typeof process<"u"&&"string"==typeof(null==(o=null==process?void 0:process.versions)?void 0:o.node)&&(sw=process);var hw="string"==typeof(null==(a=null==sw?void 0:sw.versions)?void 0:a.electron)&&"renderer"===(null==sw?void 0:sw.type);if("object"==typeof sw){sw.platform,sw.platform,"linux"===sw.platform&&!!sw.env.SNAP&&sw.env.SNAP_REVISION,!!sw.env.CI||sw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,aw=nw;let e=sw.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,aw=t.resolvedLanguage||nw,null==(l=t.languagePack)?void 0:l.translationsConfigFile}catch{}ow=!0}else"object"!=typeof navigator||hw?console.error("Unable to resolve platform."):((rw=navigator.userAgent).indexOf("Windows"),rw.indexOf("Macintosh"),(rw.indexOf("Macintosh")>=0||rw.indexOf("iPad")>=0||rw.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,rw.indexOf("Linux")>=0,null==rw||rw.indexOf("Mobi"),aw=globalThis._VSCODE_NLS_LANGUAGE||nw,navigator.language.toLowerCase());var cw,uw=ow,dw=rw,fw=aw;(e=>{e.value=function(){return fw},e.isDefaultVariant=function(){return 2===fw.length?"en"===fw:fw.length>=3&&("e"===fw[0]&&"n"===fw[1]&&"-"===fw[2])},e.isDefault=function(){return"en"===fw}})(cw||(cw={}));var _w="function"==typeof lw.postMessage&&!lw.importScripts;(()=>{if(_w){let e=[];lw.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),lw.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var pw=!!(dw&&dw.indexOf("Chrome")>=0);dw&&dw.indexOf("Firefox"),!pw&&dw&&dw.indexOf("Safari"),dw&&dw.indexOf("Edg/"),dw&&dw.indexOf("Android");var gw="object"==typeof navigator?navigator:{};uw||document.queryCommandSupported&&document.queryCommandSupported("copy")||gw&&gw.clipboard&&gw.clipboard.writeText,uw||gw&&gw.clipboard&&gw.clipboard.readText;var vw,mw,yw=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},bw=new yw,Sw=new yw,ww=new yw;new Array(230),(mw=vw||(vw={})).toString=function(e){return bw.keyCodeToStr(e)},mw.fromString=function(e){return bw.strToKeyCode(e)},mw.toUserSettingsUS=function(e){return Sw.keyCodeToStr(e)},mw.toUserSettingsGeneral=function(e){return ww.keyCodeToStr(e)},mw.fromUserSettings=function(e){return Sw.strToKeyCode(e)||ww.strToKeyCode(e)},mw.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return bw.keyCodeToStr(e)};var xw,Cw=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Lw||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Vb.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Cw})})(xw||(xw={}));var kw,Lw=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?Cw:(this._emitter||(this._emitter=new dS),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(e=>{e.settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},e.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(mw){i(mw)}})}})(kw||(kw={}));var Ew=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new dS,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await Vb.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Ew.EMPTY=Ew.fromArray([]);var{getWindow:Mw}=function(){let e=new Map,t={window:JS,disposables:new sb};e.set(JS.vscodeWindowId,t);let i=new dS,r=new dS,s=new dS;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return nb.None;let n=new sb,o={window:t,disposables:n.add(new sb)};return e.set(t.vscodeWindowId,o),n.add(ib(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),n.add(Tw(t,Pw.BEFORE_UNLOAD,()=>{s.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,r){return("number"==typeof i?e.get(i):void 0)??(r?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let r=e;return(null==r?void 0:r.view)?r.view.window:JS},getDocument:e=>Mw(e).document}}(),Rw=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Tw(e,t,i,r){return new Rw(e,t,i,r)}var Pw={BEFORE_UNLOAD:"beforeunload"},Dw=class extends nb{constructor(e,t,i,r,s,n,o,a,l){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new ob,this._charAtlasDisposable=this._register(new ob),this._observerDisposable=this._register(new ob),this._model=new FS,this._workCell=new LS,this._workCell2=new LS,this._rectangleRenderer=this._register(new ob),this._glyphRenderer=this._register(new ob),this._onChangeTextureAtlas=this._register(new dS),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new dS),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new dS),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new dS),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new dS),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Ib(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new QS(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,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(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Tw(this._canvas,"webglcontextlost",e=>{console.log("webglcontextlost event received"),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(e)},3e3)})),this._register(Tw(this._canvas,"webglcontextrestored",e=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,wS(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=kS(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=kS(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(ib(()=>{var e;for(let t of this._renderLayers)t.dispose();null==(e=this._canvas.parentElement)||e.removeChild(this._canvas),wS(this._terminal)}))}get textureAtlas(){var e;return null==(e=this._charAtlas)?void 0:e.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(e,t){var i,r,s,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.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`,null==(i=this._rectangleRenderer.value)||i.setDimensions(this.dimensions),null==(r=this._rectangleRenderer.value)||r.handleResize(),null==(s=this._glyphRenderer.value)||s.setDimensions(this.dimensions),null==(n=this._glyphRenderer.value)||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var e;for(let t of this._renderLayers)t.handleBlur(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.pause(),this._requestRedrawViewport()}handleFocus(){var e;for(let t of this._renderLayers)t.handleFocus(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,i){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,i);this._model.selection.update(this._core,e,t,i),this._requestRedrawViewport()}handleCursorMove(){var e;for(let t of this._renderLayers)t.handleCursorMove(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new GS(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new OS(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);let t=SS(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=tb(Vb.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Vb.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),null==(e=this._glyphRenderer.value)||e.setAtlas(this._charAtlas)}_clearModel(e){var t;this._model.clear(),e&&(null==(t=this._glyphRenderer.value)||t.clear())}clearTextureAtlas(){var e;null==(e=this._charAtlas)||e.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var e;this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){var i;if(!this._isAttached){if(!((null==(i=this._core.screenElement)?void 0:i.isConnected)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let r of this._renderLayers)r.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),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 CS(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let i,r,s,n,o,a,l,h,c,u,d,f,_,p,g,v=this._core,m=this._workCell,y=0,b=!0;e=Aw(e,v.rows-1,0),t=Aw(t,v.rows-1,0);let S=this._coreService.decPrivateModes.cursorStyle??v.options.cursorStyle??"block",w=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,x=w-v.buffer.ydisp,C=Math.min(this._terminal.buffer.active.cursorX,v.cols-1),k=-1,L=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let E=!1;for(r=e;r<=t;r++)for(s=r+v.buffer.ydisp,n=v.buffer.lines.get(s),this._model.lineLengths[r]=0,c=w===s,y=0,o=this._characterJoinerService.getJoinedCharacters(s),p=0;p<v.cols;p++){if(i=this._cellColorResolver.result.bg,n.loadCell(p,m),0===p&&(i=this._cellColorResolver.result.bg),a=!1,b=p>=y,l=p,o.length>0&&p===o[0][0]&&b){h=o.shift();let e=this._model.selection.isCellSelected(this._terminal,h[0],s);for(_=h[0]+1;_<h[1];_++)b&&(b=e===this._model.selection.isCellSelected(this._terminal,_,s));b&&(b=!c||C<h[0]||C>=h[1]),b?(a=!0,m=new Bw(m,n.translateToString(!0,h[0],h[1]),h[1]-h[0]),l=h[1]-1):y=h[1]}if(u=m.getChars(),d=m.getCode(),_=4*(r*v.cols+p),this._cellColorResolver.resolve(m,p,s,this.dimensions.device.cell.width),L&&s===w&&(p===C&&(this._model.cursor={x:C,y:x,width:m.getWidth(),style:this._coreBrowserService.isFocused?S:v.options.cursorInactiveStyle,cursorWidth:v.options.cursorWidth,dpr:this._devicePixelRatio},k=C+m.getWidth()-1),p>=C&&p<=k&&(this._coreBrowserService.isFocused&&"block"===S||!1===this._coreBrowserService.isFocused&&"block"===v.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!==d&&(this._model.lineLengths[r]=p+1),(this._model.cells[_]!==d||this._model.cells[_+1]!==this._cellColorResolver.result.bg||this._model.cells[_+2]!==this._cellColorResolver.result.fg||this._model.cells[_+3]!==this._cellColorResolver.result.ext)&&(E=!0,u.length>1&&(d|=2147483648),this._model.cells[_]=d,this._model.cells[_+1]=this._cellColorResolver.result.bg,this._model.cells[_+2]=this._cellColorResolver.result.fg,this._model.cells[_+3]=this._cellColorResolver.result.ext,f=m.getWidth(),this._glyphRenderer.value.updateCell(p,r,d,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,u,f,i),a)){for(m=this._workCell,p++;p<=l;p++)g=4*(r*v.cols+p),this._glyphRenderer.value.updateCell(p,r,0,0,0,0,"",0,0),this._model.cells[g]=0,this._model.cells[g+1]=this._cellColorResolver.result.bg,this._model.cells[g+2]=this._cellColorResolver.result.fg,this._model.cells[g+3]=this._cellColorResolver.result.ext;p--}}E&&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(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Bw=class extends Jb{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Aw(e,t,i=0){return Math.max(Math.min(e,t),i)}var Nw="di$target",Iw="di$dependencies",Ow=new Map;function zw(e){if(Ow.has(e))return Ow.get(e);let t=function(e,i,r){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[Nw]===t?t[Iw].push({id:e,index:i}):(t[Iw]=[{id:e,index:i}],t[Nw]=t)}(t,e,r)};return t._id=e,Ow.set(e,t),t}zw("BufferService"),zw("CoreMouseService"),zw("CoreService"),zw("CharsetService"),zw("InstantiationService"),zw("LogService");var Fw=zw("OptionsService");zw("OscLinkService"),zw("UnicodeService"),zw("DecorationService");var jw={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ww=class extends nb{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=jw[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Ww=((e,t)=>{for(var i,r=t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=i(r)||r);return r})([((e,t)=>(i,r)=>t(i,r,e))(0,Fw)],Ww);var Hw=class extends nb{constructor(e){if(db&&function(){if(!db)return 0;let e=lb.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new dS),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new dS),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new dS),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new dS),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element)return void this._register(t.onWillOpen(()=>this.activate(e)));this._terminal=e;let i=t.coreService,r=t.optionsService,s=t,n=s._renderService,o=s._characterJoinerService,a=s._charSizeService,l=s._coreBrowserService,h=s._decorationService;s._logService;let c=s._themeService;this._renderer=this._register(new Dw(e,o,a,l,i,h,r,c,this._preserveDrawingBuffer)),this._register(Vb.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Vb.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Vb.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Vb.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(ib(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){var e;return null==(e=this._renderer)?void 0:e.textureAtlas}clearTextureAtlas(){var e;null==(e=this._renderer)||e.clearTextureAtlas()}};function $w(){return"light"===dd(gd.getState().theme)?Gu:Yu}const Uw=new Set,Kw=new Map,qw=new Map,Vw=new Map,Yw=new Map,Gw=new Map;function Xw(e){const t="light"===dd(gd.getState().theme);e.options.theme=$w(),e.options.minimumContrastRatio=t?7:1}let Qw=gd.getState().theme;function Jw(e,t){if(!Yw.has(e))try{const i=new Hw;i.onContextLoss(()=>{i.dispose(),Yw.delete(e)}),t.loadAddon(i),Yw.set(e,i)}catch{}}function Zw(e){const t=Yw.get(e);t&&(t.dispose(),Yw.delete(e))}gd.subscribe(e=>{if(e.theme!==Qw){Qw=e.theme;for(const e of Gw.values())Xw(e)}});let ex=gd.getState().gpuRendering;function tx(e){return qw.get(e)}gd.subscribe(e=>{if(e.gpuRendering!==ex){ex=e.gpuRendering;for(const[t,i]of Gw)e.gpuRendering?Jw(t,i):Zw(t)}});const ix=new Map;function rx({terminalId:e,projectId:t,cwd:i}){const r=Y.useRef(null),s=Y.useRef(null),n=Y.useRef(null),o=Y.useRef(null),a=$u(e=>e.setTerminalInstance),l=$u(e=>e.createSession),h=gd(e=>e.setFocusedTerminal);Y.useEffect(()=>{var c,u;const d=r.current;if(!d)return;d.innerHTML="";const f=$u.getState().sessions[e],_=Kw.get(e);if((null==f?void 0:f.terminal)&&_){const t=f.terminal;s.current=t,d.appendChild(_);let i=Vw.get(e);return i||(i=new Fm,t.loadAddon(i),Vw.set(e,i)),n.current=i,requestAnimationFrame(()=>{try{i.fit(),t.scrollToBottom();const{cols:r,rows:s}=t;o.current={cols:r,rows:s},ox({type:"pty:resize",terminalId:e,cols:r,rows:s})}catch{}}),()=>{}}const p=$w(),g="light"===dd(gd.getState().theme),v=new zm({theme:p,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontSize:13,lineHeight:1.2,cursorBlink:!0,cursorStyle:"bar",allowProposedApi:!0,scrollback:1e4,minimumContrastRatio:g?7:1}),m=new Fm,y=new Km((e,t)=>{(e.ctrlKey||e.metaKey)&&ox({type:"open:url",url:t})}),b=new Ky;v.loadAddon(m),v.loadAddon(y),v.loadAddon(b),v.open(d),Vw.set(e,m),qw.set(e,b),s.current=v,n.current=m,v.element&&Kw.set(e,v.element),gd.getState().gpuRendering&&Jw(e,v);const S=null==(c=v.element)?void 0:c.querySelector(".xterm-screen");return S&&S.addEventListener("mouseup",t=>{const i=t;i.ctrlKey||i.metaKey||setTimeout(()=>{if(v.hasSelection())return;const t=v.buffer.active;if(t.viewportY!==t.baseY)return;const r=S.getBoundingClientRect(),s=Math.floor((i.clientX-r.left)/(r.width/v.cols));if(Math.floor((i.clientY-r.top)/(r.height/v.rows))!==t.cursorY)return;const n=t.getLine(t.baseY+t.cursorY);if(!n)return;const o=n.translateToString().trimEnd().length,a=Math.min(s,o)-t.cursorX;if(0===a)return;ox({type:"pty:input",terminalId:e,data:(a>0?"":"").repeat(Math.abs(a))})},0)}),null==(u=v.element)||u.addEventListener("copy",e=>{var t;const i=v.getSelection();if(i){const r=i.split("\n").map(e=>e.trimEnd()).join("\n");null==(t=e.clipboardData)||t.setData("text/plain",r),e.preventDefault()}}),l(e,t),a(e,v),v.attachCustomKeyEventHandler(t=>{if("Enter"===t.key&&t.shiftKey)return"keydown"===t.type&&ox({type:"pty:input",terminalId:e,data:"\n"}),!1;if(t.metaKey&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&"keydown"===t.type){if("ArrowLeft"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1;if("ArrowRight"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1;if("Backspace"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1}return!(t.metaKey&&"f"===t.key&&!t.altKey&&!t.ctrlKey)&&(!(t.metaKey&&"p"===t.key&&!t.altKey&&!t.ctrlKey)&&(!(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)&&t.ctrlKey&&t.shiftKey&&!t.metaKey&&!t.altKey)&&(!(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)&&t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey)||"alternate"===v.buffer.active.type)))}),v.onData(t=>{ox({type:"pty:input",terminalId:e,data:t})}),v.onTitleChange(t=>{$u.getState().setTitle(e,t)}),Uw.has(e)||(Uw.add(e),requestAnimationFrame(()=>{try{m.fit()}catch{}ox({type:"pty:spawn",terminalId:e,projectId:t,cwd:i}),ox({type:"pty:resize",terminalId:e,cols:v.cols,rows:v.rows}),o.current={cols:v.cols,rows:v.rows},v.focus(),h(e)})),()=>{}},[e,t,i,l,a]),Y.useEffect(()=>{const t=s.current;t&&(Xw(t),function(e,t){Gw.set(e,t)}(e,t));const i=window.matchMedia("(prefers-color-scheme: light)"),r=()=>{t&&"system"===gd.getState().theme&&Xw(t)};return i.addEventListener("change",r),()=>{var t;t=e,Gw.delete(t),i.removeEventListener("change",r)}},[e]);const c=Y.useCallback(()=>{const t=n.current,i=s.current;if(t&&i)try{t.fit(),i.scrollToBottom();const{cols:r,rows:s}=i,n=o.current;n&&n.cols===r&&n.rows===s||(o.current={cols:r,rows:s},ox({type:"pty:resize",terminalId:e,cols:r,rows:s}))}catch{}},[e]),u=Y.useCallback(()=>{var t;null==(t=s.current)||t.focus(),h(e)},[e,h]);return{containerRef:r,fit:c,focus:u,terminalRef:s}}function sx(e){Uw.delete(e),Kw.delete(e),Vw.delete(e),qw.delete(e),Zw(e),Gw.delete(e)}let nx=null;function ox(e){(null==nx?void 0:nx.readyState)===WebSocket.OPEN&&nx.send(JSON.stringify(e))}function ax(){const e=gd(e=>e.setConnectionStatus),t=Vu(e=>e.addProject),i=Vu(e=>e.setActiveProject),r=Y.useRef(),s=Y.useCallback(()=>{if((null==nx?void 0:nx.readyState)===WebSocket.OPEN||(null==nx?void 0:nx.readyState)===WebSocket.CONNECTING)return;e("connecting");const n=new WebSocket(`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws`);nx=n,n.onopen=()=>{e("connected"),ox({type:"editor:sync",enabled:gd.getState().editorSyncEnabled})},n.onmessage=e=>{var r,s,n;try{const o=JSON.parse(e.data);if("pty:output"===o.type){const e=$u.getState().sessions[o.terminalId];null==(r=null==e?void 0:e.terminal)||r.write(o.data);const t=function(e){const t=ix.get(e);return void 0!==t?(ix.delete(e),t):null}(o.terminalId);return void(t&&ox({type:"pty:input",terminalId:o.terminalId,data:t}))}if("pty:exit"===o.type){const e=o.terminalId,t=$u.getState().sessions[e],i=null==t?void 0:t.projectId;if(null==(s=null==t?void 0:t.terminal)||s.dispose(),$u.getState().removeSession(e),sx(e),i){cd.getState().removePaneFromProject(i,e),Vu.getState().removeTerminalFromProject(i,e);const t=Xu(cd.getState().getLayout(i)),r=gd.getState().focusedTerminalId;if(r===e&&t.length>0){const e=t[0];gd.getState().setFocusedTerminal(e);const i=$u.getState().sessions[e];null==(n=null==i?void 0:i.terminal)||n.focus()}else r===e&&gd.getState().setFocusedTerminal(null)}return}if("project:spawned"===o.type){const e=Object.values(Vu.getState().projects).find(e=>e.cwd===o.cwd);return void(e?i(e.id):(t({id:o.projectId,name:o.name,cwd:o.cwd,terminalIds:[]}),i(o.projectId)))}if("port:status"===o.type)return void $u.getState().setActivePorts(o.ports);if("claude:status"===o.type)return void $u.getState().setClaudeStatus(o.statuses);if("git:branch"===o.type)return void $u.getState().setGitBranches(o.branches);if("inbox:paste"===o.type){const e=gd.getState().focusedTerminalId;if(e&&o.files.length>0){ox({type:"pty:input",terminalId:e,data:o.files.map(e=>"'"+e.replace(/'/g,"'\\''")+"'").join(" ")})}return}if("editor:status"===o.type)return void $u.getState().setEditorNeedsAccessibility(o.needsAccessibility);if("editor:active"===o.type){if(!gd.getState().editorSyncEnabled)return;const{projects:e,activeProjectId:t}=Vu.getState(),r=Object.values(e).find(e=>{const t=e.cwd.replace(/\/$/,"").split("/").pop();return e.name===o.projectName||t===o.projectName});r&&r.id!==t&&(gd.getState().showSyncToast(r.name),i(r.id))}}catch{}},n.onclose=()=>{e("disconnected"),$u.getState().setActivePorts({}),$u.getState().setClaudeStatus({}),$u.getState().setGitBranches({}),$u.getState().setEditorNeedsAccessibility(!1),nx=null,r.current=setTimeout(s,2e3)},n.onerror=()=>{n.close()}},[e,t,i]);Y.useEffect(()=>(s(),()=>{clearTimeout(r.current)}),[s])}const lx=new Set(["n","w","t","d","r","f","p"]);const hx=Hu()((e,t)=>({favourites:{},addFavourite:i=>{e(e=>({favourites:{...e.favourites,[i.id]:i}})),qu({favourites:{...t().favourites}})},updateFavourite:(i,r)=>{e(e=>{const t=e.favourites[i];return t?{favourites:{...e.favourites,[i]:{...t,...r}}}:e}),qu({favourites:{...t().favourites}})},removeFavourite:i=>{e(e=>{const{[i]:t,...r}=e.favourites;return{favourites:r}}),qu({favourites:{...t().favourites}})},hydrateFromServer:async()=>{try{const t=await fetch("/api/settings"),i=await t.json();i.favourites&&e({favourites:i.favourites})}catch{}}})),cx=(...e)=>e.filter((e,t,i)=>Boolean(e)&&i.indexOf(e)===t).join(" ");
62
+ */function Vm(e){(function(e){return e instanceof Jm||e instanceof Error&&e.name===Ym&&e.message===Ym})(e)||qm.onUnexpectedError(e)}var Ym="Canceled";var Gm,Xm,Qm,Jm=class extends Error{constructor(){super(Ym),this.name=this.message}},Zm=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function ey(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function ty(e){if(Qm.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(sp){t.push(sp)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function iy(...e){return ry(()=>ty(e))}function ry(e){return{dispose:ey(()=>{e()})}}(Xm=Gm||(Gm={})).isLessThan=function(e){return e<0},Xm.isLessThanOrEqual=function(e){return e<=0},Xm.isGreaterThan=function(e){return e>0},Xm.isNeitherLessOrGreaterThan=function(e){return 0===e},Xm.greaterThan=1,Xm.lessThan=-1,Xm.neitherLessOrGreaterThan=0,(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(Qm||(Qm={}));var sy=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{ty(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};sy.DISABLE_DISPOSED_WARNING=!1;var ny=sy,oy=class{constructor(){this._store=new ny,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};oy.None=Object.freeze({dispose(){}});var ay,ly=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},hy=globalThis.performance&&"function"==typeof globalThis.performance.now,cy=class e{static create(t){return new e(t)}constructor(e){this._now=hy&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new Sy({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,h,c,u=0,d=new Sy({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!h&&(d.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){s&&u>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>oy.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>{let s=iy(...e.map(e=>e(e=>t.call(i,e))));return function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(s,r)}},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new Sy({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Sy({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new Sy({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new Sy;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Sy(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof ny?r.add(a):Array.isArray(r)&&r.push(a),a}}})(ay||(ay={}));var uy=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new cy,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};uy.all=new Set,uy._idPool=0;var dy=uy,fy=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new vy(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};fy._idPool=1;var _y,py=fy,gy=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},vy=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},my=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},yy=0,by=class{constructor(e){this.value=e,this.id=yy++}},Sy=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new py((null==e?void 0:e.onListenerError)??Vm,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new dy(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new my(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||Vm)(i),oy.None}if(this._disposed)return oy.None;t&&(e=e.bind(t));let l,h=new by(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=gy.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof by?(this._deliveryQueue??(this._deliveryQueue=new wy),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=ry(()=>{null==l||l(),this._removeListener(h)});return i instanceof ny?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||Vm;if(r)try{e.value(t)}catch(h_){r(h_)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof by)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},wy=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},xy=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Ly||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ay.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:xy})})(_y||(_y={}));var Cy,ky,Ly=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?xy:(this._emitter||(this._emitter=new Sy),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ey="en",My=Ey,Ry=globalThis;typeof Ry.vscode<"u"&&typeof Ry.vscode.process<"u"?ky=Ry.vscode.process:typeof process<"u"&&"string"==typeof(null==(r=null==process?void 0:process.versions)?void 0:r.node)&&(ky=process);var Ty="string"==typeof(null==(s=null==ky?void 0:ky.versions)?void 0:s.electron)&&"renderer"===(null==ky?void 0:ky.type);if("object"==typeof ky){ky.platform,ky.platform,"linux"===ky.platform&&!!ky.env.SNAP&&ky.env.SNAP_REVISION,!!ky.env.CI||ky.env.BUILD_ARTIFACTSTAGINGDIRECTORY,My=Ey;let e=ky.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,My=t.resolvedLanguage||Ey,null==(n=t.languagePack)?void 0:n.translationsConfigFile}catch{}}else"object"!=typeof navigator||Ty?console.error("Unable to resolve platform."):((Cy=navigator.userAgent).indexOf("Windows"),Cy.indexOf("Macintosh"),(Cy.indexOf("Macintosh")>=0||Cy.indexOf("iPad")>=0||Cy.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,Cy.indexOf("Linux")>=0,null==Cy||Cy.indexOf("Mobi"),My=globalThis._VSCODE_NLS_LANGUAGE||Ey,navigator.language.toLowerCase());var Py,Dy=Cy,By=My;(e=>{e.value=function(){return By},e.isDefaultVariant=function(){return 2===By.length?"en"===By:By.length>=3&&("e"===By[0]&&"n"===By[1]&&"-"===By[2])},e.isDefault=function(){return"en"===By}})(Py||(Py={}));var Ay="function"==typeof Ry.postMessage&&!Ry.importScripts;(()=>{if(Ay){let e=[];Ry.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),Ry.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var Ny,Iy,Oy=!!(Dy&&Dy.indexOf("Chrome")>=0);function zy(e,t=0,i){let r=setTimeout(()=>{e()},t);return ry(()=>{clearTimeout(r)})}Dy&&Dy.indexOf("Firefox"),!Oy&&Dy&&Dy.indexOf("Safari"),Dy&&Dy.indexOf("Edg/"),Dy&&Dy.indexOf("Android"),(Iy=Ny||(Ny={})).settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},Iy.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(vt){i(vt)}})};var Fy=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Sy,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(h_){this.reject(h_)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await ay.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Fy.EMPTY=Fy.fromArray([]);var jy=class extends oy{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new ly),this._linesCacheDisposables=this._register(new ly),this._register(ry(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=iy(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=zy(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){var t;return null==(t=this._linesCache)?void 0:t[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){var i;let r=[],s=[0],n=this._terminal.buffer.active.getLine(e);for(;n;){let o=this._terminal.buffer.active.getLine(e+1),a=!!o&&o.isWrapped,l=n.translateToString(!a&&t);if(a&&o){let e=n.getCell(n.length-1);e&&0===e.getCode()&&1===e.getWidth()&&2===(null==(i=o.getCell(0))?void 0:i.getWidth())&&(l=l.slice(0,-1))}if(r.push(l),!a)break;s.push(s[s.length-1]+l.length),e++,n=o}return[r.join(""),s]}},Wy=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return!this._lastSearchOptions||!!e&&(this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord)}shouldUpdateHighlighting(e,t){return!!(null==t?void 0:t.decorations)&&(void 0===this._cachedSearchTerm||e!==this._cachedSearchTerm||this.didOptionsChange(t))}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Hy=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,r){if(!e||0===e.length)return void this._terminal.clearSelection();if(i>this._terminal.cols)throw new Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let s={startRow:t,startCol:i},n=this._findInLine(e,s,r);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(s.startRow=o,s.startCol=0,n=this._findInLine(e,s,r),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=0,n=0;r&&(i===e?(s=r.end.x,n=r.end.y):(s=r.start.x,n=r.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:s},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&0!==n)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&r&&(o.startRow=r.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||0===e.length)return void this._terminal.clearSelection();let r=this._terminal.getSelectionPosition();this._terminal.clearSelection();let s=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a,l={startRow:s,startCol:n};if(r&&(l.startRow=s=r.start.y,l.startCol=n=r.start.x,i!==e&&(a=this._findInLine(e,l,t,!1),a||(l.startRow=s=r.end.y,l.startCol=n=r.end.x))),a||(a=this._findInLine(e,l,t,o)),!a){l.startCol=Math.max(l.startCol,this._terminal.cols);for(let i=s-1;i>=0&&(l.startRow=i,a=this._findInLine(e,l,t,o),!a);i--);}if(!a&&s!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=s&&(l.startRow=h,a=this._findInLine(e,l,t,o),!a);h--);return a}_isWholeWord(e,t,i){return(0===e||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},r=!1){var s;let n=t.startRow,o=t.startCol;if(null==(s=this._terminal.buffer.active.getLine(n))?void 0:s.isWrapped)return r?void(t.startCol+=this._terminal.cols):(t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i));let a=this._lineCache.getLineFromCache(n);a||(a=this._lineCache.translateBufferLineToStringWithWrap(n,!0),this._lineCache.setLineInCache(n,a));let[l,h]=a,c=this._bufferColsToStringOffset(n,o),u=e,d=l;i.regex||(u=i.caseSensitive?e:e.toLowerCase(),d=i.caseSensitive?l:l.toLowerCase());let f=-1;if(i.regex){let t,s=RegExp(u,i.caseSensitive?"g":"gi");if(r)for(;t=s.exec(d.slice(0,c));)f=s.lastIndex-t[0].length,e=t[0],s.lastIndex-=e.length-1;else t=s.exec(d.slice(c)),t&&t[0].length>0&&(f=c+(s.lastIndex-t[0].length),e=t[0])}else r?c-u.length>=0&&(f=d.lastIndexOf(u,c-u.length)):f=d.indexOf(u,c);if(f>=0){if(i.wholeWord&&!this._isWholeWord(f,d,e))return;let t=0;for(;t<h.length-1&&f>=h[t+1];)t++;let r=t;for(;r<h.length-1&&f+e.length>=h[r+1];)r++;let s=f-h[t],o=f+e.length-h[r],a=this._stringLengthToBufferSize(n+t,s);return{term:e,col:a,row:n+t,size:this._stringLengthToBufferSize(n+r,o)-a+this._terminal.cols*(r-t)}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let r=0;r<t;r++){let e=i.getCell(r);if(!e)break;let s=e.getChars();s.length>1&&(t-=s.length-1);let n=i.getCell(r+1);n&&0===n.getWidth()&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,r=0,s=this._terminal.buffer.active.getLine(i);for(;t>0&&s;){for(let e=0;e<t&&e<this._terminal.cols;e++){let t=s.getCell(e);if(!t)break;t.getWidth()&&(r+=0===t.getCode()?1:t.getChars().length)}if(i++,s=this._terminal.buffer.active.getLine(i),s&&!s.isWrapped)break;t-=this._terminal.cols}return r}},$y=class extends oy{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ry(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let e=this._createResultDecorations(i,t,!1);if(e)for(let t of e)this._storeDecoration(t,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){ty(i)}}}clearHighlightDecorations(){ty(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let r=[],s=e.col,n=e.size,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let e=Math.min(this._terminal.cols-s,n);r.push([o,s,e]),s=0,n-=e,o++}let a=[];for(let l of r){let e=this._terminal.registerMarker(l[0]),r=this._terminal.registerDecoration({marker:e,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(e.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(r){let s=[];s.push(e),s.push(r.onRender(e=>this._applyStyles(e,i?t.activeMatchBorder:t.matchBorder,!1))),s.push(r.onDispose(()=>ty(s))),a.push(r)}}return 0===a.length?void 0:a}},Uy=class extends oy{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new Sy)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Ky=class extends oy{constructor(e){super(),this._highlightTimeout=this._register(new ly),this._lineCache=this._register(new ly),this._state=new Wy,this._resultTracker=this._register(new Uy),this._highlightLimit=(null==e?void 0:e.highlightLimit)??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new jy(e),this._engine=new Hy(e,this._lineCache.value),this._decorationManager=new $y(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ry(()=>this.clearDecorations()))}_updateMatches(){var e;this._highlightTimeout.clear(),this._state.cachedSearchTerm&&(null==(e=this._state.lastSearchOptions)?void 0:e.decorations)&&(this._highlightTimeout.value=zy(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){var t;this._resultTracker.clearSelectedDecoration(),null==(t=this._decorationManager)||t.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e))return void this.clearDecorations();this.clearDecorations(!0);let i,r=[],s=this._engine.find(e,0,0,t);for(;s&&((null==i?void 0:i.row)!==s.row||(null==i?void 0:i.col)!==s.col)&&!(r.length>=this._highlightLimit);)i=s,r.push(i),s=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(r,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(r,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let r=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,r}_fireResults(e){this._resultTracker.fireResultsChanged(!!(null==e?void 0:e.decorations))}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let r=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(r,null==t?void 0:t.decorations,null==i?void 0:i.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let t=e.row-this._terminal.buffer.active.viewportY;t-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(t)}return!0}},qy=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Jy.isErrorNoTelemetry(e)?new Jy(e.message+"\n\n"+e.stack):new Error(e.message+"\n\n"+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Vy(e){(function(e){return e instanceof Qy||e instanceof Error&&e.name===Yy&&e.message===Yy})(e)||qy.onUnexpectedError(e)}var Yy="Canceled";var Gy,Xy,Qy=class extends Error{constructor(){super(Yy),this.name=this.message}},Jy=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(t){if(t instanceof e)return t;let i=new e;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}};function Zy(e,t){let i,r=this,s=!1;return function(){return s||(s=!0,t||(i=e.apply(r,arguments))),i}}function eb(e){if(Xy.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(sp){t.push(sp)}if(1===t.length)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function tb(...e){return ib(()=>eb(e))}function ib(e){return{dispose:Zy(()=>{e()})}}(e=>{e.isLessThan=function(e){return e<0},e.isLessThanOrEqual=function(e){return e<=0},e.isGreaterThan=function(e){return e>0},e.isNeitherLessOrGreaterThan=function(e){return 0===e},e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Gy||(Gy={})),(e=>{function t(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=t;let i=Object.freeze([]);function*r(e){yield e}e.empty=function(){return i},e.single=r,e.wrap=function(e){return t(e)?e:r(e)},e.from=function(e){return e||i},e.reverse=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,t){let i=0;for(let r of e)if(t(r,i++))return!0;return!1},e.find=function(e,t){for(let i of e)if(t(i))return i},e.filter=function*(e,t){for(let i of e)t(i)&&(yield i)},e.map=function*(e,t){let i=0;for(let r of e)yield t(r,i++)},e.flatMap=function*(e,t){let i=0;for(let r of e)yield*t(r,i++)},e.concat=function*(...e){for(let t of e)yield*t},e.reduce=function(e,t,i){let r=i;for(let s of e)r=t(r,s);return r},e.slice=function*(e,t,i=e.length){for(t<0&&(t+=e.length),i<0?i+=e.length:i>e.length&&(i=e.length);t<i;t++)yield e[t]},e.consume=function(t,i=Number.POSITIVE_INFINITY){let r=[];if(0===i)return[r,t];let s=t[Symbol.iterator]();for(let n=0;n<i;n++){let t=s.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator]:()=>s}]},e.asyncToArray=async function(e){let t=[];for await(let i of e)t.push(i);return Promise.resolve(t)}})(Xy||(Xy={}));var rb=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{eb(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&this._toDispose.delete(e)}};rb.DISABLE_DISPOSED_WARNING=!1;var sb=rb,nb=class{constructor(){this._store=new sb,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};nb.None=Object.freeze({dispose(){}});var ob=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||(null==(t=this._value)||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,null==(e=this._value)||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ab=typeof process<"u"&&"title"in process,lb=ab?"node":navigator.userAgent,hb=ab?"node":navigator.platform,cb=lb.includes("Firefox"),ub=lb.includes("Edge"),db=/^((?!chrome|android).)*safari/i.test(lb);hb.indexOf("Linux");var fb,_b,pb,gb,vb,mb=0,yb=0,bb=0,Sb=0,wb={css:"#00000000",rgba:0};function xb(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Cb(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function kb(e){if(!e)throw new Error("value must not be falsy");return e}function Lb(e){return 57508<=e&&e<=57558}function Eb(e){return Lb(e)||function(e){return 9472<=e&&e<=9631}(e)}function Mb(e,t,i=0){return(e-(2*Math.round(t)-i))%(2*Math.round(t))}(e=>{e.toCss=function(e,t,i,r){return void 0!==r?`#${xb(e)}${xb(t)}${xb(i)}${xb(r)}`:`#${xb(e)}${xb(t)}${xb(i)}`},e.toRgba=function(e,t,i,r=255){return(e<<24|t<<16|i<<8|r)>>>0},e.toColor=function(t,i,r,s){return{css:e.toCss(t,i,r,s),rgba:e.toRgba(t,i,r,s)}}})(fb||(fb={})),(e=>{function t(e,t){return Sb=Math.round(255*t),[mb,yb,bb]=vb.toChannels(e.rgba),{css:fb.toCss(mb,yb,bb,Sb),rgba:fb.toRgba(mb,yb,bb,Sb)}}e.blend=function(e,t){if(1===(Sb=(255&t.rgba)/255))return{css:t.css,rgba:t.rgba};let i=t.rgba>>24&255,r=t.rgba>>16&255,s=t.rgba>>8&255,n=e.rgba>>24&255,o=e.rgba>>16&255,a=e.rgba>>8&255;return mb=n+Math.round((i-n)*Sb),yb=o+Math.round((r-o)*Sb),bb=a+Math.round((s-a)*Sb),{css:fb.toCss(mb,yb,bb),rgba:fb.toRgba(mb,yb,bb)}},e.isOpaque=function(e){return!(255&~e.rgba)},e.ensureContrastRatio=function(e,t,i){let r=vb.ensureContrastRatio(e.rgba,t.rgba,i);if(r)return fb.toColor(r>>24&255,r>>16&255,r>>8&255)},e.opaque=function(e){let t=(255|e.rgba)>>>0;return[mb,yb,bb]=vb.toChannels(t),{css:fb.toCss(mb,yb,bb),rgba:t}},e.opacity=t,e.multiplyOpacity=function(e,i){return t(e,(Sb=255&e.rgba)*i/255)},e.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}})(_b||(_b={})),(e=>{let t,i;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return mb=parseInt(e.slice(1,2).repeat(2),16),yb=parseInt(e.slice(2,3).repeat(2),16),bb=parseInt(e.slice(3,4).repeat(2),16),fb.toColor(mb,yb,bb);case 5:return mb=parseInt(e.slice(1,2).repeat(2),16),yb=parseInt(e.slice(2,3).repeat(2),16),bb=parseInt(e.slice(3,4).repeat(2),16),Sb=parseInt(e.slice(4,5).repeat(2),16),fb.toColor(mb,yb,bb,Sb);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return mb=parseInt(r[1]),yb=parseInt(r[2]),bb=parseInt(r[3]),Sb=Math.round(255*(void 0===r[5]?1:parseFloat(r[5]))),fb.toColor(mb,yb,bb,Sb);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=e,"string"!=typeof t.fillStyle)throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[mb,yb,bb,Sb]=t.getImageData(0,0,1,1).data,255!==Sb)throw new Error("css.toColor: Unsupported css format");return{rgba:fb.toRgba(mb,yb,bb,Sb),css:e}}})(pb||(pb={})),(e=>{function t(e,t,i){let r=e/255,s=t/255,n=i/255;return.2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}e.relativeLuminance=function(e){return t(e>>16&255,e>>8&255,255&e)},e.relativeLuminance2=t})(gb||(gb={})),(e=>{function t(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));for(;h<i&&(o>0||a>0||l>0);)o-=Math.max(0,Math.ceil(.1*o)),a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}function i(e,t,i){let r=e>>24&255,s=e>>16&255,n=e>>8&255,o=t>>24&255,a=t>>16&255,l=t>>8&255,h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));for(;h<i&&(o<255||a<255||l<255);)o=Math.min(255,o+Math.ceil(.1*(255-o))),a=Math.min(255,a+Math.ceil(.1*(255-a))),l=Math.min(255,l+Math.ceil(.1*(255-l))),h=Cb(gb.relativeLuminance2(o,a,l),gb.relativeLuminance2(r,s,n));return(o<<24|a<<16|l<<8|255)>>>0}e.blend=function(e,t){if(1===(Sb=(255&t)/255))return t;let i=t>>24&255,r=t>>16&255,s=t>>8&255,n=e>>24&255,o=e>>16&255,a=e>>8&255;return mb=n+Math.round((i-n)*Sb),yb=o+Math.round((r-o)*Sb),bb=a+Math.round((s-a)*Sb),fb.toRgba(mb,yb,bb)},e.ensureContrastRatio=function(e,r,s){let n=gb.relativeLuminance(e>>8),o=gb.relativeLuminance(r>>8);if(Cb(n,o)<s){if(o<n){let o=t(e,r,s),a=Cb(n,gb.relativeLuminance(o>>8));if(a<s){let t=i(e,r,s);return a>Cb(n,gb.relativeLuminance(t>>8))?o:t}return o}let a=i(e,r,s),l=Cb(n,gb.relativeLuminance(a>>8));if(l<s){let i=t(e,r,s);return l>Cb(n,gb.relativeLuminance(i>>8))?a:i}return a}},e.reduceLuminance=t,e.increaseLuminance=i,e.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]}})(vb||(vb={}));var Rb,Tb=0,Pb=0,Db=!1,Bb=!1,Ab=!1,Nb=0,Ib=class{constructor(e,t,i,r,s,n){this._terminal=e,this._optionService=t,this._selectionRenderModel=i,this._decorationService=r,this._coreBrowserService=s,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(e,t,i,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=268435456&e.bg?e.extended.ext:0,Pb=0,Tb=0,Bb=!1,Db=!1,Ab=!1,Rb=this._themeService.colors,Nb=0,0!==e.getCode()&&4===e.extended.underlineStyle){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Nb=t*r%(2*Math.round(e))}if(this._decorationService.forEachDecorationAtCell(t,i,"bottom",e=>{e.backgroundColorRGB&&(Pb=e.backgroundColorRGB.rgba>>8&16777215,Bb=!0),e.foregroundColorRGB&&(Tb=e.foregroundColorRGB.rgba>>8&16777215,Db=!0)}),Ab=this._selectionRenderModel.isCellSelected(this._terminal,t,i)){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:Pb=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:Pb=(16777215&this.result.fg)<<8|255;break;default:Pb=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:Pb=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:Pb=(16777215&this.result.bg)<<8|255}Pb=vb.blend(Pb,4294967040&(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else Pb=(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Bb=!0,Rb.selectionForeground&&(Tb=Rb.selectionForeground.rgba>>8&16777215,Db=!0),Eb(e.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))Tb=(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:Tb=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:Tb=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:Tb=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:Tb=(16777215&this.result.fg)<<8|255;break;default:Tb=this._themeService.colors.foreground.rgba}Tb=vb.blend(Tb,4294967040&(this._coreBrowserService.isFocused?Rb.selectionBackgroundOpaque:Rb.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}Db=!0}}this._decorationService.forEachDecorationAtCell(t,i,"top",e=>{e.backgroundColorRGB&&(Pb=e.backgroundColorRGB.rgba>>8&16777215,Bb=!0),e.foregroundColorRGB&&(Tb=e.foregroundColorRGB.rgba>>8&16777215,Db=!0)}),Bb&&(Pb=Ab?-16777216&e.bg&-134217729|Pb|50331648:-16777216&e.bg|Pb|50331648),Db&&(Tb=-16777216&e.fg&-67108865|Tb|50331648),67108864&this.result.fg&&(Bb&&!Db&&(Tb=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&Rb.background.rgba>>8|50331648,Db=!0),!Bb&&Db&&(Pb=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&Rb.foreground.rgba>>8|50331648,Bb=!0)),Rb=void 0,this.result.bg=Bb?Pb:this.result.bg,this.result.fg=Db?Tb:this.result.fg,this.result.ext&=536870911,this.result.ext|=Nb<<29&3758096384}},Ob=cb||ub?"bottom":"ideographic",zb={"▀":[{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}]},Fb={"░":[[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]]},jb={"─":{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:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},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:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},Wb={"":{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}};function Hb(e,t,i,r,s,n,o,a){let l=zb[t];if(l)return function(e,t,i,r,s,n){for(let o=0;o<t.length;o++){let a=t[o],l=s/8,h=n/8;e.fillRect(i+a.x*l,r+a.y*h,a.w*l,a.h*h)}}(e,l,i,r,s,n),!0;let h=Fb[t];if(h)return function(e,t,i,r,s,n){let o=$b.get(t);o||(o=new Map,$b.set(t,o));let a=e.fillStyle;if("string"!=typeof a)throw new Error(`Unexpected fillStyle type "${a}"`);let l=o.get(a);if(!l){let i=t[0].length,r=t.length,s=e.canvas.ownerDocument.createElement("canvas");s.width=i,s.height=r;let n,h,c,u,d=kb(s.getContext("2d")),f=new ImageData(i,r);if(a.startsWith("#"))n=parseInt(a.slice(1,3),16),h=parseInt(a.slice(3,5),16),c=parseInt(a.slice(5,7),16),u=a.length>7&&parseInt(a.slice(7,9),16)||1;else{if(!a.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${a}" when drawing pattern glyph`);[n,h,c,u]=a.substring(5,a.length-1).split(",").map(e=>parseFloat(e))}for(let e=0;e<r;e++)for(let r=0;r<i;r++)f.data[4*(e*i+r)]=n,f.data[4*(e*i+r)+1]=h,f.data[4*(e*i+r)+2]=c,f.data[4*(e*i+r)+3]=t[e][r]*(255*u);d.putImageData(f,0,0),l=kb(e.createPattern(s,null)),o.set(a,l)}e.fillStyle=l,e.fillRect(i,r,s,n)}(e,h,i,r,s,n),!0;let c=jb[t];if(c)return function(e,t,i,r,s,n,o){e.strokeStyle=e.fillStyle;for(let[a,l]of Object.entries(t)){let t;if(e.beginPath(),e.lineWidth=o*Number.parseInt(a),"function"==typeof l){t=l(.15,.15/n*s)}else t=l;for(let a of t.split(" ")){let t=a[0],l=Kb[t];if(!l){console.error(`Could not find drawing instructions for "${t}"`);continue}let h=a.substring(1).split(",");!h[0]||!h[1]||l(e,qb(h,s,n,i,r,!0,o))}e.stroke(),e.closePath()}}(e,c,i,r,s,n,a),!0;let u=Wb[t];return!!u&&(function(e,t,i,r,s,n,o,a){let l=new Path2D;l.rect(i,r,s,n),e.clip(l),e.beginPath();let h=o/12;e.lineWidth=a*h;for(let c of t.d.split(" ")){let o=c[0],l=Kb[o];if(!l){console.error(`Could not find drawing instructions for "${o}"`);continue}let u=c.substring(1).split(",");!u[0]||!u[1]||l(e,qb(u,s,n,i,r,!1,a,(t.leftPadding??0)*(h/2),(t.rightPadding??0)*(h/2)))}1===t.type?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}(e,u,i,r,s,n,o,a),!0)}Wb[""]=Wb[""],Wb[""]=Wb[""];var $b=new Map;function Ub(e,t,i=0){return Math.max(Math.min(e,t),i)}var Kb={C:(e,t)=>e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function qb(e,t,i,r,s,n,o,a=0,l=0){let h=e.map(e=>parseFloat(e)||parseInt(e));if(h.length<2)throw new Error("Too few arguments for instruction");for(let c=0;c<h.length;c+=2)h[c]*=t-a*o-l*o,n&&0!==h[c]&&(h[c]=Ub(Math.round(h[c]+.5)-.5,t,0)),h[c]+=r+a*o;for(let c=1;c<h.length;c+=2)h[c]*=i,n&&0!==h[c]&&(h[c]=Ub(Math.round(h[c]+.5)-.5,i,0)),h[c]+=s;return h}var Vb,Yb=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Gb=class{constructor(){this._data=new Yb}set(e,t,i,r,s){this._data.get(e,t)||this._data.set(e,t,new Yb),this._data.get(e,t).set(i,r,s)}get(e,t,i,r){var s;return null==(s=this._data.get(e,t))?void 0:s.get(i,r)}clear(){this._data.clear()}},Xb=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,r=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),s=e.timeRemaining(),1.5*i>s)return r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),void this._start();r=s}this.clear()}},Qb=!ab&&"requestIdleCallback"in window?class extends Xb{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}}:class extends Xb{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Jb=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Zb}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return!(50331648&~this.fg)}isBgRGB(){return!(50331648&~this.bg)}isFgPalette(){return 16777216==(50331648&this.fg)||33554432==(50331648&this.fg)}isBgPalette(){return 16777216==(50331648&this.bg)||33554432==(50331648&this.bg)}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&~this.extended.underlineColor):this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?16777216==(50331648&this.extended.underlineColor)||33554432==(50331648&this.extended.underlineColor):this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?!(50331648&this.extended.underlineColor):this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Zb=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(e){this._ext&=-67108864,this._ext|=67108863&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(3758096384&this._ext)>>29;return e<0?4294967288^e:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},eS=globalThis.performance&&"function"==typeof globalThis.performance.now,tS=class e{static create(t){return new e(t)}constructor(e){this._now=eS&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return-1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function t(e){return(t,i=null,r)=>{let s,n=!1;return s=e(e=>{if(!n)return s?s.dispose():n=!0,t.call(i,e)},null,r),n&&s.dispose(),s}}function i(e,t,i){return s((i,r=null,s)=>e(e=>i.call(r,t(e)),null,s),i)}function r(e,t,i){return s((i,r=null,s)=>e(e=>t(e)&&i.call(r,e),null,s),i)}function s(e,t){let i,r=new dS({onWillAddFirstListener(){i=e(r.fire,r)},onDidRemoveLastListener(){null==i||i.dispose()}});return null==t||t.add(r),r.event}function n(e,t,i=100,r=!1,s=!1,n,o){let a,l,h,c,u=0,d=new dS({leakWarningThreshold:n,onWillAddFirstListener(){a=e(e=>{u++,l=t(l,e),r&&!h&&(d.fire(l),l=void 0),c=()=>{let e=l;l=void 0,h=void 0,(!r||u>1)&&d.fire(e),u=0},"number"==typeof i?(clearTimeout(h),h=setTimeout(c,i)):void 0===h&&(h=0,queueMicrotask(c))})},onWillRemoveListener(){s&&u>0&&(null==c||c())},onDidRemoveLastListener(){c=void 0,a.dispose()}});return null==o||o.add(d),d.event}e.None=()=>nb.None,e.defer=function(e,t){return n(e,()=>{},0,void 0,!0,void 0,t)},e.once=t,e.map=i,e.forEach=function(e,t,i){return s((i,r=null,s)=>e(e=>{t(e),i.call(r,e)},null,s),i)},e.filter=r,e.signal=function(e){return e},e.any=function(...e){return(t,i=null,r)=>function(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}(tb(...e.map(e=>e(e=>t.call(i,e)))),r)},e.reduce=function(e,t,r,s){let n=r;return i(e,e=>(n=t(n,e),n),s)},e.debounce=n,e.accumulate=function(t,i=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],i,void 0,!0,void 0,r)},e.latch=function(e,t=(e,t)=>e===t,i){let s,n=!0;return r(e,e=>{let i=n||!t(e,s);return n=!1,s=e,i},i)},e.split=function(t,i,r){return[e.filter(t,i,r),e.filter(t,e=>!i(e),r)]},e.buffer=function(e,t=!1,i=[],r){let s=i.slice(),n=e(e=>{s?s.push(e):a.fire(e)});r&&r.add(n);let o=()=>{null==s||s.forEach(e=>a.fire(e)),s=null},a=new dS({onWillAddFirstListener(){n||(n=e(e=>a.fire(e)),r&&r.add(n))},onDidAddFirstListener(){s&&(t?setTimeout(o):o())},onDidRemoveLastListener(){n&&n.dispose(),n=null}});return r&&r.add(a),a.event},e.chain=function(e,t){return(i,r,s)=>{let n=t(new a);return e(function(e){let t=n.evaluate(e);t!==o&&i.call(r,t)},void 0,s)}};let o=Symbol("HaltChainable");class a{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:o),this}reduce(e,t){let i=t;return this.steps.push(t=>(i=e(i,t),i)),this}latch(e=(e,t)=>e===t){let t,i=!0;return this.steps.push(r=>{let s=i||!e(r,t);return i=!1,t=r,s?r:o}),this}evaluate(e){for(let t of this.steps)if((e=t(e))===o)break;return e}}e.fromNodeEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new dS({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return s.event},e.fromDOMEventEmitter=function(e,t,i=e=>e){let r=(...e)=>s.fire(i(...e)),s=new dS({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return s.event},e.toPromise=function(e){return new Promise(i=>t(e)(i))},e.fromPromise=function(e){let t=new dS;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event},e.forward=function(e,t){return e(e=>t.fire(e))},e.runAndSubscribe=function(e,t,i){return t(i),e(e=>t(e))};class l{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let i={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new dS(i),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,t){return new l(e,t).emitter.event},e.fromObservableLight=function(e){return(t,i,r)=>{let s=0,n=!1,o={beginUpdate(){s++},endUpdate(){s--,0===s&&(e.reportChanges(),n&&(n=!1,t.call(i)))},handlePossibleChange(){},handleChange(){n=!0}};e.addObserver(o),e.reportChanges();let a={dispose(){e.removeObserver(o)}};return r instanceof sb?r.add(a):Array.isArray(r)&&r.push(a),a}}})(Vb||(Vb={}));var iS=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new tS,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};iS.all=new Set,iS._idPool=0;var rS=iS,sS=class e{constructor(t,i,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=r,this._warnCountdown=0}dispose(){var e;null==(e=this._stacks)||e.clear()}check(e,t){let i=this.threshold;if(i<=0||t<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*i;let[e,r]=this.getMostFrequentStack(),s=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(s),console.warn(e);let n=new lS(s,e);this._errorHandler(n)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[i,r]of this._stacks)(!e||t<r)&&(e=[i,r],t=r);return e}};sS._idPool=1;var nS,oS=sS,aS=class e{constructor(e){this.value=e}static create(){let t=new Error;return new e(t.stack??"")}print(){console.warn(this.value.split("\n").slice(2).join("\n"))}},lS=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},hS=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},cS=0,uS=class{constructor(e){this.value=e,this.id=cS++}},dS=class{constructor(e){var t,i,r,s;this._size=0,this._options=e,this._leakageMon=(null==(t=this._options)?void 0:t.leakWarningThreshold)?new oS((null==e?void 0:e.onListenerError)??Vy,(null==(i=this._options)?void 0:i.leakWarningThreshold)??-1):void 0,this._perfMon=(null==(r=this._options)?void 0:r._profName)?new rS(this._options._profName):void 0,this._deliveryQueue=null==(s=this._options)?void 0:s.deliveryQueue}dispose(){var e,t,i,r;this._disposed||(this._disposed=!0,(null==(e=this._deliveryQueue)?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),null==(i=null==(t=this._options)?void 0:t.onDidRemoveLastListener)||i.call(t),null==(r=this._leakageMon)||r.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var r,s,n,o,a;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],i=new hS(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return((null==(r=this._options)?void 0:r.onListenerError)||Vy)(i),nb.None}if(this._disposed)return nb.None;t&&(e=e.bind(t));let l,h=new uS(e);this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(h.stack=aS.create(),l=this._leakageMon.check(h.stack,this._size+1)),this._listeners?this._listeners instanceof uS?(this._deliveryQueue??(this._deliveryQueue=new fS),this._listeners=[this._listeners,h]):this._listeners.push(h):(null==(n=null==(s=this._options)?void 0:s.onWillAddFirstListener)||n.call(s,this),this._listeners=h,null==(a=null==(o=this._options)?void 0:o.onDidAddFirstListener)||a.call(o,this)),this._size++;let c=ib(()=>{null==l||l(),this._removeListener(h)});return i instanceof sb?i.add(c):Array.isArray(i)&&i.push(c),c}),this._event}_removeListener(e){var t,i,r,s;if(null==(i=null==(t=this._options)?void 0:t.onWillRemoveListener)||i.call(t,this),!this._listeners)return;if(1===this._size)return this._listeners=void 0,null==(s=null==(r=this._options)?void 0:r.onDidRemoveLastListener)||s.call(r,this),void(this._size=0);let n=this._listeners,o=n.indexOf(e);if(-1===o)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,n[o]=void 0;let a=this._deliveryQueue.current===this;if(2*this._size<=n.length){let e=0;for(let t=0;t<n.length;t++)n[t]?n[e++]=n[t]:a&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);n.length=e}}_deliver(e,t){var i;if(!e)return;let r=(null==(i=this._options)?void 0:i.onListenerError)||Vy;if(r)try{e.value(t)}catch(s){r(s)}else e.value(t)}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,r,s;if((null==(t=this._deliveryQueue)?void 0:t.current)&&(this._deliverQueue(this._deliveryQueue),null==(i=this._perfMon)||i.stop()),null==(r=this._perfMon)||r.start(this._size),this._listeners)if(this._listeners instanceof uS)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}null==(s=this._perfMon)||s.stop()}hasListeners(){return this._size>0}},fS=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},_S={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}},pS=class e{constructor(e,t,i){this._document=e,this._config=t,this._unicodeService=i,this._didWarmUp=!1,this._cacheMap=new Gb,this._cacheMapCombined=new Gb,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Jb,this._textureSize=512,this._onAddTextureAtlasCanvas=new dS,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new dS,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=mS(e,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=kb(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Qb;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(0!==this._pages[0].currentRow.x||0!==this._pages[0].currentRow.y){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>2*t.canvas.width<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width!==e.canvas.width?t.canvas.width-e.canvas.width:t.percentageUsed-e.percentageUsed),i=-1,r=0;for(let e=0;e<t.length;e++)if(t[e].canvas.width!==r)i=e,r=t[e].canvas.width;else if(e-i===3)break;let s=t.slice(i,i+4),n=s.map(e=>e.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-s.length,a=this._mergePages(s,o);a.version++;for(let e=n.length-1;e>=0;e--)this._deletePage(n[e]);this.pages.push(a),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(a.canvas)}let t=new gS(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let i=2*e[0].canvas.width,r=new gS(this._document,i,e);for(let[s,n]of e.entries()){let e=s*n.canvas.width%i,o=Math.floor(s/2)*n.canvas.height;r.ctx.drawImage(n.canvas,e,o);for(let r of n.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/i,r.sizeClipSpace.y=r.size.y/i,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/i,r.texturePositionClipSpace.y=r.texturePosition.y/i;this._onRemoveTextureAtlasCanvas.fire(n.canvas);let a=this._activePages.indexOf(n);-1!==a&&this._activePages.splice(a,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let e=this._pages[t];for(let t of e.glyphs)t.texturePage--;e.version++}}getRasterizedGlyphCombinedChar(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMapCombined,e,t,i,r,s,n)}getRasterizedGlyph(e,t,i,r,s,n){return this._getFromCacheMap(this._cacheMap,e,t,i,r,s,n)}_getFromCacheMap(e,t,i,r,s,n,o){return(nS=e.get(t,i,r,s))||(nS=this._drawToCache(t,i,r,s,n,o),e.set(t,i,r,s,nS)),nS}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,i,r){if(this._config.allowTransparency)return wb;let s;switch(e){case 16777216:case 33554432:s=this._getColorFromAnsiIndex(t);break;case 50331648:let e=Jb.toColorRGB(t);s=fb.toColor(e[0],e[1],e[2]);break;default:s=i?_b.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(s=_b.opaque(s)),s}_getForegroundColor(e,t,i,r,s,n,o,a,l,h){let c,u=this._getMinimumContrastColor(e,t,i,r,s,n,o,l,a,h);if(u)return u;switch(s){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&l&&n<8&&(n+=8),c=this._getColorFromAnsiIndex(n);break;case 50331648:let e=Jb.toColorRGB(n);c=fb.toColor(e[0],e[1],e[2]);break;default:c=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(c=_b.opaque(c)),a&&(c=_b.multiplyOpacity(c,.5)),c}_resolveBackgroundRgba(e,t,i){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,i,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return i?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,i,r,s,n,o,a,l,h){if(1===this._config.minimumContrastRatio||h)return;let c=this._getContrastCache(l),u=c.getColor(e,r);if(void 0!==u)return u||void 0;let d=this._resolveBackgroundRgba(t,i,o),f=this._resolveForegroundRgba(s,n,o,a),_=vb.ensureContrastRatio(d,f,this._config.minimumContrastRatio/(l?2:1));if(!_)return void c.setColor(e,r,null);let p=fb.toColor(_>>24&255,_>>16&255,_>>8&255);return c.setColor(e,r,p),p}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,i,r,s,n,o){let a="number"==typeof t?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let l=Math.min(this._config.deviceCellWidth*Math.max(a.length,2)+4,this._config.deviceMaxTextureSize);this._tmpCanvas.width<l&&(this._tmpCanvas.width=l);let h=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<h&&(this._tmpCanvas.height=h),this._tmpCtx.save(),this._workAttributeData.fg=r,this._workAttributeData.bg=i,this._workAttributeData.extended.ext=s,this._workAttributeData.isInvisible())return _S;let c=!!this._workAttributeData.isBold(),u=!!this._workAttributeData.isInverse(),d=!!this._workAttributeData.isDim(),f=!!this._workAttributeData.isItalic(),_=!!this._workAttributeData.isUnderline(),p=!!this._workAttributeData.isStrikethrough(),g=!!this._workAttributeData.isOverline(),v=this._workAttributeData.getFgColor(),m=this._workAttributeData.getFgColorMode(),y=this._workAttributeData.getBgColor(),b=this._workAttributeData.getBgColorMode();if(u){let e=v;v=y,y=e;let t=m;m=b,b=t}let S=this._getBackgroundColor(b,y,u,d);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=S.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let w=c?this._config.fontWeightBold:this._config.fontWeight,x=f?"italic":"";this._tmpCtx.font=`${x} ${w} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=Ob;let C=1===a.length&&Lb(a.charCodeAt(0)),k=1===a.length&&function(e){return 57520<=e&&e<=57527}(a.charCodeAt(0)),L=this._getForegroundColor(i,b,y,r,m,v,u,d,c,Eb(a.charCodeAt(0)));this._tmpCtx.fillStyle=L.css;let E=k?0:4,M=!1;!1!==this._config.customGlyphs&&(M=Hb(this._tmpCtx,a,E,E,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let R,T=!C;if(R="number"==typeof t?this._unicodeService.wcwidth(t):this._unicodeService.getStringCellWidth(t),_){this._tmpCtx.save();let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;if(this._tmpCtx.lineWidth=e,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())T=!1,this._tmpCtx.strokeStyle=`rgb(${Jb.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{T=!1;let e=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&e<8&&(e+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(e).css}this._tmpCtx.beginPath();let i=E,r=Math.ceil(E+this._config.deviceCharHeight)-t-(n?2*e:0),s=r+e,o=r+2*e,l=this._workAttributeData.getUnderlineVariantOffset();for(let n=0;n<R;n++){this._tmpCtx.save();let a=i+n*this._config.deviceCellWidth,h=i+(n+1)*this._config.deviceCellWidth,c=a+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r),this._tmpCtx.moveTo(a,o),this._tmpCtx.lineTo(h,o);break;case 3:let i=e<=1?o:Math.ceil(E+this._config.deviceCharHeight-e/2)-t,n=e<=1?r:Math.ceil(E+this._config.deviceCharHeight+e/2)-t,u=new Path2D;u.rect(a,r,this._config.deviceCellWidth,o-r),this._tmpCtx.clip(u),this._tmpCtx.moveTo(a-this._config.deviceCellWidth/2,s),this._tmpCtx.bezierCurveTo(a-this._config.deviceCellWidth/2,n,a,n,a,s),this._tmpCtx.bezierCurveTo(a,i,c,i,c,s),this._tmpCtx.bezierCurveTo(c,n,h,n,h,s),this._tmpCtx.bezierCurveTo(h,i,h+this._config.deviceCellWidth/2,i,h+this._config.deviceCellWidth/2,s);break;case 4:let d=0===l?0:l>=e?2*e-l:e-l;!1==!(l>=e)||0===d?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a+d,r),this._tmpCtx.lineTo(h,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(a+d,r),this._tmpCtx.moveTo(a+d+e,r),this._tmpCtx.lineTo(h,r)),l=Mb(h-a,e,l);break;case 5:let f=.6,_=.3,p=h-a,g=Math.floor(f*p),v=Math.floor(_*p),m=p-g-v;this._tmpCtx.setLineDash([g,v,m]),this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r);break;default:this._tmpCtx.moveTo(a,r),this._tmpCtx.lineTo(h,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!M&&this._config.fontSize>=12&&!this._config.allowTransparency&&" "!==a){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let t=this._tmpCtx.measureText(a);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(i,r-Math.ceil(e/2),this._config.deviceCellWidth*R,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=S.css,this._tmpCtx.strokeText(a,E,E+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*R,E+t),this._tmpCtx.stroke()}if(M||this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight),"_"===a&&!this._config.allowTransparency){let e=vS(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),S,L,T);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=S.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(a,E,E+this._config.deviceCharHeight-t),e=vS(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),S,L,T),e);t++);}if(p){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*R,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let P,D=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);if(P=this._config.allowTransparency?function(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}(D):vS(D,S,L,T),P)return _S;let B,A,N=this._findGlyphBoundingBox(D,this._workBoundingBox,l,k,M,E);for(;;){if(0===this._activePages.length){let e=this._createNewPage();B=e,A=e.currentRow,A.height=N.size.y;break}B=this._activePages[this._activePages.length-1],A=B.currentRow;for(let e of this._activePages)N.size.y<=e.currentRow.height&&(B=e,A=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=A.height&&N.size.y<=t.height&&(B=this._activePages[e],A=t);if(N.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new gS(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),B=this._overflowSizePage,A=this._overflowSizePage.currentRow,A.x+N.size.x>=B.canvas.width&&(A.x=0,A.y+=A.height,A.height=0);break}if(A.y+N.size.y>=B.canvas.height||A.height>N.size.y+2){let t=!1;if(B.currentRow.y+B.currentRow.height+N.size.y>=B.canvas.height){let i;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+N.size.y<e.canvas.height){i=e;break}if(i)B=i;else if(e.maxAtlasPages&&this._pages.length>=e.maxAtlasPages&&A.y+N.size.y<=B.canvas.height&&A.height>=N.size.y&&A.x+N.size.x<=B.canvas.width)t=!0;else{let e=this._createNewPage();B=e,A=e.currentRow,A.height=N.size.y,t=!0}}t||(B.currentRow.height>0&&B.fixedRows.push(B.currentRow),A={x:0,y:B.currentRow.y+B.currentRow.height,height:N.size.y},B.fixedRows.push(A),B.currentRow={x:0,y:A.y+A.height,height:0})}if(A.x+N.size.x<=B.canvas.width)break;A===B.currentRow?(A.x=0,A.y+=A.height,A.height=0):B.fixedRows.splice(B.fixedRows.indexOf(A),1)}return N.texturePage=this._pages.indexOf(B),N.texturePosition.x=A.x,N.texturePosition.y=A.y,N.texturePositionClipSpace.x=A.x/B.canvas.width,N.texturePositionClipSpace.y=A.y/B.canvas.height,N.sizeClipSpace.x/=B.canvas.width,N.sizeClipSpace.y/=B.canvas.height,A.height=Math.max(A.height,N.size.y),A.x+=N.size.x,B.ctx.putImageData(D,N.texturePosition.x-this._workBoundingBox.left,N.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,N.size.x,N.size.y),B.addGlyph(N),B.version++,N}_findGlyphBoundingBox(e,t,i,r,s,n){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,a=r?this._config.deviceCellWidth:i,l=!1;for(let h=0;h<o;h++){for(let i=0;i<a;i++){let r=h*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.top=h,l=!0;break}}if(l)break}t.left=0,l=!1;for(let h=0;h<n+a;h++){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*h+3;if(0!==e.data[r]){t.left=h,l=!0;break}}if(l)break}t.right=a,l=!1;for(let h=n+a-1;h>=n;h--){for(let i=0;i<o;i++){let r=i*this._tmpCanvas.width*4+4*h+3;if(0!==e.data[r]){t.right=h,l=!0;break}}if(l)break}t.bottom=o,l=!1;for(let h=o-1;h>=0;h--){for(let i=0;i<a;i++){let r=h*this._tmpCanvas.width*4+4*i+3;if(0!==e.data[r]){t.bottom=h,l=!0;break}}if(l)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+n+(r||s?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+n+(r||s?1===this._config.lineHeight?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},gS=class{constructor(e,t,i){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],i)for(let r of i)this._glyphs.push(...r.glyphs),this._usedPixels+=r._usedPixels;this.canvas=mS(e,t,t),this.ctx=kb(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(e){this._glyphs.push(e),this._usedPixels+=e.size.x*e.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 vS(e,t,i,r){let s=t.rgba>>>24,n=t.rgba>>>16&255,o=t.rgba>>>8&255,a=i.rgba>>>24,l=i.rgba>>>16&255,h=i.rgba>>>8&255,c=Math.floor((Math.abs(s-a)+Math.abs(n-l)+Math.abs(o-h))/12),u=!0;for(let d=0;d<e.data.length;d+=4)e.data[d]===s&&e.data[d+1]===n&&e.data[d+2]===o||r&&Math.abs(e.data[d]-s)+Math.abs(e.data[d+1]-n)+Math.abs(e.data[d+2]-o)<c?e.data[d+3]=0:u=!1;return u}function mS(e,t,i){let r=e.createElement("canvas");return r.width=t,r.height=i,r}function yS(e,t){for(let i=0;i<e.colors.ansi.length;i++)if(e.colors.ansi[i].rgba!==t.colors.ansi[i].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}var bS=[];function SS(e,t,i,r,s,n,o,a,l){let h=function(e,t,i,r,s,n,o,a){let l={foreground:n.foreground,background:n.background,cursor:wb,cursorAccent:wb,selectionForeground:wb,selectionBackgroundTransparent:wb,selectionBackgroundOpaque:wb,selectionInactiveBackgroundTransparent:wb,selectionInactiveBackgroundOpaque:wb,overviewRulerBorder:wb,scrollbarSliderBackground:wb,scrollbarSliderHoverBackground:wb,scrollbarSliderActiveBackground:wb,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:s.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:a,letterSpacing:s.letterSpacing,lineHeight:s.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:i,deviceCharHeight:r,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,fontWeightBold:s.fontWeightBold,allowTransparency:s.allowTransparency,drawBoldTextInBrightColors:s.drawBoldTextInBrightColors,minimumContrastRatio:s.minimumContrastRatio,colors:l}}(r,s,n,o,t,i,a,l);for(let d=0;d<bS.length;d++){let t=bS[d],i=t.ownedBy.indexOf(e);if(i>=0){if(yS(t.config,h))return t.atlas;1===t.ownedBy.length?(t.atlas.dispose(),bS.splice(d,1)):t.ownedBy.splice(i,1);break}}for(let d=0;d<bS.length;d++){let t=bS[d];if(yS(t.config,h))return t.ownedBy.push(e),t.atlas}let c=e._core,u={atlas:new pS(document,h,c.unicodeService),config:h,ownedBy:[e]};return bS.push(u),u.atlas}function wS(e){for(let t=0;t<bS.length;t++){let i=bS[t].ownedBy.indexOf(e);if(-1!==i){1===bS[t].ownedBy.length?(bS[t].atlas.dispose(),bS.splice(t,1)):bS[t].ownedBy.splice(i,1);break}}}var xS=600,CS=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,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(e=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=xS-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0)return void this._restartInterval(e)}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=xS-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(e)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},xS)},e)}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 kS(e,t,i){let r=new t.ResizeObserver(t=>{let s=t.find(t=>t.target===e);if(!s)return;if(!("devicePixelContentBoxSize"in s))return null==r||r.disconnect(),void(r=void 0);let n=s.devicePixelContentBoxSize[0].inlineSize,o=s.devicePixelContentBoxSize[0].blockSize;n>0&&o>0&&i(n,o)});try{r.observe(e,{box:["device-pixel-content-box"]})}catch{r.disconnect(),r=void 0}return ib(()=>null==r?void 0:r.disconnect())}var LS=class e extends Jb{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Zb,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?function(e){return e>65535?(e-=65536,String.fromCharCode(55296+(e>>10))+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(2===e[1].length){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=1024*(i-55296)+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ES=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function MS(e,t,i){let r=kb(e.createProgram());if(e.attachShader(r,kb(RS(e,e.VERTEX_SHADER,t))),e.attachShader(r,kb(RS(e,e.FRAGMENT_SHADER,i))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function RS(e,t,i){let r=kb(e.createShader(t));if(e.shaderSource(r,i),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}var TS=class{constructor(e){this.texture=e,this.version=-1}};var PS,DS=11,BS=DS*Float32Array.BYTES_PER_ELEMENT,AS=0,NS=0,IS=0,OS=class extends nb{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._optionsService=r,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let s=this._gl;void 0===pS.maxAtlasPages&&(pS.maxAtlasPages=Math.min(32,kb(s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS))),pS.maxTextureSize=kb(s.getParameter(s.MAX_TEXTURE_SIZE))),this._program=kb(MS(s,"#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(e){let t="";for(let i=1;i<e;i++)t+=` else if (v_texpage == ${i}) { outColor = texture(u_texture[${i}], v_texcoord); }`;return`#version 300 es\nprecision lowp float;\n\nin vec2 v_texcoord;\nflat in int v_texpage;\n\nuniform sampler2D u_texture[${e}];\n\nout vec4 outColor;\n\nvoid main() {\n if (v_texpage == 0) {\n outColor = texture(u_texture[0], v_texcoord);\n } ${t}\n}`}(pS.maxAtlasPages))),this._register(ib(()=>s.deleteProgram(this._program))),this._projectionLocation=kb(s.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=kb(s.getUniformLocation(this._program,"u_resolution")),this._textureLocation=kb(s.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(ib(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,s.STATIC_DRAW),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(ib(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=kb(s.createBuffer()),this._register(ib(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,2,s.FLOAT,!1,BS,0),s.vertexAttribDivisor(2,1),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,s.FLOAT,!1,BS,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(3,1),s.enableVertexAttribArray(4),s.vertexAttribPointer(4,1,s.FLOAT,!1,BS,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(4,1),s.enableVertexAttribArray(5),s.vertexAttribPointer(5,2,s.FLOAT,!1,BS,5*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(5,1),s.enableVertexAttribArray(6),s.vertexAttribPointer(6,2,s.FLOAT,!1,BS,7*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(6,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,BS,9*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.useProgram(this._program);let h=new Int32Array(pS.maxAtlasPages);for(let c=0;c<pS.maxAtlasPages;c++)h[c]=c;s.uniform1iv(this._textureLocation,h),s.uniformMatrix4fv(this._projectionLocation,!1,ES),this._atlasTextures=[];for(let c=0;c<pS.maxAtlasPages;c++){let e=new TS(kb(s.createTexture()));this._register(ib(()=>s.deleteTexture(e.texture))),s.activeTexture(s.TEXTURE0+c),s.bindTexture(s.TEXTURE_2D,e.texture),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[c]=e}s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,i,r,s,n,o,a,l){this._updateCell(this._vertices.attributes,e,t,i,r,s,n,o,a,l)}_updateCell(e,t,i,r,s,n,o,a,l,h){AS=(i*this._terminal.cols+t)*DS,0!==r&&void 0!==r?this._atlas&&(PS=a&&a.length>1?this._atlas.getRasterizedGlyphCombinedChar(a,s,n,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,s,n,o,!1,this._terminal.element),NS=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),s!==h&&PS.offset.x>NS?(IS=PS.offset.x-NS,e[AS]=-(PS.offset.x-IS)+this._dimensions.device.char.left,e[AS+1]=-PS.offset.y+this._dimensions.device.char.top,e[AS+2]=(PS.size.x-IS)/this._dimensions.device.canvas.width,e[AS+3]=PS.size.y/this._dimensions.device.canvas.height,e[AS+4]=PS.texturePage,e[AS+5]=PS.texturePositionClipSpace.x+IS/this._atlas.pages[PS.texturePage].canvas.width,e[AS+6]=PS.texturePositionClipSpace.y,e[AS+7]=PS.sizeClipSpace.x-IS/this._atlas.pages[PS.texturePage].canvas.width,e[AS+8]=PS.sizeClipSpace.y):(e[AS]=-PS.offset.x+this._dimensions.device.char.left,e[AS+1]=-PS.offset.y+this._dimensions.device.char.top,e[AS+2]=PS.size.x/this._dimensions.device.canvas.width,e[AS+3]=PS.size.y/this._dimensions.device.canvas.height,e[AS+4]=PS.texturePage,e[AS+5]=PS.texturePositionClipSpace.x,e[AS+6]=PS.texturePositionClipSpace.y,e[AS+7]=PS.sizeClipSpace.x,e[AS+8]=PS.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&function(e,t,i,r){return 1===t&&i>Math.ceil(1.5*r)&&void 0!==e&&e>255&&!function(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}(e)&&!Lb(e)&&!function(e){return 57344<=e&&e<=63743}(e)}(r,l,PS.size.x,this._dimensions.device.cell.width)&&(e[AS+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width)):e.fill(0,AS,AS+DS-1-2)}clear(){let e=this._terminal,t=e.cols*e.rows*DS;this._vertices.count!==t?this._vertices.attributes=new Float32Array(t):this._vertices.attributes.fill(0);let i=0;for(;i<this._vertices.attributesBuffers.length;i++)this._vertices.count!==t?this._vertices.attributesBuffers[i]=new Float32Array(t):this._vertices.attributesBuffers[i].fill(0);this._vertices.count=t,i=0;for(let r=0;r<e.rows;r++)for(let t=0;t<e.cols;t++)this._vertices.attributes[i+9]=t/e.cols,this._vertices.attributes[i+10]=r/e.rows,i+=DS}handleResize(){let e=this._gl;e.useProgram(this._program),e.viewport(0,0,e.canvas.width,e.canvas.height),e.uniform2f(this._resolutionLocation,e.canvas.width,e.canvas.height),this.clear()}render(e){if(!this._atlas)return;let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let i=this._vertices.attributesBuffers[this._activeBuffer],r=0;for(let s=0;s<e.lineLengths.length;s++){let t=s*this._terminal.cols*DS,n=this._vertices.attributes.subarray(t,t+e.lineLengths[s]*DS);i.set(n,r),r+=n.length}t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,i.subarray(0,r),t.STREAM_DRAW);for(let s=0;s<this._atlas.pages.length;s++)this._atlas.pages[s].version!==this._atlasTextures[s].version&&this._bindAtlasPageTexture(t,this._atlas,s);t.drawElementsInstanced(t.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,r/DS)}setAtlas(e){this._atlas=e;for(let t of this._atlasTextures)t.version=-1}_bindAtlasPageTexture(e,t,i){e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,this._atlasTextures[i].texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.pages[i].canvas),e.generateMipmap(e.TEXTURE_2D),this._atlasTextures[i].version=t.pages[i].version}setDimensions(e){this._dimensions=e}},zS=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,r=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1])return void this.clear();let s=e.buffers.active.ydisp,n=t[1]-s,o=i[1]-s,a=Math.max(n,0),l=Math.min(o,e.rows-1);a>=e.rows||l<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0])}isCellSelected(e,t,i){return!!this.hasSelection&&(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol)}};var FS=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=new zS}resize(e,t){let i=e*t*4;i!==this.cells.length&&(this.cells=new Uint32Array(i),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},jS=8*Float32Array.BYTES_PER_ELEMENT,WS=class{constructor(){this.attributes=new Float32Array(160),this.count=0}},HS=0,$S=0,US=0,KS=0,qS=0,VS=0,YS=0,GS=class extends nb{constructor(e,t,i,r){super(),this._terminal=e,this._gl=t,this._dimensions=i,this._themeService=r,this._vertices=new WS,this._verticesCursor=new WS;let s=this._gl;this._program=kb(MS(s,"#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(ib(()=>s.deleteProgram(this._program))),this._projectionLocation=kb(s.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=s.createVertexArray(),s.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=s.createBuffer();this._register(ib(()=>s.deleteBuffer(o))),s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,n,s.STATIC_DRAW),s.enableVertexAttribArray(3),s.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let a=new Uint8Array([0,1,2,3]),l=s.createBuffer();this._register(ib(()=>s.deleteBuffer(l))),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,l),s.bufferData(s.ELEMENT_ARRAY_BUFFER,a,s.STATIC_DRAW),this._attributesBuffer=kb(s.createBuffer()),this._register(ib(()=>s.deleteBuffer(this._attributesBuffer))),s.bindBuffer(s.ARRAY_BUFFER,this._attributesBuffer),s.enableVertexAttribArray(0),s.vertexAttribPointer(0,2,s.FLOAT,!1,jS,0),s.vertexAttribDivisor(0,1),s.enableVertexAttribArray(1),s.vertexAttribPointer(1,2,s.FLOAT,!1,jS,2*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(1,1),s.enableVertexAttribArray(2),s.vertexAttribPointer(2,4,s.FLOAT,!1,jS,4*Float32Array.BYTES_PER_ELEMENT),s.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,ES),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.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(e){let t,i,r,s,n,o,a,l,h,c,u,d=this._terminal,f=this._vertices,_=1;for(t=0;t<d.rows;t++){for(r=-1,s=0,n=0,o=!1,i=0;i<d.cols;i++)a=4*(t*d.cols+i),l=e.cells[a+1],h=e.cells[a+2],c=!!(67108864&h),(l!==s||h!==n&&(o||c))&&((0!==s||o&&0!==n)&&(u=8*_++,this._updateRectangle(f,u,n,s,r,i,t)),r=i,s=l,n=h,o=c);(0!==s||o&&0!==n)&&(u=8*_++,this._updateRectangle(f,u,n,s,r,d.cols,t))}f.count=_}updateCursor(e){let t=this._verticesCursor,i=e.cursor;if(!i||"block"===i.style)return void(t.count=0);let r,s=0;("bar"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,"bar"===i.style?i.dpr*i.cursorWidth:i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),("underline"===i.style||"outline"===i.style)&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,(i.y+1)*this._dimensions.device.cell.height-i.dpr,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat)),"outline"===i.style&&(r=8*s++,this._addRectangleFloat(t.attributes,r,i.x*this._dimensions.device.cell.width,i.y*this._dimensions.device.cell.height,i.width*this._dimensions.device.cell.width,i.dpr,this._cursorFloat),r=8*s++,this._addRectangleFloat(t.attributes,r,(i.x+i.width)*this._dimensions.device.cell.width-i.dpr,i.y*this._dimensions.device.cell.height,i.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=s}_updateRectangle(e,t,i,r,s,n,o){if(67108864&i)switch(50331648&i){case 16777216:case 33554432:HS=this._themeService.colors.ansi[255&i].rgba;break;case 50331648:HS=(16777215&i)<<8;break;default:HS=this._themeService.colors.foreground.rgba}else switch(50331648&r){case 16777216:case 33554432:HS=this._themeService.colors.ansi[255&r].rgba;break;case 50331648:HS=(16777215&r)<<8;break;default:HS=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=function(e,t){let i=Math.min(2*e.length,t),r=new Float32Array(i);for(let s=0;s<e.length;s++)r[s]=e[s];return r}(e.attributes,this._terminal.rows*this._terminal.cols*8)),$S=s*this._dimensions.device.cell.width,US=o*this._dimensions.device.cell.height,KS=(HS>>24&255)/255,qS=(HS>>16&255)/255,VS=(HS>>8&255)/255,YS=1,this._addRectangle(e.attributes,t,$S,US,(n-s)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,KS,qS,VS,YS)}_addRectangle(e,t,i,r,s,n,o,a,l,h){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=n/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=a,e[t+6]=l,e[t+7]=h}_addRectangleFloat(e,t,i,r,s,n,o){e[t]=i/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=s/this._dimensions.device.canvas.width,e[t+3]=n/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(255&e.rgba)/255])}},XS=class extends nb{constructor(e,t,i,r,s,n,o,a){super(),this._container=t,this._alpha=s,this._coreBrowserService=n,this._optionsService=o,this._themeService=a,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${i}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(ib(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=kb(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,i){}handleSelectionChanged(e,t,i,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let i=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,i),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=SS(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,i=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,i*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,i,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,i,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=Ob,this._clipCell(i,r,t.getWidth()),this._ctx.fillText(t.getChars(),i*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,i){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,i*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,i){return`${i?"italic":""} ${t?e.options.fontWeightBold:e.options.fontWeight} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},QS=class extends XS{constructor(e,t,i,r,s,n,o){super(i,e,"link",t,!0,s,n,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(257===e.fg?this._ctx.fillStyle=this._themeService.colors.background.css:void 0!==e.fg&&function(e){return 16777216==(50331648&e)||33554432==(50331648&e)}(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},JS="object"==typeof window?window:globalThis,ZS=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new dS,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new dS,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(i,e),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let i=this.getWindowId(t);this.mapWindowIdToFullScreen.set(i,e),this._onDidChangeFullscreen.fire(i)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};ZS.INSTANCE=new ZS;var ew=ZS;ew.INSTANCE.onDidChangeZoomLevel,ew.INSTANCE.onDidChangeFullscreen;var tw="object"==typeof navigator?navigator.userAgent:"";tw.indexOf("Firefox"),tw.indexOf("AppleWebKit"),!(tw.indexOf("Chrome")>=0)&&tw.indexOf("Safari"),tw.indexOf("Electron/"),tw.indexOf("Android");var iw=!1;if("function"==typeof JS.matchMedia){let e=JS.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=JS.matchMedia("(display-mode: fullscreen)");iw=e.matches,function(e,t,i){"string"==typeof t&&(t=e.matchMedia(t)),t.addEventListener("change",i)}(JS,e,({matches:e})=>{iw&&t.matches||(iw=e)})}var rw,sw,nw="en",ow=!1,aw=nw,lw=globalThis;typeof lw.vscode<"u"&&typeof lw.vscode.process<"u"?sw=lw.vscode.process:typeof process<"u"&&"string"==typeof(null==(o=null==process?void 0:process.versions)?void 0:o.node)&&(sw=process);var hw="string"==typeof(null==(a=null==sw?void 0:sw.versions)?void 0:a.electron)&&"renderer"===(null==sw?void 0:sw.type);if("object"==typeof sw){sw.platform,sw.platform,"linux"===sw.platform&&!!sw.env.SNAP&&sw.env.SNAP_REVISION,!!sw.env.CI||sw.env.BUILD_ARTIFACTSTAGINGDIRECTORY,aw=nw;let e=sw.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,aw=t.resolvedLanguage||nw,null==(l=t.languagePack)?void 0:l.translationsConfigFile}catch{}ow=!0}else"object"!=typeof navigator||hw?console.error("Unable to resolve platform."):((rw=navigator.userAgent).indexOf("Windows"),rw.indexOf("Macintosh"),(rw.indexOf("Macintosh")>=0||rw.indexOf("iPad")>=0||rw.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints,rw.indexOf("Linux")>=0,null==rw||rw.indexOf("Mobi"),aw=globalThis._VSCODE_NLS_LANGUAGE||nw,navigator.language.toLowerCase());var cw,uw=ow,dw=rw,fw=aw;(e=>{e.value=function(){return fw},e.isDefaultVariant=function(){return 2===fw.length?"en"===fw:fw.length>=3&&("e"===fw[0]&&"n"===fw[1]&&"-"===fw[2])},e.isDefault=function(){return"en"===fw}})(cw||(cw={}));var _w="function"==typeof lw.postMessage&&!lw.importScripts;(()=>{if(_w){let e=[];lw.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let r=e[i];if(r.id===t.data.vscodeScheduleAsyncWork)return e.splice(i,1),void r.callback()}});let t=0;return i=>{let r=++t;e.push({id:r,callback:i}),lw.postMessage({vscodeScheduleAsyncWork:r},"*")}}})();var pw=!!(dw&&dw.indexOf("Chrome")>=0);dw&&dw.indexOf("Firefox"),!pw&&dw&&dw.indexOf("Safari"),dw&&dw.indexOf("Edg/"),dw&&dw.indexOf("Android");var gw="object"==typeof navigator?navigator:{};uw||document.queryCommandSupported&&document.queryCommandSupported("copy")||gw&&gw.clipboard&&gw.clipboard.writeText,uw||gw&&gw.clipboard&&gw.clipboard.readText;var vw,mw,yw=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},bw=new yw,Sw=new yw,ww=new yw;new Array(230),(mw=vw||(vw={})).toString=function(e){return bw.keyCodeToStr(e)},mw.fromString=function(e){return bw.strToKeyCode(e)},mw.toUserSettingsUS=function(e){return Sw.keyCodeToStr(e)},mw.toUserSettingsGeneral=function(e){return ww.keyCodeToStr(e)},mw.fromUserSettings=function(e){return Sw.strToKeyCode(e)||ww.strToKeyCode(e)},mw.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return bw.keyCodeToStr(e)};var xw,Cw=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}});(e=>{e.isCancellationToken=function(t){return t===e.None||t===e.Cancelled||t instanceof Lw||!(!t||"object"!=typeof t)&&("boolean"==typeof t.isCancellationRequested&&"function"==typeof t.onCancellationRequested)},e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Vb.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Cw})})(xw||(xw={}));var kw,Lw=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?Cw:(this._emitter||(this._emitter=new dS),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};(e=>{e.settled=async function(e){let t,i=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||(t=e)})));if(typeof t<"u")throw t;return i},e.withAsyncBody=function(e){return new Promise(async(t,i)=>{try{await e(t,i)}catch(mw){i(mw)}})}})(kw||(kw={}));var Ew=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let i of t)e.emitOne(i)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new dS,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(i){this.reject(i)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await Vb.toPromise(this._onStateChanged.event)}},return:async()=>{var e;return null==(e=this._onReturn)||e.call(this),{done:!0,value:void 0}}}}static map(t,i){return new e(async e=>{for await(let r of t)e.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async e=>{for await(let r of t)i(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let i of e)t.push(i);return t}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Ew.EMPTY=Ew.fromArray([]);var{getWindow:Mw}=function(){let e=new Map,t={window:JS,disposables:new sb};e.set(JS.vscodeWindowId,t);let i=new dS,r=new dS,s=new dS;return{onDidRegisterWindow:i.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return nb.None;let n=new sb,o={window:t,disposables:n.add(new sb)};return e.set(t.vscodeWindowId,o),n.add(ib(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),n.add(Tw(t,Pw.BEFORE_UNLOAD,()=>{s.fire(t)})),i.fire(o),n},getWindows:()=>e.values(),getWindowsCount:()=>e.size,getWindowId:e=>e.vscodeWindowId,hasWindow:t=>e.has(t),getWindowById:function(i,r){return("number"==typeof i?e.get(i):void 0)??(r?t:void 0)},getWindow(e){var t;let i=e;if(null==(t=null==i?void 0:i.ownerDocument)?void 0:t.defaultView)return i.ownerDocument.defaultView.window;let r=e;return(null==r?void 0:r.view)?r.view.window:JS},getDocument:e=>Mw(e).document}}(),Rw=class{constructor(e,t,i,r){this._node=e,this._type=t,this._handler=i,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Tw(e,t,i,r){return new Rw(e,t,i,r)}var Pw={BEFORE_UNLOAD:"beforeunload"},Dw=class extends nb{constructor(e,t,i,r,s,n,o,a,l){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=i,this._coreBrowserService=r,this._coreService=s,this._decorationService=n,this._optionsService=o,this._themeService=a,this._cursorBlinkStateManager=new ob,this._charAtlasDisposable=this._register(new ob),this._observerDisposable=this._register(new ob),this._model=new FS,this._workCell=new LS,this._workCell2=new LS,this._rectangleRenderer=this._register(new ob),this._glyphRenderer=this._register(new ob),this._onChangeTextureAtlas=this._register(new dS),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new dS),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new dS),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new dS),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new dS),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let h={antialias:!1,depth:!1,preserveDrawingBuffer:l};if(this._gl=this._canvas.getContext("webgl2",h),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Ib(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new QS(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,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(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Tw(this._canvas,"webglcontextlost",e=>{console.log("webglcontextlost event received"),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(e)},3e3)})),this._register(Tw(this._canvas,"webglcontextrestored",e=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,wS(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=kS(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=kS(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(ib(()=>{var e;for(let t of this._renderLayers)t.dispose();null==(e=this._canvas.parentElement)||e.removeChild(this._canvas),wS(this._terminal)}))}get textureAtlas(){var e;return null==(e=this._charAtlas)?void 0:e.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(e,t){var i,r,s,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.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`,null==(i=this._rectangleRenderer.value)||i.setDimensions(this.dimensions),null==(r=this._rectangleRenderer.value)||r.handleResize(),null==(s=this._glyphRenderer.value)||s.setDimensions(this.dimensions),null==(n=this._glyphRenderer.value)||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var e;for(let t of this._renderLayers)t.handleBlur(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.pause(),this._requestRedrawViewport()}handleFocus(){var e;for(let t of this._renderLayers)t.handleFocus(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,i){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,i);this._model.selection.update(this._core,e,t,i),this._requestRedrawViewport()}handleCursorMove(){var e;for(let t of this._renderLayers)t.handleCursorMove(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new GS(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new OS(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);let t=SS(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=tb(Vb.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Vb.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),null==(e=this._glyphRenderer.value)||e.setAtlas(this._charAtlas)}_clearModel(e){var t;this._model.clear(),e&&(null==(t=this._glyphRenderer.value)||t.clear())}clearTextureAtlas(){var e;null==(e=this._charAtlas)||e.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var e;this._clearModel(!0);for(let t of this._renderLayers)t.reset(this._terminal);null==(e=this._cursorBlinkStateManager.value)||e.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){var i;if(!this._isAttached){if(!((null==(i=this._core.screenElement)?void 0:i.isConnected)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(let r of this._renderLayers)r.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),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 CS(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let i,r,s,n,o,a,l,h,c,u,d,f,_,p,g,v=this._core,m=this._workCell,y=0,b=!0;e=Aw(e,v.rows-1,0),t=Aw(t,v.rows-1,0);let S=this._coreService.decPrivateModes.cursorStyle??v.options.cursorStyle??"block",w=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,x=w-v.buffer.ydisp,C=Math.min(this._terminal.buffer.active.cursorX,v.cols-1),k=-1,L=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let E=!1;for(r=e;r<=t;r++)for(s=r+v.buffer.ydisp,n=v.buffer.lines.get(s),this._model.lineLengths[r]=0,c=w===s,y=0,o=this._characterJoinerService.getJoinedCharacters(s),p=0;p<v.cols;p++){if(i=this._cellColorResolver.result.bg,n.loadCell(p,m),0===p&&(i=this._cellColorResolver.result.bg),a=!1,b=p>=y,l=p,o.length>0&&p===o[0][0]&&b){h=o.shift();let e=this._model.selection.isCellSelected(this._terminal,h[0],s);for(_=h[0]+1;_<h[1];_++)b&&(b=e===this._model.selection.isCellSelected(this._terminal,_,s));b&&(b=!c||C<h[0]||C>=h[1]),b?(a=!0,m=new Bw(m,n.translateToString(!0,h[0],h[1]),h[1]-h[0]),l=h[1]-1):y=h[1]}if(u=m.getChars(),d=m.getCode(),_=4*(r*v.cols+p),this._cellColorResolver.resolve(m,p,s,this.dimensions.device.cell.width),L&&s===w&&(p===C&&(this._model.cursor={x:C,y:x,width:m.getWidth(),style:this._coreBrowserService.isFocused?S:v.options.cursorInactiveStyle,cursorWidth:v.options.cursorWidth,dpr:this._devicePixelRatio},k=C+m.getWidth()-1),p>=C&&p<=k&&(this._coreBrowserService.isFocused&&"block"===S||!1===this._coreBrowserService.isFocused&&"block"===v.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!==d&&(this._model.lineLengths[r]=p+1),(this._model.cells[_]!==d||this._model.cells[_+1]!==this._cellColorResolver.result.bg||this._model.cells[_+2]!==this._cellColorResolver.result.fg||this._model.cells[_+3]!==this._cellColorResolver.result.ext)&&(E=!0,u.length>1&&(d|=2147483648),this._model.cells[_]=d,this._model.cells[_+1]=this._cellColorResolver.result.bg,this._model.cells[_+2]=this._cellColorResolver.result.fg,this._model.cells[_+3]=this._cellColorResolver.result.ext,f=m.getWidth(),this._glyphRenderer.value.updateCell(p,r,d,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,u,f,i),a)){for(m=this._workCell,p++;p<=l;p++)g=4*(r*v.cols+p),this._glyphRenderer.value.updateCell(p,r,0,0,0,0,"",0,0),this._model.cells[g]=0,this._model.cells[g+1]=this._cellColorResolver.result.bg,this._model.cells[g+2]=this._cellColorResolver.result.fg,this._model.cells[g+3]=this._cellColorResolver.result.ext;p--}}E&&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(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Bw=class extends Jb{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Aw(e,t,i=0){return Math.max(Math.min(e,t),i)}var Nw="di$target",Iw="di$dependencies",Ow=new Map;function zw(e){if(Ow.has(e))return Ow.get(e);let t=function(e,i,r){if(3!==arguments.length)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");!function(e,t,i){t[Nw]===t?t[Iw].push({id:e,index:i}):(t[Iw]=[{id:e,index:i}],t[Nw]=t)}(t,e,r)};return t._id=e,Ow.set(e,t),t}zw("BufferService"),zw("CoreMouseService"),zw("CoreService"),zw("CharsetService"),zw("InstantiationService"),zw("LogService");var Fw=zw("OptionsService");zw("OscLinkService"),zw("UnicodeService"),zw("DecorationService");var jw={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ww=class extends nb{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=jw[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)"function"==typeof e[t]&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log((null==(i=this._optionsService.options.logger)?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Ww=((e,t)=>{for(var i,r=t,s=e.length-1;s>=0;s--)(i=e[s])&&(r=i(r)||r);return r})([((e,t)=>(i,r)=>t(i,r,e))(0,Fw)],Ww);var Hw=class extends nb{constructor(e){if(db&&function(){if(!db)return 0;let e=lb.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new dS),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new dS),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new dS),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new dS),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element)return void this._register(t.onWillOpen(()=>this.activate(e)));this._terminal=e;let i=t.coreService,r=t.optionsService,s=t,n=s._renderService,o=s._characterJoinerService,a=s._charSizeService,l=s._coreBrowserService,h=s._decorationService;s._logService;let c=s._themeService;this._renderer=this._register(new Dw(e,o,a,l,i,h,r,c,this._preserveDrawingBuffer)),this._register(Vb.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Vb.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Vb.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Vb.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(ib(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){var e;return null==(e=this._renderer)?void 0:e.textureAtlas}clearTextureAtlas(){var e;null==(e=this._renderer)||e.clearTextureAtlas()}};function $w(){return"light"===dd(gd.getState().theme)?Gu:Yu}const Uw=new Set,Kw=new Map,qw=new Map,Vw=new Map,Yw=new Map,Gw=new Map;function Xw(e){const t="light"===dd(gd.getState().theme);e.options.theme=$w(),e.options.minimumContrastRatio=t?7:1}let Qw=gd.getState().theme;function Jw(e,t){if(!Yw.has(e))try{const i=new Hw;i.onContextLoss(()=>{i.dispose(),Yw.delete(e)}),t.loadAddon(i),Yw.set(e,i)}catch{}}function Zw(e){const t=Yw.get(e);t&&(t.dispose(),Yw.delete(e))}gd.subscribe(e=>{if(e.theme!==Qw){Qw=e.theme;for(const e of Gw.values())Xw(e)}});let ex=gd.getState().gpuRendering;function tx(e){return qw.get(e)}gd.subscribe(e=>{if(e.gpuRendering!==ex){ex=e.gpuRendering;for(const[t,i]of Gw)e.gpuRendering?Jw(t,i):Zw(t)}});const ix=new Map;function rx({terminalId:e,projectId:t,cwd:i}){const r=Y.useRef(null),s=Y.useRef(null),n=Y.useRef(null),o=Y.useRef(null),a=$u(e=>e.setTerminalInstance),l=$u(e=>e.createSession),h=gd(e=>e.setFocusedTerminal);Y.useEffect(()=>{var c,u;const d=r.current;if(!d)return;d.innerHTML="";const f=$u.getState().sessions[e],_=Kw.get(e);if((null==f?void 0:f.terminal)&&_){const t=f.terminal;s.current=t,d.appendChild(_);let i=Vw.get(e);return i||(i=new Fm,t.loadAddon(i),Vw.set(e,i)),n.current=i,requestAnimationFrame(()=>{try{i.fit(),t.scrollToBottom();const{cols:r,rows:s}=t;o.current={cols:r,rows:s},ox({type:"pty:resize",terminalId:e,cols:r,rows:s})}catch{}}),()=>{}}const p=$w(),g="light"===dd(gd.getState().theme),v=new zm({theme:p,fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', 'Menlo', monospace",fontSize:13,lineHeight:1.2,cursorBlink:!0,cursorStyle:"bar",allowProposedApi:!0,scrollback:1e4,minimumContrastRatio:g?7:1}),m=new Fm,y=new Km((e,t)=>{(e.ctrlKey||e.metaKey)&&ox({type:"open:url",url:t})}),b=new Ky;v.loadAddon(m),v.loadAddon(y),v.loadAddon(b),v.open(d),Vw.set(e,m),qw.set(e,b),s.current=v,n.current=m,v.element&&Kw.set(e,v.element),gd.getState().gpuRendering&&Jw(e,v);const S=null==(c=v.element)?void 0:c.querySelector(".xterm-screen");return S&&S.addEventListener("mouseup",t=>{const i=t;i.ctrlKey||i.metaKey||setTimeout(()=>{if(v.hasSelection())return;const t=v.buffer.active;if(t.viewportY!==t.baseY)return;const r=S.getBoundingClientRect(),s=Math.floor((i.clientX-r.left)/(r.width/v.cols));if(Math.floor((i.clientY-r.top)/(r.height/v.rows))!==t.cursorY)return;const n=t.getLine(t.baseY+t.cursorY);if(!n)return;const o=n.translateToString().trimEnd().length,a=Math.min(s,o)-t.cursorX;if(0===a)return;ox({type:"pty:input",terminalId:e,data:(a>0?"":"").repeat(Math.abs(a))})},0)}),null==(u=v.element)||u.addEventListener("copy",e=>{var t;const i=v.getSelection();if(i){const r=i.split("\n").map(e=>e.trimEnd()).join("\n");null==(t=e.clipboardData)||t.setData("text/plain",r),e.preventDefault()}}),l(e,t),a(e,v),v.attachCustomKeyEventHandler(t=>{if("Enter"===t.key&&t.shiftKey)return"keydown"===t.type&&ox({type:"pty:input",terminalId:e,data:"\n"}),!1;if(t.metaKey&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&"keydown"===t.type){if("ArrowLeft"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1;if("ArrowRight"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1;if("Backspace"===t.key)return ox({type:"pty:input",terminalId:e,data:""}),!1}return!(t.metaKey&&"f"===t.key&&!t.altKey&&!t.ctrlKey)&&(!(t.metaKey&&"p"===t.key&&!t.altKey&&!t.ctrlKey)&&(!(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)&&t.ctrlKey&&t.shiftKey&&!t.metaKey&&!t.altKey)&&(!(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)&&t.shiftKey&&!t.ctrlKey&&!t.metaKey&&!t.altKey)||"alternate"===v.buffer.active.type)))}),v.onData(t=>{ox({type:"pty:input",terminalId:e,data:t})}),v.onTitleChange(t=>{$u.getState().setTitle(e,t)}),Uw.has(e)||(Uw.add(e),requestAnimationFrame(()=>{try{m.fit()}catch{}ox({type:"pty:spawn",terminalId:e,projectId:t,cwd:i}),ox({type:"pty:resize",terminalId:e,cols:v.cols,rows:v.rows}),o.current={cols:v.cols,rows:v.rows},v.focus(),h(e)})),()=>{}},[e,t,i,l,a]),Y.useEffect(()=>{const t=s.current;t&&(Xw(t),function(e,t){Gw.set(e,t)}(e,t));const i=window.matchMedia("(prefers-color-scheme: light)"),r=()=>{t&&"system"===gd.getState().theme&&Xw(t)};return i.addEventListener("change",r),()=>{var t;t=e,Gw.delete(t),i.removeEventListener("change",r)}},[e]);const c=Y.useCallback(()=>{const t=n.current,i=s.current;if(t&&i)try{t.fit(),i.scrollToBottom();const{cols:r,rows:s}=i,n=o.current;n&&n.cols===r&&n.rows===s||(o.current={cols:r,rows:s},ox({type:"pty:resize",terminalId:e,cols:r,rows:s}))}catch{}},[e]),u=Y.useCallback(()=>{var t;null==(t=s.current)||t.focus(),h(e)},[e,h]);return{containerRef:r,fit:c,focus:u,terminalRef:s}}function sx(e){Uw.delete(e),Kw.delete(e),Vw.delete(e),qw.delete(e),Zw(e),Gw.delete(e)}let nx=null;function ox(e){(null==nx?void 0:nx.readyState)===WebSocket.OPEN&&nx.send(JSON.stringify(e))}function ax(){const e=gd(e=>e.setConnectionStatus),t=Vu(e=>e.addProject),i=Vu(e=>e.setActiveProject),r=Y.useRef(),s=Y.useCallback(()=>{if((null==nx?void 0:nx.readyState)===WebSocket.OPEN||(null==nx?void 0:nx.readyState)===WebSocket.CONNECTING)return;e("connecting");const n=new WebSocket(`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/ws`);nx=n,n.onopen=()=>{e("connected"),ox({type:"editor:sync",enabled:gd.getState().editorSyncEnabled})},n.onmessage=e=>{var r,s;try{const n=JSON.parse(e.data);if("pty:output"===n.type){const e=$u.getState().sessions[n.terminalId];if(null==e?void 0:e.terminal){const t=e.terminal,i=t.buffer.active,r=i.viewportY>=i.baseY-1;t.write(n.data,()=>{r&&t.scrollToBottom()})}const t=function(e){const t=ix.get(e);return void 0!==t?(ix.delete(e),t):null}(n.terminalId);return void(t&&ox({type:"pty:input",terminalId:n.terminalId,data:t}))}if("pty:exit"===n.type){const e=n.terminalId,t=$u.getState().sessions[e],i=null==t?void 0:t.projectId;if(null==(r=null==t?void 0:t.terminal)||r.dispose(),$u.getState().removeSession(e),sx(e),i){cd.getState().removePaneFromProject(i,e),Vu.getState().removeTerminalFromProject(i,e);const t=Xu(cd.getState().getLayout(i)),r=gd.getState().focusedTerminalId;if(r===e&&t.length>0){const e=t[0];gd.getState().setFocusedTerminal(e);const i=$u.getState().sessions[e];null==(s=null==i?void 0:i.terminal)||s.focus()}else r===e&&gd.getState().setFocusedTerminal(null)}return}if("project:spawned"===n.type){const e=Object.values(Vu.getState().projects).find(e=>e.cwd===n.cwd);return void(e?i(e.id):(t({id:n.projectId,name:n.name,cwd:n.cwd,terminalIds:[]}),i(n.projectId)))}if("port:status"===n.type)return void $u.getState().setActivePorts(n.ports);if("claude:status"===n.type)return void $u.getState().setClaudeStatus(n.statuses);if("git:branch"===n.type)return void $u.getState().setGitBranches(n.branches);if("inbox:paste"===n.type){const e=gd.getState().focusedTerminalId;if(e&&n.files.length>0){ox({type:"pty:input",terminalId:e,data:n.files.map(e=>"'"+e.replace(/'/g,"'\\''")+"'").join(" ")})}return}if("editor:status"===n.type)return void $u.getState().setEditorNeedsAccessibility(n.needsAccessibility);if("editor:active"===n.type){if(!gd.getState().editorSyncEnabled)return;const{projects:e,activeProjectId:t}=Vu.getState(),r=Object.values(e).find(e=>{const t=e.cwd.replace(/\/$/,"").split("/").pop();return e.name===n.projectName||t===n.projectName});r&&r.id!==t&&(gd.getState().showSyncToast(r.name),i(r.id))}}catch{}},n.onclose=()=>{e("disconnected"),$u.getState().setActivePorts({}),$u.getState().setClaudeStatus({}),$u.getState().setGitBranches({}),$u.getState().setEditorNeedsAccessibility(!1),nx=null,r.current=setTimeout(s,2e3)},n.onerror=()=>{n.close()}},[e,t,i]);Y.useEffect(()=>(s(),()=>{clearTimeout(r.current)}),[s])}const lx=new Set(["n","w","t","d","r","f","p"]);const hx=Hu()((e,t)=>({favourites:{},addFavourite:i=>{e(e=>({favourites:{...e.favourites,[i.id]:i}})),qu({favourites:{...t().favourites}})},updateFavourite:(i,r)=>{e(e=>{const t=e.favourites[i];return t?{favourites:{...e.favourites,[i]:{...t,...r}}}:e}),qu({favourites:{...t().favourites}})},removeFavourite:i=>{e(e=>{const{[i]:t,...r}=e.favourites;return{favourites:r}}),qu({favourites:{...t().favourites}})},hydrateFromServer:async()=>{try{const t=await fetch("/api/settings"),i=await t.json();i.favourites&&e({favourites:i.favourites})}catch{}}})),cx=(...e)=>e.filter((e,t,i)=>Boolean(e)&&i.indexOf(e)===t).join(" ");
63
63
  /**
64
64
  * @license lucide-react v0.400.0 - ISC
65
65
  *
@@ -15,7 +15,7 @@
15
15
  document.documentElement.setAttribute('data-theme', t);
16
16
  })();
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-g078iI8U.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-BO_xZPlW.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-BptWthNY.css">
20
20
  </head>
21
21
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paneful",
3
- "version": "0.9.15",
4
- "description": "A fast, GPU-accelerated terminal multiplexer in your browser or as a native macOS app. Split panes, organize projects, sync with your editor, detect AI agents.",
3
+ "version": "0.9.16",
4
+ "description": "A fast, GPU-accelerated terminal manager with split panes, project organization, editor sync, and AI agent detection. Native macOS app or browser.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "paneful": "./dist/server/index.js"