UNPKG

ssh-terminal

Version:

SSH Terminal component based on xterm.js for multiple frontend frameworks

5 lines (4 loc) 615 kB
(function(er,tr){typeof exports=="object"&&typeof module<"u"?module.exports=tr():typeof define=="function"&&define.amd?define(tr):(er=typeof globalThis<"u"?globalThis:er||self,er.SshTerminal=tr())})(this,function(){"use strict";function er(e,t){for(var i=0;i<t.length;i++){const r=t[i];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in e)){const c=Object.getOwnPropertyDescriptor(r,n);c&&Object.defineProperty(e,n,c.get?c:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var tr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function vn(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var i=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(i,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}),i}var Vi={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={4567:function(a,s,o){var l=this&&this.__decorate||function(v,C,S,b){var w,E=arguments.length,x=E<3?C:b===null?b=Object.getOwnPropertyDescriptor(C,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(v,C,S,b);else for(var R=v.length-1;R>=0;R--)(w=v[R])&&(x=(E<3?w(x):E>3?w(C,S,x):w(C,S))||x);return E>3&&x&&Object.defineProperty(C,S,x),x},f=this&&this.__param||function(v,C){return function(S,b){C(S,b,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const u=o(9042),g=o(6114),m=o(9924),y=o(844),_=o(5596),h=o(4725),d=o(3656);let p=s.AccessibilityManager=class extends y.Disposable{constructor(v,C){super(),this._terminal=v,this._renderService=C,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(S=>this._handleResize(S.rows))),this.register(this._terminal.onRender(S=>this._refreshRows(S.start,S.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(S=>this._handleChar(S))),this.register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this.register(this._terminal.onA11yTab(S=>this._handleTab(S))),this.register(this._terminal.onKey(S=>this._handleKey(S.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new _.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,d.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,y.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(v){for(let C=0;C<v;C++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout(()=>{this._accessibilityContainer.appendChild(this._liveRegion)},0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(v){this._clearLiveRegion(),/\p{Control}/u.test(v)||this._charsToConsume.push(v)}_refreshRows(v,C){this._liveRegionDebouncer.refresh(v,C,this._terminal.rows)}_renderRows(v,C){const S=this._terminal.buffer,b=S.lines.length.toString();for(let w=v;w<=C;w++){const E=S.translateBufferLineToString(S.ydisp+w,!0),x=(S.ydisp+w+1).toString(),R=this._rowElements[w];R&&(E.length===0?R.innerText=" ":R.textContent=E,R.setAttribute("aria-posinset",x),R.setAttribute("aria-setsize",b))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,C){const S=v.target,b=this._rowElements[C===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==b)return;let w,E;if(C===0?(w=S,E=this._rowElements.pop(),this._rowContainer.removeChild(E)):(w=this._rowElements.shift(),E=S,this._rowContainer.removeChild(w)),w.removeEventListener("focus",this._topBoundaryFocusListener),E.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const x=this._createAccessibilityTreeNode();this._rowElements.unshift(x),this._rowContainer.insertAdjacentElement("afterbegin",x)}else{const x=this._createAccessibilityTreeNode();this._rowElements.push(x),this._rowContainer.appendChild(x)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(C===0?-1:1),this._rowElements[C===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let C=this._rowContainer.children.length;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=document.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};s.AccessibilityManager=p=l([f(1,h.IRenderService)],p)},3614:(a,s)=>{function o(g){return g.replace(/\r?\n/g,"\r")}function l(g,m){return m?"\x1B[200~"+g+"\x1B[201~":g}function f(g,m,y,_){g=l(g=o(g),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),m.value=""}function u(g,m,y){const _=y.getBoundingClientRect(),h=g.clientX-_.left-10,d=g.clientY-_.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${h}px`,m.style.top=`${d}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(s,"__esModule",{value:!0}),s.rightClickHandler=s.moveTextAreaUnderMouseCursor=s.paste=s.handlePasteEvent=s.copyHandler=s.bracketTextForPaste=s.prepareTextForTerminal=void 0,s.prepareTextForTerminal=o,s.bracketTextForPaste=l,s.copyHandler=function(g,m){g.clipboardData&&g.clipboardData.setData("text/plain",m.selectionText),g.preventDefault()},s.handlePasteEvent=function(g,m,y,_){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),m,y,_)},s.paste=f,s.moveTextAreaUnderMouseCursor=u,s.rightClickHandler=function(g,m,y,_,h){u(g,m,y),h&&_.rightClickSelect(g),m.value=_.selectionText,m.select()}},7239:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorContrastCache=void 0;const l=o(1505);s.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(f,u,g){this._css.set(f,u,g)}getCss(f,u){return this._css.get(f,u)}setColor(f,u,g){this._color.set(f,u,g)}getColor(f,u){return this._color.get(f,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,l,f,u){o.addEventListener(l,f,u);let g=!1;return{dispose:()=>{g||(g=!0,o.removeEventListener(l,f,u))}}}},6465:function(a,s,o){var l=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Linkifier2=void 0;const u=o(3656),g=o(8460),m=o(844),y=o(2585);let _=s.Linkifier2=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(h){super(),this._bufferService=h,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)(()=>{this._lastMouseEvent=void 0})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0}))}registerLinkProvider(h){return this._linkProviders.push(h),{dispose:()=>{const d=this._linkProviders.indexOf(h);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(h,d,p){this._element=h,this._mouseService=d,this._renderService=p,this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(h){if(this._lastMouseEvent=h,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const p=h.composedPath();for(let v=0;v<p.length;v++){const C=p[v];if(C.classList.contains("xterm"))break;if(C.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(h){if(this._activeLine!==h.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(h,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,h)||(this._clearCurrentLink(),this._askForLink(h,!0))}_askForLink(h,d){var p,v;this._activeProviderReplies&&d||((p=this._activeProviderReplies)===null||p===void 0||p.forEach(S=>{S?.forEach(b=>{b.link.dispose&&b.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=h.y);let C=!1;for(const[S,b]of this._linkProviders.entries())d?!((v=this._activeProviderReplies)===null||v===void 0)&&v.get(S)&&(C=this._checkLinkProviderResult(S,h,C)):b.provideLinks(h.y,w=>{var E,x;if(this._isMouseOut)return;const R=w?.map(P=>({link:P}));(E=this._activeProviderReplies)===null||E===void 0||E.set(S,R),C=this._checkLinkProviderResult(S,h,C),((x=this._activeProviderReplies)===null||x===void 0?void 0:x.size)===this._linkProviders.length&&this._removeIntersectingLinks(h.y,this._activeProviderReplies)})}_removeIntersectingLinks(h,d){const p=new Set;for(let v=0;v<d.size;v++){const C=d.get(v);if(C)for(let S=0;S<C.length;S++){const b=C[S],w=b.link.range.start.y<h?0:b.link.range.start.x,E=b.link.range.end.y>h?this._bufferService.cols:b.link.range.end.x;for(let x=w;x<=E;x++){if(p.has(x)){C.splice(S--,1);break}p.add(x)}}}}_checkLinkProviderResult(h,d,p){var v;if(!this._activeProviderReplies)return p;const C=this._activeProviderReplies.get(h);let S=!1;for(let b=0;b<h;b++)this._activeProviderReplies.has(b)&&!this._activeProviderReplies.get(b)||(S=!0);if(!S&&C){const b=C.find(w=>this._linkAtPosition(w.link,d));b&&(p=!0,this._handleNewLink(b))}if(this._activeProviderReplies.size===this._linkProviders.length&&!p)for(let b=0;b<this._activeProviderReplies.size;b++){const w=(v=this._activeProviderReplies.get(b))===null||v===void 0?void 0:v.find(E=>this._linkAtPosition(E.link,d));if(w){p=!0,this._handleNewLink(w);break}}return p}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(h){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(h,this._currentLink.link.text)}_clearCurrentLink(h,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!h||!d||this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(h){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(h.link,d)&&(this._currentLink=h,this._currentLink.state={decorations:{underline:h.link.decorations===void 0||h.link.decorations.underline,pointerCursor:h.link.decorations===void 0||h.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,h.link,this._lastMouseEvent),h.link.decorations={},Object.defineProperties(h.link.decorations,{pointerCursor:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.pointerCursor},set:p=>{var v,C;!((v=this._currentLink)===null||v===void 0)&&v.state&&this._currentLink.state.decorations.pointerCursor!==p&&(this._currentLink.state.decorations.pointerCursor=p,this._currentLink.state.isHovered&&((C=this._element)===null||C===void 0||C.classList.toggle("xterm-cursor-pointer",p)))}},underline:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.underline},set:p=>{var v,C,S;!((v=this._currentLink)===null||v===void 0)&&v.state&&((S=(C=this._currentLink)===null||C===void 0?void 0:C.state)===null||S===void 0?void 0:S.decorations.underline)!==p&&(this._currentLink.state.decorations.underline=p,this._currentLink.state.isHovered&&this._fireUnderlineEvent(h.link,p))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(p=>{if(!this._currentLink)return;const v=p.start===0?0:p.start+1+this._bufferService.buffer.ydisp,C=this._bufferService.buffer.ydisp+1+p.end;if(this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=C&&(this._clearCurrentLink(v,C),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}})))}_linkHover(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&h.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(p,d.text)}_fireUnderlineEvent(h,d){const p=h.range,v=this._bufferService.buffer.ydisp,C=this._createLinkUnderlineEvent(p.start.x-1,p.start.y-v-1,p.end.x,p.end.y-v-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(C)}_linkLeave(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&h.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(p,d.text)}_linkAtPosition(h,d){const p=h.range.start.y*this._bufferService.cols+h.range.start.x,v=h.range.end.y*this._bufferService.cols+h.range.end.x,C=d.y*this._bufferService.cols+d.x;return p<=C&&C<=v}_positionFromMouseEvent(h,d,p){const v=p.getCoords(h,d,this._bufferService.cols,this._bufferService.rows);if(v)return{x:v[0],y:v[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(h,d,p,v,C){return{x1:h,y1:d,x2:p,y2:v,cols:this._bufferService.cols,fg:C}}};s.Linkifier2=_=l([f(0,y.IBufferService)],_)},9042:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tooMuchOutput=s.promptLabel=void 0,s.promptLabel="Terminal input",s.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,s,o){var l=this&&this.__decorate||function(_,h,d,p){var v,C=arguments.length,S=C<3?h:p===null?p=Object.getOwnPropertyDescriptor(h,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,h,d,p);else for(var b=_.length-1;b>=0;b--)(v=_[b])&&(S=(C<3?v(S):C>3?v(h,d,S):v(h,d))||S);return C>3&&S&&Object.defineProperty(h,d,S),S},f=this&&this.__param||function(_,h){return function(d,p){h(d,p,_)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkProvider=void 0;const u=o(511),g=o(2585);let m=s.OscLinkProvider=class{constructor(_,h,d){this._bufferService=_,this._optionsService=h,this._oscLinkService=d}provideLinks(_,h){var d;const p=this._bufferService.buffer.lines.get(_-1);if(!p)return void h(void 0);const v=[],C=this._optionsService.rawOptions.linkHandler,S=new u.CellData,b=p.getTrimmedLength();let w=-1,E=-1,x=!1;for(let R=0;R<b;R++)if(E!==-1||p.hasContent(R)){if(p.loadCell(R,S),S.hasExtendedAttrs()&&S.extended.urlId){if(E===-1){E=R,w=S.extended.urlId;continue}x=S.extended.urlId!==w}else E!==-1&&(x=!0);if(x||E!==-1&&R===b-1){const P=(d=this._oscLinkService.getLinkData(w))===null||d===void 0?void 0:d.uri;if(P){const k={start:{x:E+1,y:_},end:{x:R+(x||R!==b-1?0:1),y:_}};let D=!1;if(!C?.allowNonHttpProtocols)try{const V=new URL(P);["http:","https:"].includes(V.protocol)||(D=!0)}catch{D=!0}D||v.push({text:P,range:k,activate:(V,q)=>C?C.activate(V,q,k):y(0,q),hover:(V,q)=>{var $;return($=C?.hover)===null||$===void 0?void 0:$.call(C,V,q,k)},leave:(V,q)=>{var $;return($=C?.leave)===null||$===void 0?void 0:$.call(C,V,q,k)}})}x=!1,S.hasExtendedAttrs()&&S.extended.urlId?(E=R,w=S.extended.urlId):(E=-1,w=-1)}}h(v)}};function y(_,h){if(confirm(`Do you want to navigate to ${h}? WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=h}else console.warn("Opening link blocked as opener could not be cleared")}}s.OscLinkProvider=m=l([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],m)},6193:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderDebouncer=void 0,s.RenderDebouncer=class{constructor(o,l){this._parentWindow=o,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(o,l,f){this._rowCount=f,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ScreenDprMonitor=void 0;const l=o(844);class f extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)(()=>{this.clearListener()}))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}s.ScreenDprMonitor=f},3236:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Terminal=void 0;const l=o(3614),f=o(3656),u=o(6465),g=o(9042),m=o(3730),y=o(1680),_=o(3107),h=o(5744),d=o(2950),p=o(1296),v=o(428),C=o(4269),S=o(5114),b=o(8934),w=o(3230),E=o(9312),x=o(4725),R=o(6731),P=o(8055),k=o(8969),D=o(8460),V=o(844),q=o(6114),$=o(8437),W=o(2584),L=o(7399),N=o(5941),O=o(9074),U=o(2585),Y=o(5435),ee=o(4567),le=typeof window<"u"?window.document:null;class se extends k.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(I={}){super(I),this.browser=q,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new V.MutableDisposable),this._onCursorMove=this.register(new D.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new D.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new D.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new D.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new D.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new D.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new D.EventEmitter),this._onBlur=this.register(new D.EventEmitter),this._onA11yCharEmitter=this.register(new D.EventEmitter),this._onA11yTabEmitter=this.register(new D.EventEmitter),this._onWillOpen=this.register(new D.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(u.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(m.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(U.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((K,G)=>this.refresh(K,G))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(K=>this._reportWindowsOptions(K))),this.register(this._inputHandler.onColor(K=>this._handleColorEvent(K))),this.register((0,D.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,D.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,D.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(K=>this._afterResize(K.cols,K.rows))),this.register((0,V.toDisposable)(()=>{var K,G;this._customKeyEventHandler=void 0,(G=(K=this.element)===null||K===void 0?void 0:K.parentNode)===null||G===void 0||G.removeChild(this.element)}))}_handleColorEvent(I){if(this._themeService)for(const K of I){let G,j="";switch(K.index){case 256:G="foreground",j="10";break;case 257:G="background",j="11";break;case 258:G="cursor",j="12";break;default:G="ansi",j="4;"+K.index}switch(K.type){case 0:const ce=P.color.toColorRGB(G==="ansi"?this._themeService.colors.ansi[K.index]:this._themeService.colors[G]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${j};${(0,N.toRgbString)(ce)}${W.C1_ESCAPED.ST}`);break;case 1:if(G==="ansi")this._themeService.modifyColors(re=>re.ansi[K.index]=P.rgba.toColor(...K.color));else{const re=G;this._themeService.modifyColors(de=>de[re]=P.rgba.toColor(...K.color))}break;case 2:this._themeService.restoreColor(K.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(I){I?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ee.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(I){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[I"),this.updateCursorStyle(I),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var I;return(I=this.textarea)===null||I===void 0?void 0:I.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const I=this.buffer.ybase+this.buffer.y,K=this.buffer.lines.get(I);if(!K)return;const G=Math.min(this.buffer.x,this.cols-1),j=this._renderService.dimensions.css.cell.height,ce=K.getWidth(G),re=this._renderService.dimensions.css.cell.width*ce,de=this.buffer.y*this._renderService.dimensions.css.cell.height,xe=G*this._renderService.dimensions.css.cell.width;this.textarea.style.left=xe+"px",this.textarea.style.top=de+"px",this.textarea.style.width=re+"px",this.textarea.style.height=j+"px",this.textarea.style.lineHeight=j+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",K=>{this.hasSelection()&&(0,l.copyHandler)(K,this._selectionService)}));const I=K=>(0,l.handlePasteEvent)(K,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",I)),this.register((0,f.addDisposableDomListener)(this.element,"paste",I)),q.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",K=>{K.button===2&&(0,l.rightClickHandler)(K,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",K=>{(0,l.rightClickHandler)(K,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),q.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",K=>{K.button===1&&(0,l.moveTextAreaUnderMouseCursor)(K,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",I=>this._keyUp(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",I=>this._keyDown(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",I=>this._keyPress(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",I=>this._compositionHelper.compositionupdate(I))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,f.addDisposableDomListener)(this.textarea,"input",I=>this._inputEvent(I),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(I){var K;if(!I)throw new Error("Terminal requires a parent element.");I.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=I.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),I.appendChild(this.element);const G=le.createDocumentFragment();this._viewportElement=le.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),G.appendChild(this._viewportElement),this._viewportScrollArea=le.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=le.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=le.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),G.appendChild(this.screenElement),this.textarea=le.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),q.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(K=this._document.defaultView)!==null&&K!==void 0?K:window),this._instantiationService.setService(x.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",j=>this._handleTextAreaFocus(j))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(C.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(w.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(j=>this._onRender.fire(j))),this.onResize(j=>this._renderService.resize(j.cols,j.rows)),this._compositionView=le.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(G);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(b.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(j=>this.scrollLines(j.amount,j.suppressScrollEvent,1)),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),this.register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this.register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this.register(this.onBlur(()=>this._renderService.handleBlur())),this.register(this.onFocus(()=>this._renderService.handleFocus())),this.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(E.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(j=>this.scrollLines(j.amount,j.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(j=>this._renderService.handleSelectionChanged(j.start,j.end,j.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(j=>{this.textarea.value=j,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(j=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",j=>this._selectionService.handleMouseDown(j))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ee.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",j=>this._handleScreenReaderModeOptionChange(j))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",j=>{!this._overviewRulerRenderer&&j&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(p.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const I=this,K=this.element;function G(re){const de=I._mouseService.getMouseReportCoords(re,I.screenElement);if(!de)return!1;let xe,Ae;switch(re.overrideType||re.type){case"mousemove":Ae=32,re.buttons===void 0?(xe=3,re.button!==void 0&&(xe=re.button<3?re.button:3)):xe=1&re.buttons?0:4&re.buttons?1:2&re.buttons?2:3;break;case"mouseup":Ae=0,xe=re.button<3?re.button:3;break;case"mousedown":Ae=1,xe=re.button<3?re.button:3;break;case"wheel":if(I.viewport.getLinesScrolled(re)===0)return!1;Ae=re.deltaY<0?0:1,xe=4;break;default:return!1}return!(Ae===void 0||xe===void 0||xe>4)&&I.coreMouseService.triggerMouseEvent({col:de.col,row:de.row,x:de.x,y:de.y,button:xe,action:Ae,ctrl:re.ctrlKey,alt:re.altKey,shift:re.shiftKey})}const j={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ce={mouseup:re=>(G(re),re.buttons||(this._document.removeEventListener("mouseup",j.mouseup),j.mousedrag&&this._document.removeEventListener("mousemove",j.mousedrag)),this.cancel(re)),wheel:re=>(G(re),this.cancel(re,!0)),mousedrag:re=>{re.buttons&&G(re)},mousemove:re=>{re.buttons||G(re)}};this.register(this.coreMouseService.onProtocolChange(re=>{re?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(re)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&re?j.mousemove||(K.addEventListener("mousemove",ce.mousemove),j.mousemove=ce.mousemove):(K.removeEventListener("mousemove",j.mousemove),j.mousemove=null),16&re?j.wheel||(K.addEventListener("wheel",ce.wheel,{passive:!1}),j.wheel=ce.wheel):(K.removeEventListener("wheel",j.wheel),j.wheel=null),2&re?j.mouseup||(K.addEventListener("mouseup",ce.mouseup),j.mouseup=ce.mouseup):(this._document.removeEventListener("mouseup",j.mouseup),K.removeEventListener("mouseup",j.mouseup),j.mouseup=null),4&re?j.mousedrag||(j.mousedrag=ce.mousedrag):(this._document.removeEventListener("mousemove",j.mousedrag),j.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(K,"mousedown",re=>{if(re.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(re))return G(re),j.mouseup&&this._document.addEventListener("mouseup",j.mouseup),j.mousedrag&&this._document.addEventListener("mousemove",j.mousedrag),this.cancel(re)})),this.register((0,f.addDisposableDomListener)(K,"wheel",re=>{if(!j.wheel){if(!this.buffer.hasScrollback){const de=this.viewport.getLinesScrolled(re);if(de===0)return;const xe=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(re.deltaY<0?"A":"B");let Ae="";for(let Jt=0;Jt<Math.abs(de);Jt++)Ae+=xe;return this.coreService.triggerDataEvent(Ae,!0),this.cancel(re,!0)}return this.viewport.handleWheel(re)?this.cancel(re):void 0}},{passive:!1})),this.register((0,f.addDisposableDomListener)(K,"touchstart",re=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(re),this.cancel(re)},{passive:!0})),this.register((0,f.addDisposableDomListener)(K,"touchmove",re=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(re)?void 0:this.cancel(re)},{passive:!1}))}refresh(I,K){var G;(G=this._renderService)===null||G===void 0||G.refreshRows(I,K)}updateCursorStyle(I){var K;!((K=this._selectionService)===null||K===void 0)&&K.shouldColumnSelect(I)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(I,K,G=0){var j;G===1?(super.scrollLines(I,K,G),this.refresh(0,this.rows-1)):(j=this.viewport)===null||j===void 0||j.scrollLines(I)}paste(I){(0,l.paste)(I,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(I){this._customKeyEventHandler=I}registerLinkProvider(I){return this.linkifier2.registerLinkProvider(I)}registerCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const K=this._characterJoinerService.register(I);return this.refresh(0,this.rows-1),K}deregisterCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(I)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(I){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+I)}registerDecoration(I){return this._decorationService.registerDecoration(I)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(I,K,G){this._selectionService.setSelection(I,K,G)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var I;(I=this._selectionService)===null||I===void 0||I.clearSelection()}selectAll(){var I;(I=this._selectionService)===null||I===void 0||I.selectAll()}selectLines(I,K){var G;(G=this._selectionService)===null||G===void 0||G.selectLines(I,K)}_keyDown(I){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;const K=this.browser.isMac&&this.options.macOptionIsMeta&&I.altKey;if(!K&&!this._compositionHelper.keydown(I))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;K||I.key!=="Dead"&&I.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const G=(0,L.evaluateKeyboardEvent)(I,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(I),G.type===3||G.type===2){const j=this.rows-1;return this.scrollLines(G.type===2?-j:j),this.cancel(I,!0)}return G.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,I)||(G.cancel&&this.cancel(I,!0),!G.key||!!(I.key&&!I.ctrlKey&&!I.altKey&&!I.metaKey&&I.key.length===1&&I.key.charCodeAt(0)>=65&&I.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(G.key!==W.C0.ETX&&G.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:G.key,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(G.key,!0),!this.optionsService.rawOptions.screenReaderMode||I.altKey||I.ctrlKey?this.cancel(I,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(I,K){const G=I.isMac&&!this.options.macOptionIsMeta&&K.altKey&&!K.ctrlKey&&!K.metaKey||I.isWindows&&K.altKey&&K.ctrlKey&&!K.metaKey||I.isWindows&&K.getModifierState("AltGraph");return K.type==="keypress"?G:G&&(!K.keyCode||K.keyCode>47)}_keyUp(I){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1||(function(K){return K.keyCode===16||K.keyCode===17||K.keyCode===18}(I)||this.focus(),this.updateCursorStyle(I),this._keyPressHandled=!1)}_keyPress(I){let K;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;if(this.cancel(I),I.charCode)K=I.charCode;else if(I.which===null||I.which===void 0)K=I.keyCode;else{if(I.which===0||I.charCode===0)return!1;K=I.which}return!(!K||(I.altKey||I.ctrlKey||I.metaKey)&&!this._isThirdLevelShift(this.browser,I)||(K=String.fromCharCode(K),this._onKey.fire({key:K,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(K,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(I){if(I.data&&I.inputType==="insertText"&&(!I.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const K=I.data;return this.coreService.triggerDataEvent(K,!0),this.cancel(I),!0}return!1}resize(I,K){I!==this.cols||K!==this.rows?super.resize(I,K):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(I,K){var G,j;(G=this._charSizeService)===null||G===void 0||G.measure(),(j=this.viewport)===null||j===void 0||j.syncScrollArea(!0)}clear(){var I;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let K=1;K<this.rows;K++)this.buffer.lines.push(this.buffer.getBlankLine($.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(I=this.viewport)===null||I===void 0||I.reset(),this.refresh(0,this.rows-1)}}reset(){var I,K;this.options.rows=this.rows,this.options.cols=this.cols;const G=this._customKeyEventHandler;this._setup(),super.reset(),(I=this._selectionService)===null||I===void 0||I.reset(),this._decorationService.reset(),(K=this.viewport)===null||K===void 0||K.reset(),this._customKeyEventHandler=G,this.refresh(0,this.rows-1)}clearTextureAtlas(){var I;(I=this._renderService)===null||I===void 0||I.clearTextureAtlas()}_reportFocus(){var I;!((I=this.element)===null||I===void 0)&&I.classList.contains("focus")?this.coreService.triggerDataEvent(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(I){if(this._renderService)switch(I){case Y.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const K=this._renderService.dimensions.css.canvas.width.toFixed(0),G=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${G};${K}t`);break;case Y.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const j=this._renderService.dimensions.css.cell.width.toFixed(0),ce=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ce};${j}t`)}}cancel(I,K){if(this.options.cancelEvents||K)return I.preventDefault(),I.stopPropagation(),!1}}s.Terminal=se},9924:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TimeBasedDebouncer=void 0,s.TimeBasedDebouncer=class{constructor(o,l=1e3){this._renderCallback=o,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,l,f){this._rowCount=f,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const u=Date.now();if(u-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=u,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=u-this._lastRefreshMs,m=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},m)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l)}}},1680:function(a,s,o){var l=this&&this.__decorate||function(d,p,v,C){var S,b=arguments.length,w=b<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,v):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,p,v,C);else for(var E=d.length-1;E>=0;E--)(S=d[E])&&(w=(b<3?S(w):b>3?S(p,v,w):S(p,v))||w);return b>3&&w&&Object.defineProperty(p,v,w),w},f=this&&this.__param||function(d,p){return function(v,C){p(v,C,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Viewport=void 0;const u=o(3656),g=o(4725),m=o(8460),y=o(844),_=o(2585);let h=s.Viewport=class extends y.Disposable{constructor(d,p,v,C,S,b,w,E){super(),this._viewportElement=d,this._scrollArea=p,this._bufferService=v,this._optionsService=C,this._charSizeService=S,this._renderService=b,this._coreBrowserService=w,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange(x=>this._renderDimensions=x)),this._handleThemeChange(E.colors),this.register(E.onChangeColors(x=>this._handleThemeChange(x))),this.register(this._optionsService.onSpeci