accompany 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var xs=Object.create;var{getPrototypeOf:Es,defineProperty:Gt,getOwnPropertyNames:As}=Object;var qt=Object.prototype.hasOwnProperty;function ks(e){return this[e]}var Ls,Ts,Rs=(e,r,s)=>{var c=e!=null&&typeof e==="object";if(c){var f=r?Ls??=new WeakMap:Ts??=new WeakMap,a=f.get(e);if(a)return a}s=e!=null?xs(Es(e)):{};let y=r||!e||!e.__esModule||!qt.call(e,"default")?Gt(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let t of As(e))if(!qt.call(y,t))Gt(y,t,{get:ks.bind(e,t),enumerable:!0})}if(c)f.set(e,y);return y};var Bs=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Xt=(e)=>JSON.parse(e);var Br=Bs(function(Rr){(()=>{var e={5639:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;let l=n(7150),p=n(802);class g extends l.Disposable{constructor(d){super(),this._maxLength=d,this.onDeleteEmitter=this._register(new p.Emitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new p.Emitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new p.Emitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(d){if(this._maxLength===d)return;let _=Array(d);for(let v=0;v<Math.min(d,this.length);v++)_[v]=this._array[this._getCyclicIndex(v)];this._array=_,this._maxLength=d,this._startIndex=0}get length(){return this._length}set length(d){if(d>this._length)for(let _=this._length;_<d;_++)this._array[_]=void 0;this._length=d}get(d){return this._array[this._getCyclicIndex(d)]}set(d,_){this._array[this._getCyclicIndex(d)]=_}push(d){this._array[this._getCyclicIndex(this._length)]=d,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(d,_,...v){if(_){for(let o=d;o<this._length-_;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+_)];this._length-=_,this.onDeleteEmitter.fire({index:d,amount:_})}for(let o=this._length-1;o>=d;o--)this._array[this._getCyclicIndex(o+v.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<v.length;o++)this._array[this._getCyclicIndex(d+o)]=v[o];if(v.length&&this.onInsertEmitter.fire({index:d,amount:v.length}),this._length+v.length>this._maxLength){let o=this._length+v.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=v.length}trimStart(d){d>this._length&&(d=this._length),this._startIndex+=d,this._length-=d,this.onTrimEmitter.fire(d)}shiftElements(d,_,v){if(!(_<=0)){if(d<0||d>=this._length)throw Error("start argument out of range");if(d+v<0)throw Error("Cannot shift elements in list beyond index 0");if(v>0){for(let i=_-1;i>=0;i--)this.set(d+i+v,this.get(d+i));let o=d+_+v-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<_;o++)this.set(d+o+v,this.get(d+o))}}_getCyclicIndex(d){return(this._startIndex+d)%this._maxLength}}t.CircularList=g},7453:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=function n(l,p=5){if(typeof l!="object")return l;let g=Array.isArray(l)?[]:{};for(let d in l)g[d]=p<=1?l[d]:l[d]&&n(l[d],p-1);return g}},5777:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;let l=n(6501),p=n(6025),g=n(7276),d=n(9640),_=n(56),v=n(4071),o=n(7792),i=n(6415),w=n(5746),h=n(5882),m=n(2486),u=n(3562),S=n(8811),C=n(802),T=n(7150),B=!1;class O extends T.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new C.Emitter),this._onScroll.event((A)=>{this._onScrollApi?.fire(A.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(A){for(let M in A)this.optionsService.options[M]=A[M]}constructor(A){super(),this._windowsWrappingHeuristics=this._register(new T.MutableDisposable),this._onBinary=this._register(new C.Emitter),this.onBinary=this._onBinary.event,this._onData=this._register(new C.Emitter),this.onData=this._onData.event,this._onLineFeed=this._register(new C.Emitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new C.Emitter),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new C.Emitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new C.Emitter),this._instantiationService=new p.InstantiationService,this.optionsService=this._register(new _.OptionsService(A)),this._instantiationService.setService(l.IOptionsService,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(d.BufferService)),this._instantiationService.setService(l.IBufferService,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(l.ILogService,this._logService),this.coreService=this._register(this._instantiationService.createInstance(v.CoreService)),this._instantiationService.setService(l.ICoreService,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(o.CoreMouseService)),this._instantiationService.setService(l.ICoreMouseService,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(i.UnicodeService)),this._instantiationService.setService(l.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(w.CharsetService),this._instantiationService.setService(l.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(S.OscLinkService),this._instantiationService.setService(l.IOscLinkService,this._oscLinkService),this._inputHandler=this._register(new m.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(C.Event.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(C.Event.forward(this._bufferService.onResize,this._onResize)),this._register(C.Event.forward(this.coreService.onData,this._onData)),this._register(C.Event.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new u.WriteBuffer((M,k)=>this._inputHandler.parse(M,k))),this._register(C.Event.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(A,M){this._writeBuffer.write(A,M)}writeSync(A,M){this._logService.logLevel<=l.LogLevelEnum.WARN&&!B&&(this._logService.warn("writeSync is unreliable and will be removed soon."),B=!0),this._writeBuffer.writeSync(A,M)}input(A,M=!0){this.coreService.triggerDataEvent(A,M)}resize(A,M){isNaN(A)||isNaN(M)||(A=Math.max(A,d.MINIMUM_COLS),M=Math.max(M,d.MINIMUM_ROWS),this._bufferService.resize(A,M))}scroll(A,M=!1){this._bufferService.scroll(A,M)}scrollLines(A,M){this._bufferService.scrollLines(A,M)}scrollPages(A){this.scrollLines(A*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(A){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(A){let M=A-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(A,M){return this._inputHandler.registerEscHandler(A,M)}registerDcsHandler(A,M){return this._inputHandler.registerDcsHandler(A,M)}registerCsiHandler(A,M){return this._inputHandler.registerCsiHandler(A,M)}registerOscHandler(A,M){return this._inputHandler.registerOscHandler(A,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let A=!1,M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?A=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(A=!0),A?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let A=[];A.push(this.onLineFeed(h.updateWindowsModeWrappedState.bind(null,this._bufferService))),A.push(this.registerCsiHandler({final:"H"},()=>((0,h.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,T.toDisposable)(()=>{for(let M of A)M.dispose()})}}}t.CoreTerminal=O},2486:function(y,t,n){var l=this&&this.__decorate||function(b,x,L,E){var D,H=arguments.length,I=H<3?x:E===null?E=Object.getOwnPropertyDescriptor(x,L):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(b,x,L,E);else for(var N=b.length-1;N>=0;N--)(D=b[N])&&(I=(H<3?D(I):H>3?D(x,L,I):D(x,L))||I);return H>3&&I&&Object.defineProperty(x,L,I),I},p=this&&this.__param||function(b,x){return function(L,E){x(L,E,b)}};Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0,t.isValidColorIndex=F;let g=n(3534),d=n(6760),_=n(6717),v=n(7150),o=n(726),i=n(6107),w=n(8938),h=n(3055),m=n(5451),u=n(6501),S=n(6415),C=n(1346),T=n(9823),B=n(8693),O=n(802),A={"(":0,")":1,"*":2,"+":3,"-":1,".":2},M=131072;function k(b,x){if(b>24)return x.setWinLines||!1;switch(b){case 1:return!!x.restoreWin;case 2:return!!x.minimizeWin;case 3:return!!x.setWinPosition;case 4:return!!x.setWinSizePixels;case 5:return!!x.raiseWin;case 6:return!!x.lowerWin;case 7:return!!x.refreshWin;case 8:return!!x.setWinSizeChars;case 9:return!!x.maximizeWin;case 10:return!!x.fullscreenWin;case 11:return!!x.getWinState;case 13:return!!x.getWinPosition;case 14:return!!x.getWinSizePixels;case 15:return!!x.getScreenSizePixels;case 16:return!!x.getCellSizePixels;case 18:return!!x.getWinSizeChars;case 19:return!!x.getScreenSizeChars;case 20:return!!x.getIconTitle;case 21:return!!x.getWinTitle;case 22:return!!x.pushTitle;case 23:return!!x.popTitle;case 24:return!!x.setWinLines}return!1}var P;(function(b){b[b.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",b[b.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(P||(t.WindowsOptionsReportType=P={}));let W=0;class z extends v.Disposable{getAttrData(){return this._curAttrData}constructor(b,x,L,E,D,H,I,N,j=new _.EscapeSequenceParser){super(),this._bufferService=b,this._charsetService=x,this._coreService=L,this._logService=E,this._optionsService=D,this._oscLinkService=H,this._coreMouseService=I,this._unicodeService=N,this._parser=j,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new o.StringToUtf32,this._utf8Decoder=new o.Utf8ToUtf32,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this._register(new O.Emitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O.Emitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O.Emitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O.Emitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O.Emitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O.Emitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O.Emitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O.Emitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O.Emitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O.Emitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O.Emitter),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O.Emitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O.Emitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new q(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((R)=>this._activeBuffer=R.activeBuffer)),this._parser.setCsiHandlerFallback((R,G)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:G.toArray()})}),this._parser.setEscHandlerFallback((R)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})}),this._parser.setExecuteHandlerFallback((R)=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})}),this._parser.setOscHandlerFallback((R,G,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:G,data:U})}),this._parser.setDcsHandlerFallback((R,G,U)=>{G==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:G,payload:U})}),this._parser.setPrintHandler((R,G,U)=>this.print(R,G,U)),this._parser.registerCsiHandler({final:"@"},(R)=>this.insertChars(R)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R)=>this.scrollLeft(R)),this._parser.registerCsiHandler({final:"A"},(R)=>this.cursorUp(R)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R)=>this.scrollRight(R)),this._parser.registerCsiHandler({final:"B"},(R)=>this.cursorDown(R)),this._parser.registerCsiHandler({final:"C"},(R)=>this.cursorForward(R)),this._parser.registerCsiHandler({final:"D"},(R)=>this.cursorBackward(R)),this._parser.registerCsiHandler({final:"E"},(R)=>this.cursorNextLine(R)),this._parser.registerCsiHandler({final:"F"},(R)=>this.cursorPrecedingLine(R)),this._parser.registerCsiHandler({final:"G"},(R)=>this.cursorCharAbsolute(R)),this._parser.registerCsiHandler({final:"H"},(R)=>this.cursorPosition(R)),this._parser.registerCsiHandler({final:"I"},(R)=>this.cursorForwardTab(R)),this._parser.registerCsiHandler({final:"J"},(R)=>this.eraseInDisplay(R,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R)=>this.eraseInDisplay(R,!0)),this._parser.registerCsiHandler({final:"K"},(R)=>this.eraseInLine(R,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R)=>this.eraseInLine(R,!0)),this._parser.registerCsiHandler({final:"L"},(R)=>this.insertLines(R)),this._parser.registerCsiHandler({final:"M"},(R)=>this.deleteLines(R)),this._parser.registerCsiHandler({final:"P"},(R)=>this.deleteChars(R)),this._parser.registerCsiHandler({final:"S"},(R)=>this.scrollUp(R)),this._parser.registerCsiHandler({final:"T"},(R)=>this.scrollDown(R)),this._parser.registerCsiHandler({final:"X"},(R)=>this.eraseChars(R)),this._parser.registerCsiHandler({final:"Z"},(R)=>this.cursorBackwardTab(R)),this._parser.registerCsiHandler({final:"`"},(R)=>this.charPosAbsolute(R)),this._parser.registerCsiHandler({final:"a"},(R)=>this.hPositionRelative(R)),this._parser.registerCsiHandler({final:"b"},(R)=>this.repeatPrecedingCharacter(R)),this._parser.registerCsiHandler({final:"c"},(R)=>this.sendDeviceAttributesPrimary(R)),this._parser.registerCsiHandler({prefix:">",final:"c"},(R)=>this.sendDeviceAttributesSecondary(R)),this._parser.registerCsiHandler({final:"d"},(R)=>this.linePosAbsolute(R)),this._parser.registerCsiHandler({final:"e"},(R)=>this.vPositionRelative(R)),this._parser.registerCsiHandler({final:"f"},(R)=>this.hVPosition(R)),this._parser.registerCsiHandler({final:"g"},(R)=>this.tabClear(R)),this._parser.registerCsiHandler({final:"h"},(R)=>this.setMode(R)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R)=>this.setModePrivate(R)),this._parser.registerCsiHandler({final:"l"},(R)=>this.resetMode(R)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R)=>this.resetModePrivate(R)),this._parser.registerCsiHandler({final:"m"},(R)=>this.charAttributes(R)),this._parser.registerCsiHandler({final:"n"},(R)=>this.deviceStatus(R)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R)=>this.deviceStatusPrivate(R)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R)=>this.softReset(R)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R)=>this.setCursorStyle(R)),this._parser.registerCsiHandler({final:"r"},(R)=>this.setScrollRegion(R)),this._parser.registerCsiHandler({final:"s"},(R)=>this.saveCursor(R)),this._parser.registerCsiHandler({final:"t"},(R)=>this.windowOptions(R)),this._parser.registerCsiHandler({final:"u"},(R)=>this.restoreCursor(R)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R)=>this.insertColumns(R)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R)=>this.deleteColumns(R)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R)=>this.selectProtected(R)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R)=>this.requestMode(R,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R)=>this.requestMode(R,!1)),this._parser.setExecuteHandler(g.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(g.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(g.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(g.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(g.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(g.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(g.C1.IND,()=>this.index()),this._parser.setExecuteHandler(g.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(g.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new C.OscHandler((R)=>(this.setTitle(R),this.setIconName(R),!0))),this._parser.registerOscHandler(1,new C.OscHandler((R)=>this.setIconName(R))),this._parser.registerOscHandler(2,new C.OscHandler((R)=>this.setTitle(R))),this._parser.registerOscHandler(4,new C.OscHandler((R)=>this.setOrReportIndexedColor(R))),this._parser.registerOscHandler(8,new C.OscHandler((R)=>this.setHyperlink(R))),this._parser.registerOscHandler(10,new C.OscHandler((R)=>this.setOrReportFgColor(R))),this._parser.registerOscHandler(11,new C.OscHandler((R)=>this.setOrReportBgColor(R))),this._parser.registerOscHandler(12,new C.OscHandler((R)=>this.setOrReportCursorColor(R))),this._parser.registerOscHandler(104,new C.OscHandler((R)=>this.restoreIndexedColor(R))),this._parser.registerOscHandler(110,new C.OscHandler((R)=>this.restoreFgColor(R))),this._parser.registerOscHandler(111,new C.OscHandler((R)=>this.restoreBgColor(R))),this._parser.registerOscHandler(112,new C.OscHandler((R)=>this.restoreCursorColor(R))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let R in d.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},()=>this.selectCharset("("+R)),this._parser.registerEscHandler({intermediates:")",final:R},()=>this.selectCharset(")"+R)),this._parser.registerEscHandler({intermediates:"*",final:R},()=>this.selectCharset("*"+R)),this._parser.registerEscHandler({intermediates:"+",final:R},()=>this.selectCharset("+"+R)),this._parser.registerEscHandler({intermediates:"-",final:R},()=>this.selectCharset("-"+R)),this._parser.registerEscHandler({intermediates:".",final:R},()=>this.selectCharset("."+R)),this._parser.registerEscHandler({intermediates:"/",final:R},()=>this.selectCharset("/"+R));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((R)=>(this._logService.error("Parsing error: ",R),R)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new T.DcsHandler((R,G)=>this.requestStatusString(R,G)))}_preserveStack(b,x,L,E){this._parseStack.paused=!0,this._parseStack.cursorStartX=b,this._parseStack.cursorStartY=x,this._parseStack.decodedLength=L,this._parseStack.position=E}_logSlowResolvingAsync(b){this._logService.logLevel<=u.LogLevelEnum.WARN&&Promise.race([b,new Promise((x,L)=>setTimeout(()=>L("#SLOW_TIMEOUT"),5000))]).catch((x)=>{if(x!=="#SLOW_TIMEOUT")throw x;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(b,x){let L,E=this._activeBuffer.x,D=this._activeBuffer.y,H=0,I=this._parseStack.paused;if(I){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,x))return this._logSlowResolvingAsync(L),L;E=this._parseStack.cursorStartX,D=this._parseStack.cursorStartY,this._parseStack.paused=!1,b.length>M&&(H=this._parseStack.position+M)}if(this._logService.logLevel<=u.LogLevelEnum.DEBUG&&this._logService.debug("parsing data "+(typeof b=="string"?` "${b}"`:` "${Array.prototype.map.call(b,(R)=>String.fromCharCode(R)).join("")}"`)),this._logService.logLevel===u.LogLevelEnum.TRACE&&this._logService.trace("parsing data (codes)",typeof b=="string"?b.split("").map((R)=>R.charCodeAt(0)):b),this._parseBuffer.length<b.length&&this._parseBuffer.length<M&&(this._parseBuffer=new Uint32Array(Math.min(b.length,M))),I||this._dirtyRowTracker.clearRange(),b.length>M)for(let R=H;R<b.length;R+=M){let G=R+M<b.length?R+M:b.length,U=typeof b=="string"?this._stringDecoder.decode(b.substring(R,G),this._parseBuffer):this._utf8Decoder.decode(b.subarray(R,G),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,U))return this._preserveStack(E,D,U,R),this._logSlowResolvingAsync(L),L}else if(!I){let R=typeof b=="string"?this._stringDecoder.decode(b,this._parseBuffer):this._utf8Decoder.decode(b,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,R))return this._preserveStack(E,D,R,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===E&&this._activeBuffer.y===D||this._onCursorMove.fire();let N=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),j=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);j<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(j,this._bufferService.rows-1),end:Math.min(N,this._bufferService.rows-1)})}print(b,x,L){let E,D,H=this._charsetService.charset,I=this._optionsService.rawOptions.screenReaderMode,N=this._bufferService.cols,j=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,G=this._curAttrData,U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-x>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodepoint(this._activeBuffer.x-1,0,1,G);let X=this._parser.precedingJoinState;for(let se=x;se<L;++se){if(E=b[se],E<127&&H){let he=H[String.fromCharCode(E)];he&&(E=he.charCodeAt(0))}let ie=this._unicodeService.charProperties(E,X);D=S.UnicodeService.extractWidth(ie);let ae=S.UnicodeService.extractShouldJoin(ie),ce=ae?S.UnicodeService.extractWidth(X):0;if(X=ie,I&&this._onA11yChar.fire((0,o.stringFromCodePoint)(E)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+D-ce>N){if(j){let he=U,Se=this._activeBuffer.x-ce;for(this._activeBuffer.x=ce,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),ce>0&&U instanceof i.BufferLine&&U.copyCellsFrom(he,Se,0,ce,!1);Se<N;)he.setCellFromCodepoint(Se++,0,1,G)}else if(this._activeBuffer.x=N-1,D===2)continue}if(ae&&this._activeBuffer.x){let he=U.getWidth(this._activeBuffer.x-1)?1:2;U.addCodepointToCell(this._activeBuffer.x-he,E,D);for(let Se=D-ce;--Se>=0;)U.setCellFromCodepoint(this._activeBuffer.x++,0,0,G)}else if(R&&(U.insertCells(this._activeBuffer.x,D-ce,this._activeBuffer.getNullCell(G)),U.getWidth(N-1)===2&&U.setCellFromCodepoint(N-1,w.NULL_CELL_CODE,w.NULL_CELL_WIDTH,G)),U.setCellFromCodepoint(this._activeBuffer.x++,E,D,G),D>0)for(;--D;)U.setCellFromCodepoint(this._activeBuffer.x++,0,0,G)}this._parser.precedingJoinState=X,this._activeBuffer.x<N&&L-x>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.setCellFromCodepoint(this._activeBuffer.x,0,1,G),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(b,x){return b.final!=="t"||b.prefix||b.intermediates?this._parser.registerCsiHandler(b,x):this._parser.registerCsiHandler(b,(L)=>!k(L.params[0],this._optionsService.rawOptions.windowOptions)||x(L))}registerDcsHandler(b,x){return this._parser.registerDcsHandler(b,new T.DcsHandler(x))}registerEscHandler(b,x){return this._parser.registerEscHandler(b,x)}registerOscHandler(b,x){return this._parser.registerOscHandler(b,new C.OscHandler(x))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);b.hasWidth(this._activeBuffer.x)&&!b.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-b),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(b=this._bufferService.cols-1){this._activeBuffer.x=Math.min(b,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(b,x){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=b,this._activeBuffer.y=this._activeBuffer.scrollTop+x):(this._activeBuffer.x=b,this._activeBuffer.y=x),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(b,x){this._restrictCursor(),this._setCursor(this._activeBuffer.x+b,this._activeBuffer.y+x)}cursorUp(b){let x=this._activeBuffer.y-this._activeBuffer.scrollTop;return x>=0?this._moveCursor(0,-Math.min(x,b.params[0]||1)):this._moveCursor(0,-(b.params[0]||1)),!0}cursorDown(b){let x=this._activeBuffer.scrollBottom-this._activeBuffer.y;return x>=0?this._moveCursor(0,Math.min(x,b.params[0]||1)):this._moveCursor(0,b.params[0]||1),!0}cursorForward(b){return this._moveCursor(b.params[0]||1,0),!0}cursorBackward(b){return this._moveCursor(-(b.params[0]||1),0),!0}cursorNextLine(b){return this.cursorDown(b),this._activeBuffer.x=0,!0}cursorPrecedingLine(b){return this.cursorUp(b),this._activeBuffer.x=0,!0}cursorCharAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(b){return this._setCursor(b.length>=2?(b.params[1]||1)-1:0,(b.params[0]||1)-1),!0}charPosAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(b){return this._moveCursor(b.params[0]||1,0),!0}linePosAbsolute(b){return this._setCursor(this._activeBuffer.x,(b.params[0]||1)-1),!0}vPositionRelative(b){return this._moveCursor(0,b.params[0]||1),!0}hVPosition(b){return this.cursorPosition(b),!0}tabClear(b){let x=b.params[0];return x===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:x===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let x=b.params[0]||1;for(;x--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let x=b.params[0]||1;for(;x--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(b){let x=b.params[0];return x===1&&(this._curAttrData.bg|=536870912),x!==2&&x!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(b,x,L,E=!1,D=!1){let H=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);H.replaceCells(x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),D),E&&(H.isWrapped=!1)}_resetBufferLine(b,x=!1){let L=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),x),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+b),L.isWrapped=!1)}eraseInDisplay(b,x=!1){let L;switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,x);L<this._bufferService.rows;L++)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,x),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(L=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,L-1);L--;)if(this._activeBuffer.lines.get(this._activeBuffer.ybase+L)?.getTrimmedLength())break;for(;L>=0;L--)this._bufferService.scroll(this._eraseAttrData())}else{for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(0)}break;case 3:let E=this._activeBuffer.lines.length-this._bufferService.rows;E>0&&(this._activeBuffer.lines.trimStart(E),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-E,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-E,0),this._onScroll.fire(0))}return!0}eraseInLine(b,x=!1){switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,x);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,x);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,x)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(b){this._restrictCursor();let x=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=this._activeBuffer.ybase+this._activeBuffer.y,E=this._bufferService.rows-1-this._activeBuffer.scrollBottom,D=this._bufferService.rows-1+this._activeBuffer.ybase-E+1;for(;x--;)this._activeBuffer.lines.splice(D-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(b){this._restrictCursor();let x=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=this._activeBuffer.ybase+this._activeBuffer.y,E;for(E=this._bufferService.rows-1-this._activeBuffer.scrollBottom,E=this._bufferService.rows-1+this._activeBuffer.ybase-E;x--;)this._activeBuffer.lines.splice(L,1),this._activeBuffer.lines.splice(E,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.insertCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.deleteCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(b){let x=b.params[0]||1;for(;x--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(b){let x=b.params[0]||1;for(;x--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.deleteCells(0,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.insertCells(0,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.insertCells(this._activeBuffer.x,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.deleteCells(this._activeBuffer.x,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(b.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(b){let x=this._parser.precedingJoinState;if(!x)return!0;let L=b.params[0]||1,E=S.UnicodeService.extractWidth(x),D=this._activeBuffer.x-E,H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(D),I=new Uint32Array(H.length*L),N=0;for(let R=0;R<H.length;){let G=H.codePointAt(R)||0;I[N++]=G,R+=G>65535?2:1}let j=N;for(let R=1;R<L;++R)I.copyWithin(j,0,N),j+=N;return this.print(I,0,j),!0}sendDeviceAttributesPrimary(b){return b.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(g.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(g.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(b){return b.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(g.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(g.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(b.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(g.C0.ESC+"[>83;40003;0c")),!0}_is(b){return(this._optionsService.rawOptions.termName+"").indexOf(b)===0}setMode(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,d.DEFAULT_CHARSET),this._charsetService.setgCharset(1,d.DEFAULT_CHARSET),this._charsetService.setgCharset(2,d.DEFAULT_CHARSET),this._charsetService.setgCharset(3,d.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1000:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1000:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),b.params[x]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(b,x){let L=this._coreService.decPrivateModes,{activeProtocol:E,activeEncoding:D}=this._coreMouseService,H=this._coreService,{buffers:I,cols:N}=this._bufferService,{active:j,alt:R}=I,G=this._optionsService.rawOptions,U=(ae)=>ae?1:2,X=b.params[0];return se=X,ie=x?X===2?4:X===4?U(H.modes.insertMode):X===12?3:X===20?U(G.convertEol):0:X===1?U(L.applicationCursorKeys):X===3?G.windowOptions.setWinLines?N===80?2:N===132?1:0:0:X===6?U(L.origin):X===7?U(L.wraparound):X===8?3:X===9?U(E==="X10"):X===12?U(G.cursorBlink):X===25?U(!H.isCursorHidden):X===45?U(L.reverseWraparound):X===66?U(L.applicationKeypad):X===67?4:X===1000?U(E==="VT200"):X===1002?U(E==="DRAG"):X===1003?U(E==="ANY"):X===1004?U(L.sendFocus):X===1005?4:X===1006?U(D==="SGR"):X===1015?4:X===1016?U(D==="SGR_PIXELS"):X===1048?1:X===47||X===1047||X===1049?U(j===R):X===2004?U(L.bracketedPasteMode):X===2026?U(L.synchronizedOutput):0,H.triggerDataEvent(`${g.C0.ESC}[${x?"":"?"}${se};${ie}$y`),!0;var se,ie}_updateAttrColor(b,x,L,E,D){return x===2?(b|=50331648,b&=-16777216,b|=m.AttributeData.fromColorRGB([L,E,D])):x===5&&(b&=-50331904,b|=33554432|255&L),b}_extractColor(b,x,L){let E=[0,0,-1,0,0,0],D=0,H=0;do{if(E[H+D]=b.params[x+H],b.hasSubParams(x+H)){let I=b.getSubParams(x+H),N=0;do E[1]===5&&(D=1),E[H+N+1+D]=I[N];while(++N<I.length&&N+H+1+D<E.length);break}if(E[1]===5&&H+D>=2||E[1]===2&&H+D>=5)break;E[1]&&(D=1)}while(++H+x<b.length&&H+D<E.length);for(let I=2;I<E.length;++I)E[I]===-1&&(E[I]=0);switch(E[0]){case 38:L.fg=this._updateAttrColor(L.fg,E[1],E[3],E[4],E[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,E[1],E[3],E[4],E[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,E[1],E[3],E[4],E[5])}return H}_processUnderline(b,x){x.extended=x.extended.clone(),(!~b||b>5)&&(b=1),x.extended.underlineStyle=b,x.fg|=268435456,b===0&&(x.fg&=-268435457),x.updateExtended()}_processSGR0(b){b.fg=i.DEFAULT_ATTR_DATA.fg,b.bg=i.DEFAULT_ATTR_DATA.bg,b.extended=b.extended.clone(),b.extended.underlineStyle=0,b.extended.underlineColor&=-67108864,b.updateExtended()}charAttributes(b){if(b.length===1&&b.params[0]===0)return this._processSGR0(this._curAttrData),!0;let x=b.length,L,E=this._curAttrData;for(let D=0;D<x;D++)L=b.params[D],L>=30&&L<=37?(E.fg&=-50331904,E.fg|=16777216|L-30):L>=40&&L<=47?(E.bg&=-50331904,E.bg|=16777216|L-40):L>=90&&L<=97?(E.fg&=-50331904,E.fg|=16777224|L-90):L>=100&&L<=107?(E.bg&=-50331904,E.bg|=16777224|L-100):L===0?this._processSGR0(E):L===1?E.fg|=134217728:L===3?E.bg|=67108864:L===4?(E.fg|=268435456,this._processUnderline(b.hasSubParams(D)?b.getSubParams(D)[0]:1,E)):L===5?E.fg|=536870912:L===7?E.fg|=67108864:L===8?E.fg|=1073741824:L===9?E.fg|=2147483648:L===2?E.bg|=134217728:L===21?this._processUnderline(2,E):L===22?(E.fg&=-134217729,E.bg&=-134217729):L===23?E.bg&=-67108865:L===24?(E.fg&=-268435457,this._processUnderline(0,E)):L===25?E.fg&=-536870913:L===27?E.fg&=-67108865:L===28?E.fg&=-1073741825:L===29?E.fg&=2147483647:L===39?(E.fg&=-67108864,E.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):L===49?(E.bg&=-67108864,E.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?D+=this._extractColor(b,D,E):L===53?E.bg|=1073741824:L===55?E.bg&=-1073741825:L===59?(E.extended=E.extended.clone(),E.extended.underlineColor=-1,E.updateExtended()):L===100?(E.fg&=-67108864,E.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,E.bg&=-67108864,E.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(b){switch(b.params[0]){case 5:this._coreService.triggerDataEvent(`${g.C0.ESC}[0n`);break;case 6:let x=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[${x};${L}R`)}return!0}deviceStatusPrivate(b){if(b.params[0]===6){let x=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[?${x};${L}R`)}return!0}softReset(b){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(b){let x=b.length===0?1:b.params[0];if(x===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(x){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}let L=x%2==1;this._coreService.decPrivateModes.cursorBlink=L}return!0}setScrollRegion(b){let x=b.params[0]||1,L;return(b.length<2||(L=b.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>x&&(this._activeBuffer.scrollTop=x-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(b){if(!k(b.params[0],this._optionsService.rawOptions.windowOptions))return!0;let x=b.length>1?b.params[1]:0;switch(b.params[0]){case 14:x!==2&&this._onRequestWindowsOptionsReport.fire(P.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(P.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${g.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:x!==0&&x!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),x!==0&&x!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:x!==0&&x!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),x!==0&&x!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(b){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(b){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(b){return this._windowTitle=b,this._onTitleChange.fire(b),!0}setIconName(b){return this._iconName=b,!0}setOrReportIndexedColor(b){let x=[],L=b.split(";");for(;L.length>1;){let E=L.shift(),D=L.shift();if(/^\d+$/.exec(E)){let H=parseInt(E);if(F(H))if(D==="?")x.push({type:0,index:H});else{let I=(0,B.parseColor)(D);I&&x.push({type:1,index:H,color:I})}}}return x.length&&this._onColor.fire(x),!0}setHyperlink(b){let x=b.indexOf(";");if(x===-1)return!0;let L=b.slice(0,x).trim(),E=b.slice(x+1);return E?this._createHyperlink(L,E):!L.trim()&&this._finishHyperlink()}_createHyperlink(b,x){this._getCurrentLinkId()&&this._finishHyperlink();let L=b.split(":"),E,D=L.findIndex((H)=>H.startsWith("id="));return D!==-1&&(E=L[D].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:E,uri:x}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(b,x){let L=b.split(";");for(let E=0;E<L.length&&!(x>=this._specialColors.length);++E,++x)if(L[E]==="?")this._onColor.fire([{type:0,index:this._specialColors[x]}]);else{let D=(0,B.parseColor)(L[E]);D&&this._onColor.fire([{type:1,index:this._specialColors[x],color:D}])}return!0}setOrReportFgColor(b){return this._setOrReportSpecialColor(b,0)}setOrReportBgColor(b){return this._setOrReportSpecialColor(b,1)}setOrReportCursorColor(b){return this._setOrReportSpecialColor(b,2)}restoreIndexedColor(b){if(!b)return this._onColor.fire([{type:2}]),!0;let x=[],L=b.split(";");for(let E=0;E<L.length;++E)if(/^\d+$/.exec(L[E])){let D=parseInt(L[E]);F(D)&&x.push({type:2,index:D})}return x.length&&this._onColor.fire(x),!0}restoreFgColor(b){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(b){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(b){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,d.DEFAULT_CHARSET),!0}selectCharset(b){return b.length!==2?(this.selectDefaultCharset(),!0):(b[0]==="/"||this._charsetService.setgCharset(A[b[0]],d.CHARSETS[b[1]]||d.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let b=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,b,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(b){return this._charsetService.setgLevel(b),!0}screenAlignmentPattern(){let b=new h.CellData;b.content=4194373,b.fg=this._curAttrData.fg,b.bg=this._curAttrData.bg,this._setCursor(0,0);for(let x=0;x<this._bufferService.rows;++x){let L=this._activeBuffer.ybase+this._activeBuffer.y+x,E=this._activeBuffer.lines.get(L);E&&(E.fill(b),E.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(b,x){let L=this._bufferService.buffer,E=this._optionsService.rawOptions;return((D)=>(this._coreService.triggerDataEvent(`${g.C0.ESC}${D}${g.C0.ESC}\\`),!0))(b==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:b==='"p'?'P1$r61;1"p':b==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:b==="m"?"P1$r0m":b===" q"?`P1$r${{block:2,underline:4,bar:6}[E.cursorStyle]-(E.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(b,x){this._dirtyRowTracker.markRangeDirty(b,x)}}t.InputHandler=z;let q=class{constructor(b){this._bufferService=b,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(b){b<this.start?this.start=b:b>this.end&&(this.end=b)}markRangeDirty(b,x){b>x&&(W=b,b=x,x=W),b<this.start&&(this.start=b),x>this.end&&(this.end=x)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(b){return 0<=b&&b<256}q=l([p(0,u.IBufferService)],q)},701:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.getSafariVersion=function(){if(!t.isSafari)return 0;let p=n.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},t.isNode=typeof process<"u"&&"title"in process;let n=t.isNode?"node":navigator.userAgent,l=t.isNode?"node":navigator.platform;t.isFirefox=n.includes("Firefox"),t.isLegacyEdge=n.includes("Edge"),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),t.isIpad=l==="iPad",t.isIphone=l==="iPhone",t.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),t.isLinux=l.indexOf("Linux")>=0,t.isChromeOS=/\bCrOS\b/.test(n)},6168:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let l=n(701);class p{constructor(){this._tasks=[],this._i=0}enqueue(d){this._tasks.push(d),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(d){this._idleCallback=void 0;let _=0,v=0,o=d.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(_=performance.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,performance.now()-_),v=Math.max(_,v),i=d.timeRemaining(),1.5*v>i)return o-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-_))}ms`),void this._start();o=i}this.clear()}}class g extends p{_requestCallback(d){return setTimeout(()=>d(this._createDeadline(16)))}_cancelCallback(d){clearTimeout(d)}_createDeadline(d){let _=performance.now()+d;return{timeRemaining:()=>Math.max(0,_-performance.now())}}}t.PriorityTaskQueue=g,t.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(d){return requestIdleCallback(d)}_cancelCallback(d){cancelIdleCallback(d)}}:g,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(d){this._queue.clear(),this._queue.enqueue(d)}flush(){this._queue.flush()}}},5882:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=function(p){let g=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),d=g?.get(p.cols-1),_=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);_&&d&&(_.isWrapped=d[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&d[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)};let l=n(8938)},5451:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(p){return[p>>>16&255,p>>>8&255,255&p]}static fromColorRGB(p){return(255&p[0])<<16|(255&p[1])<<8|255&p[2]}clone(){let p=new n;return p.fg=this.fg,p.bg=this.bg,p.extended=this.extended.clone(),p}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?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(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return this.fg===0&&this.bg===0}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?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432: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}}t.AttributeData=n;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(p){this._ext=p}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(p){this._ext&=-469762049,this._ext|=p<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(p){this._ext&=-67108864,this._ext|=67108863&p}get urlId(){return this._urlId}set urlId(p){this._urlId=p}get underlineVariantOffset(){let p=(3758096384&this._ext)>>29;return p<0?4294967288^p:p}set underlineVariantOffset(p){this._ext&=536870911,this._ext|=p<<29&3758096384}constructor(p=0,g=0){this._ext=0,this._urlId=0,this._ext=p,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=l},1073:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;let l=n(5639),p=n(6168),g=n(5451),d=n(6107),_=n(732),v=n(3055),o=n(8938),i=n(8158),w=n(6760);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=class{constructor(h,m,u){this._hasScrollback=h,this._optionsService=m,this._bufferService=u,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=d.DEFAULT_ATTR_DATA.clone(),this.savedCharset=w.DEFAULT_CHARSET,this.markers=[],this._nullCell=v.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]),this._whitespaceCell=v.CellData.fromCharData([0,o.WHITESPACE_CELL_CHAR,o.WHITESPACE_CELL_WIDTH,o.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new g.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new g.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,m){return new d.BufferLine(this._bufferService.cols,this.getNullCell(h),m)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;let m=h+this._optionsService.rawOptions.scrollback;return m>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:m}fillViewportRows(h){if(this.lines.length===0){h===void 0&&(h=d.DEFAULT_ATTR_DATA);let m=this._rows;for(;m--;)this.lines.push(this.getBlankLine(h))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(h,m){let u=this.getNullCell(d.DEFAULT_ATTR_DATA),S=0,C=this._getCorrectBufferLength(m);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<h)for(let B=0;B<this.lines.length;B++)S+=+this.lines.get(B).resize(h,u);let T=0;if(this._rows<m)for(let B=this._rows;B<m;B++)this.lines.length<m+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new d.BufferLine(h,u)):this.ybase>0&&this.lines.length<=this.ybase+this.y+T+1?(this.ybase--,T++,this.ydisp>0&&this.ydisp--):this.lines.push(new d.BufferLine(h,u)));else for(let B=this._rows;B>m;B--)this.lines.length>m+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){let B=this.lines.length-C;B>0&&(this.lines.trimStart(B),this.ybase=Math.max(this.ybase-B,0),this.ydisp=Math.max(this.ydisp-B,0),this.savedY=Math.max(this.savedY-B,0)),this.lines.maxLength=C}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,m-1),T&&(this.y+=T),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=m-1,this._isReflowEnabled&&(this._reflow(h,m),this._cols>h))for(let T=0;T<this.lines.length;T++)S+=+this.lines.get(T).resize(h,u);this._cols=h,this._rows=m,this._memoryCleanupQueue.clear(),S>0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let h=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,h=!1);let m=0;for(;this._memoryCleanupPosition<this.lines.length;)if(m+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),m>100)return!0;return h}get _isReflowEnabled(){let h=this._optionsService.rawOptions.windowsPty;return h&&h.buildNumber?this._hasScrollback&&h.backend==="conpty"&&h.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(h,m){this._cols!==h&&(h>this._cols?this._reflowLarger(h,m):this._reflowSmaller(h,m))}_reflowLarger(h,m){let u=this._optionsService.rawOptions.reflowCursorLine,S=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(d.DEFAULT_ATTR_DATA),u);if(S.length>0){let C=(0,_.reflowLargerCreateNewLayout)(this.lines,S);(0,_.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(h,m,C.countRemoved)}}_reflowLargerAdjustViewport(h,m,u){let S=this.getNullCell(d.DEFAULT_ATTR_DATA),C=u;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<m&&this.lines.push(new d.BufferLine(h,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-u,0)}_reflowSmaller(h,m){let u=this._optionsService.rawOptions.reflowCursorLine,S=this.getNullCell(d.DEFAULT_ATTR_DATA),C=[],T=0;for(let B=this.lines.length-1;B>=0;B--){let O=this.lines.get(B);if(!O||!O.isWrapped&&O.getTrimmedLength()<=h)continue;let A=[O];for(;O.isWrapped&&B>0;)O=this.lines.get(--B),A.unshift(O);if(!u){let E=this.ybase+this.y;if(E>=B&&E<B+A.length)continue}let M=A[A.length-1].getTrimmedLength(),k=(0,_.reflowSmallerGetNewLineLengths)(A,this._cols,h),P=k.length-A.length,W;W=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);let z=[];for(let E=0;E<P;E++){let D=this.getBlankLine(d.DEFAULT_ATTR_DATA,!0);z.push(D)}z.length>0&&(C.push({start:B+A.length+T,newLines:z}),T+=z.length),A.push(...z);let q=k.length-1,F=k[q];F===0&&(q--,F=k[q]);let b=A.length-P-1,x=M;for(;b>=0;){let E=Math.min(x,F);if(A[q]===void 0)break;if(A[q].copyCellsFrom(A[b],x-E,F-E,E,!0),F-=E,F===0&&(q--,F=k[q]),x-=E,x===0){b--;let D=Math.max(b,0);x=(0,_.getWrappedLineTrimmedLength)(A,D,this._cols)}}for(let E=0;E<A.length;E++)k[E]<h&&A[E].setCell(k[E],S);let L=P-W;for(;L-- >0;)this.ybase===0?this.y<m-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-m&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+m-1)}if(C.length>0){let B=[],O=[];for(let F=0;F<this.lines.length;F++)O.push(this.lines.get(F));let A=this.lines.length,M=A-1,k=0,P=C[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let W=0;for(let F=Math.min(this.lines.maxLength-1,A+T-1);F>=0;F--)if(P&&P.start>M+W){for(let b=P.newLines.length-1;b>=0;b--)this.lines.set(F--,P.newLines[b]);F++,B.push({index:M+1,amount:P.newLines.length}),W+=P.newLines.length,P=C[++k]}else this.lines.set(F,O[M--]);let z=0;for(let F=B.length-1;F>=0;F--)B[F].index+=z,this.lines.onInsertEmitter.fire(B[F]),z+=B[F].amount;let q=Math.max(0,A+T-this.lines.maxLength);q>0&&this.lines.onTrimEmitter.fire(q)}}translateBufferLineToString(h,m,u=0,S){let C=this.lines.get(h);return C?C.translateToString(m,u,S):""}getWrappedRangeForLine(h){let m=h,u=h;for(;m>0&&this.lines.get(m).isWrapped;)m--;for(;u+1<this.lines.length&&this.lines.get(u+1).isWrapped;)u++;return{first:m,last:u}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let m=0;m<this.markers.length;m++)this.markers[m].line===h&&(this.markers[m].dispose(),this.markers.splice(m--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose();this.markers.length=0,this._isClearing=!1}addMarker(h){let m=new i.Marker(h);return this.markers.push(m),m.register(this.lines.onTrim((u)=>{m.line-=u,m.line<0&&m.dispose()})),m.register(this.lines.onInsert((u)=>{m.line>=u.index&&(m.line+=u.amount)})),m.register(this.lines.onDelete((u)=>{m.line>=u.index&&m.line<u.index+u.amount&&m.dispose(),m.line>u.index&&(m.line-=u.amount)})),m.register(m.onDispose(()=>this._removeMarker(m))),m}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},6107:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;let l=n(5451),p=n(3055),g=n(8938),d=n(726);t.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class v{constructor(o,i,w=!1){this.isWrapped=w,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);let h=i||p.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]);for(let m=0;m<o;++m)this.setCell(m,h);this.length=o}get(o){let i=this._data[3*o+0],w=2097151&i;return[this._data[3*o+1],2097152&i?this._combined[o]:w?(0,d.stringFromCodePoint)(w):"",i>>22,2097152&i?this._combined[o].charCodeAt(this._combined[o].length-1):w]}set(o,i){this._data[3*o+1]=i[g.CHAR_DATA_ATTR_INDEX],i[g.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=i[1],this._data[3*o+0]=2097152|o|i[g.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=i[g.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|i[g.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){let i=this._data[3*o+0];return 2097152&i?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&i}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){let i=this._data[3*o+0];return 2097152&i?this._combined[o]:2097151&i?(0,d.stringFromCodePoint)(2097151&i):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,i){return _=3*o,i.content=this._data[_+0],i.fg=this._data[_+1],i.bg=this._data[_+2],2097152&i.content&&(i.combinedData=this._combined[o]),268435456&i.bg&&(i.extended=this._extendedAttrs[o]),i}setCell(o,i){2097152&i.content&&(this._combined[o]=i.combinedData),268435456&i.bg&&(this._extendedAttrs[o]=i.extended),this._data[3*o+0]=i.content,this._data[3*o+1]=i.fg,this._data[3*o+2]=i.bg}setCellFromCodepoint(o,i,w,h){268435456&h.bg&&(this._extendedAttrs[o]=h.extended),this._data[3*o+0]=i|w<<22,this._data[3*o+1]=h.fg,this._data[3*o+2]=h.bg}addCodepointToCell(o,i,w){let h=this._data[3*o+0];2097152&h?this._combined[o]+=(0,d.stringFromCodePoint)(i):2097151&h?(this._combined[o]=(0,d.stringFromCodePoint)(2097151&h)+(0,d.stringFromCodePoint)(i),h&=-2097152,h|=2097152):h=i|4194304,w&&(h&=-12582913,h|=w<<22),this._data[3*o+0]=h}insertCells(o,i,w){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,w),i<this.length-o){let h=new p.CellData;for(let m=this.length-o-i-1;m>=0;--m)this.setCell(o+i+m,this.loadCell(o+m,h));for(let m=0;m<i;++m)this.setCell(o+m,w)}else for(let h=o;h<this.length;++h)this.setCell(h,w);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,w)}deleteCells(o,i,w){if(o%=this.length,i<this.length-o){let h=new p.CellData;for(let m=0;m<this.length-o-i;++m)this.setCell(o+m,this.loadCell(o+i+m,h));for(let m=this.length-i;m<this.length;++m)this.setCell(m,w)}else for(let h=o;h<this.length;++h)this.setCell(h,w);o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,w),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodepoint(o,0,1,w)}replaceCells(o,i,w,h=!1){if(h)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodepoint(o-1,0,1,w),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,w);o<i&&o<this.length;)this.isProtected(o)||this.setCell(o,w),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,w),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,w);o<i&&o<this.length;)this.setCell(o++,w)}resize(o,i){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let w=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*w)this._data=new Uint32Array(this._data.buffer,0,w);else{let h=new Uint32Array(w);h.set(this._data),this._data=h}for(let h=this.length;h<o;++h)this.setCell(h,i)}else{this._data=this._data.subarray(0,w);let h=Object.keys(this._combined);for(let u=0;u<h.length;u++){let S=parseInt(h[u],10);S>=o&&delete this._combined[S]}let m=Object.keys(this._extendedAttrs);for(let u=0;u<m.length;u++){let S=parseInt(m[u],10);S>=o&&delete this._extendedAttrs[S]}}return this.length=o,4*w*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,i=!1){if(i)for(let w=0;w<this.length;++w)this.isProtected(w)||this.setCell(w,o);else{this._combined={},this._extendedAttrs={};for(let w=0;w<this.length;++w)this.setCell(w,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(let i in o._combined)this._combined[i]=o._combined[i];this._extendedAttrs={};for(let i in o._extendedAttrs)this._extendedAttrs[i]=o._extendedAttrs[i];this.isWrapped=o.isWrapped}clone(){let o=new v(0);o._data=new Uint32Array(this._data),o.length=this.length;for(let i in this._combined)o._combined[i]=this._combined[i];for(let i in this._extendedAttrs)o._extendedAttrs[i]=this._extendedAttrs[i];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,i,w,h,m){let u=o._data;if(m)for(let C=h-1;C>=0;C--){for(let T=0;T<3;T++)this._data[3*(w+C)+T]=u[3*(i+C)+T];268435456&u[3*(i+C)+2]&&(this._extendedAttrs[w+C]=o._extendedAttrs[i+C])}else for(let C=0;C<h;C++){for(let T=0;T<3;T++)this._data[3*(w+C)+T]=u[3*(i+C)+T];268435456&u[3*(i+C)+2]&&(this._extendedAttrs[w+C]=o._extendedAttrs[i+C])}let S=Object.keys(o._combined);for(let C=0;C<S.length;C++){let T=parseInt(S[C],10);T>=i&&(this._combined[T-i+w]=o._combined[T])}}translateToString(o,i,w,h){i=i??0,w=w??this.length,o&&(w=Math.min(w,this.getTrimmedLength())),h&&(h.length=0);let m="";for(;i<w;){let u=this._data[3*i+0],S=2097151&u,C=2097152&u?this._combined[i]:S?(0,d.stringFromCodePoint)(S):g.WHITESPACE_CELL_CHAR;if(m+=C,h)for(let T=0;T<C.length;++T)h.push(i);i+=u>>22||1}return h&&h.push(i),m}}t.BufferLine=v},732:(y,t)=>{function n(l,p,g){if(p===l.length-1)return l[p].getTrimmedLength();let d=!l[p].hasContent(g-1)&&l[p].getWidth(g-1)===1,_=l[p+1].getWidth(0)===2;return d&&_?g-1:g}Object.defineProperty(t,"__esModule",{value:!0}),t.reflowLargerGetLinesToRemove=function(l,p,g,d,_,v){let o=[];for(let i=0;i<l.length-1;i++){let w=i,h=l.get(++w);if(!h.isWrapped)continue;let m=[l.get(i)];for(;w<l.length&&h.isWrapped;)m.push(h),h=l.get(++w);if(!v&&d>=i&&d<w){i+=m.length-1;continue}let u=0,S=n(m,u,p),C=1,T=0;for(;C<m.length;){let O=n(m,C,p),A=O-T,M=g-S,k=Math.min(A,M);m[u].copyCellsFrom(m[C],T,S,k,!1),S+=k,S===g&&(u++,S=0),T+=k,T===O&&(C++,T=0),S===0&&u!==0&&m[u-1].getWidth(g-1)===2&&(m[u].copyCellsFrom(m[u-1],g-1,S++,1,!1),m[u-1].setCell(g-1,_))}m[u].replaceCells(S,g,_);let B=0;for(let O=m.length-1;O>0&&(O>u||m[O].getTrimmedLength()===0);O--)B++;B>0&&(o.push(i+m.length-B),o.push(B)),i+=m.length-1}return o},t.reflowLargerCreateNewLayout=function(l,p){let g=[],d=0,_=p[d],v=0;for(let o=0;o<l.length;o++)if(_===o){let i=p[++d];l.onDeleteEmitter.fire({index:o-v,amount:i}),o+=i-1,v+=i,_=p[++d]}else g.push(o);return{layout:g,countRemoved:v}},t.reflowLargerApplyNewLayout=function(l,p){let g=[];for(let d=0;d<p.length;d++)g.push(l.get(p[d]));for(let d=0;d<g.length;d++)l.set(d,g[d]);l.length=p.length},t.reflowSmallerGetNewLineLengths=function(l,p,g){let d=[],_=l.map((w,h)=>n(l,h,p)).reduce((w,h)=>w+h),v=0,o=0,i=0;for(;i<_;){if(_-i<g){d.push(_-i);break}v+=g;let w=n(l,o,p);v>w&&(v-=w,o++);let h=l[o].getWidth(v-1)===2;h&&v--;let m=h?g-1:g;d.push(m),i+=m}return d},t.getWrappedLineTrimmedLength=n},4097:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;let l=n(7150),p=n(1073),g=n(802);class d extends l.Disposable{constructor(_,v){super(),this._optionsService=_,this._bufferService=v,this._onBufferActivate=this._register(new g.Emitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new p.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new p.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(_,v){this._normal.resize(_,v),this._alt.resize(_,v),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}t.BufferSet=d},3055:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;let l=n(726),p=n(8938),g=n(5451);class d extends g.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new g.ExtendedAttrs,this.combinedData=""}static fromCharData(_){let v=new d;return v.setFromCharData(_),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(_[p.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(_[p.CHAR_DATA_CHAR_INDEX].length===2){let o=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){let i=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(o-55296)+i-56320+65536|_[p.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[p.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=_[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=d},8938:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=t.DEFAULT_COLOR<<9|256,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},8158:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;let l=n(802),p=n(7150);class g{get id(){return this._id}constructor(d){this.line=d,this.isDisposed=!1,this._disposables=[],this._id=g._nextId++,this._onDispose=this.register(new l.Emitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.dispose)(this._disposables),this._disposables.length=0)}register(d){return this._disposables.push(d),d}}t.Marker=g,g._nextId=1},6760:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},t.CHARSETS.A={"#":"\xA3"},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},t.CHARSETS.C=t.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},t.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},t.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},t.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},t.CHARSETS.E=t.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},t.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},t.CHARSETS.H=t.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},3534:(y,t)=>{var n,l,p;Object.defineProperty(t,"__esModule",{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(g){g.NUL="\x00",g.SOH="\x01",g.STX="\x02",g.ETX="\x03",g.EOT="\x04",g.ENQ="\x05",g.ACK="\x06",g.BEL="\x07",g.BS="\b",g.HT="\t",g.LF=`
4
- `,g.VT="\v",g.FF="\f",g.CR="\r",g.SO="\x0E",g.SI="\x0F",g.DLE="\x10",g.DC1="\x11",g.DC2="\x12",g.DC3="\x13",g.DC4="\x14",g.NAK="\x15",g.SYN="\x16",g.ETB="\x17",g.CAN="\x18",g.EM="\x19",g.SUB="\x1A",g.ESC="\x1B",g.FS="\x1C",g.GS="\x1D",g.RS="\x1E",g.US="\x1F",g.SP=" ",g.DEL="\x7F"}(n||(t.C0=n={})),function(g){g.PAD="\x80",g.HOP="\x81",g.BPH="\x82",g.NBH="\x83",g.IND="\x84",g.NEL="\x85",g.SSA="\x86",g.ESA="\x87",g.HTS="\x88",g.HTJ="\x89",g.VTS="\x8A",g.PLD="\x8B",g.PLU="\x8C",g.RI="\x8D",g.SS2="\x8E",g.SS3="\x8F",g.DCS="\x90",g.PU1="\x91",g.PU2="\x92",g.STS="\x93",g.CCH="\x94",g.MW="\x95",g.SPA="\x96",g.EPA="\x97",g.SOS="\x98",g.SGCI="\x99",g.SCI="\x9A",g.CSI="\x9B",g.ST="\x9C",g.OSC="\x9D",g.PM="\x9E",g.APC="\x9F"}(l||(t.C1=l={})),function(g){g.ST=`${n.ESC}\\`}(p||(t.C1_ESCAPED=p={}))},726:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=void 0,t.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},t.utf32ToString=function(n,l=0,p=n.length){let g="";for(let d=l;d<p;++d){let _=n[d];_>65535?(_-=65536,g+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):g+=String.fromCharCode(_)}return g},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,l){let p=n.length;if(!p)return 0;let g=0,d=0;if(this._interim){let _=n.charCodeAt(d++);56320<=_&&_<=57343?l[g++]=1024*(this._interim-55296)+_-56320+65536:(l[g++]=this._interim,l[g++]=_),this._interim=0}for(let _=d;_<p;++_){let v=n.charCodeAt(_);if(55296<=v&&v<=56319){if(++_>=p)return this._interim=v,g;let o=n.charCodeAt(_);56320<=o&&o<=57343?l[g++]=1024*(v-55296)+o-56320+65536:(l[g++]=v,l[g++]=o)}else v!==65279&&(l[g++]=v)}return g}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,l){let p=n.length;if(!p)return 0;let g,d,_,v,o=0,i=0,w=0;if(this.interim[0]){let u=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let C,T=0;for(;(C=63&this.interim[++T])&&T<4;)S<<=6,S|=C;let B=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=B-T;for(;w<O;){if(w>=p)return 0;if(C=n[w++],(192&C)!=128){w--,u=!0;break}this.interim[T++]=C,S<<=6,S|=63&C}u||(B===2?S<128?w--:l[o++]=S:B===3?S<2048||S>=55296&&S<=57343||S===65279||(l[o++]=S):S<65536||S>1114111||(l[o++]=S)),this.interim.fill(0)}let h=p-4,m=w;for(;m<p;){for(;!(!(m<h)||128&(g=n[m])||128&(d=n[m+1])||128&(_=n[m+2])||128&(v=n[m+3]));)l[o++]=g,l[o++]=d,l[o++]=_,l[o++]=v,m+=4;if(g=n[m++],g<128)l[o++]=g;else if((224&g)==192){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(i=(31&g)<<6|63&d,i<128){m--;continue}l[o++]=i}else if((240&g)==224){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,o;if(_=n[m++],(192&_)!=128){m--;continue}if(i=(15&g)<<12|(63&d)<<6|63&_,i<2048||i>=55296&&i<=57343||i===65279)continue;l[o++]=i}else if((248&g)==240){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,o;if(_=n[m++],(192&_)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,this.interim[2]=_,o;if(v=n[m++],(192&v)!=128){m--;continue}if(i=(7&g)<<18|(63&d)<<12|(63&_)<<6|63&v,i<65536||i>1114111)continue;l[o++]=i}}return o}}},7428:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let l=n(6415),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],g=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],d;t.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let _=0;_<p.length;++_)d.fill(0,p[_][0],p[_][1]+1)}}wcwidth(_){return _<32?0:_<127?1:_<65536?d[_]:function(v,o){let i,w=0,h=o.length-1;if(v<o[0][0]||v>o[h][1])return!1;for(;h>=w;)if(i=w+h>>1,v>o[i][1])w=i+1;else{if(!(v<o[i][0]))return!0;h=i-1}return!1}(_,g)?0:_>=131072&&_<=196605||_>=196608&&_<=262141?2:1}charProperties(_,v){let o=this.wcwidth(_),i=o===0&&v!==0;if(i){let w=l.UnicodeService.extractWidth(v);w===0?i=!1:w>o&&(o=w)}return l.UnicodeService.createPropertyValue(0,o,i)}}},3562:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;let l=n(7150),p=n(802);class g extends l.Disposable{constructor(d){super(),this._action=d,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new p.Emitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(d,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let v;for(this._isSyncWriting=!0;v=this._writeBuffer.shift();){this._action(v);let o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(d,_){if(this._pendingData>50000000)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(_),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(_)}_innerWrite(d=0,_=!0){let v=d||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let o=this._writeBuffer[this._bufferOffset],i=this._action(o,_);if(i){let h=(m)=>performance.now()-v>=12?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(v,m);return void i.catch((m)=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(h)}let w=this._callbacks[this._bufferOffset];if(w&&w(),this._bufferOffset++,this._pendingData-=o.length,performance.now()-v>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=g},8693:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseColor=function(g){if(!g)return;let d=g.toLowerCase();if(d.indexOf("rgb:")===0){d=d.slice(4);let _=n.exec(d);if(_){let v=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/v*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/v*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/v*255)]}}else if(d.indexOf("#")===0&&(d=d.slice(1),l.exec(d)&&[3,6,9,12].includes(d.length))){let _=d.length/3,v=[0,0,0];for(let o=0;o<3;++o){let i=parseInt(d.slice(_*o,_*o+_),16);v[o]=_===1?i<<4:_===2?i:_===3?i>>4:i>>8}return v}},t.toRgbString=function(g,d=16){let[_,v,o]=g;return`rgb:${p(_,d)}/${p(v,d)}/${p(o,d)}`};let n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function p(g,d){let _=g.toString(16),v=_.length<2?"0"+_:_;switch(d){case 4:return _[0];case 8:return v;case 12:return(v+v).slice(0,3);default:return v+v}}},1263:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},9823:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;let l=n(726),p=n(7262),g=n(1263),d=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=d,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}registerHandler(v,o){this._handlers[v]===void 0&&(this._handlers[v]=[]);let i=this._handlers[v];return i.push(o),{dispose:()=>{let w=i.indexOf(o);w!==-1&&i.splice(w,1)}}}clearHandler(v){this._handlers[v]&&delete this._handlers[v]}setHandlerFallback(v){this._handlerFb=v}reset(){if(this._active.length)for(let v=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;v>=0;--v)this._active[v].unhook(!1);this._stack.paused=!1,this._active=d,this._ident=0}hook(v,o){if(this.reset(),this._ident=v,this._active=this._handlers[v]||d,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(o);else this._handlerFb(this._ident,"HOOK",o)}put(v,o,i){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(v,o,i);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(v,o,i))}unhook(v,o=!0){if(this._active.length){let i=!1,w=this._active.length-1,h=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,i=o,h=this._stack.fallThrough,this._stack.paused=!1),!h&&i===!1){for(;w>=0&&(i=this._active[w].unhook(v),i!==!0);w--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,i;w--}for(;w>=0;w--)if(i=this._active[w].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",v);this._active=d,this._ident=0}};let _=new p.Params;_.addParam(0),t.DcsHandler=class{constructor(v){this._handler=v,this._data="",this._params=_,this._hitLimit=!1}hook(v){this._params=v.length>1||v.params[0]?v.clone():_,this._data="",this._hitLimit=!1}put(v,o,i){this._hitLimit||(this._data+=(0,l.utf32ToString)(v,o,i),this._data.length>g.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(v){let o=!1;if(this._hitLimit)o=!1;else if(v&&(o=this._handler(this._data,this._params),o instanceof Promise))return o.then((i)=>(this._params=_,this._data="",this._hitLimit=!1,i));return this._params=_,this._data="",this._hitLimit=!1,o}}},6717:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let l=n(7150),p=n(7262),g=n(1346),d=n(9823);class _{constructor(i){this.table=new Uint8Array(i)}setDefault(i,w){this.table.fill(i<<4|w)}add(i,w,h,m){this.table[w<<8|i]=h<<4|m}addMany(i,w,h,m){for(let u=0;u<i.length;u++)this.table[w<<8|i[u]]=h<<4|m}}t.TransitionTable=_;let v=160;t.VT500_TRANSITION_TABLE=function(){let i=new _(4095),w=Array.apply(null,Array(256)).map((T,B)=>B),h=(T,B)=>w.slice(T,B),m=h(32,127),u=h(0,24);u.push(25),u.push.apply(u,h(28,32));let S=h(0,14),C;for(C in i.setDefault(1,0),i.addMany(m,0,2,0),S)i.addMany([24,26,153,154],C,3,0),i.addMany(h(128,144),C,3,0),i.addMany(h(144,152),C,3,0),i.add(156,C,0,0),i.add(27,C,11,1),i.add(157,C,4,8),i.addMany([152,158,159],C,0,7),i.add(155,C,11,3),i.add(144,C,11,9);return i.addMany(u,0,3,0),i.addMany(u,1,3,1),i.add(127,1,0,1),i.addMany(u,8,0,8),i.addMany(u,3,3,3),i.add(127,3,0,3),i.addMany(u,4,3,4),i.add(127,4,0,4),i.addMany(u,6,3,6),i.addMany(u,5,3,5),i.add(127,5,0,5),i.addMany(u,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(m,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(h(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(m,7,0,7),i.addMany(u,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(h(64,127),3,7,0),i.addMany(h(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(h(48,60),4,8,4),i.addMany(h(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(h(32,64),6,0,6),i.add(127,6,0,6),i.addMany(h(64,127),6,0,0),i.addMany(h(32,48),3,9,5),i.addMany(h(32,48),5,9,5),i.addMany(h(48,64),5,0,6),i.addMany(h(64,127),5,7,0),i.addMany(h(32,48),4,9,5),i.addMany(h(32,48),1,9,2),i.addMany(h(32,48),2,9,2),i.addMany(h(48,127),2,10,0),i.addMany(h(48,80),1,10,0),i.addMany(h(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(h(96,127),1,10,0),i.add(80,1,11,9),i.addMany(u,9,0,9),i.add(127,9,0,9),i.addMany(h(28,32),9,0,9),i.addMany(h(32,48),9,9,12),i.addMany(h(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(u,11,0,11),i.addMany(h(32,128),11,0,11),i.addMany(h(28,32),11,0,11),i.addMany(u,10,0,10),i.add(127,10,0,10),i.addMany(h(28,32),10,0,10),i.addMany(h(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(h(32,48),10,9,12),i.addMany(u,12,0,12),i.add(127,12,0,12),i.addMany(h(28,32),12,0,12),i.addMany(h(32,48),12,9,12),i.addMany(h(48,64),12,0,11),i.addMany(h(64,127),12,12,13),i.addMany(h(64,127),10,12,13),i.addMany(h(64,127),9,12,13),i.addMany(u,13,13,13),i.addMany(m,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(v,0,2,0),i.add(v,8,5,8),i.add(v,6,0,6),i.add(v,11,0,11),i.add(v,13,13,13),i}();class o extends l.Disposable{constructor(i=t.VT500_TRANSITION_TABLE){super(),this._transitions=i,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(w,h,m)=>{},this._executeHandlerFb=(w)=>{},this._csiHandlerFb=(w,h)=>{},this._escHandlerFb=(w)=>{},this._errorHandlerFb=(w)=>w,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register((0,l.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new g.OscParser),this._dcsParser=this._register(new d.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(i,w=[64,126]){let h=0;if(i.prefix){if(i.prefix.length>1)throw Error("only one byte as prefix supported");if(h=i.prefix.charCodeAt(0),h&&60>h||h>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(i.intermediates){if(i.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let u=0;u<i.intermediates.length;++u){let S=i.intermediates.charCodeAt(u);if(32>S||S>47)throw Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=S}}if(i.final.length!==1)throw Error("final must be a single byte");let m=i.final.charCodeAt(0);if(w[0]>m||m>w[1])throw Error(`final must be in range ${w[0]} .. ${w[1]}`);return h<<=8,h|=m,h}identToString(i){let w=[];for(;i;)w.push(String.fromCharCode(255&i)),i>>=8;return w.reverse().join("")}setPrintHandler(i){this._printHandler=i}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(i,w){let h=this._identifier(i,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);let m=this._escHandlers[h];return m.push(w),{dispose:()=>{let u=m.indexOf(w);u!==-1&&m.splice(u,1)}}}clearEscHandler(i){this._escHandlers[this._identifier(i,[48,126])]&&delete this._escHandlers[this._identifier(i,[48,126])]}setEscHandlerFallback(i){this._escHandlerFb=i}setExecuteHandler(i,w){this._executeHandlers[i.charCodeAt(0)]=w}clearExecuteHandler(i){this._executeHandlers[i.charCodeAt(0)]&&delete this._executeHandlers[i.charCodeAt(0)]}setExecuteHandlerFallback(i){this._executeHandlerFb=i}registerCsiHandler(i,w){let h=this._identifier(i);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);let m=this._csiHandlers[h];return m.push(w),{dispose:()=>{let u=m.indexOf(w);u!==-1&&m.splice(u,1)}}}clearCsiHandler(i){this._csiHandlers[this._identifier(i)]&&delete this._csiHandlers[this._identifier(i)]}setCsiHandlerFallback(i){this._csiHandlerFb=i}registerDcsHandler(i,w){return this._dcsParser.registerHandler(this._identifier(i),w)}clearDcsHandler(i){this._dcsParser.clearHandler(this._identifier(i))}setDcsHandlerFallback(i){this._dcsParser.setHandlerFallback(i)}registerOscHandler(i,w){return this._oscParser.registerHandler(i,w)}clearOscHandler(i){this._oscParser.clearHandler(i)}setOscHandlerFallback(i){this._oscParser.setHandlerFallback(i)}setErrorHandler(i){this._errorHandler=i}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(i,w,h,m,u){this._parseStack.state=i,this._parseStack.handlers=w,this._parseStack.handlerPos=h,this._parseStack.transition=m,this._parseStack.chunkPos=u}parse(i,w,h){let m,u=0,S=0,C=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,C=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let T=this._parseStack.handlers,B=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&B>-1){for(;B>=0&&(m=T[B](this._params),m!==!0);B--)if(m instanceof Promise)return this._parseStack.handlerPos=B,m}this._parseStack.handlers=[];break;case 4:if(h===!1&&B>-1){for(;B>=0&&(m=T[B](),m!==!0);B--)if(m instanceof Promise)return this._parseStack.handlerPos=B,m}this._parseStack.handlers=[];break;case 6:if(u=i[this._parseStack.chunkPos],m=this._dcsParser.unhook(u!==24&&u!==26,h),m)return m;u===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(u=i[this._parseStack.chunkPos],m=this._oscParser.end(u!==24&&u!==26,h),m)return m;u===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,C=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let T=C;T<w;++T){switch(u=i[T],S=this._transitions.table[this.currentState<<8|(u<160?u:v)],S>>4){case 2:for(let k=T+1;;++k){if(k>=w||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=w||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=w||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=w||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}}break;case 3:this._executeHandlers[u]?this._executeHandlers[u]():this._executeHandlerFb(u),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:T,code:u,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let B=this._csiHandlers[this._collect<<8|u],O=B?B.length-1:-1;for(;O>=0&&(m=B[O](this._params),m!==!0);O--)if(m instanceof Promise)return this._preserveStack(3,B,O,S,T),m;O<0&&this._csiHandlerFb(this._collect<<8|u,this._params),this.precedingJoinState=0;break;case 8:do switch(u){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(u-48)}while(++T<w&&(u=i[T])>47&&u<60);T--;break;case 9:this._collect<<=8,this._collect|=u;break;case 10:let A=this._escHandlers[this._collect<<8|u],M=A?A.length-1:-1;for(;M>=0&&(m=A[M](),m!==!0);M--)if(m instanceof Promise)return this._preserveStack(4,A,M,S,T),m;M<0&&this._escHandlerFb(this._collect<<8|u),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|u,this._params);break;case 13:for(let k=T+1;;++k)if(k>=w||(u=i[k])===24||u===26||u===27||u>127&&u<v){this._dcsParser.put(i,T,k),T=k-1;break}break;case 14:if(m=this._dcsParser.unhook(u!==24&&u!==26),m)return this._preserveStack(6,[],0,S,T),m;u===27&&(S|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let k=T+1;;k++)if(k>=w||(u=i[k])<32||u>127&&u<v){this._oscParser.put(i,T,k),T=k-1;break}break;case 6:if(m=this._oscParser.end(u!==24&&u!==26),m)return this._preserveStack(5,[],0,S,T),m;u===27&&(S|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&S}}}t.EscapeSequenceParser=o},1346:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;let l=n(1263),p=n(726),g=[];t.OscParser=class{constructor(){this._state=0,this._active=g,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(d,_){this._handlers[d]===void 0&&(this._handlers[d]=[]);let v=this._handlers[d];return v.push(_),{dispose:()=>{let o=v.indexOf(_);o!==-1&&v.splice(o,1)}}}clearHandler(d){this._handlers[d]&&delete this._handlers[d]}setHandlerFallback(d){this._handlerFb=d}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}reset(){if(this._state===2)for(let d=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;d>=0;--d)this._active[d].end(!1);this._stack.paused=!1,this._active=g,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||g,this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].start();else this._handlerFb(this._id,"START")}_put(d,_,v){if(this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].put(d,_,v);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(d,_,v))}start(){this.reset(),this._state=1}put(d,_,v){if(this._state!==3){if(this._state===1)for(;_<v;){let o=d[_++];if(o===59){this._state=2,this._start();break}if(o<48||57<o)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+o-48}this._state===2&&v-_>0&&this._put(d,_,v)}}end(d,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let v=!1,o=this._active.length-1,i=!1;if(this._stack.paused&&(o=this._stack.loopPosition-1,v=_,i=this._stack.fallThrough,this._stack.paused=!1),!i&&v===!1){for(;o>=0&&(v=this._active[o].end(d),v!==!0);o--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!1,v;o--}for(;o>=0;o--)if(v=this._active[o].end(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!0,v}else this._handlerFb(this._id,"END",d);this._active=g,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(d){this._handler=d,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(d,_,v){this._hitLimit||(this._data+=(0,p.utf32ToString)(d,_,v),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(d){let _=!1;if(this._hitLimit)_=!1;else if(d&&(_=this._handler(this._data),_ instanceof Promise))return _.then((v)=>(this._data="",this._hitLimit=!1,v));return this._data="",this._hitLimit=!1,_}}},7262:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;let n=2147483647;class l{static fromArray(p){let g=new l;if(!p.length)return g;for(let d=Array.isArray(p[0])?1:0;d<p.length;++d){let _=p[d];if(Array.isArray(_))for(let v=0;v<_.length;++v)g.addSubParam(_[v]);else g.addParam(_)}return g}constructor(p=32,g=32){if(this.maxLength=p,this.maxSubParamsLength=g,g>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(p),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(p),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let p=new l(this.maxLength,this.maxSubParamsLength);return p.params.set(this.params),p.length=this.length,p._subParams.set(this._subParams),p._subParamsLength=this._subParamsLength,p._subParamsIdx.set(this._subParamsIdx),p._rejectDigits=this._rejectDigits,p._rejectSubDigits=this._rejectSubDigits,p._digitIsSub=this._digitIsSub,p}toArray(){let p=[];for(let g=0;g<this.length;++g){p.push(this.params[g]);let d=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-d>0&&p.push(Array.prototype.slice.call(this._subParams,d,_))}return p}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(p){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(p<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=p>n?n:p}}addSubParam(p){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(p<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=p>n?n:p,this._subParamsIdx[this.length-1]++}}hasSubParams(p){return(255&this._subParamsIdx[p])-(this._subParamsIdx[p]>>8)>0}getSubParams(p){let g=this._subParamsIdx[p]>>8,d=255&this._subParamsIdx[p];return d-g>0?this._subParams.subarray(g,d):null}getSubParamsAll(){let p={};for(let g=0;g<this.length;++g){let d=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-d>0&&(p[g]=this._subParams.slice(d,_))}return p}addDigit(p){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let d=this._digitIsSub?this._subParams:this.params,_=d[g-1];d[g-1]=~_?Math.min(10*_+p,n):p}}t.Params=l},3027:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,l){let p={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(p),l.dispose=()=>this._wrappedAddonDispose(p),l.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let l=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===n){l=p;break}if(l===-1)throw Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(l,1)}}},3235:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;let l=n(793),p=n(3055);t.BufferApiView=class{constructor(g,d){this._buffer=g,this.type=d}init(g){return this._buffer=g,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(g){let d=this._buffer.lines.get(g);if(d)return new l.BufferLineApiView(d)}getNullCell(){return new p.CellData}}},793:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;let l=n(3055);t.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,g){if(!(p<0||p>=this._line.length))return g?(this._line.loadCell(p,g),g):this._line.loadCell(p,new l.CellData)}translateToString(p,g,d){return this._line.translateToString(p,g,d)}}},5101:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;let l=n(3235),p=n(7150),g=n(802);class d extends p.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this._register(new g.Emitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=d},6097:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,l){return this._core.registerCsiHandler(n,(p)=>l(p.toArray()))}addCsiHandler(n,l){return this.registerCsiHandler(n,l)}registerDcsHandler(n,l){return this._core.registerDcsHandler(n,(p,g)=>l(p,g.toArray()))}addDcsHandler(n,l){return this.registerDcsHandler(n,l)}registerEscHandler(n,l){return this._core.registerEscHandler(n,l)}addEscHandler(n,l){return this.registerEscHandler(n,l)}registerOscHandler(n,l){return this._core.registerOscHandler(n,l)}addOscHandler(n,l){return this.registerOscHandler(n,l)}}},4335:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},9640:function(y,t,n){var l=this&&this.__decorate||function(i,w,h,m){var u,S=arguments.length,C=S<3?w:m===null?m=Object.getOwnPropertyDescriptor(w,h):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,w,h,m);else for(var T=i.length-1;T>=0;T--)(u=i[T])&&(C=(S<3?u(C):S>3?u(w,h,C):u(w,h))||C);return S>3&&C&&Object.defineProperty(w,h,C),C},p=this&&this.__param||function(i,w){return function(h,m){w(h,m,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let g=n(7150),d=n(4097),_=n(6501),v=n(802);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let o=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this._register(new v.Emitter),this.onResize=this._onResize.event,this._onScroll=this._register(new v.Emitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this._register(new d.BufferSet(i,this)),this._register(this.buffers.onBufferActivate((w)=>{this._onScroll.fire(w.activeBuffer.ydisp)}))}resize(i,w){let h=this.cols!==i,m=this.rows!==w;this.cols=i,this.rows=w,this.buffers.resize(i,w),this._onResize.fire({cols:i,rows:w,colsChanged:h,rowsChanged:m})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,w=!1){let h=this.buffer,m;m=this._cachedBlankLine,m&&m.length===this.cols&&m.getFg(0)===i.fg&&m.getBg(0)===i.bg||(m=h.getBlankLine(i,w),this._cachedBlankLine=m),m.isWrapped=w;let u=h.ybase+h.scrollTop,S=h.ybase+h.scrollBottom;if(h.scrollTop===0){let C=h.lines.isFull;S===h.lines.length-1?C?h.lines.recycle().copyFrom(m):h.lines.push(m.clone()):h.lines.splice(S+1,0,m.clone()),C?this.isUserScrolling&&(h.ydisp=Math.max(h.ydisp-1,0)):(h.ybase++,this.isUserScrolling||h.ydisp++)}else{let C=S-u+1;h.lines.shiftElements(u+1,C-1,-1),h.lines.set(S,m.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(i,w){let h=this.buffer;if(i<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else i+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);let m=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+i,h.ybase),0),m!==h.ydisp&&(w||this._onScroll.fire(h.ydisp))}};t.BufferService=o,t.BufferService=o=l([p(0,_.IOptionsService)],o)},5746:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,l){this._charsets[n]=l,this.glevel===n&&(this.charset=l)}}},7792:function(y,t,n){var l=this&&this.__decorate||function(m,u,S,C){var T,B=arguments.length,O=B<3?u:C===null?C=Object.getOwnPropertyDescriptor(u,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(m,u,S,C);else for(var A=m.length-1;A>=0;A--)(T=m[A])&&(O=(B<3?T(O):B>3?T(u,S,O):T(u,S))||O);return B>3&&O&&Object.defineProperty(u,S,O),O},p=this&&this.__param||function(m,u){return function(S,C){u(S,C,m)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;let g=n(6501),d=n(7150),_=n(802),v={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:(m)=>m.button!==4&&m.action===1&&(m.ctrl=!1,m.alt=!1,m.shift=!1,!0)},VT200:{events:19,restrict:(m)=>m.action!==32},DRAG:{events:23,restrict:(m)=>m.action!==32||m.button!==3},ANY:{events:31,restrict:(m)=>!0}};function o(m,u){let S=(m.ctrl?16:0)|(m.shift?4:0)|(m.alt?8:0);return m.button===4?(S|=64,S|=m.action):(S|=3&m.button,4&m.button&&(S|=64),8&m.button&&(S|=128),m.action===32?S|=32:m.action!==0||u||(S|=3)),S}let i=String.fromCharCode,w={DEFAULT:(m)=>{let u=[o(m,!1)+32,m.col+32,m.row+32];return u[0]>255||u[1]>255||u[2]>255?"":`\x1B[M${i(u[0])}${i(u[1])}${i(u[2])}`},SGR:(m)=>{let u=m.action===0&&m.button!==4?"m":"M";return`\x1B[<${o(m,!0)};${m.col};${m.row}${u}`},SGR_PIXELS:(m)=>{let u=m.action===0&&m.button!==4?"m":"M";return`\x1B[<${o(m,!0)};${m.x};${m.y}${u}`}},h=class extends d.Disposable{constructor(m,u,S){super(),this._bufferService=m,this._coreService=u,this._optionsService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _.Emitter),this.onProtocolChange=this._onProtocolChange.event;for(let C of Object.keys(v))this.addProtocol(C,v[C]);for(let C of Object.keys(w))this.addEncoding(C,w[C]);this.reset()}addProtocol(m,u){this._protocols[m]=u}addEncoding(m,u){this._encodings[m]=u}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(m){if(!this._protocols[m])throw Error(`unknown protocol "${m}"`);this._activeProtocol=m,this._onProtocolChange.fire(this._protocols[m].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(m){if(!this._encodings[m])throw Error(`unknown encoding "${m}"`);this._activeEncoding=m}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(m,u,S){if(m.deltaY===0||m.shiftKey)return 0;if(u===void 0||S===void 0)return 0;let C=u/S,T=this._applyScrollModifier(m.deltaY,m);return m.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(T/=C+0,Math.abs(m.deltaY)<50&&(T*=0.3),this._wheelPartialScroll+=T,T=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):m.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(T*=this._bufferService.rows),T}_applyScrollModifier(m,u){return u.altKey||u.ctrlKey||u.shiftKey?m*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:m*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(m){if(m.col<0||m.col>=this._bufferService.cols||m.row<0||m.row>=this._bufferService.rows)return!1;if(m.button===4&&m.action===32)return!1;if(m.button===3&&m.action!==32)return!1;if(m.button!==4&&(m.action===2||m.action===3))return!1;if(m.col++,m.row++,m.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,m,this._activeEncoding==="SGR_PIXELS"))return!1;if(!this._protocols[this._activeProtocol].restrict(m))return!1;let u=this._encodings[this._activeEncoding](m);return u&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(u):this._coreService.triggerDataEvent(u,!0)),this._lastEvent=m,!0}explainEvents(m){return{down:!!(1&m),up:!!(2&m),drag:!!(4&m),move:!!(8&m),wheel:!!(16&m)}}_equalEvents(m,u,S){if(S){if(m.x!==u.x)return!1;if(m.y!==u.y)return!1}else{if(m.col!==u.col)return!1;if(m.row!==u.row)return!1}return m.button===u.button&&m.action===u.action&&m.ctrl===u.ctrl&&m.alt===u.alt&&m.shift===u.shift}};t.CoreMouseService=h,t.CoreMouseService=h=l([p(0,g.IBufferService),p(1,g.ICoreService),p(2,g.IOptionsService)],h)},4071:function(y,t,n){var l=this&&this.__decorate||function(h,m,u,S){var C,T=arguments.length,B=T<3?m:S===null?S=Object.getOwnPropertyDescriptor(m,u):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(h,m,u,S);else for(var O=h.length-1;O>=0;O--)(C=h[O])&&(B=(T<3?C(B):T>3?C(m,u,B):C(m,u))||B);return T>3&&B&&Object.defineProperty(m,u,B),B},p=this&&this.__param||function(h,m){return function(u,S){m(u,S,h)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;let g=n(7453),d=n(7150),_=n(6501),v=n(802),o=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),w=class extends d.Disposable{constructor(h,m,u){super(),this._bufferService=h,this._logService=m,this._optionsService=u,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new v.Emitter),this.onData=this._onData.event,this._onUserInput=this._register(new v.Emitter),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new v.Emitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new v.Emitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,g.clone)(o),this.decPrivateModes=(0,g.clone)(i)}reset(){this.modes=(0,g.clone)(o),this.decPrivateModes=(0,g.clone)(i)}triggerDataEvent(h,m=!1){if(this._optionsService.rawOptions.disableStdin)return;let u=this._bufferService.buffer;m&&this._optionsService.rawOptions.scrollOnUserInput&&u.ybase!==u.ydisp&&this._onRequestScrollToBottom.fire(),m&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`),this._logService.trace("sending data (codes)",()=>h.split("").map((S)=>S.charCodeAt(0))),this._onData.fire(h)}triggerBinaryEvent(h){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${h}"`),this._logService.trace("sending binary (codes)",()=>h.split("").map((m)=>m.charCodeAt(0))),this._onBinary.fire(h))}};t.CoreService=w,t.CoreService=w=l([p(0,_.IBufferService),p(1,_.ILogService),p(2,_.IOptionsService)],w)},6025:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let l=n(6501),p=n(6201);class g{constructor(...d){this._entries=new Map;for(let[_,v]of d)this.set(_,v)}set(d,_){let v=this._entries.get(d);return this._entries.set(d,_),v}forEach(d){for(let[_,v]of this._entries.entries())d(_,v)}has(d){return this._entries.has(d)}get(d){return this._entries.get(d)}}t.ServiceCollection=g,t.InstantiationService=class{constructor(){this._services=new g,this._services.set(l.IInstantiationService,this)}setService(d,_){this._services.set(d,_)}getService(d){return this._services.get(d)}createInstance(d,..._){let v=(0,p.getServiceDependencies)(d).sort((w,h)=>w.index-h.index),o=[];for(let w of v){let h=this._services.get(w.id);if(!h)throw Error(`[createInstance] ${d.name} depends on UNKNOWN service ${w.id._id}.`);o.push(h)}let i=v.length>0?v[0].index:_.length;if(_.length!==i)throw Error(`[createInstance] First service dependency of ${d.name} at position ${i+1} conflicts with ${_.length} static arguments`);return new d(...[..._,...o])}}},7276:function(y,t,n){var l=this&&this.__decorate||function(i,w,h,m){var u,S=arguments.length,C=S<3?w:m===null?m=Object.getOwnPropertyDescriptor(w,h):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,w,h,m);else for(var T=i.length-1;T>=0;T--)(u=i[T])&&(C=(S<3?u(C):S>3?u(w,h,C):u(w,h))||C);return S>3&&C&&Object.defineProperty(w,h,C),C},p=this&&this.__param||function(i,w){return function(h,m){w(h,m,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogService=void 0,t.setTraceLogger=function(i){v=i},t.traceCall=function(i,w,h){if(typeof h.value!="function")throw Error("not supported");let m=h.value;h.value=function(...u){if(v.logLevel!==d.LogLevelEnum.TRACE)return m.apply(this,u);v.trace(`GlyphRenderer#${m.name}(${u.map((C)=>JSON.stringify(C)).join(", ")})`);let S=m.apply(this,u);return v.trace(`GlyphRenderer#${m.name} return`,S),S}};let g=n(7150),d=n(6501),_={trace:d.LogLevelEnum.TRACE,debug:d.LogLevelEnum.DEBUG,info:d.LogLevelEnum.INFO,warn:d.LogLevelEnum.WARN,error:d.LogLevelEnum.ERROR,off:d.LogLevelEnum.OFF},v,o=class extends g.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=d.LogLevelEnum.OFF,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),v=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let w=0;w<i.length;w++)typeof i[w]=="function"&&(i[w]=i[w]())}_log(i,w,h){this._evalLazyOptionalParams(h),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+w,...h)}trace(i,...w){this._logLevel<=d.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,i,w)}debug(i,...w){this._logLevel<=d.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,i,w)}info(i,...w){this._logLevel<=d.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,i,w)}warn(i,...w){this._logLevel<=d.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,i,w)}error(i,...w){this._logLevel<=d.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,i,w)}};t.LogService=o,t.LogService=o=l([p(0,d.IOptionsService)],o)},56:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let l=n(7150),p=n(701),g=n(802);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1000,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:p.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}};let d=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends l.Disposable{constructor(v){super(),this._onOptionChange=this._register(new g.Emitter),this.onOptionChange=this._onOptionChange.event;let o={...t.DEFAULT_OPTIONS};for(let i in v)if(i in o)try{let w=v[i];o[i]=this._sanitizeAndValidateOption(i,w)}catch(w){console.error(w)}this.rawOptions=o,this.options={...o},this._setupOptions(),this._register((0,l.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(v,o){return this.onOptionChange((i)=>{i===v&&o(this.rawOptions[v])})}onMultipleOptionChange(v,o){return this.onOptionChange((i)=>{v.indexOf(i)!==-1&&o()})}_setupOptions(){let v=(i)=>{if(!(i in t.DEFAULT_OPTIONS))throw Error(`No option with key "${i}"`);return this.rawOptions[i]},o=(i,w)=>{if(!(i in t.DEFAULT_OPTIONS))throw Error(`No option with key "${i}"`);w=this._sanitizeAndValidateOption(i,w),this.rawOptions[i]!==w&&(this.rawOptions[i]=w,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let w={get:v.bind(this,i),set:o.bind(this,i)};Object.defineProperty(this.options,i,w)}}_sanitizeAndValidateOption(v,o){switch(v){case"cursorStyle":if(o||(o=t.DEFAULT_OPTIONS[v]),!function(i){return i==="block"||i==="underline"||i==="bar"}(o))throw Error(`"${o}" is not a valid value for ${v}`);break;case"wordSeparator":o||(o=t.DEFAULT_OPTIONS[v]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1000)break;o=d.includes(o)?o:t.DEFAULT_OPTIONS[v];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw Error(`${v} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw Error(`${v} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw Error(`${v} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw Error(`${v} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}t.OptionsService=_},8811:function(y,t,n){var l=this&&this.__decorate||function(_,v,o,i){var w,h=arguments.length,m=h<3?v:i===null?i=Object.getOwnPropertyDescriptor(v,o):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(_,v,o,i);else for(var u=_.length-1;u>=0;u--)(w=_[u])&&(m=(h<3?w(m):h>3?w(v,o,m):w(v,o))||m);return h>3&&m&&Object.defineProperty(v,o,m),m},p=this&&this.__param||function(_,v){return function(o,i){v(o,i,_)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkService=void 0;let g=n(6501),d=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){let v=this._bufferService.buffer;if(_.id===void 0){let u=v.addMarker(v.ybase+v.y),S={data:_,id:this._nextId++,lines:[u]};return u.onDispose(()=>this._removeMarkerFromLink(S,u)),this._dataByLinkId.set(S.id,S),S.id}let o=_,i=this._getEntryIdKey(o),w=this._entriesWithId.get(i);if(w)return this.addLineToLink(w.id,v.ybase+v.y),w.id;let h=v.addMarker(v.ybase+v.y),m={id:this._nextId++,key:this._getEntryIdKey(o),data:o,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(m,h)),this._entriesWithId.set(m.key,m),this._dataByLinkId.set(m.id,m),m.id}addLineToLink(_,v){let o=this._dataByLinkId.get(_);if(o&&o.lines.every((i)=>i.line!==v)){let i=this._bufferService.buffer.addMarker(v);o.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(o,i))}}getLinkData(_){return this._dataByLinkId.get(_)?.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,v){let o=_.lines.indexOf(v);o!==-1&&(_.lines.splice(o,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};t.OscLinkService=d,t.OscLinkService=d=l([p(0,g.IBufferService)],d)},6201:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.serviceRegistry=void 0,t.getServiceDependencies=function(p){return p[l]||[]},t.createDecorator=function(p){if(t.serviceRegistry.has(p))return t.serviceRegistry.get(p);let g=function(d,_,v){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");(function(o,i,w){i[n]===i?i[l].push({id:o,index:w}):(i[l]=[{id:o,index:w}],i[n]=i)})(g,d,v)};return g._id=p,t.serviceRegistry.set(p,g),g};let n="di$target",l="di$dependencies";t.serviceRegistry=new Map},6501:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let l=n(6201);var p;t.IBufferService=(0,l.createDecorator)("BufferService"),t.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),t.ICoreService=(0,l.createDecorator)("CoreService"),t.ICharsetService=(0,l.createDecorator)("CharsetService"),t.IInstantiationService=(0,l.createDecorator)("InstantiationService"),function(g){g[g.TRACE=0]="TRACE",g[g.DEBUG=1]="DEBUG",g[g.INFO=2]="INFO",g[g.WARN=3]="WARN",g[g.ERROR=4]="ERROR",g[g.OFF=5]="OFF"}(p||(t.LogLevelEnum=p={})),t.ILogService=(0,l.createDecorator)("LogService"),t.IOptionsService=(0,l.createDecorator)("OptionsService"),t.IOscLinkService=(0,l.createDecorator)("OscLinkService"),t.IUnicodeService=(0,l.createDecorator)("UnicodeService"),t.IDecorationService=(0,l.createDecorator)("DecorationService")},6415:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let l=n(7428),p=n(802);class g{static extractShouldJoin(d){return!!(1&d)}static extractWidth(d){return d>>1&3}static extractCharKind(d){return d>>3}static createPropertyValue(d,_,v=!1){return(16777215&d)<<3|(3&_)<<1|(v?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new p.Emitter,this.onChange=this._onChange.event;let d=new l.UnicodeV6;this.register(d),this._active=d.version,this._activeProvider=d}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(d){if(!this._providers[d])throw Error(`unknown Unicode version "${d}"`);this._active=d,this._activeProvider=this._providers[d],this._onChange.fire(d)}register(d){this._providers[d.version]=d}wcwidth(d){return this._activeProvider.wcwidth(d)}getStringCellWidth(d){let _=0,v=0,o=d.length;for(let i=0;i<o;++i){let w=d.charCodeAt(i);if(55296<=w&&w<=56319){if(++i>=o)return _+this.wcwidth(w);let u=d.charCodeAt(i);56320<=u&&u<=57343?w=1024*(w-55296)+u-56320+65536:_+=this.wcwidth(u)}let h=this.charProperties(w,v),m=g.extractWidth(h);g.extractShouldJoin(h)&&(m-=g.extractWidth(v)),_+=m,v=h}return _}charProperties(d,_){return this._activeProvider.charProperties(d,_)}}t.UnicodeService=g},5856:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;let l=n(6107),p=n(5777),g=n(802);class d extends p.CoreTerminal{constructor(_={}){super(_),this._onBell=this._register(new g.Emitter),this.onBell=this._onBell.event,this._onCursorMove=this._register(new g.Emitter),this.onCursorMove=this._onCursorMove.event,this._onTitleChange=this._register(new g.Emitter),this.onTitleChange=this._onTitleChange.event,this._onA11yCharEmitter=this._register(new g.Emitter),this.onA11yChar=this._onA11yCharEmitter.event,this._onA11yTabEmitter=this._register(new g.Emitter),this.onA11yTab=this._onA11yTabEmitter.event,this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(g.Event.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(g.Event.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(g.Event.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(g.Event.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(_){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+_)}bell(){this._onBell.fire()}input(_,v=!0){this.coreService.triggerDataEvent(_,v)}resize(_,v){_===this.cols&&v===this.rows||super.resize(_,v)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){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 _=1;_<this.rows;_++)this.buffer.lines.push(this.buffer.getBlankLine(l.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}}t.Terminal=d},3058:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Permutation=t.CallbackIterable=t.ArrayQueue=t.booleanComparator=t.numberComparator=t.CompareResult=void 0,t.tail=function(u,S=0){return u[u.length-(1+S)]},t.tail2=function(u){if(u.length===0)throw Error("Invalid tail call");return[u.slice(0,u.length-1),u[u.length-1]]},t.equals=function(u,S,C=(T,B)=>T===B){if(u===S)return!0;if(!u||!S)return!1;if(u.length!==S.length)return!1;for(let T=0,B=u.length;T<B;T++)if(!C(u[T],S[T]))return!1;return!0},t.removeFastWithoutKeepingOrder=function(u,S){let C=u.length-1;S<C&&(u[S]=u[C]),u.pop()},t.binarySearch=function(u,S,C){return g(u.length,(T)=>C(u[T],S))},t.binarySearch2=g,t.quickSelect=function u(S,C,T){if((S|=0)>=C.length)throw TypeError("invalid index");let B=C[Math.floor(C.length*Math.random())],O=[],A=[],M=[];for(let k of C){let P=T(k,B);P<0?O.push(k):P>0?A.push(k):M.push(k)}return S<O.length?u(S,O,T):S<O.length+M.length?M[0]:u(S-(O.length+M.length),A,T)},t.groupBy=function(u,S){let C=[],T;for(let B of u.slice(0).sort(S))T&&S(T[0],B)===0?T.push(B):(T=[B],C.push(T));return C},t.groupAdjacentBy=function*(u,S){let C,T;for(let B of u)T!==void 0&&S(T,B)?C.push(B):(C&&(yield C),C=[B]),T=B;C&&(yield C)},t.forEachAdjacent=function(u,S){for(let C=0;C<=u.length;C++)S(C===0?void 0:u[C-1],C===u.length?void 0:u[C])},t.forEachWithNeighbors=function(u,S){for(let C=0;C<u.length;C++)S(C===0?void 0:u[C-1],u[C],C+1===u.length?void 0:u[C+1])},t.sortedDiff=d,t.delta=function(u,S,C){let T=d(u,S,C),B=[],O=[];for(let A of T)B.push(...u.slice(A.start,A.start+A.deleteCount)),O.push(...A.toInsert);return{removed:B,added:O}},t.top=function(u,S,C){if(C===0)return[];let T=u.slice(0,C).sort(S);return _(u,S,T,C,u.length),T},t.topAsync=function(u,S,C,T,B){return C===0?Promise.resolve([]):new Promise((O,A)=>{(async()=>{let M=u.length,k=u.slice(0,C).sort(S);for(let P=C,W=Math.min(C+T,M);P<M;P=W,W=Math.min(W+T,M)){if(P>C&&await new Promise((z)=>setTimeout(z)),B&&B.isCancellationRequested)throw new l.CancellationError;_(u,S,k,P,W)}return k})().then(O,A)})},t.coalesce=function(u){return u.filter((S)=>!!S)},t.coalesceInPlace=function(u){let S=0;for(let C=0;C<u.length;C++)u[C]&&(u[S]=u[C],S+=1);u.length=S},t.move=function(u,S,C){u.splice(C,0,u.splice(S,1)[0])},t.isFalsyOrEmpty=function(u){return!Array.isArray(u)||u.length===0},t.isNonEmptyArray=function(u){return Array.isArray(u)&&u.length>0},t.distinct=function(u,S=(C)=>C){let C=new Set;return u.filter((T)=>{let B=S(T);return!C.has(B)&&(C.add(B),!0)})},t.uniqueFilter=function(u){let S=new Set;return(C)=>{let T=u(C);return!S.has(T)&&(S.add(T),!0)}},t.firstOrDefault=function(u,S){return u.length>0?u[0]:S},t.lastOrDefault=function(u,S){return u.length>0?u[u.length-1]:S},t.commonPrefixLength=function(u,S,C=(T,B)=>T===B){let T=0;for(let B=0,O=Math.min(u.length,S.length);B<O&&C(u[B],S[B]);B++)T++;return T},t.range=function(u,S){let C=typeof S=="number"?u:0;typeof S=="number"?C=u:(C=0,S=u);let T=[];if(C<=S)for(let B=C;B<S;B++)T.push(B);else for(let B=C;B>S;B--)T.push(B);return T},t.index=function(u,S,C){return u.reduce((T,B)=>(T[S(B)]=C?C(B):B,T),Object.create(null))},t.insert=function(u,S){return u.push(S),()=>v(u,S)},t.remove=v,t.arrayInsert=function(u,S,C){let T=u.slice(0,S),B=u.slice(S);return T.concat(C,B)},t.shuffle=function(u,S){let C;if(typeof S=="number"){let T=S;C=()=>{let B=179426549*Math.sin(T++);return B-Math.floor(B)}}else C=Math.random;for(let T=u.length-1;T>0;T-=1){let B=Math.floor(C()*(T+1)),O=u[T];u[T]=u[B],u[B]=O}},t.pushToStart=function(u,S){let C=u.indexOf(S);C>-1&&(u.splice(C,1),u.unshift(S))},t.pushToEnd=function(u,S){let C=u.indexOf(S);C>-1&&(u.splice(C,1),u.push(S))},t.pushMany=function(u,S){for(let C of S)u.push(C)},t.mapArrayOrNot=function(u,S){return Array.isArray(u)?u.map(S):S(u)},t.asArray=function(u){return Array.isArray(u)?u:[u]},t.getRandomElement=function(u){return u[Math.floor(Math.random()*u.length)]},t.insertInto=o,t.splice=function(u,S,C,T){let B=i(u,S),O=u.splice(B,C);return O===void 0&&(O=[]),o(u,B,T),O},t.compareBy=function(u,S){return(C,T)=>S(u(C),u(T))},t.tieBreakComparators=function(...u){return(S,C)=>{for(let T of u){let B=T(S,C);if(!w.isNeitherLessOrGreaterThan(B))return B}return w.neitherLessOrGreaterThan}},t.reverseOrder=function(u){return(S,C)=>-u(S,C)};let l=n(9807),p=n(8297);function g(u,S){let C=0,T=u-1;for(;C<=T;){let B=(C+T)/2|0,O=S(B);if(O<0)C=B+1;else{if(!(O>0))return B;T=B-1}}return-(C+1)}function d(u,S,C){let T=[];function B(M,k,P){if(k===0&&P.length===0)return;let W=T[T.length-1];W&&W.start+W.deleteCount===M?(W.deleteCount+=k,W.toInsert.push(...P)):T.push({start:M,deleteCount:k,toInsert:P})}let O=0,A=0;for(;;){if(O===u.length){B(O,0,S.slice(A));break}if(A===S.length){B(O,u.length-O,[]);break}let M=u[O],k=S[A],P=C(M,k);P===0?(O+=1,A+=1):P<0?(B(O,1,[]),O+=1):P>0&&(B(O,0,[k]),A+=1)}return T}function _(u,S,C,T,B){for(let O=C.length;T<B;T++){let A=u[T];if(S(A,C[O-1])<0){C.pop();let M=(0,p.findFirstIdxMonotonousOrArrLen)(C,(k)=>S(A,k)<0);C.splice(M,0,A)}}}function v(u,S){let C=u.indexOf(S);if(C>-1)return u.splice(C,1),S}function o(u,S,C){let T=i(u,S),B=u.length,O=C.length;u.length=B+O;for(let A=B-1;A>=T;A--)u[A+O]=u[A];for(let A=0;A<O;A++)u[A+T]=C[A]}function i(u,S){return S<0?Math.max(S+u.length,0):Math.min(S,u.length)}var w;(function(u){u.isLessThan=function(S){return S<0},u.isLessThanOrEqual=function(S){return S<=0},u.isGreaterThan=function(S){return S>0},u.isNeitherLessOrGreaterThan=function(S){return S===0},u.greaterThan=1,u.lessThan=-1,u.neitherLessOrGreaterThan=0})(w||(t.CompareResult=w={})),t.numberComparator=(u,S)=>u-S,t.booleanComparator=(u,S)=>(0,t.numberComparator)(u?1:0,S?1:0),t.ArrayQueue=class{constructor(u){this.items=u,this.firstIdx=0,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(u){let S=this.firstIdx;for(;S<this.items.length&&u(this.items[S]);)S++;let C=S===this.firstIdx?null:this.items.slice(this.firstIdx,S);return this.firstIdx=S,C}takeFromEndWhile(u){let S=this.lastIdx;for(;S>=0&&u(this.items[S]);)S--;let C=S===this.lastIdx?null:this.items.slice(S+1,this.lastIdx+1);return this.lastIdx=S,C}peek(){if(this.length!==0)return this.items[this.firstIdx]}peekLast(){if(this.length!==0)return this.items[this.lastIdx]}dequeue(){let u=this.items[this.firstIdx];return this.firstIdx++,u}removeLast(){let u=this.items[this.lastIdx];return this.lastIdx--,u}takeCount(u){let S=this.items.slice(this.firstIdx,this.firstIdx+u);return this.firstIdx+=u,S}};class h{static{this.empty=new h((u)=>{})}constructor(u){this.iterate=u}forEach(u){this.iterate((S)=>(u(S),!0))}toArray(){let u=[];return this.iterate((S)=>(u.push(S),!0)),u}filter(u){return new h((S)=>this.iterate((C)=>!u(C)||S(C)))}map(u){return new h((S)=>this.iterate((C)=>S(u(C))))}some(u){let S=!1;return this.iterate((C)=>(S=u(C),!S)),S}findFirst(u){let S;return this.iterate((C)=>!u(C)||(S=C,!1)),S}findLast(u){let S;return this.iterate((C)=>(u(C)&&(S=C),!0)),S}findLastMaxBy(u){let S,C=!0;return this.iterate((T)=>((C||w.isGreaterThan(u(T,S)))&&(C=!1,S=T),!0)),S}}t.CallbackIterable=h;class m{constructor(u){this._indexMap=u}static createSortPermutation(u,S){let C=Array.from(u.keys()).sort((T,B)=>S(u[T],u[B]));return new m(C)}apply(u){return u.map((S,C)=>u[this._indexMap[C]])}inverse(){let u=this._indexMap.slice();for(let S=0;S<this._indexMap.length;S++)u[this._indexMap[S]]=S;return new m(u)}}t.Permutation=m},8297:(y,t)=>{function n(_,v,o=_.length-1){for(let i=o;i>=0;i--)if(v(_[i]))return i;return-1}function l(_,v,o=0,i=_.length){let w=o,h=i;for(;w<h;){let m=Math.floor((w+h)/2);v(_[m])?w=m+1:h=m}return w-1}function p(_,v,o=0,i=_.length){let w=o,h=i;for(;w<h;){let m=Math.floor((w+h)/2);v(_[m])?h=m:w=m+1}return w}Object.defineProperty(t,"__esModule",{value:!0}),t.MonotonousArray=void 0,t.findLast=function(_,v){let o=n(_,v);if(o!==-1)return _[o]},t.findLastIdx=n,t.findLastMonotonous=function(_,v){let o=l(_,v);return o===-1?void 0:_[o]},t.findLastIdxMonotonous=l,t.findFirstMonotonous=function(_,v){let o=p(_,v);return o===_.length?void 0:_[o]},t.findFirstIdxMonotonousOrArrLen=p,t.findFirstIdxMonotonous=function(_,v,o=0,i=_.length){let w=p(_,v,o,i);return w===_.length?-1:w},t.findFirstMax=d,t.findLastMax=function(_,v){if(_.length===0)return;let o=_[0];for(let i=1;i<_.length;i++){let w=_[i];v(w,o)>=0&&(o=w)}return o},t.findFirstMin=function(_,v){return d(_,(o,i)=>-v(o,i))},t.findMaxIdx=function(_,v){if(_.length===0)return-1;let o=0;for(let i=1;i<_.length;i++)v(_[i],_[o])>0&&(o=i);return o},t.mapFindFirst=function(_,v){for(let o of _){let i=v(o);if(i!==void 0)return i}};class g{static{this.assertInvariants=!1}constructor(_){this._array=_,this._findLastMonotonousLastIdx=0}findLastMonotonous(_){if(g.assertInvariants){if(this._prevFindLastPredicate){for(let o of this._array)if(this._prevFindLastPredicate(o)&&!_(o))throw Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=_}let v=l(this._array,_,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=v+1,v===-1?void 0:this._array[v]}}function d(_,v){if(_.length===0)return;let o=_[0];for(let i=1;i<_.length;i++){let w=_[i];v(w,o)>0&&(o=w)}return o}t.MonotonousArray=g},9087:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SetWithKey=void 0,t.groupBy=function(p,g){let d=Object.create(null);for(let _ of p){let v=g(_),o=d[v];o||(o=d[v]=[]),o.push(_)}return d},t.diffSets=function(p,g){let d=[],_=[];for(let v of p)g.has(v)||d.push(v);for(let v of g)p.has(v)||_.push(v);return{removed:d,added:_}},t.diffMaps=function(p,g){let d=[],_=[];for(let[v,o]of p)g.has(v)||d.push(o);for(let[v,o]of g)p.has(v)||_.push(o);return{removed:d,added:_}},t.intersection=function(p,g){let d=new Set;for(let _ of g)p.has(_)&&d.add(_);return d};class l{static{n=Symbol.toStringTag}constructor(p,g){this.toKey=g,this._map=new Map,this[n]="SetWithKey";for(let d of p)this.add(d)}get size(){return this._map.size}add(p){let g=this.toKey(p);return this._map.set(g,p),this}delete(p){return this._map.delete(this.toKey(p))}has(p){return this._map.has(this.toKey(p))}*entries(){for(let p of this._map.values())yield[p,p]}keys(){return this.values()}*values(){for(let p of this._map.values())yield p}clear(){this._map.clear()}forEach(p,g){this._map.forEach((d)=>p.call(g,d,d,this))}[Symbol.iterator](){return this.values()}}t.SetWithKey=l},9807:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BugIndicatingError=t.ErrorNoTelemetry=t.ExpectedError=t.NotSupportedError=t.NotImplementedError=t.ReadonlyError=t.CancellationError=t.errorHandler=t.ErrorHandler=void 0,t.setUnexpectedErrorHandler=function(h){t.errorHandler.setUnexpectedErrorHandler(h)},t.isSigPipeError=function(h){if(!h||typeof h!="object")return!1;let m=h;return m.code==="EPIPE"&&m.syscall?.toUpperCase()==="WRITE"},t.onUnexpectedError=function(h){p(h)||t.errorHandler.onUnexpectedError(h)},t.onUnexpectedExternalError=function(h){p(h)||t.errorHandler.onUnexpectedExternalError(h)},t.transformErrorForSerialization=function(h){if(h instanceof Error){let{name:m,message:u}=h;return{$isError:!0,name:m,message:u,stack:h.stacktrace||h.stack,noTelemetry:i.isErrorNoTelemetry(h)}}return h},t.transformErrorFromSerialization=function(h){let m;return h.noTelemetry?m=new i:(m=Error(),m.name=h.name),m.message=h.message,m.stack=h.stack,m},t.isCancellationError=p,t.canceled=function(){let h=Error(l);return h.name=h.message,h},t.illegalArgument=function(h){return h?Error(`Illegal argument: ${h}`):Error("Illegal argument")},t.illegalState=function(h){return h?Error(`Illegal state: ${h}`):Error("Illegal state")},t.getErrorMessage=function(h){return h?h.message?h.message:h.stack?h.stack.split(`
3
+ var Ls=Object.create;var{getPrototypeOf:Ts,defineProperty:Xt,getOwnPropertyNames:Rs}=Object;var Vt=Object.prototype.hasOwnProperty;function Bs(e){return this[e]}var Ds,Ms,Ps=(e,r,s)=>{var c=e!=null&&typeof e==="object";if(c){var f=r?Ds??=new WeakMap:Ms??=new WeakMap,a=f.get(e);if(a)return a}s=e!=null?Ls(Ts(e)):{};let y=r||!e||!e.__esModule||!Vt.call(e,"default")?Xt(s,"default",{value:e,enumerable:!0}):s;if(e&&typeof e==="object"||typeof e==="function"){for(let t of Rs(e))if(!Vt.call(y,t))Xt(y,t,{get:Bs.bind(e,t),enumerable:!0})}if(c)f.set(e,y);return y};var Os=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Qt=(e)=>JSON.parse(e);var Mr=Os(function(Dr){(()=>{var e={5639:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CircularList=void 0;let l=n(7150),p=n(802);class g extends l.Disposable{constructor(d){super(),this._maxLength=d,this.onDeleteEmitter=this._register(new p.Emitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new p.Emitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new p.Emitter),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(d){if(this._maxLength===d)return;let _=Array(d);for(let v=0;v<Math.min(d,this.length);v++)_[v]=this._array[this._getCyclicIndex(v)];this._array=_,this._maxLength=d,this._startIndex=0}get length(){return this._length}set length(d){if(d>this._length)for(let _=this._length;_<d;_++)this._array[_]=void 0;this._length=d}get(d){return this._array[this._getCyclicIndex(d)]}set(d,_){this._array[this._getCyclicIndex(d)]=_}push(d){this._array[this._getCyclicIndex(this._length)]=d,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(d,_,...v){if(_){for(let o=d;o<this._length-_;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+_)];this._length-=_,this.onDeleteEmitter.fire({index:d,amount:_})}for(let o=this._length-1;o>=d;o--)this._array[this._getCyclicIndex(o+v.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<v.length;o++)this._array[this._getCyclicIndex(d+o)]=v[o];if(v.length&&this.onInsertEmitter.fire({index:d,amount:v.length}),this._length+v.length>this._maxLength){let o=this._length+v.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=v.length}trimStart(d){d>this._length&&(d=this._length),this._startIndex+=d,this._length-=d,this.onTrimEmitter.fire(d)}shiftElements(d,_,v){if(!(_<=0)){if(d<0||d>=this._length)throw Error("start argument out of range");if(d+v<0)throw Error("Cannot shift elements in list beyond index 0");if(v>0){for(let i=_-1;i>=0;i--)this.set(d+i+v,this.get(d+i));let o=d+_+v-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<_;o++)this.set(d+o+v,this.get(d+o))}}_getCyclicIndex(d){return(this._startIndex+d)%this._maxLength}}t.CircularList=g},7453:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clone=function n(l,p=5){if(typeof l!="object")return l;let g=Array.isArray(l)?[]:{};for(let d in l)g[d]=p<=1?l[d]:l[d]&&n(l[d],p-1);return g}},5777:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreTerminal=void 0;let l=n(6501),p=n(6025),g=n(7276),d=n(9640),_=n(56),v=n(4071),o=n(7792),i=n(6415),S=n(5746),h=n(5882),m=n(2486),u=n(3562),w=n(8811),C=n(802),T=n(7150),B=!1;class O extends T.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new C.Emitter),this._onScroll.event((A)=>{this._onScrollApi?.fire(A.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(A){for(let M in A)this.optionsService.options[M]=A[M]}constructor(A){super(),this._windowsWrappingHeuristics=this._register(new T.MutableDisposable),this._onBinary=this._register(new C.Emitter),this.onBinary=this._onBinary.event,this._onData=this._register(new C.Emitter),this.onData=this._onData.event,this._onLineFeed=this._register(new C.Emitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new C.Emitter),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new C.Emitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new C.Emitter),this._instantiationService=new p.InstantiationService,this.optionsService=this._register(new _.OptionsService(A)),this._instantiationService.setService(l.IOptionsService,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(d.BufferService)),this._instantiationService.setService(l.IBufferService,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(l.ILogService,this._logService),this.coreService=this._register(this._instantiationService.createInstance(v.CoreService)),this._instantiationService.setService(l.ICoreService,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(o.CoreMouseService)),this._instantiationService.setService(l.ICoreMouseService,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(i.UnicodeService)),this._instantiationService.setService(l.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(S.CharsetService),this._instantiationService.setService(l.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(w.OscLinkService),this._instantiationService.setService(l.IOscLinkService,this._oscLinkService),this._inputHandler=this._register(new m.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(C.Event.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(C.Event.forward(this._bufferService.onResize,this._onResize)),this._register(C.Event.forward(this.coreService.onData,this._onData)),this._register(C.Event.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new u.WriteBuffer((M,k)=>this._inputHandler.parse(M,k))),this._register(C.Event.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(A,M){this._writeBuffer.write(A,M)}writeSync(A,M){this._logService.logLevel<=l.LogLevelEnum.WARN&&!B&&(this._logService.warn("writeSync is unreliable and will be removed soon."),B=!0),this._writeBuffer.writeSync(A,M)}input(A,M=!0){this.coreService.triggerDataEvent(A,M)}resize(A,M){isNaN(A)||isNaN(M)||(A=Math.max(A,d.MINIMUM_COLS),M=Math.max(M,d.MINIMUM_ROWS),this._bufferService.resize(A,M))}scroll(A,M=!1){this._bufferService.scroll(A,M)}scrollLines(A,M){this._bufferService.scrollLines(A,M)}scrollPages(A){this.scrollLines(A*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(A){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(A){let M=A-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(A,M){return this._inputHandler.registerEscHandler(A,M)}registerDcsHandler(A,M){return this._inputHandler.registerDcsHandler(A,M)}registerCsiHandler(A,M){return this._inputHandler.registerCsiHandler(A,M)}registerOscHandler(A,M){return this._inputHandler.registerOscHandler(A,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let A=!1,M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?A=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(A=!0),A?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let A=[];A.push(this.onLineFeed(h.updateWindowsModeWrappedState.bind(null,this._bufferService))),A.push(this.registerCsiHandler({final:"H"},()=>((0,h.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,T.toDisposable)(()=>{for(let M of A)M.dispose()})}}}t.CoreTerminal=O},2486:function(y,t,n){var l=this&&this.__decorate||function(b,x,L,E){var D,H=arguments.length,I=H<3?x:E===null?E=Object.getOwnPropertyDescriptor(x,L):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(b,x,L,E);else for(var N=b.length-1;N>=0;N--)(D=b[N])&&(I=(H<3?D(I):H>3?D(x,L,I):D(x,L))||I);return H>3&&I&&Object.defineProperty(x,L,I),I},p=this&&this.__param||function(b,x){return function(L,E){x(L,E,b)}};Object.defineProperty(t,"__esModule",{value:!0}),t.InputHandler=t.WindowsOptionsReportType=void 0,t.isValidColorIndex=F;let g=n(3534),d=n(6760),_=n(6717),v=n(7150),o=n(726),i=n(6107),S=n(8938),h=n(3055),m=n(5451),u=n(6501),w=n(6415),C=n(1346),T=n(9823),B=n(8693),O=n(802),A={"(":0,")":1,"*":2,"+":3,"-":1,".":2},M=131072;function k(b,x){if(b>24)return x.setWinLines||!1;switch(b){case 1:return!!x.restoreWin;case 2:return!!x.minimizeWin;case 3:return!!x.setWinPosition;case 4:return!!x.setWinSizePixels;case 5:return!!x.raiseWin;case 6:return!!x.lowerWin;case 7:return!!x.refreshWin;case 8:return!!x.setWinSizeChars;case 9:return!!x.maximizeWin;case 10:return!!x.fullscreenWin;case 11:return!!x.getWinState;case 13:return!!x.getWinPosition;case 14:return!!x.getWinSizePixels;case 15:return!!x.getScreenSizePixels;case 16:return!!x.getCellSizePixels;case 18:return!!x.getWinSizeChars;case 19:return!!x.getScreenSizeChars;case 20:return!!x.getIconTitle;case 21:return!!x.getWinTitle;case 22:return!!x.pushTitle;case 23:return!!x.popTitle;case 24:return!!x.setWinLines}return!1}var P;(function(b){b[b.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",b[b.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(P||(t.WindowsOptionsReportType=P={}));let W=0;class j extends v.Disposable{getAttrData(){return this._curAttrData}constructor(b,x,L,E,D,H,I,N,z=new _.EscapeSequenceParser){super(),this._bufferService=b,this._charsetService=x,this._coreService=L,this._logService=E,this._optionsService=D,this._oscLinkService=H,this._coreMouseService=I,this._unicodeService=N,this._parser=z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new o.StringToUtf32,this._utf8Decoder=new o.Utf8ToUtf32,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this._register(new O.Emitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O.Emitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O.Emitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O.Emitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O.Emitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O.Emitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O.Emitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O.Emitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O.Emitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O.Emitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O.Emitter),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O.Emitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O.Emitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new q(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((R)=>this._activeBuffer=R.activeBuffer)),this._parser.setCsiHandlerFallback((R,G)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(R),params:G.toArray()})}),this._parser.setEscHandlerFallback((R)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(R)})}),this._parser.setExecuteHandlerFallback((R)=>{this._logService.debug("Unknown EXECUTE code: ",{code:R})}),this._parser.setOscHandlerFallback((R,G,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:R,action:G,data:U})}),this._parser.setDcsHandlerFallback((R,G,U)=>{G==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(R),action:G,payload:U})}),this._parser.setPrintHandler((R,G,U)=>this.print(R,G,U)),this._parser.registerCsiHandler({final:"@"},(R)=>this.insertChars(R)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(R)=>this.scrollLeft(R)),this._parser.registerCsiHandler({final:"A"},(R)=>this.cursorUp(R)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(R)=>this.scrollRight(R)),this._parser.registerCsiHandler({final:"B"},(R)=>this.cursorDown(R)),this._parser.registerCsiHandler({final:"C"},(R)=>this.cursorForward(R)),this._parser.registerCsiHandler({final:"D"},(R)=>this.cursorBackward(R)),this._parser.registerCsiHandler({final:"E"},(R)=>this.cursorNextLine(R)),this._parser.registerCsiHandler({final:"F"},(R)=>this.cursorPrecedingLine(R)),this._parser.registerCsiHandler({final:"G"},(R)=>this.cursorCharAbsolute(R)),this._parser.registerCsiHandler({final:"H"},(R)=>this.cursorPosition(R)),this._parser.registerCsiHandler({final:"I"},(R)=>this.cursorForwardTab(R)),this._parser.registerCsiHandler({final:"J"},(R)=>this.eraseInDisplay(R,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(R)=>this.eraseInDisplay(R,!0)),this._parser.registerCsiHandler({final:"K"},(R)=>this.eraseInLine(R,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(R)=>this.eraseInLine(R,!0)),this._parser.registerCsiHandler({final:"L"},(R)=>this.insertLines(R)),this._parser.registerCsiHandler({final:"M"},(R)=>this.deleteLines(R)),this._parser.registerCsiHandler({final:"P"},(R)=>this.deleteChars(R)),this._parser.registerCsiHandler({final:"S"},(R)=>this.scrollUp(R)),this._parser.registerCsiHandler({final:"T"},(R)=>this.scrollDown(R)),this._parser.registerCsiHandler({final:"X"},(R)=>this.eraseChars(R)),this._parser.registerCsiHandler({final:"Z"},(R)=>this.cursorBackwardTab(R)),this._parser.registerCsiHandler({final:"`"},(R)=>this.charPosAbsolute(R)),this._parser.registerCsiHandler({final:"a"},(R)=>this.hPositionRelative(R)),this._parser.registerCsiHandler({final:"b"},(R)=>this.repeatPrecedingCharacter(R)),this._parser.registerCsiHandler({final:"c"},(R)=>this.sendDeviceAttributesPrimary(R)),this._parser.registerCsiHandler({prefix:">",final:"c"},(R)=>this.sendDeviceAttributesSecondary(R)),this._parser.registerCsiHandler({final:"d"},(R)=>this.linePosAbsolute(R)),this._parser.registerCsiHandler({final:"e"},(R)=>this.vPositionRelative(R)),this._parser.registerCsiHandler({final:"f"},(R)=>this.hVPosition(R)),this._parser.registerCsiHandler({final:"g"},(R)=>this.tabClear(R)),this._parser.registerCsiHandler({final:"h"},(R)=>this.setMode(R)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(R)=>this.setModePrivate(R)),this._parser.registerCsiHandler({final:"l"},(R)=>this.resetMode(R)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(R)=>this.resetModePrivate(R)),this._parser.registerCsiHandler({final:"m"},(R)=>this.charAttributes(R)),this._parser.registerCsiHandler({final:"n"},(R)=>this.deviceStatus(R)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(R)=>this.deviceStatusPrivate(R)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(R)=>this.softReset(R)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(R)=>this.setCursorStyle(R)),this._parser.registerCsiHandler({final:"r"},(R)=>this.setScrollRegion(R)),this._parser.registerCsiHandler({final:"s"},(R)=>this.saveCursor(R)),this._parser.registerCsiHandler({final:"t"},(R)=>this.windowOptions(R)),this._parser.registerCsiHandler({final:"u"},(R)=>this.restoreCursor(R)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(R)=>this.insertColumns(R)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(R)=>this.deleteColumns(R)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(R)=>this.selectProtected(R)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(R)=>this.requestMode(R,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(R)=>this.requestMode(R,!1)),this._parser.setExecuteHandler(g.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(g.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(g.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(g.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(g.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(g.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(g.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(g.C1.IND,()=>this.index()),this._parser.setExecuteHandler(g.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(g.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new C.OscHandler((R)=>(this.setTitle(R),this.setIconName(R),!0))),this._parser.registerOscHandler(1,new C.OscHandler((R)=>this.setIconName(R))),this._parser.registerOscHandler(2,new C.OscHandler((R)=>this.setTitle(R))),this._parser.registerOscHandler(4,new C.OscHandler((R)=>this.setOrReportIndexedColor(R))),this._parser.registerOscHandler(8,new C.OscHandler((R)=>this.setHyperlink(R))),this._parser.registerOscHandler(10,new C.OscHandler((R)=>this.setOrReportFgColor(R))),this._parser.registerOscHandler(11,new C.OscHandler((R)=>this.setOrReportBgColor(R))),this._parser.registerOscHandler(12,new C.OscHandler((R)=>this.setOrReportCursorColor(R))),this._parser.registerOscHandler(104,new C.OscHandler((R)=>this.restoreIndexedColor(R))),this._parser.registerOscHandler(110,new C.OscHandler((R)=>this.restoreFgColor(R))),this._parser.registerOscHandler(111,new C.OscHandler((R)=>this.restoreBgColor(R))),this._parser.registerOscHandler(112,new C.OscHandler((R)=>this.restoreCursorColor(R))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let R in d.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:R},()=>this.selectCharset("("+R)),this._parser.registerEscHandler({intermediates:")",final:R},()=>this.selectCharset(")"+R)),this._parser.registerEscHandler({intermediates:"*",final:R},()=>this.selectCharset("*"+R)),this._parser.registerEscHandler({intermediates:"+",final:R},()=>this.selectCharset("+"+R)),this._parser.registerEscHandler({intermediates:"-",final:R},()=>this.selectCharset("-"+R)),this._parser.registerEscHandler({intermediates:".",final:R},()=>this.selectCharset("."+R)),this._parser.registerEscHandler({intermediates:"/",final:R},()=>this.selectCharset("/"+R));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((R)=>(this._logService.error("Parsing error: ",R),R)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new T.DcsHandler((R,G)=>this.requestStatusString(R,G)))}_preserveStack(b,x,L,E){this._parseStack.paused=!0,this._parseStack.cursorStartX=b,this._parseStack.cursorStartY=x,this._parseStack.decodedLength=L,this._parseStack.position=E}_logSlowResolvingAsync(b){this._logService.logLevel<=u.LogLevelEnum.WARN&&Promise.race([b,new Promise((x,L)=>setTimeout(()=>L("#SLOW_TIMEOUT"),5000))]).catch((x)=>{if(x!=="#SLOW_TIMEOUT")throw x;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(b,x){let L,E=this._activeBuffer.x,D=this._activeBuffer.y,H=0,I=this._parseStack.paused;if(I){if(L=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,x))return this._logSlowResolvingAsync(L),L;E=this._parseStack.cursorStartX,D=this._parseStack.cursorStartY,this._parseStack.paused=!1,b.length>M&&(H=this._parseStack.position+M)}if(this._logService.logLevel<=u.LogLevelEnum.DEBUG&&this._logService.debug("parsing data "+(typeof b=="string"?` "${b}"`:` "${Array.prototype.map.call(b,(R)=>String.fromCharCode(R)).join("")}"`)),this._logService.logLevel===u.LogLevelEnum.TRACE&&this._logService.trace("parsing data (codes)",typeof b=="string"?b.split("").map((R)=>R.charCodeAt(0)):b),this._parseBuffer.length<b.length&&this._parseBuffer.length<M&&(this._parseBuffer=new Uint32Array(Math.min(b.length,M))),I||this._dirtyRowTracker.clearRange(),b.length>M)for(let R=H;R<b.length;R+=M){let G=R+M<b.length?R+M:b.length,U=typeof b=="string"?this._stringDecoder.decode(b.substring(R,G),this._parseBuffer):this._utf8Decoder.decode(b.subarray(R,G),this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,U))return this._preserveStack(E,D,U,R),this._logSlowResolvingAsync(L),L}else if(!I){let R=typeof b=="string"?this._stringDecoder.decode(b,this._parseBuffer):this._utf8Decoder.decode(b,this._parseBuffer);if(L=this._parser.parse(this._parseBuffer,R))return this._preserveStack(E,D,R,0),this._logSlowResolvingAsync(L),L}this._activeBuffer.x===E&&this._activeBuffer.y===D||this._onCursorMove.fire();let N=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),z=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);z<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(z,this._bufferService.rows-1),end:Math.min(N,this._bufferService.rows-1)})}print(b,x,L){let E,D,H=this._charsetService.charset,I=this._optionsService.rawOptions.screenReaderMode,N=this._bufferService.cols,z=this._coreService.decPrivateModes.wraparound,R=this._coreService.modes.insertMode,G=this._curAttrData,U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&L-x>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodepoint(this._activeBuffer.x-1,0,1,G);let X=this._parser.precedingJoinState;for(let se=x;se<L;++se){if(E=b[se],E<127&&H){let le=H[String.fromCharCode(E)];le&&(E=le.charCodeAt(0))}let ie=this._unicodeService.charProperties(E,X);D=w.UnicodeService.extractWidth(ie);let ae=w.UnicodeService.extractShouldJoin(ie),ce=ae?w.UnicodeService.extractWidth(X):0;if(X=ie,I&&this._onA11yChar.fire((0,o.stringFromCodePoint)(E)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+D-ce>N){if(z){let le=U,we=this._activeBuffer.x-ce;for(this._activeBuffer.x=ce,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),ce>0&&U instanceof i.BufferLine&&U.copyCellsFrom(le,we,0,ce,!1);we<N;)le.setCellFromCodepoint(we++,0,1,G)}else if(this._activeBuffer.x=N-1,D===2)continue}if(ae&&this._activeBuffer.x){let le=U.getWidth(this._activeBuffer.x-1)?1:2;U.addCodepointToCell(this._activeBuffer.x-le,E,D);for(let we=D-ce;--we>=0;)U.setCellFromCodepoint(this._activeBuffer.x++,0,0,G)}else if(R&&(U.insertCells(this._activeBuffer.x,D-ce,this._activeBuffer.getNullCell(G)),U.getWidth(N-1)===2&&U.setCellFromCodepoint(N-1,S.NULL_CELL_CODE,S.NULL_CELL_WIDTH,G)),U.setCellFromCodepoint(this._activeBuffer.x++,E,D,G),D>0)for(;--D;)U.setCellFromCodepoint(this._activeBuffer.x++,0,0,G)}this._parser.precedingJoinState=X,this._activeBuffer.x<N&&L-x>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.setCellFromCodepoint(this._activeBuffer.x,0,1,G),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(b,x){return b.final!=="t"||b.prefix||b.intermediates?this._parser.registerCsiHandler(b,x):this._parser.registerCsiHandler(b,(L)=>!k(L.params[0],this._optionsService.rawOptions.windowOptions)||x(L))}registerDcsHandler(b,x){return this._parser.registerDcsHandler(b,new T.DcsHandler(x))}registerEscHandler(b,x){return this._parser.registerEscHandler(b,x)}registerOscHandler(b,x){return this._parser.registerOscHandler(b,new C.OscHandler(x))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);b.hasWidth(this._activeBuffer.x)&&!b.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-b),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(b=this._bufferService.cols-1){this._activeBuffer.x=Math.min(b,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(b,x){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=b,this._activeBuffer.y=this._activeBuffer.scrollTop+x):(this._activeBuffer.x=b,this._activeBuffer.y=x),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(b,x){this._restrictCursor(),this._setCursor(this._activeBuffer.x+b,this._activeBuffer.y+x)}cursorUp(b){let x=this._activeBuffer.y-this._activeBuffer.scrollTop;return x>=0?this._moveCursor(0,-Math.min(x,b.params[0]||1)):this._moveCursor(0,-(b.params[0]||1)),!0}cursorDown(b){let x=this._activeBuffer.scrollBottom-this._activeBuffer.y;return x>=0?this._moveCursor(0,Math.min(x,b.params[0]||1)):this._moveCursor(0,b.params[0]||1),!0}cursorForward(b){return this._moveCursor(b.params[0]||1,0),!0}cursorBackward(b){return this._moveCursor(-(b.params[0]||1),0),!0}cursorNextLine(b){return this.cursorDown(b),this._activeBuffer.x=0,!0}cursorPrecedingLine(b){return this.cursorUp(b),this._activeBuffer.x=0,!0}cursorCharAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(b){return this._setCursor(b.length>=2?(b.params[1]||1)-1:0,(b.params[0]||1)-1),!0}charPosAbsolute(b){return this._setCursor((b.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(b){return this._moveCursor(b.params[0]||1,0),!0}linePosAbsolute(b){return this._setCursor(this._activeBuffer.x,(b.params[0]||1)-1),!0}vPositionRelative(b){return this._moveCursor(0,b.params[0]||1),!0}hVPosition(b){return this.cursorPosition(b),!0}tabClear(b){let x=b.params[0];return x===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:x===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let x=b.params[0]||1;for(;x--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(b){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let x=b.params[0]||1;for(;x--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(b){let x=b.params[0];return x===1&&(this._curAttrData.bg|=536870912),x!==2&&x!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(b,x,L,E=!1,D=!1){let H=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);H.replaceCells(x,L,this._activeBuffer.getNullCell(this._eraseAttrData()),D),E&&(H.isWrapped=!1)}_resetBufferLine(b,x=!1){let L=this._activeBuffer.lines.get(this._activeBuffer.ybase+b);L&&(L.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),x),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+b),L.isWrapped=!1)}eraseInDisplay(b,x=!1){let L;switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,x);L<this._bufferService.rows;L++)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(L);break;case 1:for(L=this._activeBuffer.y,this._dirtyRowTracker.markDirty(L),this._eraseInBufferLine(L,0,this._activeBuffer.x+1,!0,x),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(L+1).isWrapped=!1);L--;)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(L=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,L-1);L--;)if(this._activeBuffer.lines.get(this._activeBuffer.ybase+L)?.getTrimmedLength())break;for(;L>=0;L--)this._bufferService.scroll(this._eraseAttrData())}else{for(L=this._bufferService.rows,this._dirtyRowTracker.markDirty(L-1);L--;)this._resetBufferLine(L,x);this._dirtyRowTracker.markDirty(0)}break;case 3:let E=this._activeBuffer.lines.length-this._bufferService.rows;E>0&&(this._activeBuffer.lines.trimStart(E),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-E,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-E,0),this._onScroll.fire(0))}return!0}eraseInLine(b,x=!1){switch(this._restrictCursor(this._bufferService.cols),b.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,x);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,x);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,x)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(b){this._restrictCursor();let x=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=this._activeBuffer.ybase+this._activeBuffer.y,E=this._bufferService.rows-1-this._activeBuffer.scrollBottom,D=this._bufferService.rows-1+this._activeBuffer.ybase-E+1;for(;x--;)this._activeBuffer.lines.splice(D-1,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(b){this._restrictCursor();let x=b.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let L=this._activeBuffer.ybase+this._activeBuffer.y,E;for(E=this._bufferService.rows-1-this._activeBuffer.scrollBottom,E=this._bufferService.rows-1+this._activeBuffer.ybase-E;x--;)this._activeBuffer.lines.splice(L,1),this._activeBuffer.lines.splice(E,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.insertCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.deleteCells(this._activeBuffer.x,b.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(b){let x=b.params[0]||1;for(;x--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(b){let x=b.params[0]||1;for(;x--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(i.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.deleteCells(0,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.insertCells(0,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.insertCells(this._activeBuffer.x,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(b){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let x=b.params[0]||1;for(let L=this._activeBuffer.scrollTop;L<=this._activeBuffer.scrollBottom;++L){let E=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);E.deleteCells(this._activeBuffer.x,x,this._activeBuffer.getNullCell(this._eraseAttrData())),E.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(b){this._restrictCursor();let x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return x&&(x.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(b.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(b){let x=this._parser.precedingJoinState;if(!x)return!0;let L=b.params[0]||1,E=w.UnicodeService.extractWidth(x),D=this._activeBuffer.x-E,H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(D),I=new Uint32Array(H.length*L),N=0;for(let R=0;R<H.length;){let G=H.codePointAt(R)||0;I[N++]=G,R+=G>65535?2:1}let z=N;for(let R=1;R<L;++R)I.copyWithin(z,0,N),z+=N;return this.print(I,0,z),!0}sendDeviceAttributesPrimary(b){return b.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(g.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(g.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(b){return b.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(g.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(g.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(b.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(g.C0.ESC+"[>83;40003;0c")),!0}_is(b){return(this._optionsService.rawOptions.termName+"").indexOf(b)===0}setMode(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,d.DEFAULT_CHARSET),this._charsetService.setgCharset(1,d.DEFAULT_CHARSET),this._charsetService.setgCharset(2,d.DEFAULT_CHARSET),this._charsetService.setgCharset(3,d.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1000:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(b){for(let x=0;x<b.length;x++)switch(b.params[x]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1000:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),b.params[x]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(b,x){let L=this._coreService.decPrivateModes,{activeProtocol:E,activeEncoding:D}=this._coreMouseService,H=this._coreService,{buffers:I,cols:N}=this._bufferService,{active:z,alt:R}=I,G=this._optionsService.rawOptions,U=(ae)=>ae?1:2,X=b.params[0];return se=X,ie=x?X===2?4:X===4?U(H.modes.insertMode):X===12?3:X===20?U(G.convertEol):0:X===1?U(L.applicationCursorKeys):X===3?G.windowOptions.setWinLines?N===80?2:N===132?1:0:0:X===6?U(L.origin):X===7?U(L.wraparound):X===8?3:X===9?U(E==="X10"):X===12?U(G.cursorBlink):X===25?U(!H.isCursorHidden):X===45?U(L.reverseWraparound):X===66?U(L.applicationKeypad):X===67?4:X===1000?U(E==="VT200"):X===1002?U(E==="DRAG"):X===1003?U(E==="ANY"):X===1004?U(L.sendFocus):X===1005?4:X===1006?U(D==="SGR"):X===1015?4:X===1016?U(D==="SGR_PIXELS"):X===1048?1:X===47||X===1047||X===1049?U(z===R):X===2004?U(L.bracketedPasteMode):X===2026?U(L.synchronizedOutput):0,H.triggerDataEvent(`${g.C0.ESC}[${x?"":"?"}${se};${ie}$y`),!0;var se,ie}_updateAttrColor(b,x,L,E,D){return x===2?(b|=50331648,b&=-16777216,b|=m.AttributeData.fromColorRGB([L,E,D])):x===5&&(b&=-50331904,b|=33554432|255&L),b}_extractColor(b,x,L){let E=[0,0,-1,0,0,0],D=0,H=0;do{if(E[H+D]=b.params[x+H],b.hasSubParams(x+H)){let I=b.getSubParams(x+H),N=0;do E[1]===5&&(D=1),E[H+N+1+D]=I[N];while(++N<I.length&&N+H+1+D<E.length);break}if(E[1]===5&&H+D>=2||E[1]===2&&H+D>=5)break;E[1]&&(D=1)}while(++H+x<b.length&&H+D<E.length);for(let I=2;I<E.length;++I)E[I]===-1&&(E[I]=0);switch(E[0]){case 38:L.fg=this._updateAttrColor(L.fg,E[1],E[3],E[4],E[5]);break;case 48:L.bg=this._updateAttrColor(L.bg,E[1],E[3],E[4],E[5]);break;case 58:L.extended=L.extended.clone(),L.extended.underlineColor=this._updateAttrColor(L.extended.underlineColor,E[1],E[3],E[4],E[5])}return H}_processUnderline(b,x){x.extended=x.extended.clone(),(!~b||b>5)&&(b=1),x.extended.underlineStyle=b,x.fg|=268435456,b===0&&(x.fg&=-268435457),x.updateExtended()}_processSGR0(b){b.fg=i.DEFAULT_ATTR_DATA.fg,b.bg=i.DEFAULT_ATTR_DATA.bg,b.extended=b.extended.clone(),b.extended.underlineStyle=0,b.extended.underlineColor&=-67108864,b.updateExtended()}charAttributes(b){if(b.length===1&&b.params[0]===0)return this._processSGR0(this._curAttrData),!0;let x=b.length,L,E=this._curAttrData;for(let D=0;D<x;D++)L=b.params[D],L>=30&&L<=37?(E.fg&=-50331904,E.fg|=16777216|L-30):L>=40&&L<=47?(E.bg&=-50331904,E.bg|=16777216|L-40):L>=90&&L<=97?(E.fg&=-50331904,E.fg|=16777224|L-90):L>=100&&L<=107?(E.bg&=-50331904,E.bg|=16777224|L-100):L===0?this._processSGR0(E):L===1?E.fg|=134217728:L===3?E.bg|=67108864:L===4?(E.fg|=268435456,this._processUnderline(b.hasSubParams(D)?b.getSubParams(D)[0]:1,E)):L===5?E.fg|=536870912:L===7?E.fg|=67108864:L===8?E.fg|=1073741824:L===9?E.fg|=2147483648:L===2?E.bg|=134217728:L===21?this._processUnderline(2,E):L===22?(E.fg&=-134217729,E.bg&=-134217729):L===23?E.bg&=-67108865:L===24?(E.fg&=-268435457,this._processUnderline(0,E)):L===25?E.fg&=-536870913:L===27?E.fg&=-67108865:L===28?E.fg&=-1073741825:L===29?E.fg&=2147483647:L===39?(E.fg&=-67108864,E.fg|=16777215&i.DEFAULT_ATTR_DATA.fg):L===49?(E.bg&=-67108864,E.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):L===38||L===48||L===58?D+=this._extractColor(b,D,E):L===53?E.bg|=1073741824:L===55?E.bg&=-1073741825:L===59?(E.extended=E.extended.clone(),E.extended.underlineColor=-1,E.updateExtended()):L===100?(E.fg&=-67108864,E.fg|=16777215&i.DEFAULT_ATTR_DATA.fg,E.bg&=-67108864,E.bg|=16777215&i.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",L);return!0}deviceStatus(b){switch(b.params[0]){case 5:this._coreService.triggerDataEvent(`${g.C0.ESC}[0n`);break;case 6:let x=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[${x};${L}R`)}return!0}deviceStatusPrivate(b){if(b.params[0]===6){let x=this._activeBuffer.y+1,L=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${g.C0.ESC}[?${x};${L}R`)}return!0}softReset(b){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(b){let x=b.length===0?1:b.params[0];if(x===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(x){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}let L=x%2==1;this._coreService.decPrivateModes.cursorBlink=L}return!0}setScrollRegion(b){let x=b.params[0]||1,L;return(b.length<2||(L=b.params[1])>this._bufferService.rows||L===0)&&(L=this._bufferService.rows),L>x&&(this._activeBuffer.scrollTop=x-1,this._activeBuffer.scrollBottom=L-1,this._setCursor(0,0)),!0}windowOptions(b){if(!k(b.params[0],this._optionsService.rawOptions.windowOptions))return!0;let x=b.length>1?b.params[1]:0;switch(b.params[0]){case 14:x!==2&&this._onRequestWindowsOptionsReport.fire(P.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(P.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${g.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:x!==0&&x!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),x!==0&&x!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:x!==0&&x!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),x!==0&&x!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(b){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(b){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(b){return this._windowTitle=b,this._onTitleChange.fire(b),!0}setIconName(b){return this._iconName=b,!0}setOrReportIndexedColor(b){let x=[],L=b.split(";");for(;L.length>1;){let E=L.shift(),D=L.shift();if(/^\d+$/.exec(E)){let H=parseInt(E);if(F(H))if(D==="?")x.push({type:0,index:H});else{let I=(0,B.parseColor)(D);I&&x.push({type:1,index:H,color:I})}}}return x.length&&this._onColor.fire(x),!0}setHyperlink(b){let x=b.indexOf(";");if(x===-1)return!0;let L=b.slice(0,x).trim(),E=b.slice(x+1);return E?this._createHyperlink(L,E):!L.trim()&&this._finishHyperlink()}_createHyperlink(b,x){this._getCurrentLinkId()&&this._finishHyperlink();let L=b.split(":"),E,D=L.findIndex((H)=>H.startsWith("id="));return D!==-1&&(E=L[D].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:E,uri:x}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(b,x){let L=b.split(";");for(let E=0;E<L.length&&!(x>=this._specialColors.length);++E,++x)if(L[E]==="?")this._onColor.fire([{type:0,index:this._specialColors[x]}]);else{let D=(0,B.parseColor)(L[E]);D&&this._onColor.fire([{type:1,index:this._specialColors[x],color:D}])}return!0}setOrReportFgColor(b){return this._setOrReportSpecialColor(b,0)}setOrReportBgColor(b){return this._setOrReportSpecialColor(b,1)}setOrReportCursorColor(b){return this._setOrReportSpecialColor(b,2)}restoreIndexedColor(b){if(!b)return this._onColor.fire([{type:2}]),!0;let x=[],L=b.split(";");for(let E=0;E<L.length;++E)if(/^\d+$/.exec(L[E])){let D=parseInt(L[E]);F(D)&&x.push({type:2,index:D})}return x.length&&this._onColor.fire(x),!0}restoreFgColor(b){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(b){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(b){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,d.DEFAULT_CHARSET),!0}selectCharset(b){return b.length!==2?(this.selectDefaultCharset(),!0):(b[0]==="/"||this._charsetService.setgCharset(A[b[0]],d.CHARSETS[b[1]]||d.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let b=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,b,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=i.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=i.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(b){return this._charsetService.setgLevel(b),!0}screenAlignmentPattern(){let b=new h.CellData;b.content=4194373,b.fg=this._curAttrData.fg,b.bg=this._curAttrData.bg,this._setCursor(0,0);for(let x=0;x<this._bufferService.rows;++x){let L=this._activeBuffer.ybase+this._activeBuffer.y+x,E=this._activeBuffer.lines.get(L);E&&(E.fill(b),E.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(b,x){let L=this._bufferService.buffer,E=this._optionsService.rawOptions;return((D)=>(this._coreService.triggerDataEvent(`${g.C0.ESC}${D}${g.C0.ESC}\\`),!0))(b==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:b==='"p'?'P1$r61;1"p':b==="r"?`P1$r${L.scrollTop+1};${L.scrollBottom+1}r`:b==="m"?"P1$r0m":b===" q"?`P1$r${{block:2,underline:4,bar:6}[E.cursorStyle]-(E.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(b,x){this._dirtyRowTracker.markRangeDirty(b,x)}}t.InputHandler=j;let q=class{constructor(b){this._bufferService=b,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(b){b<this.start?this.start=b:b>this.end&&(this.end=b)}markRangeDirty(b,x){b>x&&(W=b,b=x,x=W),b<this.start&&(this.start=b),x>this.end&&(this.end=x)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(b){return 0<=b&&b<256}q=l([p(0,u.IBufferService)],q)},701:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isChromeOS=t.isLinux=t.isWindows=t.isIphone=t.isIpad=t.isMac=t.isSafari=t.isLegacyEdge=t.isFirefox=t.isNode=void 0,t.getSafariVersion=function(){if(!t.isSafari)return 0;let p=n.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},t.isNode=typeof process<"u"&&"title"in process;let n=t.isNode?"node":navigator.userAgent,l=t.isNode?"node":navigator.platform;t.isFirefox=n.includes("Firefox"),t.isLegacyEdge=n.includes("Edge"),t.isSafari=/^((?!chrome|android).)*safari/i.test(n),t.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(l),t.isIpad=l==="iPad",t.isIphone=l==="iPhone",t.isWindows=["Windows","Win16","Win32","WinCE"].includes(l),t.isLinux=l.indexOf("Linux")>=0,t.isChromeOS=/\bCrOS\b/.test(n)},6168:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DebouncedIdleTask=t.IdleTaskQueue=t.PriorityTaskQueue=void 0;let l=n(701);class p{constructor(){this._tasks=[],this._i=0}enqueue(d){this._tasks.push(d),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(d){this._idleCallback=void 0;let _=0,v=0,o=d.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(_=performance.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,performance.now()-_),v=Math.max(_,v),i=d.timeRemaining(),1.5*v>i)return o-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-_))}ms`),void this._start();o=i}this.clear()}}class g extends p{_requestCallback(d){return setTimeout(()=>d(this._createDeadline(16)))}_cancelCallback(d){clearTimeout(d)}_createDeadline(d){let _=performance.now()+d;return{timeRemaining:()=>Math.max(0,_-performance.now())}}}t.PriorityTaskQueue=g,t.IdleTaskQueue=!l.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(d){return requestIdleCallback(d)}_cancelCallback(d){cancelIdleCallback(d)}}:g,t.DebouncedIdleTask=class{constructor(){this._queue=new t.IdleTaskQueue}set(d){this._queue.clear(),this._queue.enqueue(d)}flush(){this._queue.flush()}}},5882:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateWindowsModeWrappedState=function(p){let g=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),d=g?.get(p.cols-1),_=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);_&&d&&(_.isWrapped=d[l.CHAR_DATA_CODE_INDEX]!==l.NULL_CELL_CODE&&d[l.CHAR_DATA_CODE_INDEX]!==l.WHITESPACE_CELL_CODE)};let l=n(8938)},5451:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtendedAttrs=t.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new l}static toColorRGB(p){return[p>>>16&255,p>>>8&255,255&p]}static fromColorRGB(p){return(255&p[0])<<16|(255&p[1])<<8|255&p[2]}clone(){let p=new n;return p.fg=this.fg,p.bg=this.bg,p.extended=this.extended.clone(),p}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?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(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return!(50331648&this.fg)}isBgDefault(){return!(50331648&this.bg)}isAttributeDefault(){return this.fg===0&&this.bg===0}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?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432: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}}t.AttributeData=n;class l{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(p){this._ext=p}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(p){this._ext&=-469762049,this._ext|=p<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(p){this._ext&=-67108864,this._ext|=67108863&p}get urlId(){return this._urlId}set urlId(p){this._urlId=p}get underlineVariantOffset(){let p=(3758096384&this._ext)>>29;return p<0?4294967288^p:p}set underlineVariantOffset(p){this._ext&=536870911,this._ext|=p<<29&3758096384}constructor(p=0,g=0){this._ext=0,this._urlId=0,this._ext=p,this._urlId=g}clone(){return new l(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}t.ExtendedAttrs=l},1073:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Buffer=t.MAX_BUFFER_SIZE=void 0;let l=n(5639),p=n(6168),g=n(5451),d=n(6107),_=n(732),v=n(3055),o=n(8938),i=n(8158),S=n(6760);t.MAX_BUFFER_SIZE=4294967295,t.Buffer=class{constructor(h,m,u){this._hasScrollback=h,this._optionsService=m,this._bufferService=u,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=d.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=v.CellData.fromCharData([0,o.NULL_CELL_CHAR,o.NULL_CELL_WIDTH,o.NULL_CELL_CODE]),this._whitespaceCell=v.CellData.fromCharData([0,o.WHITESPACE_CELL_CHAR,o.WHITESPACE_CELL_WIDTH,o.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(h){return h?(this._nullCell.fg=h.fg,this._nullCell.bg=h.bg,this._nullCell.extended=h.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new g.ExtendedAttrs),this._nullCell}getWhitespaceCell(h){return h?(this._whitespaceCell.fg=h.fg,this._whitespaceCell.bg=h.bg,this._whitespaceCell.extended=h.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new g.ExtendedAttrs),this._whitespaceCell}getBlankLine(h,m){return new d.BufferLine(this._bufferService.cols,this.getNullCell(h),m)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let h=this.ybase+this.y-this.ydisp;return h>=0&&h<this._rows}_getCorrectBufferLength(h){if(!this._hasScrollback)return h;let m=h+this._optionsService.rawOptions.scrollback;return m>t.MAX_BUFFER_SIZE?t.MAX_BUFFER_SIZE:m}fillViewportRows(h){if(this.lines.length===0){h===void 0&&(h=d.DEFAULT_ATTR_DATA);let m=this._rows;for(;m--;)this.lines.push(this.getBlankLine(h))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new l.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(h,m){let u=this.getNullCell(d.DEFAULT_ATTR_DATA),w=0,C=this._getCorrectBufferLength(m);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<h)for(let B=0;B<this.lines.length;B++)w+=+this.lines.get(B).resize(h,u);let T=0;if(this._rows<m)for(let B=this._rows;B<m;B++)this.lines.length<m+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new d.BufferLine(h,u)):this.ybase>0&&this.lines.length<=this.ybase+this.y+T+1?(this.ybase--,T++,this.ydisp>0&&this.ydisp--):this.lines.push(new d.BufferLine(h,u)));else for(let B=this._rows;B>m;B--)this.lines.length>m+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){let B=this.lines.length-C;B>0&&(this.lines.trimStart(B),this.ybase=Math.max(this.ybase-B,0),this.ydisp=Math.max(this.ydisp-B,0),this.savedY=Math.max(this.savedY-B,0)),this.lines.maxLength=C}this.x=Math.min(this.x,h-1),this.y=Math.min(this.y,m-1),T&&(this.y+=T),this.savedX=Math.min(this.savedX,h-1),this.scrollTop=0}if(this.scrollBottom=m-1,this._isReflowEnabled&&(this._reflow(h,m),this._cols>h))for(let T=0;T<this.lines.length;T++)w+=+this.lines.get(T).resize(h,u);this._cols=h,this._rows=m,this._memoryCleanupQueue.clear(),w>0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let h=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,h=!1);let m=0;for(;this._memoryCleanupPosition<this.lines.length;)if(m+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),m>100)return!0;return h}get _isReflowEnabled(){let h=this._optionsService.rawOptions.windowsPty;return h&&h.buildNumber?this._hasScrollback&&h.backend==="conpty"&&h.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(h,m){this._cols!==h&&(h>this._cols?this._reflowLarger(h,m):this._reflowSmaller(h,m))}_reflowLarger(h,m){let u=this._optionsService.rawOptions.reflowCursorLine,w=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,h,this.ybase+this.y,this.getNullCell(d.DEFAULT_ATTR_DATA),u);if(w.length>0){let C=(0,_.reflowLargerCreateNewLayout)(this.lines,w);(0,_.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(h,m,C.countRemoved)}}_reflowLargerAdjustViewport(h,m,u){let w=this.getNullCell(d.DEFAULT_ATTR_DATA),C=u;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<m&&this.lines.push(new d.BufferLine(h,w))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-u,0)}_reflowSmaller(h,m){let u=this._optionsService.rawOptions.reflowCursorLine,w=this.getNullCell(d.DEFAULT_ATTR_DATA),C=[],T=0;for(let B=this.lines.length-1;B>=0;B--){let O=this.lines.get(B);if(!O||!O.isWrapped&&O.getTrimmedLength()<=h)continue;let A=[O];for(;O.isWrapped&&B>0;)O=this.lines.get(--B),A.unshift(O);if(!u){let E=this.ybase+this.y;if(E>=B&&E<B+A.length)continue}let M=A[A.length-1].getTrimmedLength(),k=(0,_.reflowSmallerGetNewLineLengths)(A,this._cols,h),P=k.length-A.length,W;W=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);let j=[];for(let E=0;E<P;E++){let D=this.getBlankLine(d.DEFAULT_ATTR_DATA,!0);j.push(D)}j.length>0&&(C.push({start:B+A.length+T,newLines:j}),T+=j.length),A.push(...j);let q=k.length-1,F=k[q];F===0&&(q--,F=k[q]);let b=A.length-P-1,x=M;for(;b>=0;){let E=Math.min(x,F);if(A[q]===void 0)break;if(A[q].copyCellsFrom(A[b],x-E,F-E,E,!0),F-=E,F===0&&(q--,F=k[q]),x-=E,x===0){b--;let D=Math.max(b,0);x=(0,_.getWrappedLineTrimmedLength)(A,D,this._cols)}}for(let E=0;E<A.length;E++)k[E]<h&&A[E].setCell(k[E],w);let L=P-W;for(;L-- >0;)this.ybase===0?this.y<m-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-m&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+m-1)}if(C.length>0){let B=[],O=[];for(let F=0;F<this.lines.length;F++)O.push(this.lines.get(F));let A=this.lines.length,M=A-1,k=0,P=C[k];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let W=0;for(let F=Math.min(this.lines.maxLength-1,A+T-1);F>=0;F--)if(P&&P.start>M+W){for(let b=P.newLines.length-1;b>=0;b--)this.lines.set(F--,P.newLines[b]);F++,B.push({index:M+1,amount:P.newLines.length}),W+=P.newLines.length,P=C[++k]}else this.lines.set(F,O[M--]);let j=0;for(let F=B.length-1;F>=0;F--)B[F].index+=j,this.lines.onInsertEmitter.fire(B[F]),j+=B[F].amount;let q=Math.max(0,A+T-this.lines.maxLength);q>0&&this.lines.onTrimEmitter.fire(q)}}translateBufferLineToString(h,m,u=0,w){let C=this.lines.get(h);return C?C.translateToString(m,u,w):""}getWrappedRangeForLine(h){let m=h,u=h;for(;m>0&&this.lines.get(m).isWrapped;)m--;for(;u+1<this.lines.length&&this.lines.get(u+1).isWrapped;)u++;return{first:m,last:u}}setupTabStops(h){for(h!=null?this.tabs[h]||(h=this.prevStop(h)):(this.tabs={},h=0);h<this._cols;h+=this._optionsService.rawOptions.tabStopWidth)this.tabs[h]=!0}prevStop(h){for(h==null&&(h=this.x);!this.tabs[--h]&&h>0;);return h>=this._cols?this._cols-1:h<0?0:h}nextStop(h){for(h==null&&(h=this.x);!this.tabs[++h]&&h<this._cols;);return h>=this._cols?this._cols-1:h<0?0:h}clearMarkers(h){this._isClearing=!0;for(let m=0;m<this.markers.length;m++)this.markers[m].line===h&&(this.markers[m].dispose(),this.markers.splice(m--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].dispose();this.markers.length=0,this._isClearing=!1}addMarker(h){let m=new i.Marker(h);return this.markers.push(m),m.register(this.lines.onTrim((u)=>{m.line-=u,m.line<0&&m.dispose()})),m.register(this.lines.onInsert((u)=>{m.line>=u.index&&(m.line+=u.amount)})),m.register(this.lines.onDelete((u)=>{m.line>=u.index&&m.line<u.index+u.amount&&m.dispose(),m.line>u.index&&(m.line-=u.amount)})),m.register(m.onDispose(()=>this._removeMarker(m))),m}_removeMarker(h){this._isClearing||this.markers.splice(this.markers.indexOf(h),1)}}},6107:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLine=t.DEFAULT_ATTR_DATA=void 0;let l=n(5451),p=n(3055),g=n(8938),d=n(726);t.DEFAULT_ATTR_DATA=Object.freeze(new l.AttributeData);let _=0;class v{constructor(o,i,S=!1){this.isWrapped=S,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);let h=i||p.CellData.fromCharData([0,g.NULL_CELL_CHAR,g.NULL_CELL_WIDTH,g.NULL_CELL_CODE]);for(let m=0;m<o;++m)this.setCell(m,h);this.length=o}get(o){let i=this._data[3*o+0],S=2097151&i;return[this._data[3*o+1],2097152&i?this._combined[o]:S?(0,d.stringFromCodePoint)(S):"",i>>22,2097152&i?this._combined[o].charCodeAt(this._combined[o].length-1):S]}set(o,i){this._data[3*o+1]=i[g.CHAR_DATA_ATTR_INDEX],i[g.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=i[1],this._data[3*o+0]=2097152|o|i[g.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=i[g.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|i[g.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){let i=this._data[3*o+0];return 2097152&i?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&i}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){let i=this._data[3*o+0];return 2097152&i?this._combined[o]:2097151&i?(0,d.stringFromCodePoint)(2097151&i):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,i){return _=3*o,i.content=this._data[_+0],i.fg=this._data[_+1],i.bg=this._data[_+2],2097152&i.content&&(i.combinedData=this._combined[o]),268435456&i.bg&&(i.extended=this._extendedAttrs[o]),i}setCell(o,i){2097152&i.content&&(this._combined[o]=i.combinedData),268435456&i.bg&&(this._extendedAttrs[o]=i.extended),this._data[3*o+0]=i.content,this._data[3*o+1]=i.fg,this._data[3*o+2]=i.bg}setCellFromCodepoint(o,i,S,h){268435456&h.bg&&(this._extendedAttrs[o]=h.extended),this._data[3*o+0]=i|S<<22,this._data[3*o+1]=h.fg,this._data[3*o+2]=h.bg}addCodepointToCell(o,i,S){let h=this._data[3*o+0];2097152&h?this._combined[o]+=(0,d.stringFromCodePoint)(i):2097151&h?(this._combined[o]=(0,d.stringFromCodePoint)(2097151&h)+(0,d.stringFromCodePoint)(i),h&=-2097152,h|=2097152):h=i|4194304,S&&(h&=-12582913,h|=S<<22),this._data[3*o+0]=h}insertCells(o,i,S){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,S),i<this.length-o){let h=new p.CellData;for(let m=this.length-o-i-1;m>=0;--m)this.setCell(o+i+m,this.loadCell(o+m,h));for(let m=0;m<i;++m)this.setCell(o+m,S)}else for(let h=o;h<this.length;++h)this.setCell(h,S);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,S)}deleteCells(o,i,S){if(o%=this.length,i<this.length-o){let h=new p.CellData;for(let m=0;m<this.length-o-i;++m)this.setCell(o+m,this.loadCell(o+i+m,h));for(let m=this.length-i;m<this.length;++m)this.setCell(m,S)}else for(let h=o;h<this.length;++h)this.setCell(h,S);o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,S),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodepoint(o,0,1,S)}replaceCells(o,i,S,h=!1){if(h)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodepoint(o-1,0,1,S),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,S);o<i&&o<this.length;)this.isProtected(o)||this.setCell(o,S),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodepoint(o-1,0,1,S),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,S);o<i&&o<this.length;)this.setCell(o++,S)}resize(o,i){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let S=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*S)this._data=new Uint32Array(this._data.buffer,0,S);else{let h=new Uint32Array(S);h.set(this._data),this._data=h}for(let h=this.length;h<o;++h)this.setCell(h,i)}else{this._data=this._data.subarray(0,S);let h=Object.keys(this._combined);for(let u=0;u<h.length;u++){let w=parseInt(h[u],10);w>=o&&delete this._combined[w]}let m=Object.keys(this._extendedAttrs);for(let u=0;u<m.length;u++){let w=parseInt(m[u],10);w>=o&&delete this._extendedAttrs[w]}}return this.length=o,4*S*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,i=!1){if(i)for(let S=0;S<this.length;++S)this.isProtected(S)||this.setCell(S,o);else{this._combined={},this._extendedAttrs={};for(let S=0;S<this.length;++S)this.setCell(S,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(let i in o._combined)this._combined[i]=o._combined[i];this._extendedAttrs={};for(let i in o._extendedAttrs)this._extendedAttrs[i]=o._extendedAttrs[i];this.isWrapped=o.isWrapped}clone(){let o=new v(0);o._data=new Uint32Array(this._data),o.length=this.length;for(let i in this._combined)o._combined[i]=this._combined[i];for(let i in this._extendedAttrs)o._extendedAttrs[i]=this._extendedAttrs[i];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,i,S,h,m){let u=o._data;if(m)for(let C=h-1;C>=0;C--){for(let T=0;T<3;T++)this._data[3*(S+C)+T]=u[3*(i+C)+T];268435456&u[3*(i+C)+2]&&(this._extendedAttrs[S+C]=o._extendedAttrs[i+C])}else for(let C=0;C<h;C++){for(let T=0;T<3;T++)this._data[3*(S+C)+T]=u[3*(i+C)+T];268435456&u[3*(i+C)+2]&&(this._extendedAttrs[S+C]=o._extendedAttrs[i+C])}let w=Object.keys(o._combined);for(let C=0;C<w.length;C++){let T=parseInt(w[C],10);T>=i&&(this._combined[T-i+S]=o._combined[T])}}translateToString(o,i,S,h){i=i??0,S=S??this.length,o&&(S=Math.min(S,this.getTrimmedLength())),h&&(h.length=0);let m="";for(;i<S;){let u=this._data[3*i+0],w=2097151&u,C=2097152&u?this._combined[i]:w?(0,d.stringFromCodePoint)(w):g.WHITESPACE_CELL_CHAR;if(m+=C,h)for(let T=0;T<C.length;++T)h.push(i);i+=u>>22||1}return h&&h.push(i),m}}t.BufferLine=v},732:(y,t)=>{function n(l,p,g){if(p===l.length-1)return l[p].getTrimmedLength();let d=!l[p].hasContent(g-1)&&l[p].getWidth(g-1)===1,_=l[p+1].getWidth(0)===2;return d&&_?g-1:g}Object.defineProperty(t,"__esModule",{value:!0}),t.reflowLargerGetLinesToRemove=function(l,p,g,d,_,v){let o=[];for(let i=0;i<l.length-1;i++){let S=i,h=l.get(++S);if(!h.isWrapped)continue;let m=[l.get(i)];for(;S<l.length&&h.isWrapped;)m.push(h),h=l.get(++S);if(!v&&d>=i&&d<S){i+=m.length-1;continue}let u=0,w=n(m,u,p),C=1,T=0;for(;C<m.length;){let O=n(m,C,p),A=O-T,M=g-w,k=Math.min(A,M);m[u].copyCellsFrom(m[C],T,w,k,!1),w+=k,w===g&&(u++,w=0),T+=k,T===O&&(C++,T=0),w===0&&u!==0&&m[u-1].getWidth(g-1)===2&&(m[u].copyCellsFrom(m[u-1],g-1,w++,1,!1),m[u-1].setCell(g-1,_))}m[u].replaceCells(w,g,_);let B=0;for(let O=m.length-1;O>0&&(O>u||m[O].getTrimmedLength()===0);O--)B++;B>0&&(o.push(i+m.length-B),o.push(B)),i+=m.length-1}return o},t.reflowLargerCreateNewLayout=function(l,p){let g=[],d=0,_=p[d],v=0;for(let o=0;o<l.length;o++)if(_===o){let i=p[++d];l.onDeleteEmitter.fire({index:o-v,amount:i}),o+=i-1,v+=i,_=p[++d]}else g.push(o);return{layout:g,countRemoved:v}},t.reflowLargerApplyNewLayout=function(l,p){let g=[];for(let d=0;d<p.length;d++)g.push(l.get(p[d]));for(let d=0;d<g.length;d++)l.set(d,g[d]);l.length=p.length},t.reflowSmallerGetNewLineLengths=function(l,p,g){let d=[],_=l.map((S,h)=>n(l,h,p)).reduce((S,h)=>S+h),v=0,o=0,i=0;for(;i<_;){if(_-i<g){d.push(_-i);break}v+=g;let S=n(l,o,p);v>S&&(v-=S,o++);let h=l[o].getWidth(v-1)===2;h&&v--;let m=h?g-1:g;d.push(m),i+=m}return d},t.getWrappedLineTrimmedLength=n},4097:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferSet=void 0;let l=n(7150),p=n(1073),g=n(802);class d extends l.Disposable{constructor(_,v){super(),this._optionsService=_,this._bufferService=v,this._onBufferActivate=this._register(new g.Emitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new p.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new p.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(_,v){this._normal.resize(_,v),this._alt.resize(_,v),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}t.BufferSet=d},3055:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CellData=void 0;let l=n(726),p=n(8938),g=n(5451);class d extends g.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new g.ExtendedAttrs,this.combinedData=""}static fromCharData(_){let v=new d;return v.setFromCharData(_),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,l.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(_[p.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(_[p.CHAR_DATA_CHAR_INDEX].length===2){let o=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){let i=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=i&&i<=57343?this.content=1024*(o-55296)+i-56320+65536|_[p.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=_[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[p.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=_[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.CellData=d},8938:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WHITESPACE_CELL_CODE=t.WHITESPACE_CELL_WIDTH=t.WHITESPACE_CELL_CHAR=t.NULL_CELL_CODE=t.NULL_CELL_WIDTH=t.NULL_CELL_CHAR=t.CHAR_DATA_CODE_INDEX=t.CHAR_DATA_WIDTH_INDEX=t.CHAR_DATA_CHAR_INDEX=t.CHAR_DATA_ATTR_INDEX=t.DEFAULT_EXT=t.DEFAULT_ATTR=t.DEFAULT_COLOR=void 0,t.DEFAULT_COLOR=0,t.DEFAULT_ATTR=t.DEFAULT_COLOR<<9|256,t.DEFAULT_EXT=0,t.CHAR_DATA_ATTR_INDEX=0,t.CHAR_DATA_CHAR_INDEX=1,t.CHAR_DATA_WIDTH_INDEX=2,t.CHAR_DATA_CODE_INDEX=3,t.NULL_CELL_CHAR="",t.NULL_CELL_WIDTH=1,t.NULL_CELL_CODE=0,t.WHITESPACE_CELL_CHAR=" ",t.WHITESPACE_CELL_WIDTH=1,t.WHITESPACE_CELL_CODE=32},8158:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Marker=void 0;let l=n(802),p=n(7150);class g{get id(){return this._id}constructor(d){this.line=d,this.isDisposed=!1,this._disposables=[],this._id=g._nextId++,this._onDispose=this.register(new l.Emitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.dispose)(this._disposables),this._disposables.length=0)}register(d){return this._disposables.push(d),d}}t.Marker=g,g._nextId=1},6760:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CHARSET=t.CHARSETS=void 0,t.CHARSETS={},t.DEFAULT_CHARSET=t.CHARSETS.B,t.CHARSETS[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"},t.CHARSETS.A={"#":"\xA3"},t.CHARSETS.B=void 0,t.CHARSETS[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"},t.CHARSETS.C=t.CHARSETS[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t.CHARSETS.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"},t.CHARSETS.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"},t.CHARSETS.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"},t.CHARSETS.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"},t.CHARSETS.E=t.CHARSETS[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"},t.CHARSETS.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"},t.CHARSETS.H=t.CHARSETS[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"},t.CHARSETS["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"}},3534:(y,t)=>{var n,l,p;Object.defineProperty(t,"__esModule",{value:!0}),t.C1_ESCAPED=t.C1=t.C0=void 0,function(g){g.NUL="\x00",g.SOH="\x01",g.STX="\x02",g.ETX="\x03",g.EOT="\x04",g.ENQ="\x05",g.ACK="\x06",g.BEL="\x07",g.BS="\b",g.HT="\t",g.LF=`
4
+ `,g.VT="\v",g.FF="\f",g.CR="\r",g.SO="\x0E",g.SI="\x0F",g.DLE="\x10",g.DC1="\x11",g.DC2="\x12",g.DC3="\x13",g.DC4="\x14",g.NAK="\x15",g.SYN="\x16",g.ETB="\x17",g.CAN="\x18",g.EM="\x19",g.SUB="\x1A",g.ESC="\x1B",g.FS="\x1C",g.GS="\x1D",g.RS="\x1E",g.US="\x1F",g.SP=" ",g.DEL="\x7F"}(n||(t.C0=n={})),function(g){g.PAD="\x80",g.HOP="\x81",g.BPH="\x82",g.NBH="\x83",g.IND="\x84",g.NEL="\x85",g.SSA="\x86",g.ESA="\x87",g.HTS="\x88",g.HTJ="\x89",g.VTS="\x8A",g.PLD="\x8B",g.PLU="\x8C",g.RI="\x8D",g.SS2="\x8E",g.SS3="\x8F",g.DCS="\x90",g.PU1="\x91",g.PU2="\x92",g.STS="\x93",g.CCH="\x94",g.MW="\x95",g.SPA="\x96",g.EPA="\x97",g.SOS="\x98",g.SGCI="\x99",g.SCI="\x9A",g.CSI="\x9B",g.ST="\x9C",g.OSC="\x9D",g.PM="\x9E",g.APC="\x9F"}(l||(t.C1=l={})),function(g){g.ST=`${n.ESC}\\`}(p||(t.C1_ESCAPED=p={}))},726:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Utf8ToUtf32=t.StringToUtf32=void 0,t.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},t.utf32ToString=function(n,l=0,p=n.length){let g="";for(let d=l;d<p;++d){let _=n[d];_>65535?(_-=65536,g+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):g+=String.fromCharCode(_)}return g},t.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,l){let p=n.length;if(!p)return 0;let g=0,d=0;if(this._interim){let _=n.charCodeAt(d++);56320<=_&&_<=57343?l[g++]=1024*(this._interim-55296)+_-56320+65536:(l[g++]=this._interim,l[g++]=_),this._interim=0}for(let _=d;_<p;++_){let v=n.charCodeAt(_);if(55296<=v&&v<=56319){if(++_>=p)return this._interim=v,g;let o=n.charCodeAt(_);56320<=o&&o<=57343?l[g++]=1024*(v-55296)+o-56320+65536:(l[g++]=v,l[g++]=o)}else v!==65279&&(l[g++]=v)}return g}},t.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,l){let p=n.length;if(!p)return 0;let g,d,_,v,o=0,i=0,S=0;if(this.interim[0]){let u=!1,w=this.interim[0];w&=(224&w)==192?31:(240&w)==224?15:7;let C,T=0;for(;(C=63&this.interim[++T])&&T<4;)w<<=6,w|=C;let B=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=B-T;for(;S<O;){if(S>=p)return 0;if(C=n[S++],(192&C)!=128){S--,u=!0;break}this.interim[T++]=C,w<<=6,w|=63&C}u||(B===2?w<128?S--:l[o++]=w:B===3?w<2048||w>=55296&&w<=57343||w===65279||(l[o++]=w):w<65536||w>1114111||(l[o++]=w)),this.interim.fill(0)}let h=p-4,m=S;for(;m<p;){for(;!(!(m<h)||128&(g=n[m])||128&(d=n[m+1])||128&(_=n[m+2])||128&(v=n[m+3]));)l[o++]=g,l[o++]=d,l[o++]=_,l[o++]=v,m+=4;if(g=n[m++],g<128)l[o++]=g;else if((224&g)==192){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(i=(31&g)<<6|63&d,i<128){m--;continue}l[o++]=i}else if((240&g)==224){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,o;if(_=n[m++],(192&_)!=128){m--;continue}if(i=(15&g)<<12|(63&d)<<6|63&_,i<2048||i>=55296&&i<=57343||i===65279)continue;l[o++]=i}else if((248&g)==240){if(m>=p)return this.interim[0]=g,o;if(d=n[m++],(192&d)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,o;if(_=n[m++],(192&_)!=128){m--;continue}if(m>=p)return this.interim[0]=g,this.interim[1]=d,this.interim[2]=_,o;if(v=n[m++],(192&v)!=128){m--;continue}if(i=(7&g)<<18|(63&d)<<12|(63&_)<<6|63&v,i<65536||i>1114111)continue;l[o++]=i}}return o}}},7428:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeV6=void 0;let l=n(6415),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],g=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],d;t.UnicodeV6=class{constructor(){if(this.version="6",!d){d=new Uint8Array(65536),d.fill(1),d[0]=0,d.fill(0,1,32),d.fill(0,127,160),d.fill(2,4352,4448),d[9001]=2,d[9002]=2,d.fill(2,11904,42192),d[12351]=1,d.fill(2,44032,55204),d.fill(2,63744,64256),d.fill(2,65040,65050),d.fill(2,65072,65136),d.fill(2,65280,65377),d.fill(2,65504,65511);for(let _=0;_<p.length;++_)d.fill(0,p[_][0],p[_][1]+1)}}wcwidth(_){return _<32?0:_<127?1:_<65536?d[_]:function(v,o){let i,S=0,h=o.length-1;if(v<o[0][0]||v>o[h][1])return!1;for(;h>=S;)if(i=S+h>>1,v>o[i][1])S=i+1;else{if(!(v<o[i][0]))return!0;h=i-1}return!1}(_,g)?0:_>=131072&&_<=196605||_>=196608&&_<=262141?2:1}charProperties(_,v){let o=this.wcwidth(_),i=o===0&&v!==0;if(i){let S=l.UnicodeService.extractWidth(v);S===0?i=!1:S>o&&(o=S)}return l.UnicodeService.createPropertyValue(0,o,i)}}},3562:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WriteBuffer=void 0;let l=n(7150),p=n(802);class g extends l.Disposable{constructor(d){super(),this._action=d,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new p.Emitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(d,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let v;for(this._isSyncWriting=!0;v=this._writeBuffer.shift();){this._action(v);let o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(d,_){if(this._pendingData>50000000)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(_),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=d.length,this._writeBuffer.push(d),this._callbacks.push(_)}_innerWrite(d=0,_=!0){let v=d||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let o=this._writeBuffer[this._bufferOffset],i=this._action(o,_);if(i){let h=(m)=>performance.now()-v>=12?setTimeout(()=>this._innerWrite(0,m)):this._innerWrite(v,m);return void i.catch((m)=>(queueMicrotask(()=>{throw m}),Promise.resolve(!1))).then(h)}let S=this._callbacks[this._bufferOffset];if(S&&S(),this._bufferOffset++,this._pendingData-=o.length,performance.now()-v>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}t.WriteBuffer=g},8693:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseColor=function(g){if(!g)return;let d=g.toLowerCase();if(d.indexOf("rgb:")===0){d=d.slice(4);let _=n.exec(d);if(_){let v=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/v*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/v*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/v*255)]}}else if(d.indexOf("#")===0&&(d=d.slice(1),l.exec(d)&&[3,6,9,12].includes(d.length))){let _=d.length/3,v=[0,0,0];for(let o=0;o<3;++o){let i=parseInt(d.slice(_*o,_*o+_),16);v[o]=_===1?i<<4:_===2?i:_===3?i>>4:i>>8}return v}},t.toRgbString=function(g,d=16){let[_,v,o]=g;return`rgb:${p(_,d)}/${p(v,d)}/${p(o,d)}`};let n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,l=/^[\da-f]+$/;function p(g,d){let _=g.toString(16),v=_.length<2?"0"+_:_;switch(d){case 4:return _[0];case 8:return v;case 12:return(v+v).slice(0,3);default:return v+v}}},1263:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PAYLOAD_LIMIT=void 0,t.PAYLOAD_LIMIT=1e7},9823:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DcsHandler=t.DcsParser=void 0;let l=n(726),p=n(7262),g=n(1263),d=[];t.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=d,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}registerHandler(v,o){this._handlers[v]===void 0&&(this._handlers[v]=[]);let i=this._handlers[v];return i.push(o),{dispose:()=>{let S=i.indexOf(o);S!==-1&&i.splice(S,1)}}}clearHandler(v){this._handlers[v]&&delete this._handlers[v]}setHandlerFallback(v){this._handlerFb=v}reset(){if(this._active.length)for(let v=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;v>=0;--v)this._active[v].unhook(!1);this._stack.paused=!1,this._active=d,this._ident=0}hook(v,o){if(this.reset(),this._ident=v,this._active=this._handlers[v]||d,this._active.length)for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(o);else this._handlerFb(this._ident,"HOOK",o)}put(v,o,i){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(v,o,i);else this._handlerFb(this._ident,"PUT",(0,l.utf32ToString)(v,o,i))}unhook(v,o=!0){if(this._active.length){let i=!1,S=this._active.length-1,h=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,i=o,h=this._stack.fallThrough,this._stack.paused=!1),!h&&i===!1){for(;S>=0&&(i=this._active[S].unhook(v),i!==!0);S--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,i;S--}for(;S>=0;S--)if(i=this._active[S].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,i}else this._handlerFb(this._ident,"UNHOOK",v);this._active=d,this._ident=0}};let _=new p.Params;_.addParam(0),t.DcsHandler=class{constructor(v){this._handler=v,this._data="",this._params=_,this._hitLimit=!1}hook(v){this._params=v.length>1||v.params[0]?v.clone():_,this._data="",this._hitLimit=!1}put(v,o,i){this._hitLimit||(this._data+=(0,l.utf32ToString)(v,o,i),this._data.length>g.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(v){let o=!1;if(this._hitLimit)o=!1;else if(v&&(o=this._handler(this._data,this._params),o instanceof Promise))return o.then((i)=>(this._params=_,this._data="",this._hitLimit=!1,i));return this._params=_,this._data="",this._hitLimit=!1,o}}},6717:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EscapeSequenceParser=t.VT500_TRANSITION_TABLE=t.TransitionTable=void 0;let l=n(7150),p=n(7262),g=n(1346),d=n(9823);class _{constructor(i){this.table=new Uint8Array(i)}setDefault(i,S){this.table.fill(i<<4|S)}add(i,S,h,m){this.table[S<<8|i]=h<<4|m}addMany(i,S,h,m){for(let u=0;u<i.length;u++)this.table[S<<8|i[u]]=h<<4|m}}t.TransitionTable=_;let v=160;t.VT500_TRANSITION_TABLE=function(){let i=new _(4095),S=Array.apply(null,Array(256)).map((T,B)=>B),h=(T,B)=>S.slice(T,B),m=h(32,127),u=h(0,24);u.push(25),u.push.apply(u,h(28,32));let w=h(0,14),C;for(C in i.setDefault(1,0),i.addMany(m,0,2,0),w)i.addMany([24,26,153,154],C,3,0),i.addMany(h(128,144),C,3,0),i.addMany(h(144,152),C,3,0),i.add(156,C,0,0),i.add(27,C,11,1),i.add(157,C,4,8),i.addMany([152,158,159],C,0,7),i.add(155,C,11,3),i.add(144,C,11,9);return i.addMany(u,0,3,0),i.addMany(u,1,3,1),i.add(127,1,0,1),i.addMany(u,8,0,8),i.addMany(u,3,3,3),i.add(127,3,0,3),i.addMany(u,4,3,4),i.add(127,4,0,4),i.addMany(u,6,3,6),i.addMany(u,5,3,5),i.add(127,5,0,5),i.addMany(u,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(m,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(h(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(m,7,0,7),i.addMany(u,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(h(64,127),3,7,0),i.addMany(h(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(h(48,60),4,8,4),i.addMany(h(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(h(32,64),6,0,6),i.add(127,6,0,6),i.addMany(h(64,127),6,0,0),i.addMany(h(32,48),3,9,5),i.addMany(h(32,48),5,9,5),i.addMany(h(48,64),5,0,6),i.addMany(h(64,127),5,7,0),i.addMany(h(32,48),4,9,5),i.addMany(h(32,48),1,9,2),i.addMany(h(32,48),2,9,2),i.addMany(h(48,127),2,10,0),i.addMany(h(48,80),1,10,0),i.addMany(h(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(h(96,127),1,10,0),i.add(80,1,11,9),i.addMany(u,9,0,9),i.add(127,9,0,9),i.addMany(h(28,32),9,0,9),i.addMany(h(32,48),9,9,12),i.addMany(h(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(u,11,0,11),i.addMany(h(32,128),11,0,11),i.addMany(h(28,32),11,0,11),i.addMany(u,10,0,10),i.add(127,10,0,10),i.addMany(h(28,32),10,0,10),i.addMany(h(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(h(32,48),10,9,12),i.addMany(u,12,0,12),i.add(127,12,0,12),i.addMany(h(28,32),12,0,12),i.addMany(h(32,48),12,9,12),i.addMany(h(48,64),12,0,11),i.addMany(h(64,127),12,12,13),i.addMany(h(64,127),10,12,13),i.addMany(h(64,127),9,12,13),i.addMany(u,13,13,13),i.addMany(m,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(v,0,2,0),i.add(v,8,5,8),i.add(v,6,0,6),i.add(v,11,0,11),i.add(v,13,13,13),i}();class o extends l.Disposable{constructor(i=t.VT500_TRANSITION_TABLE){super(),this._transitions=i,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(S,h,m)=>{},this._executeHandlerFb=(S)=>{},this._csiHandlerFb=(S,h)=>{},this._escHandlerFb=(S)=>{},this._errorHandlerFb=(S)=>S,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register((0,l.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new g.OscParser),this._dcsParser=this._register(new d.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(i,S=[64,126]){let h=0;if(i.prefix){if(i.prefix.length>1)throw Error("only one byte as prefix supported");if(h=i.prefix.charCodeAt(0),h&&60>h||h>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(i.intermediates){if(i.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let u=0;u<i.intermediates.length;++u){let w=i.intermediates.charCodeAt(u);if(32>w||w>47)throw Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=w}}if(i.final.length!==1)throw Error("final must be a single byte");let m=i.final.charCodeAt(0);if(S[0]>m||m>S[1])throw Error(`final must be in range ${S[0]} .. ${S[1]}`);return h<<=8,h|=m,h}identToString(i){let S=[];for(;i;)S.push(String.fromCharCode(255&i)),i>>=8;return S.reverse().join("")}setPrintHandler(i){this._printHandler=i}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(i,S){let h=this._identifier(i,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);let m=this._escHandlers[h];return m.push(S),{dispose:()=>{let u=m.indexOf(S);u!==-1&&m.splice(u,1)}}}clearEscHandler(i){this._escHandlers[this._identifier(i,[48,126])]&&delete this._escHandlers[this._identifier(i,[48,126])]}setEscHandlerFallback(i){this._escHandlerFb=i}setExecuteHandler(i,S){this._executeHandlers[i.charCodeAt(0)]=S}clearExecuteHandler(i){this._executeHandlers[i.charCodeAt(0)]&&delete this._executeHandlers[i.charCodeAt(0)]}setExecuteHandlerFallback(i){this._executeHandlerFb=i}registerCsiHandler(i,S){let h=this._identifier(i);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);let m=this._csiHandlers[h];return m.push(S),{dispose:()=>{let u=m.indexOf(S);u!==-1&&m.splice(u,1)}}}clearCsiHandler(i){this._csiHandlers[this._identifier(i)]&&delete this._csiHandlers[this._identifier(i)]}setCsiHandlerFallback(i){this._csiHandlerFb=i}registerDcsHandler(i,S){return this._dcsParser.registerHandler(this._identifier(i),S)}clearDcsHandler(i){this._dcsParser.clearHandler(this._identifier(i))}setDcsHandlerFallback(i){this._dcsParser.setHandlerFallback(i)}registerOscHandler(i,S){return this._oscParser.registerHandler(i,S)}clearOscHandler(i){this._oscParser.clearHandler(i)}setOscHandlerFallback(i){this._oscParser.setHandlerFallback(i)}setErrorHandler(i){this._errorHandler=i}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(i,S,h,m,u){this._parseStack.state=i,this._parseStack.handlers=S,this._parseStack.handlerPos=h,this._parseStack.transition=m,this._parseStack.chunkPos=u}parse(i,S,h){let m,u=0,w=0,C=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,C=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let T=this._parseStack.handlers,B=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&B>-1){for(;B>=0&&(m=T[B](this._params),m!==!0);B--)if(m instanceof Promise)return this._parseStack.handlerPos=B,m}this._parseStack.handlers=[];break;case 4:if(h===!1&&B>-1){for(;B>=0&&(m=T[B](),m!==!0);B--)if(m instanceof Promise)return this._parseStack.handlerPos=B,m}this._parseStack.handlers=[];break;case 6:if(u=i[this._parseStack.chunkPos],m=this._dcsParser.unhook(u!==24&&u!==26,h),m)return m;u===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(u=i[this._parseStack.chunkPos],m=this._oscParser.end(u!==24&&u!==26,h),m)return m;u===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,C=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let T=C;T<S;++T){switch(u=i[T],w=this._transitions.table[this.currentState<<8|(u<160?u:v)],w>>4){case 2:for(let k=T+1;;++k){if(k>=S||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=S||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=S||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}if(++k>=S||(u=i[k])<32||u>126&&u<v){this._printHandler(i,T,k),T=k-1;break}}break;case 3:this._executeHandlers[u]?this._executeHandlers[u]():this._executeHandlerFb(u),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:T,code:u,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let B=this._csiHandlers[this._collect<<8|u],O=B?B.length-1:-1;for(;O>=0&&(m=B[O](this._params),m!==!0);O--)if(m instanceof Promise)return this._preserveStack(3,B,O,w,T),m;O<0&&this._csiHandlerFb(this._collect<<8|u,this._params),this.precedingJoinState=0;break;case 8:do switch(u){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(u-48)}while(++T<S&&(u=i[T])>47&&u<60);T--;break;case 9:this._collect<<=8,this._collect|=u;break;case 10:let A=this._escHandlers[this._collect<<8|u],M=A?A.length-1:-1;for(;M>=0&&(m=A[M](),m!==!0);M--)if(m instanceof Promise)return this._preserveStack(4,A,M,w,T),m;M<0&&this._escHandlerFb(this._collect<<8|u),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|u,this._params);break;case 13:for(let k=T+1;;++k)if(k>=S||(u=i[k])===24||u===26||u===27||u>127&&u<v){this._dcsParser.put(i,T,k),T=k-1;break}break;case 14:if(m=this._dcsParser.unhook(u!==24&&u!==26),m)return this._preserveStack(6,[],0,w,T),m;u===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let k=T+1;;k++)if(k>=S||(u=i[k])<32||u>127&&u<v){this._oscParser.put(i,T,k),T=k-1;break}break;case 6:if(m=this._oscParser.end(u!==24&&u!==26),m)return this._preserveStack(5,[],0,w,T),m;u===27&&(w|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&w}}}t.EscapeSequenceParser=o},1346:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OscHandler=t.OscParser=void 0;let l=n(1263),p=n(726),g=[];t.OscParser=class{constructor(){this._state=0,this._active=g,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(d,_){this._handlers[d]===void 0&&(this._handlers[d]=[]);let v=this._handlers[d];return v.push(_),{dispose:()=>{let o=v.indexOf(_);o!==-1&&v.splice(o,1)}}}clearHandler(d){this._handlers[d]&&delete this._handlers[d]}setHandlerFallback(d){this._handlerFb=d}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}reset(){if(this._state===2)for(let d=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;d>=0;--d)this._active[d].end(!1);this._stack.paused=!1,this._active=g,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||g,this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].start();else this._handlerFb(this._id,"START")}_put(d,_,v){if(this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].put(d,_,v);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(d,_,v))}start(){this.reset(),this._state=1}put(d,_,v){if(this._state!==3){if(this._state===1)for(;_<v;){let o=d[_++];if(o===59){this._state=2,this._start();break}if(o<48||57<o)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+o-48}this._state===2&&v-_>0&&this._put(d,_,v)}}end(d,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let v=!1,o=this._active.length-1,i=!1;if(this._stack.paused&&(o=this._stack.loopPosition-1,v=_,i=this._stack.fallThrough,this._stack.paused=!1),!i&&v===!1){for(;o>=0&&(v=this._active[o].end(d),v!==!0);o--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!1,v;o--}for(;o>=0;o--)if(v=this._active[o].end(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!0,v}else this._handlerFb(this._id,"END",d);this._active=g,this._id=-1,this._state=0}}},t.OscHandler=class{constructor(d){this._handler=d,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(d,_,v){this._hitLimit||(this._data+=(0,p.utf32ToString)(d,_,v),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(d){let _=!1;if(this._hitLimit)_=!1;else if(d&&(_=this._handler(this._data),_ instanceof Promise))return _.then((v)=>(this._data="",this._hitLimit=!1,v));return this._data="",this._hitLimit=!1,_}}},7262:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Params=void 0;let n=2147483647;class l{static fromArray(p){let g=new l;if(!p.length)return g;for(let d=Array.isArray(p[0])?1:0;d<p.length;++d){let _=p[d];if(Array.isArray(_))for(let v=0;v<_.length;++v)g.addSubParam(_[v]);else g.addParam(_)}return g}constructor(p=32,g=32){if(this.maxLength=p,this.maxSubParamsLength=g,g>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(p),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(p),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){let p=new l(this.maxLength,this.maxSubParamsLength);return p.params.set(this.params),p.length=this.length,p._subParams.set(this._subParams),p._subParamsLength=this._subParamsLength,p._subParamsIdx.set(this._subParamsIdx),p._rejectDigits=this._rejectDigits,p._rejectSubDigits=this._rejectSubDigits,p._digitIsSub=this._digitIsSub,p}toArray(){let p=[];for(let g=0;g<this.length;++g){p.push(this.params[g]);let d=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-d>0&&p.push(Array.prototype.slice.call(this._subParams,d,_))}return p}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(p){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(p<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=p>n?n:p}}addSubParam(p){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(p<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=p>n?n:p,this._subParamsIdx[this.length-1]++}}hasSubParams(p){return(255&this._subParamsIdx[p])-(this._subParamsIdx[p]>>8)>0}getSubParams(p){let g=this._subParamsIdx[p]>>8,d=255&this._subParamsIdx[p];return d-g>0?this._subParams.subarray(g,d):null}getSubParamsAll(){let p={};for(let g=0;g<this.length;++g){let d=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-d>0&&(p[g]=this._subParams.slice(d,_))}return p}addDigit(p){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let d=this._digitIsSub?this._subParams:this.params,_=d[g-1];d[g-1]=~_?Math.min(10*_+p,n):p}}t.Params=l},3027:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AddonManager=void 0,t.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,l){let p={instance:l,dispose:l.dispose,isDisposed:!1};this._addons.push(p),l.dispose=()=>this._wrappedAddonDispose(p),l.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let l=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===n){l=p;break}if(l===-1)throw Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(l,1)}}},3235:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferApiView=void 0;let l=n(793),p=n(3055);t.BufferApiView=class{constructor(g,d){this._buffer=g,this.type=d}init(g){return this._buffer=g,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(g){let d=this._buffer.lines.get(g);if(d)return new l.BufferLineApiView(d)}getNullCell(){return new p.CellData}}},793:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferLineApiView=void 0;let l=n(3055);t.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,g){if(!(p<0||p>=this._line.length))return g?(this._line.loadCell(p,g),g):this._line.loadCell(p,new l.CellData)}translateToString(p,g,d){return this._line.translateToString(p,g,d)}}},5101:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferNamespaceApi=void 0;let l=n(3235),p=n(7150),g=n(802);class d extends p.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this._register(new g.Emitter),this.onBufferChange=this._onBufferChange.event,this._normal=new l.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new l.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}t.BufferNamespaceApi=d},6097:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ParserApi=void 0,t.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,l){return this._core.registerCsiHandler(n,(p)=>l(p.toArray()))}addCsiHandler(n,l){return this.registerCsiHandler(n,l)}registerDcsHandler(n,l){return this._core.registerDcsHandler(n,(p,g)=>l(p,g.toArray()))}addDcsHandler(n,l){return this.registerDcsHandler(n,l)}registerEscHandler(n,l){return this._core.registerEscHandler(n,l)}addEscHandler(n,l){return this.registerEscHandler(n,l)}registerOscHandler(n,l){return this._core.registerOscHandler(n,l)}addOscHandler(n,l){return this.registerOscHandler(n,l)}}},4335:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeApi=void 0,t.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},9640:function(y,t,n){var l=this&&this.__decorate||function(i,S,h,m){var u,w=arguments.length,C=w<3?S:m===null?m=Object.getOwnPropertyDescriptor(S,h):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,S,h,m);else for(var T=i.length-1;T>=0;T--)(u=i[T])&&(C=(w<3?u(C):w>3?u(S,h,C):u(S,h))||C);return w>3&&C&&Object.defineProperty(S,h,C),C},p=this&&this.__param||function(i,S){return function(h,m){S(h,m,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferService=t.MINIMUM_ROWS=t.MINIMUM_COLS=void 0;let g=n(7150),d=n(4097),_=n(6501),v=n(802);t.MINIMUM_COLS=2,t.MINIMUM_ROWS=1;let o=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(i){super(),this.isUserScrolling=!1,this._onResize=this._register(new v.Emitter),this.onResize=this._onResize.event,this._onScroll=this._register(new v.Emitter),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,t.MINIMUM_COLS),this.rows=Math.max(i.rawOptions.rows||0,t.MINIMUM_ROWS),this.buffers=this._register(new d.BufferSet(i,this)),this._register(this.buffers.onBufferActivate((S)=>{this._onScroll.fire(S.activeBuffer.ydisp)}))}resize(i,S){let h=this.cols!==i,m=this.rows!==S;this.cols=i,this.rows=S,this.buffers.resize(i,S),this._onResize.fire({cols:i,rows:S,colsChanged:h,rowsChanged:m})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,S=!1){let h=this.buffer,m;m=this._cachedBlankLine,m&&m.length===this.cols&&m.getFg(0)===i.fg&&m.getBg(0)===i.bg||(m=h.getBlankLine(i,S),this._cachedBlankLine=m),m.isWrapped=S;let u=h.ybase+h.scrollTop,w=h.ybase+h.scrollBottom;if(h.scrollTop===0){let C=h.lines.isFull;w===h.lines.length-1?C?h.lines.recycle().copyFrom(m):h.lines.push(m.clone()):h.lines.splice(w+1,0,m.clone()),C?this.isUserScrolling&&(h.ydisp=Math.max(h.ydisp-1,0)):(h.ybase++,this.isUserScrolling||h.ydisp++)}else{let C=w-u+1;h.lines.shiftElements(u+1,C-1,-1),h.lines.set(w,m.clone())}this.isUserScrolling||(h.ydisp=h.ybase),this._onScroll.fire(h.ydisp)}scrollLines(i,S){let h=this.buffer;if(i<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else i+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);let m=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+i,h.ybase),0),m!==h.ydisp&&(S||this._onScroll.fire(h.ydisp))}};t.BufferService=o,t.BufferService=o=l([p(0,_.IOptionsService)],o)},5746:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharsetService=void 0,t.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,l){this._charsets[n]=l,this.glevel===n&&(this.charset=l)}}},7792:function(y,t,n){var l=this&&this.__decorate||function(m,u,w,C){var T,B=arguments.length,O=B<3?u:C===null?C=Object.getOwnPropertyDescriptor(u,w):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(m,u,w,C);else for(var A=m.length-1;A>=0;A--)(T=m[A])&&(O=(B<3?T(O):B>3?T(u,w,O):T(u,w))||O);return B>3&&O&&Object.defineProperty(u,w,O),O},p=this&&this.__param||function(m,u){return function(w,C){u(w,C,m)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreMouseService=void 0;let g=n(6501),d=n(7150),_=n(802),v={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:(m)=>m.button!==4&&m.action===1&&(m.ctrl=!1,m.alt=!1,m.shift=!1,!0)},VT200:{events:19,restrict:(m)=>m.action!==32},DRAG:{events:23,restrict:(m)=>m.action!==32||m.button!==3},ANY:{events:31,restrict:(m)=>!0}};function o(m,u){let w=(m.ctrl?16:0)|(m.shift?4:0)|(m.alt?8:0);return m.button===4?(w|=64,w|=m.action):(w|=3&m.button,4&m.button&&(w|=64),8&m.button&&(w|=128),m.action===32?w|=32:m.action!==0||u||(w|=3)),w}let i=String.fromCharCode,S={DEFAULT:(m)=>{let u=[o(m,!1)+32,m.col+32,m.row+32];return u[0]>255||u[1]>255||u[2]>255?"":`\x1B[M${i(u[0])}${i(u[1])}${i(u[2])}`},SGR:(m)=>{let u=m.action===0&&m.button!==4?"m":"M";return`\x1B[<${o(m,!0)};${m.col};${m.row}${u}`},SGR_PIXELS:(m)=>{let u=m.action===0&&m.button!==4?"m":"M";return`\x1B[<${o(m,!0)};${m.x};${m.y}${u}`}},h=class extends d.Disposable{constructor(m,u,w){super(),this._bufferService=m,this._coreService=u,this._optionsService=w,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _.Emitter),this.onProtocolChange=this._onProtocolChange.event;for(let C of Object.keys(v))this.addProtocol(C,v[C]);for(let C of Object.keys(S))this.addEncoding(C,S[C]);this.reset()}addProtocol(m,u){this._protocols[m]=u}addEncoding(m,u){this._encodings[m]=u}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(m){if(!this._protocols[m])throw Error(`unknown protocol "${m}"`);this._activeProtocol=m,this._onProtocolChange.fire(this._protocols[m].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(m){if(!this._encodings[m])throw Error(`unknown encoding "${m}"`);this._activeEncoding=m}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(m,u,w){if(m.deltaY===0||m.shiftKey)return 0;if(u===void 0||w===void 0)return 0;let C=u/w,T=this._applyScrollModifier(m.deltaY,m);return m.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(T/=C+0,Math.abs(m.deltaY)<50&&(T*=0.3),this._wheelPartialScroll+=T,T=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):m.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(T*=this._bufferService.rows),T}_applyScrollModifier(m,u){return u.altKey||u.ctrlKey||u.shiftKey?m*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:m*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(m){if(m.col<0||m.col>=this._bufferService.cols||m.row<0||m.row>=this._bufferService.rows)return!1;if(m.button===4&&m.action===32)return!1;if(m.button===3&&m.action!==32)return!1;if(m.button!==4&&(m.action===2||m.action===3))return!1;if(m.col++,m.row++,m.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,m,this._activeEncoding==="SGR_PIXELS"))return!1;if(!this._protocols[this._activeProtocol].restrict(m))return!1;let u=this._encodings[this._activeEncoding](m);return u&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(u):this._coreService.triggerDataEvent(u,!0)),this._lastEvent=m,!0}explainEvents(m){return{down:!!(1&m),up:!!(2&m),drag:!!(4&m),move:!!(8&m),wheel:!!(16&m)}}_equalEvents(m,u,w){if(w){if(m.x!==u.x)return!1;if(m.y!==u.y)return!1}else{if(m.col!==u.col)return!1;if(m.row!==u.row)return!1}return m.button===u.button&&m.action===u.action&&m.ctrl===u.ctrl&&m.alt===u.alt&&m.shift===u.shift}};t.CoreMouseService=h,t.CoreMouseService=h=l([p(0,g.IBufferService),p(1,g.ICoreService),p(2,g.IOptionsService)],h)},4071:function(y,t,n){var l=this&&this.__decorate||function(h,m,u,w){var C,T=arguments.length,B=T<3?m:w===null?w=Object.getOwnPropertyDescriptor(m,u):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(h,m,u,w);else for(var O=h.length-1;O>=0;O--)(C=h[O])&&(B=(T<3?C(B):T>3?C(m,u,B):C(m,u))||B);return T>3&&B&&Object.defineProperty(m,u,B),B},p=this&&this.__param||function(h,m){return function(u,w){m(u,w,h)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CoreService=void 0;let g=n(7453),d=n(7150),_=n(6501),v=n(802),o=Object.freeze({insertMode:!1}),i=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),S=class extends d.Disposable{constructor(h,m,u){super(),this._bufferService=h,this._logService=m,this._optionsService=u,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new v.Emitter),this.onData=this._onData.event,this._onUserInput=this._register(new v.Emitter),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new v.Emitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new v.Emitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,g.clone)(o),this.decPrivateModes=(0,g.clone)(i)}reset(){this.modes=(0,g.clone)(o),this.decPrivateModes=(0,g.clone)(i)}triggerDataEvent(h,m=!1){if(this._optionsService.rawOptions.disableStdin)return;let u=this._bufferService.buffer;m&&this._optionsService.rawOptions.scrollOnUserInput&&u.ybase!==u.ydisp&&this._onRequestScrollToBottom.fire(),m&&this._onUserInput.fire(),this._logService.debug(`sending data "${h}"`),this._logService.trace("sending data (codes)",()=>h.split("").map((w)=>w.charCodeAt(0))),this._onData.fire(h)}triggerBinaryEvent(h){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${h}"`),this._logService.trace("sending binary (codes)",()=>h.split("").map((m)=>m.charCodeAt(0))),this._onBinary.fire(h))}};t.CoreService=S,t.CoreService=S=l([p(0,_.IBufferService),p(1,_.ILogService),p(2,_.IOptionsService)],S)},6025:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InstantiationService=t.ServiceCollection=void 0;let l=n(6501),p=n(6201);class g{constructor(...d){this._entries=new Map;for(let[_,v]of d)this.set(_,v)}set(d,_){let v=this._entries.get(d);return this._entries.set(d,_),v}forEach(d){for(let[_,v]of this._entries.entries())d(_,v)}has(d){return this._entries.has(d)}get(d){return this._entries.get(d)}}t.ServiceCollection=g,t.InstantiationService=class{constructor(){this._services=new g,this._services.set(l.IInstantiationService,this)}setService(d,_){this._services.set(d,_)}getService(d){return this._services.get(d)}createInstance(d,..._){let v=(0,p.getServiceDependencies)(d).sort((S,h)=>S.index-h.index),o=[];for(let S of v){let h=this._services.get(S.id);if(!h)throw Error(`[createInstance] ${d.name} depends on UNKNOWN service ${S.id._id}.`);o.push(h)}let i=v.length>0?v[0].index:_.length;if(_.length!==i)throw Error(`[createInstance] First service dependency of ${d.name} at position ${i+1} conflicts with ${_.length} static arguments`);return new d(...[..._,...o])}}},7276:function(y,t,n){var l=this&&this.__decorate||function(i,S,h,m){var u,w=arguments.length,C=w<3?S:m===null?m=Object.getOwnPropertyDescriptor(S,h):m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(i,S,h,m);else for(var T=i.length-1;T>=0;T--)(u=i[T])&&(C=(w<3?u(C):w>3?u(S,h,C):u(S,h))||C);return w>3&&C&&Object.defineProperty(S,h,C),C},p=this&&this.__param||function(i,S){return function(h,m){S(h,m,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogService=void 0,t.setTraceLogger=function(i){v=i},t.traceCall=function(i,S,h){if(typeof h.value!="function")throw Error("not supported");let m=h.value;h.value=function(...u){if(v.logLevel!==d.LogLevelEnum.TRACE)return m.apply(this,u);v.trace(`GlyphRenderer#${m.name}(${u.map((C)=>JSON.stringify(C)).join(", ")})`);let w=m.apply(this,u);return v.trace(`GlyphRenderer#${m.name} return`,w),w}};let g=n(7150),d=n(6501),_={trace:d.LogLevelEnum.TRACE,debug:d.LogLevelEnum.DEBUG,info:d.LogLevelEnum.INFO,warn:d.LogLevelEnum.WARN,error:d.LogLevelEnum.ERROR,off:d.LogLevelEnum.OFF},v,o=class extends g.Disposable{get logLevel(){return this._logLevel}constructor(i){super(),this._optionsService=i,this._logLevel=d.LogLevelEnum.OFF,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),v=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let S=0;S<i.length;S++)typeof i[S]=="function"&&(i[S]=i[S]())}_log(i,S,h){this._evalLazyOptionalParams(h),i.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...h)}trace(i,...S){this._logLevel<=d.LogLevelEnum.TRACE&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,i,S)}debug(i,...S){this._logLevel<=d.LogLevelEnum.DEBUG&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,i,S)}info(i,...S){this._logLevel<=d.LogLevelEnum.INFO&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,i,S)}warn(i,...S){this._logLevel<=d.LogLevelEnum.WARN&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,i,S)}error(i,...S){this._logLevel<=d.LogLevelEnum.ERROR&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,i,S)}};t.LogService=o,t.LogService=o=l([p(0,d.IOptionsService)],o)},56:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionsService=t.DEFAULT_OPTIONS=void 0;let l=n(7150),p=n(701),g=n(802);t.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1000,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:p.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}};let d=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends l.Disposable{constructor(v){super(),this._onOptionChange=this._register(new g.Emitter),this.onOptionChange=this._onOptionChange.event;let o={...t.DEFAULT_OPTIONS};for(let i in v)if(i in o)try{let S=v[i];o[i]=this._sanitizeAndValidateOption(i,S)}catch(S){console.error(S)}this.rawOptions=o,this.options={...o},this._setupOptions(),this._register((0,l.toDisposable)(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(v,o){return this.onOptionChange((i)=>{i===v&&o(this.rawOptions[v])})}onMultipleOptionChange(v,o){return this.onOptionChange((i)=>{v.indexOf(i)!==-1&&o()})}_setupOptions(){let v=(i)=>{if(!(i in t.DEFAULT_OPTIONS))throw Error(`No option with key "${i}"`);return this.rawOptions[i]},o=(i,S)=>{if(!(i in t.DEFAULT_OPTIONS))throw Error(`No option with key "${i}"`);S=this._sanitizeAndValidateOption(i,S),this.rawOptions[i]!==S&&(this.rawOptions[i]=S,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let S={get:v.bind(this,i),set:o.bind(this,i)};Object.defineProperty(this.options,i,S)}}_sanitizeAndValidateOption(v,o){switch(v){case"cursorStyle":if(o||(o=t.DEFAULT_OPTIONS[v]),!function(i){return i==="block"||i==="underline"||i==="bar"}(o))throw Error(`"${o}" is not a valid value for ${v}`);break;case"wordSeparator":o||(o=t.DEFAULT_OPTIONS[v]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1000)break;o=d.includes(o)?o:t.DEFAULT_OPTIONS[v];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw Error(`${v} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw Error(`${v} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw Error(`${v} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw Error(`${v} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}t.OptionsService=_},8811:function(y,t,n){var l=this&&this.__decorate||function(_,v,o,i){var S,h=arguments.length,m=h<3?v:i===null?i=Object.getOwnPropertyDescriptor(v,o):i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")m=Reflect.decorate(_,v,o,i);else for(var u=_.length-1;u>=0;u--)(S=_[u])&&(m=(h<3?S(m):h>3?S(v,o,m):S(v,o))||m);return h>3&&m&&Object.defineProperty(v,o,m),m},p=this&&this.__param||function(_,v){return function(o,i){v(o,i,_)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkService=void 0;let g=n(6501),d=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){let v=this._bufferService.buffer;if(_.id===void 0){let u=v.addMarker(v.ybase+v.y),w={data:_,id:this._nextId++,lines:[u]};return u.onDispose(()=>this._removeMarkerFromLink(w,u)),this._dataByLinkId.set(w.id,w),w.id}let o=_,i=this._getEntryIdKey(o),S=this._entriesWithId.get(i);if(S)return this.addLineToLink(S.id,v.ybase+v.y),S.id;let h=v.addMarker(v.ybase+v.y),m={id:this._nextId++,key:this._getEntryIdKey(o),data:o,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(m,h)),this._entriesWithId.set(m.key,m),this._dataByLinkId.set(m.id,m),m.id}addLineToLink(_,v){let o=this._dataByLinkId.get(_);if(o&&o.lines.every((i)=>i.line!==v)){let i=this._bufferService.buffer.addMarker(v);o.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(o,i))}}getLinkData(_){return this._dataByLinkId.get(_)?.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,v){let o=_.lines.indexOf(v);o!==-1&&(_.lines.splice(o,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};t.OscLinkService=d,t.OscLinkService=d=l([p(0,g.IBufferService)],d)},6201:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.serviceRegistry=void 0,t.getServiceDependencies=function(p){return p[l]||[]},t.createDecorator=function(p){if(t.serviceRegistry.has(p))return t.serviceRegistry.get(p);let g=function(d,_,v){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");(function(o,i,S){i[n]===i?i[l].push({id:o,index:S}):(i[l]=[{id:o,index:S}],i[n]=i)})(g,d,v)};return g._id=p,t.serviceRegistry.set(p,g),g};let n="di$target",l="di$dependencies";t.serviceRegistry=new Map},6501:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IDecorationService=t.IUnicodeService=t.IOscLinkService=t.IOptionsService=t.ILogService=t.LogLevelEnum=t.IInstantiationService=t.ICharsetService=t.ICoreService=t.ICoreMouseService=t.IBufferService=void 0;let l=n(6201);var p;t.IBufferService=(0,l.createDecorator)("BufferService"),t.ICoreMouseService=(0,l.createDecorator)("CoreMouseService"),t.ICoreService=(0,l.createDecorator)("CoreService"),t.ICharsetService=(0,l.createDecorator)("CharsetService"),t.IInstantiationService=(0,l.createDecorator)("InstantiationService"),function(g){g[g.TRACE=0]="TRACE",g[g.DEBUG=1]="DEBUG",g[g.INFO=2]="INFO",g[g.WARN=3]="WARN",g[g.ERROR=4]="ERROR",g[g.OFF=5]="OFF"}(p||(t.LogLevelEnum=p={})),t.ILogService=(0,l.createDecorator)("LogService"),t.IOptionsService=(0,l.createDecorator)("OptionsService"),t.IOscLinkService=(0,l.createDecorator)("OscLinkService"),t.IUnicodeService=(0,l.createDecorator)("UnicodeService"),t.IDecorationService=(0,l.createDecorator)("DecorationService")},6415:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeService=void 0;let l=n(7428),p=n(802);class g{static extractShouldJoin(d){return!!(1&d)}static extractWidth(d){return d>>1&3}static extractCharKind(d){return d>>3}static createPropertyValue(d,_,v=!1){return(16777215&d)<<3|(3&_)<<1|(v?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new p.Emitter,this.onChange=this._onChange.event;let d=new l.UnicodeV6;this.register(d),this._active=d.version,this._activeProvider=d}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(d){if(!this._providers[d])throw Error(`unknown Unicode version "${d}"`);this._active=d,this._activeProvider=this._providers[d],this._onChange.fire(d)}register(d){this._providers[d.version]=d}wcwidth(d){return this._activeProvider.wcwidth(d)}getStringCellWidth(d){let _=0,v=0,o=d.length;for(let i=0;i<o;++i){let S=d.charCodeAt(i);if(55296<=S&&S<=56319){if(++i>=o)return _+this.wcwidth(S);let u=d.charCodeAt(i);56320<=u&&u<=57343?S=1024*(S-55296)+u-56320+65536:_+=this.wcwidth(u)}let h=this.charProperties(S,v),m=g.extractWidth(h);g.extractShouldJoin(h)&&(m-=g.extractWidth(v)),_+=m,v=h}return _}charProperties(d,_){return this._activeProvider.charProperties(d,_)}}t.UnicodeService=g},5856:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;let l=n(6107),p=n(5777),g=n(802);class d extends p.CoreTerminal{constructor(_={}){super(_),this._onBell=this._register(new g.Emitter),this.onBell=this._onBell.event,this._onCursorMove=this._register(new g.Emitter),this.onCursorMove=this._onCursorMove.event,this._onTitleChange=this._register(new g.Emitter),this.onTitleChange=this._onTitleChange.event,this._onA11yCharEmitter=this._register(new g.Emitter),this.onA11yChar=this._onA11yCharEmitter.event,this._onA11yTabEmitter=this._register(new g.Emitter),this.onA11yTab=this._onA11yTabEmitter.event,this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(g.Event.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(g.Event.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(g.Event.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(g.Event.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(_){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+_)}bell(){this._onBell.fire()}input(_,v=!0){this.coreService.triggerDataEvent(_,v)}resize(_,v){_===this.cols&&v===this.rows||super.resize(_,v)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){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 _=1;_<this.rows;_++)this.buffer.lines.push(this.buffer.getBlankLine(l.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}}t.Terminal=d},3058:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Permutation=t.CallbackIterable=t.ArrayQueue=t.booleanComparator=t.numberComparator=t.CompareResult=void 0,t.tail=function(u,w=0){return u[u.length-(1+w)]},t.tail2=function(u){if(u.length===0)throw Error("Invalid tail call");return[u.slice(0,u.length-1),u[u.length-1]]},t.equals=function(u,w,C=(T,B)=>T===B){if(u===w)return!0;if(!u||!w)return!1;if(u.length!==w.length)return!1;for(let T=0,B=u.length;T<B;T++)if(!C(u[T],w[T]))return!1;return!0},t.removeFastWithoutKeepingOrder=function(u,w){let C=u.length-1;w<C&&(u[w]=u[C]),u.pop()},t.binarySearch=function(u,w,C){return g(u.length,(T)=>C(u[T],w))},t.binarySearch2=g,t.quickSelect=function u(w,C,T){if((w|=0)>=C.length)throw TypeError("invalid index");let B=C[Math.floor(C.length*Math.random())],O=[],A=[],M=[];for(let k of C){let P=T(k,B);P<0?O.push(k):P>0?A.push(k):M.push(k)}return w<O.length?u(w,O,T):w<O.length+M.length?M[0]:u(w-(O.length+M.length),A,T)},t.groupBy=function(u,w){let C=[],T;for(let B of u.slice(0).sort(w))T&&w(T[0],B)===0?T.push(B):(T=[B],C.push(T));return C},t.groupAdjacentBy=function*(u,w){let C,T;for(let B of u)T!==void 0&&w(T,B)?C.push(B):(C&&(yield C),C=[B]),T=B;C&&(yield C)},t.forEachAdjacent=function(u,w){for(let C=0;C<=u.length;C++)w(C===0?void 0:u[C-1],C===u.length?void 0:u[C])},t.forEachWithNeighbors=function(u,w){for(let C=0;C<u.length;C++)w(C===0?void 0:u[C-1],u[C],C+1===u.length?void 0:u[C+1])},t.sortedDiff=d,t.delta=function(u,w,C){let T=d(u,w,C),B=[],O=[];for(let A of T)B.push(...u.slice(A.start,A.start+A.deleteCount)),O.push(...A.toInsert);return{removed:B,added:O}},t.top=function(u,w,C){if(C===0)return[];let T=u.slice(0,C).sort(w);return _(u,w,T,C,u.length),T},t.topAsync=function(u,w,C,T,B){return C===0?Promise.resolve([]):new Promise((O,A)=>{(async()=>{let M=u.length,k=u.slice(0,C).sort(w);for(let P=C,W=Math.min(C+T,M);P<M;P=W,W=Math.min(W+T,M)){if(P>C&&await new Promise((j)=>setTimeout(j)),B&&B.isCancellationRequested)throw new l.CancellationError;_(u,w,k,P,W)}return k})().then(O,A)})},t.coalesce=function(u){return u.filter((w)=>!!w)},t.coalesceInPlace=function(u){let w=0;for(let C=0;C<u.length;C++)u[C]&&(u[w]=u[C],w+=1);u.length=w},t.move=function(u,w,C){u.splice(C,0,u.splice(w,1)[0])},t.isFalsyOrEmpty=function(u){return!Array.isArray(u)||u.length===0},t.isNonEmptyArray=function(u){return Array.isArray(u)&&u.length>0},t.distinct=function(u,w=(C)=>C){let C=new Set;return u.filter((T)=>{let B=w(T);return!C.has(B)&&(C.add(B),!0)})},t.uniqueFilter=function(u){let w=new Set;return(C)=>{let T=u(C);return!w.has(T)&&(w.add(T),!0)}},t.firstOrDefault=function(u,w){return u.length>0?u[0]:w},t.lastOrDefault=function(u,w){return u.length>0?u[u.length-1]:w},t.commonPrefixLength=function(u,w,C=(T,B)=>T===B){let T=0;for(let B=0,O=Math.min(u.length,w.length);B<O&&C(u[B],w[B]);B++)T++;return T},t.range=function(u,w){let C=typeof w=="number"?u:0;typeof w=="number"?C=u:(C=0,w=u);let T=[];if(C<=w)for(let B=C;B<w;B++)T.push(B);else for(let B=C;B>w;B--)T.push(B);return T},t.index=function(u,w,C){return u.reduce((T,B)=>(T[w(B)]=C?C(B):B,T),Object.create(null))},t.insert=function(u,w){return u.push(w),()=>v(u,w)},t.remove=v,t.arrayInsert=function(u,w,C){let T=u.slice(0,w),B=u.slice(w);return T.concat(C,B)},t.shuffle=function(u,w){let C;if(typeof w=="number"){let T=w;C=()=>{let B=179426549*Math.sin(T++);return B-Math.floor(B)}}else C=Math.random;for(let T=u.length-1;T>0;T-=1){let B=Math.floor(C()*(T+1)),O=u[T];u[T]=u[B],u[B]=O}},t.pushToStart=function(u,w){let C=u.indexOf(w);C>-1&&(u.splice(C,1),u.unshift(w))},t.pushToEnd=function(u,w){let C=u.indexOf(w);C>-1&&(u.splice(C,1),u.push(w))},t.pushMany=function(u,w){for(let C of w)u.push(C)},t.mapArrayOrNot=function(u,w){return Array.isArray(u)?u.map(w):w(u)},t.asArray=function(u){return Array.isArray(u)?u:[u]},t.getRandomElement=function(u){return u[Math.floor(Math.random()*u.length)]},t.insertInto=o,t.splice=function(u,w,C,T){let B=i(u,w),O=u.splice(B,C);return O===void 0&&(O=[]),o(u,B,T),O},t.compareBy=function(u,w){return(C,T)=>w(u(C),u(T))},t.tieBreakComparators=function(...u){return(w,C)=>{for(let T of u){let B=T(w,C);if(!S.isNeitherLessOrGreaterThan(B))return B}return S.neitherLessOrGreaterThan}},t.reverseOrder=function(u){return(w,C)=>-u(w,C)};let l=n(9807),p=n(8297);function g(u,w){let C=0,T=u-1;for(;C<=T;){let B=(C+T)/2|0,O=w(B);if(O<0)C=B+1;else{if(!(O>0))return B;T=B-1}}return-(C+1)}function d(u,w,C){let T=[];function B(M,k,P){if(k===0&&P.length===0)return;let W=T[T.length-1];W&&W.start+W.deleteCount===M?(W.deleteCount+=k,W.toInsert.push(...P)):T.push({start:M,deleteCount:k,toInsert:P})}let O=0,A=0;for(;;){if(O===u.length){B(O,0,w.slice(A));break}if(A===w.length){B(O,u.length-O,[]);break}let M=u[O],k=w[A],P=C(M,k);P===0?(O+=1,A+=1):P<0?(B(O,1,[]),O+=1):P>0&&(B(O,0,[k]),A+=1)}return T}function _(u,w,C,T,B){for(let O=C.length;T<B;T++){let A=u[T];if(w(A,C[O-1])<0){C.pop();let M=(0,p.findFirstIdxMonotonousOrArrLen)(C,(k)=>w(A,k)<0);C.splice(M,0,A)}}}function v(u,w){let C=u.indexOf(w);if(C>-1)return u.splice(C,1),w}function o(u,w,C){let T=i(u,w),B=u.length,O=C.length;u.length=B+O;for(let A=B-1;A>=T;A--)u[A+O]=u[A];for(let A=0;A<O;A++)u[A+T]=C[A]}function i(u,w){return w<0?Math.max(w+u.length,0):Math.min(w,u.length)}var S;(function(u){u.isLessThan=function(w){return w<0},u.isLessThanOrEqual=function(w){return w<=0},u.isGreaterThan=function(w){return w>0},u.isNeitherLessOrGreaterThan=function(w){return w===0},u.greaterThan=1,u.lessThan=-1,u.neitherLessOrGreaterThan=0})(S||(t.CompareResult=S={})),t.numberComparator=(u,w)=>u-w,t.booleanComparator=(u,w)=>(0,t.numberComparator)(u?1:0,w?1:0),t.ArrayQueue=class{constructor(u){this.items=u,this.firstIdx=0,this.lastIdx=this.items.length-1}get length(){return this.lastIdx-this.firstIdx+1}takeWhile(u){let w=this.firstIdx;for(;w<this.items.length&&u(this.items[w]);)w++;let C=w===this.firstIdx?null:this.items.slice(this.firstIdx,w);return this.firstIdx=w,C}takeFromEndWhile(u){let w=this.lastIdx;for(;w>=0&&u(this.items[w]);)w--;let C=w===this.lastIdx?null:this.items.slice(w+1,this.lastIdx+1);return this.lastIdx=w,C}peek(){if(this.length!==0)return this.items[this.firstIdx]}peekLast(){if(this.length!==0)return this.items[this.lastIdx]}dequeue(){let u=this.items[this.firstIdx];return this.firstIdx++,u}removeLast(){let u=this.items[this.lastIdx];return this.lastIdx--,u}takeCount(u){let w=this.items.slice(this.firstIdx,this.firstIdx+u);return this.firstIdx+=u,w}};class h{static{this.empty=new h((u)=>{})}constructor(u){this.iterate=u}forEach(u){this.iterate((w)=>(u(w),!0))}toArray(){let u=[];return this.iterate((w)=>(u.push(w),!0)),u}filter(u){return new h((w)=>this.iterate((C)=>!u(C)||w(C)))}map(u){return new h((w)=>this.iterate((C)=>w(u(C))))}some(u){let w=!1;return this.iterate((C)=>(w=u(C),!w)),w}findFirst(u){let w;return this.iterate((C)=>!u(C)||(w=C,!1)),w}findLast(u){let w;return this.iterate((C)=>(u(C)&&(w=C),!0)),w}findLastMaxBy(u){let w,C=!0;return this.iterate((T)=>((C||S.isGreaterThan(u(T,w)))&&(C=!1,w=T),!0)),w}}t.CallbackIterable=h;class m{constructor(u){this._indexMap=u}static createSortPermutation(u,w){let C=Array.from(u.keys()).sort((T,B)=>w(u[T],u[B]));return new m(C)}apply(u){return u.map((w,C)=>u[this._indexMap[C]])}inverse(){let u=this._indexMap.slice();for(let w=0;w<this._indexMap.length;w++)u[this._indexMap[w]]=w;return new m(u)}}t.Permutation=m},8297:(y,t)=>{function n(_,v,o=_.length-1){for(let i=o;i>=0;i--)if(v(_[i]))return i;return-1}function l(_,v,o=0,i=_.length){let S=o,h=i;for(;S<h;){let m=Math.floor((S+h)/2);v(_[m])?S=m+1:h=m}return S-1}function p(_,v,o=0,i=_.length){let S=o,h=i;for(;S<h;){let m=Math.floor((S+h)/2);v(_[m])?h=m:S=m+1}return S}Object.defineProperty(t,"__esModule",{value:!0}),t.MonotonousArray=void 0,t.findLast=function(_,v){let o=n(_,v);if(o!==-1)return _[o]},t.findLastIdx=n,t.findLastMonotonous=function(_,v){let o=l(_,v);return o===-1?void 0:_[o]},t.findLastIdxMonotonous=l,t.findFirstMonotonous=function(_,v){let o=p(_,v);return o===_.length?void 0:_[o]},t.findFirstIdxMonotonousOrArrLen=p,t.findFirstIdxMonotonous=function(_,v,o=0,i=_.length){let S=p(_,v,o,i);return S===_.length?-1:S},t.findFirstMax=d,t.findLastMax=function(_,v){if(_.length===0)return;let o=_[0];for(let i=1;i<_.length;i++){let S=_[i];v(S,o)>=0&&(o=S)}return o},t.findFirstMin=function(_,v){return d(_,(o,i)=>-v(o,i))},t.findMaxIdx=function(_,v){if(_.length===0)return-1;let o=0;for(let i=1;i<_.length;i++)v(_[i],_[o])>0&&(o=i);return o},t.mapFindFirst=function(_,v){for(let o of _){let i=v(o);if(i!==void 0)return i}};class g{static{this.assertInvariants=!1}constructor(_){this._array=_,this._findLastMonotonousLastIdx=0}findLastMonotonous(_){if(g.assertInvariants){if(this._prevFindLastPredicate){for(let o of this._array)if(this._prevFindLastPredicate(o)&&!_(o))throw Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=_}let v=l(this._array,_,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=v+1,v===-1?void 0:this._array[v]}}function d(_,v){if(_.length===0)return;let o=_[0];for(let i=1;i<_.length;i++){let S=_[i];v(S,o)>0&&(o=S)}return o}t.MonotonousArray=g},9087:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SetWithKey=void 0,t.groupBy=function(p,g){let d=Object.create(null);for(let _ of p){let v=g(_),o=d[v];o||(o=d[v]=[]),o.push(_)}return d},t.diffSets=function(p,g){let d=[],_=[];for(let v of p)g.has(v)||d.push(v);for(let v of g)p.has(v)||_.push(v);return{removed:d,added:_}},t.diffMaps=function(p,g){let d=[],_=[];for(let[v,o]of p)g.has(v)||d.push(o);for(let[v,o]of g)p.has(v)||_.push(o);return{removed:d,added:_}},t.intersection=function(p,g){let d=new Set;for(let _ of g)p.has(_)&&d.add(_);return d};class l{static{n=Symbol.toStringTag}constructor(p,g){this.toKey=g,this._map=new Map,this[n]="SetWithKey";for(let d of p)this.add(d)}get size(){return this._map.size}add(p){let g=this.toKey(p);return this._map.set(g,p),this}delete(p){return this._map.delete(this.toKey(p))}has(p){return this._map.has(this.toKey(p))}*entries(){for(let p of this._map.values())yield[p,p]}keys(){return this.values()}*values(){for(let p of this._map.values())yield p}clear(){this._map.clear()}forEach(p,g){this._map.forEach((d)=>p.call(g,d,d,this))}[Symbol.iterator](){return this.values()}}t.SetWithKey=l},9807:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BugIndicatingError=t.ErrorNoTelemetry=t.ExpectedError=t.NotSupportedError=t.NotImplementedError=t.ReadonlyError=t.CancellationError=t.errorHandler=t.ErrorHandler=void 0,t.setUnexpectedErrorHandler=function(h){t.errorHandler.setUnexpectedErrorHandler(h)},t.isSigPipeError=function(h){if(!h||typeof h!="object")return!1;let m=h;return m.code==="EPIPE"&&m.syscall?.toUpperCase()==="WRITE"},t.onUnexpectedError=function(h){p(h)||t.errorHandler.onUnexpectedError(h)},t.onUnexpectedExternalError=function(h){p(h)||t.errorHandler.onUnexpectedExternalError(h)},t.transformErrorForSerialization=function(h){if(h instanceof Error){let{name:m,message:u}=h;return{$isError:!0,name:m,message:u,stack:h.stacktrace||h.stack,noTelemetry:i.isErrorNoTelemetry(h)}}return h},t.transformErrorFromSerialization=function(h){let m;return h.noTelemetry?m=new i:(m=Error(),m.name=h.name),m.message=h.message,m.stack=h.stack,m},t.isCancellationError=p,t.canceled=function(){let h=Error(l);return h.name=h.message,h},t.illegalArgument=function(h){return h?Error(`Illegal argument: ${h}`):Error("Illegal argument")},t.illegalState=function(h){return h?Error(`Illegal state: ${h}`):Error("Illegal state")},t.getErrorMessage=function(h){return h?h.message?h.message:h.stack?h.stack.split(`
5
5
  `)[0]:String(h):"Error"};class n{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(h){setTimeout(()=>{if(h.stack){if(i.isErrorNoTelemetry(h))throw new i(h.message+`
6
6
 
7
7
  `+h.stack);throw Error(h.message+`
8
8
 
9
- `+h.stack)}throw h},0)}}addListener(h){return this.listeners.push(h),()=>{this._removeListener(h)}}emit(h){this.listeners.forEach((m)=>{m(h)})}_removeListener(h){this.listeners.splice(this.listeners.indexOf(h),1)}setUnexpectedErrorHandler(h){this.unexpectedErrorHandler=h}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(h){this.unexpectedErrorHandler(h),this.emit(h)}onUnexpectedExternalError(h){this.unexpectedErrorHandler(h)}}t.ErrorHandler=n,t.errorHandler=new n;let l="Canceled";function p(h){return h instanceof g||h instanceof Error&&h.name===l&&h.message===l}class g extends Error{constructor(){super(l),this.name=this.message}}t.CancellationError=g;class d extends TypeError{constructor(h){super(h?`${h} is read-only and cannot be changed`:"Cannot change read-only property")}}t.ReadonlyError=d;class _ extends Error{constructor(h){super("NotImplemented"),h&&(this.message=h)}}t.NotImplementedError=_;class v extends Error{constructor(h){super("NotSupported"),h&&(this.message=h)}}t.NotSupportedError=v;class o extends Error{constructor(){super(...arguments),this.isExpected=!0}}t.ExpectedError=o;class i extends Error{constructor(h){super(h),this.name="CodeExpectedError"}static fromError(h){if(h instanceof i)return h;let m=new i;return m.message=h.message,m.stack=h.stack,m}static isErrorNoTelemetry(h){return h.name==="CodeExpectedError"}}t.ErrorNoTelemetry=i;class w extends Error{constructor(h){super(h||"An unexpected bug occurred."),Object.setPrototypeOf(this,w.prototype)}}t.BugIndicatingError=w},802:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValueWithChangeEvent=t.Relay=t.EventBufferer=t.DynamicListEventMultiplexer=t.EventMultiplexer=t.MicrotaskEmitter=t.DebounceEmitter=t.PauseableEmitter=t.AsyncEmitter=t.createEventDeliveryQueue=t.Emitter=t.ListenerRefusalError=t.ListenerLeakError=t.EventProfiling=t.Event=void 0,t.setGlobalLeakWarningThreshold=function(k){let P=i;return i=k,{dispose(){i=P}}};let l=n(9807),p=n(8841),g=n(7150),d=n(6317),_=n(9725);var v;(function(k){function P(E){return(D,H=null,I)=>{let N,j=!1;return N=E((R)=>{if(!j)return N?N.dispose():j=!0,D.call(H,R)},null,I),j&&N.dispose(),N}}function W(E,D,H){return q((I,N=null,j)=>E((R)=>I.call(N,D(R)),null,j),H)}function z(E,D,H){return q((I,N=null,j)=>E((R)=>D(R)&&I.call(N,R),null,j),H)}function q(E,D){let H,I=new T({onWillAddFirstListener(){H=E(I.fire,I)},onDidRemoveLastListener(){H?.dispose()}});return D?.add(I),I.event}function F(E,D,H=100,I=!1,N=!1,j,R){let G,U,X,se,ie=0,ae=new T({leakWarningThreshold:j,onWillAddFirstListener(){G=E((ce)=>{ie++,U=D(U,ce),I&&!X&&(ae.fire(U),U=void 0),se=()=>{let he=U;U=void 0,X=void 0,(!I||ie>1)&&ae.fire(he),ie=0},typeof H=="number"?(clearTimeout(X),X=setTimeout(se,H)):X===void 0&&(X=0,queueMicrotask(se))})},onWillRemoveListener(){N&&ie>0&&se?.()},onDidRemoveLastListener(){se=void 0,G.dispose()}});return R?.add(ae),ae.event}k.None=()=>g.Disposable.None,k.defer=function(E,D){return F(E,()=>{},0,void 0,!0,void 0,D)},k.once=P,k.map=W,k.forEach=function(E,D,H){return q((I,N=null,j)=>E((R)=>{D(R),I.call(N,R)},null,j),H)},k.filter=z,k.signal=function(E){return E},k.any=function(...E){return(D,H=null,I)=>{return N=(0,g.combinedDisposable)(...E.map((R)=>R((G)=>D.call(H,G)))),(j=I)instanceof Array?j.push(N):j&&j.add(N),N;var N,j}},k.reduce=function(E,D,H,I){let N=H;return W(E,(j)=>(N=D(N,j),N),I)},k.debounce=F,k.accumulate=function(E,D=0,H){return k.debounce(E,(I,N)=>I?(I.push(N),I):[N],D,void 0,!0,void 0,H)},k.latch=function(E,D=(I,N)=>I===N,H){let I,N=!0;return z(E,(j)=>{let R=N||!D(j,I);return N=!1,I=j,R},H)},k.split=function(E,D,H){return[k.filter(E,D,H),k.filter(E,(I)=>!D(I),H)]},k.buffer=function(E,D=!1,H=[],I){let N=H.slice(),j=E((U)=>{N?N.push(U):G.fire(U)});I&&I.add(j);let R=()=>{N?.forEach((U)=>G.fire(U)),N=null},G=new T({onWillAddFirstListener(){j||(j=E((U)=>G.fire(U)),I&&I.add(j))},onDidAddFirstListener(){N&&(D?setTimeout(R):R())},onDidRemoveLastListener(){j&&j.dispose(),j=null}});return I&&I.add(G),G.event},k.chain=function(E,D){return(H,I,N)=>{let j=D(new x);return E(function(R){let G=j.evaluate(R);G!==b&&H.call(I,G)},void 0,N)}};let b=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push((D)=>(E(D),D)),this}filter(E){return this.steps.push((D)=>E(D)?D:b),this}reduce(E,D){let H=D;return this.steps.push((I)=>(H=E(H,I),H)),this}latch(E=(D,H)=>D===H){let D,H=!0;return this.steps.push((I)=>{let N=H||!E(I,D);return H=!1,D=I,N?I:b}),this}evaluate(E){for(let D of this.steps)if((E=D(E))===b)break;return E}}k.fromNodeEventEmitter=function(E,D,H=(I)=>I){let I=(...j)=>N.fire(H(...j)),N=new T({onWillAddFirstListener:()=>E.on(D,I),onDidRemoveLastListener:()=>E.removeListener(D,I)});return N.event},k.fromDOMEventEmitter=function(E,D,H=(I)=>I){let I=(...j)=>N.fire(H(...j)),N=new T({onWillAddFirstListener:()=>E.addEventListener(D,I),onDidRemoveLastListener:()=>E.removeEventListener(D,I)});return N.event},k.toPromise=function(E){return new Promise((D)=>P(E)(D))},k.fromPromise=function(E){let D=new T;return E.then((H)=>{D.fire(H)},()=>{D.fire(void 0)}).finally(()=>{D.dispose()}),D.event},k.forward=function(E,D){return E((H)=>D.fire(H))},k.runAndSubscribe=function(E,D,H){return D(H),E((I)=>D(I))};class L{constructor(E,D){this._observable=E,this._counter=0,this._hasChanged=!1;let H={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new T(H),D&&D.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,D){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}k.fromObservable=function(E,D){return new L(E,D).emitter.event},k.fromObservableLight=function(E){return(D,H,I)=>{let N=0,j=!1,R={beginUpdate(){N++},endUpdate(){N--,N===0&&(E.reportChanges(),j&&(j=!1,D.call(H)))},handlePossibleChange(){},handleChange(){j=!0}};E.addObserver(R),E.reportChanges();let G={dispose(){E.removeObserver(R)}};return I instanceof g.DisposableStore?I.add(G):Array.isArray(I)&&I.push(G),G}}})(v||(t.Event=v={}));class o{static{this.all=new Set}static{this._idPool=0}constructor(k){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${k}_${o._idPool++}`,o.all.add(this)}start(k){this._stopWatch=new _.StopWatch,this.listenerCount=k}stop(){if(this._stopWatch){let k=this._stopWatch.elapsed();this.durations.push(k),this.elapsedOverall+=k,this.invocationCount+=1,this._stopWatch=void 0}}}t.EventProfiling=o;let i=-1;class w{static{this._idPool=1}constructor(k,P,W=(w._idPool++).toString(16).padStart(3,"0")){this._errorHandler=k,this.threshold=P,this.name=W,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(k,P){let W=this.threshold;if(W<=0||P<W)return;this._stacks||(this._stacks=new Map);let z=this._stacks.get(k.value)||0;if(this._stacks.set(k.value,z+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=0.5*W;let[q,F]=this.getMostFrequentStack(),b=`[${this.name}] potential listener LEAK detected, having ${P} listeners already. MOST frequent listener (${F}):`;console.warn(b),console.warn(q);let x=new m(b,q);this._errorHandler(x)}return()=>{let q=this._stacks.get(k.value)||0;this._stacks.set(k.value,q-1)}}getMostFrequentStack(){if(!this._stacks)return;let k,P=0;for(let[W,z]of this._stacks)(!k||P<z)&&(k=[W,z],P=z);return k}}class h{static create(){let k=Error();return new h(k.stack??"")}constructor(k){this.value=k}print(){console.warn(this.value.split(`
9
+ `+h.stack)}throw h},0)}}addListener(h){return this.listeners.push(h),()=>{this._removeListener(h)}}emit(h){this.listeners.forEach((m)=>{m(h)})}_removeListener(h){this.listeners.splice(this.listeners.indexOf(h),1)}setUnexpectedErrorHandler(h){this.unexpectedErrorHandler=h}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(h){this.unexpectedErrorHandler(h),this.emit(h)}onUnexpectedExternalError(h){this.unexpectedErrorHandler(h)}}t.ErrorHandler=n,t.errorHandler=new n;let l="Canceled";function p(h){return h instanceof g||h instanceof Error&&h.name===l&&h.message===l}class g extends Error{constructor(){super(l),this.name=this.message}}t.CancellationError=g;class d extends TypeError{constructor(h){super(h?`${h} is read-only and cannot be changed`:"Cannot change read-only property")}}t.ReadonlyError=d;class _ extends Error{constructor(h){super("NotImplemented"),h&&(this.message=h)}}t.NotImplementedError=_;class v extends Error{constructor(h){super("NotSupported"),h&&(this.message=h)}}t.NotSupportedError=v;class o extends Error{constructor(){super(...arguments),this.isExpected=!0}}t.ExpectedError=o;class i extends Error{constructor(h){super(h),this.name="CodeExpectedError"}static fromError(h){if(h instanceof i)return h;let m=new i;return m.message=h.message,m.stack=h.stack,m}static isErrorNoTelemetry(h){return h.name==="CodeExpectedError"}}t.ErrorNoTelemetry=i;class S extends Error{constructor(h){super(h||"An unexpected bug occurred."),Object.setPrototypeOf(this,S.prototype)}}t.BugIndicatingError=S},802:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValueWithChangeEvent=t.Relay=t.EventBufferer=t.DynamicListEventMultiplexer=t.EventMultiplexer=t.MicrotaskEmitter=t.DebounceEmitter=t.PauseableEmitter=t.AsyncEmitter=t.createEventDeliveryQueue=t.Emitter=t.ListenerRefusalError=t.ListenerLeakError=t.EventProfiling=t.Event=void 0,t.setGlobalLeakWarningThreshold=function(k){let P=i;return i=k,{dispose(){i=P}}};let l=n(9807),p=n(8841),g=n(7150),d=n(6317),_=n(9725);var v;(function(k){function P(E){return(D,H=null,I)=>{let N,z=!1;return N=E((R)=>{if(!z)return N?N.dispose():z=!0,D.call(H,R)},null,I),z&&N.dispose(),N}}function W(E,D,H){return q((I,N=null,z)=>E((R)=>I.call(N,D(R)),null,z),H)}function j(E,D,H){return q((I,N=null,z)=>E((R)=>D(R)&&I.call(N,R),null,z),H)}function q(E,D){let H,I=new T({onWillAddFirstListener(){H=E(I.fire,I)},onDidRemoveLastListener(){H?.dispose()}});return D?.add(I),I.event}function F(E,D,H=100,I=!1,N=!1,z,R){let G,U,X,se,ie=0,ae=new T({leakWarningThreshold:z,onWillAddFirstListener(){G=E((ce)=>{ie++,U=D(U,ce),I&&!X&&(ae.fire(U),U=void 0),se=()=>{let le=U;U=void 0,X=void 0,(!I||ie>1)&&ae.fire(le),ie=0},typeof H=="number"?(clearTimeout(X),X=setTimeout(se,H)):X===void 0&&(X=0,queueMicrotask(se))})},onWillRemoveListener(){N&&ie>0&&se?.()},onDidRemoveLastListener(){se=void 0,G.dispose()}});return R?.add(ae),ae.event}k.None=()=>g.Disposable.None,k.defer=function(E,D){return F(E,()=>{},0,void 0,!0,void 0,D)},k.once=P,k.map=W,k.forEach=function(E,D,H){return q((I,N=null,z)=>E((R)=>{D(R),I.call(N,R)},null,z),H)},k.filter=j,k.signal=function(E){return E},k.any=function(...E){return(D,H=null,I)=>{return N=(0,g.combinedDisposable)(...E.map((R)=>R((G)=>D.call(H,G)))),(z=I)instanceof Array?z.push(N):z&&z.add(N),N;var N,z}},k.reduce=function(E,D,H,I){let N=H;return W(E,(z)=>(N=D(N,z),N),I)},k.debounce=F,k.accumulate=function(E,D=0,H){return k.debounce(E,(I,N)=>I?(I.push(N),I):[N],D,void 0,!0,void 0,H)},k.latch=function(E,D=(I,N)=>I===N,H){let I,N=!0;return j(E,(z)=>{let R=N||!D(z,I);return N=!1,I=z,R},H)},k.split=function(E,D,H){return[k.filter(E,D,H),k.filter(E,(I)=>!D(I),H)]},k.buffer=function(E,D=!1,H=[],I){let N=H.slice(),z=E((U)=>{N?N.push(U):G.fire(U)});I&&I.add(z);let R=()=>{N?.forEach((U)=>G.fire(U)),N=null},G=new T({onWillAddFirstListener(){z||(z=E((U)=>G.fire(U)),I&&I.add(z))},onDidAddFirstListener(){N&&(D?setTimeout(R):R())},onDidRemoveLastListener(){z&&z.dispose(),z=null}});return I&&I.add(G),G.event},k.chain=function(E,D){return(H,I,N)=>{let z=D(new x);return E(function(R){let G=z.evaluate(R);G!==b&&H.call(I,G)},void 0,N)}};let b=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push((D)=>(E(D),D)),this}filter(E){return this.steps.push((D)=>E(D)?D:b),this}reduce(E,D){let H=D;return this.steps.push((I)=>(H=E(H,I),H)),this}latch(E=(D,H)=>D===H){let D,H=!0;return this.steps.push((I)=>{let N=H||!E(I,D);return H=!1,D=I,N?I:b}),this}evaluate(E){for(let D of this.steps)if((E=D(E))===b)break;return E}}k.fromNodeEventEmitter=function(E,D,H=(I)=>I){let I=(...z)=>N.fire(H(...z)),N=new T({onWillAddFirstListener:()=>E.on(D,I),onDidRemoveLastListener:()=>E.removeListener(D,I)});return N.event},k.fromDOMEventEmitter=function(E,D,H=(I)=>I){let I=(...z)=>N.fire(H(...z)),N=new T({onWillAddFirstListener:()=>E.addEventListener(D,I),onDidRemoveLastListener:()=>E.removeEventListener(D,I)});return N.event},k.toPromise=function(E){return new Promise((D)=>P(E)(D))},k.fromPromise=function(E){let D=new T;return E.then((H)=>{D.fire(H)},()=>{D.fire(void 0)}).finally(()=>{D.dispose()}),D.event},k.forward=function(E,D){return E((H)=>D.fire(H))},k.runAndSubscribe=function(E,D,H){return D(H),E((I)=>D(I))};class L{constructor(E,D){this._observable=E,this._counter=0,this._hasChanged=!1;let H={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new T(H),D&&D.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,D){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}k.fromObservable=function(E,D){return new L(E,D).emitter.event},k.fromObservableLight=function(E){return(D,H,I)=>{let N=0,z=!1,R={beginUpdate(){N++},endUpdate(){N--,N===0&&(E.reportChanges(),z&&(z=!1,D.call(H)))},handlePossibleChange(){},handleChange(){z=!0}};E.addObserver(R),E.reportChanges();let G={dispose(){E.removeObserver(R)}};return I instanceof g.DisposableStore?I.add(G):Array.isArray(I)&&I.push(G),G}}})(v||(t.Event=v={}));class o{static{this.all=new Set}static{this._idPool=0}constructor(k){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${k}_${o._idPool++}`,o.all.add(this)}start(k){this._stopWatch=new _.StopWatch,this.listenerCount=k}stop(){if(this._stopWatch){let k=this._stopWatch.elapsed();this.durations.push(k),this.elapsedOverall+=k,this.invocationCount+=1,this._stopWatch=void 0}}}t.EventProfiling=o;let i=-1;class S{static{this._idPool=1}constructor(k,P,W=(S._idPool++).toString(16).padStart(3,"0")){this._errorHandler=k,this.threshold=P,this.name=W,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(k,P){let W=this.threshold;if(W<=0||P<W)return;this._stacks||(this._stacks=new Map);let j=this._stacks.get(k.value)||0;if(this._stacks.set(k.value,j+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=0.5*W;let[q,F]=this.getMostFrequentStack(),b=`[${this.name}] potential listener LEAK detected, having ${P} listeners already. MOST frequent listener (${F}):`;console.warn(b),console.warn(q);let x=new m(b,q);this._errorHandler(x)}return()=>{let q=this._stacks.get(k.value)||0;this._stacks.set(k.value,q-1)}}getMostFrequentStack(){if(!this._stacks)return;let k,P=0;for(let[W,j]of this._stacks)(!k||P<j)&&(k=[W,j],P=j);return k}}class h{static create(){let k=Error();return new h(k.stack??"")}constructor(k){this.value=k}print(){console.warn(this.value.split(`
10
10
  `).slice(2).join(`
11
- `))}}class m extends Error{constructor(k,P){super(k),this.name="ListenerLeakError",this.stack=P}}t.ListenerLeakError=m;class u extends Error{constructor(k,P){super(k),this.name="ListenerRefusalError",this.stack=P}}t.ListenerRefusalError=u;let S=0;class C{constructor(k){this.value=k,this.id=S++}}class T{constructor(k){this._size=0,this._options=k,this._leakageMon=i>0||this._options?.leakWarningThreshold?new w(k?.onListenerError??l.onUnexpectedError,this._options?.leakWarningThreshold??i):void 0,this._perfMon=this._options?._profName?new o(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(k,P,W)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let x=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],L=new u(`${b}. HINT: Stack shows most frequent listener (${x[1]}-times)`,x[0]);return(this._options?.onListenerError||l.onUnexpectedError)(L),g.Disposable.None}if(this._disposed)return g.Disposable.None;P&&(k=k.bind(P));let z=new C(k),q;this._leakageMon&&this._size>=Math.ceil(0.2*this._leakageMon.threshold)&&(z.stack=h.create(),q=this._leakageMon.check(z.stack,this._size+1)),this._listeners?this._listeners instanceof C?(this._deliveryQueue??=new B,this._listeners=[this._listeners,z]):this._listeners.push(z):(this._options?.onWillAddFirstListener?.(this),this._listeners=z,this._options?.onDidAddFirstListener?.(this)),this._size++;let F=(0,g.toDisposable)(()=>{q?.(),this._removeListener(z)});return W instanceof g.DisposableStore?W.add(F):Array.isArray(W)&&W.push(F),F},this._event}_removeListener(k){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let P=this._listeners,W=P.indexOf(k);if(W===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,P[W]=void 0;let z=this._deliveryQueue.current===this;if(2*this._size<=P.length){let q=0;for(let F=0;F<P.length;F++)P[F]?P[q++]=P[F]:z&&(this._deliveryQueue.end--,q<this._deliveryQueue.i&&this._deliveryQueue.i--);P.length=q}}_deliver(k,P){if(!k)return;let W=this._options?.onListenerError||l.onUnexpectedError;if(W)try{k.value(P)}catch(z){W(z)}else k.value(P)}_deliverQueue(k){let P=k.current._listeners;for(;k.i<k.end;)this._deliver(P[k.i++],k.value);k.reset()}fire(k){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof C)this._deliver(this._listeners,k);else{let P=this._deliveryQueue;P.enqueue(this,k,this._listeners.length),this._deliverQueue(P)}this._perfMon?.stop()}hasListeners(){return this._size>0}}t.Emitter=T,t.createEventDeliveryQueue=()=>new B;class B{constructor(){this.i=-1,this.end=0}enqueue(k,P,W){this.i=0,this.end=W,this.current=k,this.value=P}reset(){this.i=this.end,this.current=void 0,this.value=void 0}}t.AsyncEmitter=class extends T{async fireAsync(k,P,W){if(this._listeners)for(this._asyncDeliveryQueue||(this._asyncDeliveryQueue=new d.LinkedList),((z,q)=>{if(z instanceof C)q(z);else for(let F=0;F<z.length;F++){let b=z[F];b&&q(b)}})(this._listeners,(z)=>this._asyncDeliveryQueue.push([z.value,k]));this._asyncDeliveryQueue.size>0&&!P.isCancellationRequested;){let[z,q]=this._asyncDeliveryQueue.shift(),F=[],b={...q,token:P,waitUntil:(x)=>{if(Object.isFrozen(F))throw Error("waitUntil can NOT be called asynchronous");W&&(x=W(x,z)),F.push(x)}};try{z(b)}catch(x){(0,l.onUnexpectedError)(x);continue}Object.freeze(F),await Promise.allSettled(F).then((x)=>{for(let L of x)L.status==="rejected"&&(0,l.onUnexpectedError)(L.reason)})}}};class O extends T{get isPaused(){return this._isPaused!==0}constructor(k){super(k),this._isPaused=0,this._eventQueue=new d.LinkedList,this._mergeFn=k?.merge}pause(){this._isPaused++}resume(){if(this._isPaused!==0&&--this._isPaused==0)if(this._mergeFn){if(this._eventQueue.size>0){let k=Array.from(this._eventQueue);this._eventQueue.clear(),super.fire(this._mergeFn(k))}}else for(;!this._isPaused&&this._eventQueue.size!==0;)super.fire(this._eventQueue.shift())}fire(k){this._size&&(this._isPaused!==0?this._eventQueue.push(k):super.fire(k))}}t.PauseableEmitter=O,t.DebounceEmitter=class extends O{constructor(k){super(k),this._delay=k.delay??100}fire(k){this._handle||(this.pause(),this._handle=setTimeout(()=>{this._handle=void 0,this.resume()},this._delay)),super.fire(k)}},t.MicrotaskEmitter=class extends T{constructor(k){super(k),this._queuedEvents=[],this._mergeFn=k?.merge}fire(k){this.hasListeners()&&(this._queuedEvents.push(k),this._queuedEvents.length===1&&queueMicrotask(()=>{this._mergeFn?super.fire(this._mergeFn(this._queuedEvents)):this._queuedEvents.forEach((P)=>super.fire(P)),this._queuedEvents=[]}))}};class A{constructor(){this.hasListeners=!1,this.events=[],this.emitter=new T({onWillAddFirstListener:()=>this.onFirstListenerAdd(),onDidRemoveLastListener:()=>this.onLastListenerRemove()})}get event(){return this.emitter.event}add(k){let P={event:k,listener:null};return this.events.push(P),this.hasListeners&&this.hook(P),(0,g.toDisposable)((0,p.createSingleCallFunction)(()=>{this.hasListeners&&this.unhook(P);let W=this.events.indexOf(P);this.events.splice(W,1)}))}onFirstListenerAdd(){this.hasListeners=!0,this.events.forEach((k)=>this.hook(k))}onLastListenerRemove(){this.hasListeners=!1,this.events.forEach((k)=>this.unhook(k))}hook(k){k.listener=k.event((P)=>this.emitter.fire(P))}unhook(k){k.listener?.dispose(),k.listener=null}dispose(){this.emitter.dispose();for(let k of this.events)k.listener?.dispose();this.events=[]}}t.EventMultiplexer=A,t.DynamicListEventMultiplexer=class{constructor(k,P,W,z){this._store=new g.DisposableStore;let q=this._store.add(new A),F=this._store.add(new g.DisposableMap);function b(x){F.set(x,q.add(z(x)))}for(let x of k)b(x);this._store.add(P((x)=>{b(x)})),this._store.add(W((x)=>{F.deleteAndDispose(x)})),this.event=q.event}dispose(){this._store.dispose()}},t.EventBufferer=class{constructor(){this.data=[]}wrapEvent(k,P,W){return(z,q,F)=>k((b)=>{let x=this.data[this.data.length-1];if(!P)return void(x?x.buffers.push(()=>z.call(q,b)):z.call(q,b));let L=x;L?(L.items??=[],L.items.push(b),L.buffers.length===0&&x.buffers.push(()=>{L.reducedResult??=W?L.items.reduce(P,W):L.items.reduce(P),z.call(q,L.reducedResult)})):z.call(q,P(W,b))},void 0,F)}bufferEvents(k){let P={buffers:[]};this.data.push(P);let W=k();return this.data.pop(),P.buffers.forEach((z)=>z()),W}},t.Relay=class{constructor(){this.listening=!1,this.inputEvent=v.None,this.inputEventListener=g.Disposable.None,this.emitter=new T({onDidAddFirstListener:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onDidRemoveLastListener:()=>{this.listening=!1,this.inputEventListener.dispose()}}),this.event=this.emitter.event}set input(k){this.inputEvent=k,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=k(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}},t.ValueWithChangeEvent=class{static const(k){return new M(k)}constructor(k){this._value=k,this._onDidChange=new T,this.onDidChange=this._onDidChange.event}get value(){return this._value}set value(k){k!==this._value&&(this._value=k,this._onDidChange.fire(void 0))}};class M{constructor(k){this.value=k,this.onDidChange=v.None}}},8841:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSingleCallFunction=function(n,l){let p=this,g,d=!1;return function(){if(d)return g;if(d=!0,l)try{g=n.apply(p,arguments)}finally{l()}else g=n.apply(p,arguments);return g}}},4218:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Iterable=void 0,function(l){function p(_){return _&&typeof _=="object"&&typeof _[Symbol.iterator]=="function"}l.is=p;let g=Object.freeze([]);function*d(_){yield _}l.empty=function(){return g},l.single=d,l.wrap=function(_){return p(_)?_:d(_)},l.from=function(_){return _||g},l.reverse=function*(_){for(let v=_.length-1;v>=0;v--)yield _[v]},l.isEmpty=function(_){return!_||_[Symbol.iterator]().next().done===!0},l.first=function(_){return _[Symbol.iterator]().next().value},l.some=function(_,v){let o=0;for(let i of _)if(v(i,o++))return!0;return!1},l.find=function(_,v){for(let o of _)if(v(o))return o},l.filter=function*(_,v){for(let o of _)v(o)&&(yield o)},l.map=function*(_,v){let o=0;for(let i of _)yield v(i,o++)},l.flatMap=function*(_,v){let o=0;for(let i of _)yield*v(i,o++)},l.concat=function*(..._){for(let v of _)yield*v},l.reduce=function(_,v,o){let i=o;for(let w of _)i=v(i,w);return i},l.slice=function*(_,v,o=_.length){for(v<0&&(v+=_.length),o<0?o+=_.length:o>_.length&&(o=_.length);v<o;v++)yield _[v]},l.consume=function(_,v=Number.POSITIVE_INFINITY){let o=[];if(v===0)return[o,_];let i=_[Symbol.iterator]();for(let w=0;w<v;w++){let h=i.next();if(h.done)return[o,l.empty()];o.push(h.value)}return[o,{[Symbol.iterator]:()=>i}]},l.asyncToArray=async function(_){let v=[];for await(let o of _)v.push(o);return Promise.resolve(v)}}(n||(t.Iterable=n={}))},7150:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DisposableMap=t.ImmortalReference=t.AsyncReferenceCollection=t.ReferenceCollection=t.SafeDisposable=t.RefCountedDisposable=t.MandatoryMutableDisposable=t.MutableDisposable=t.Disposable=t.DisposableStore=t.DisposableTracker=void 0,t.setDisposableTracker=function(A){v=A},t.trackDisposable=i,t.markAsDisposed=w,t.markAsSingleton=function(A){return v?.markAsSingleton(A),A},t.isDisposable=m,t.dispose=u,t.disposeIfDisposable=function(A){for(let M of A)m(M)&&M.dispose();return[]},t.combinedDisposable=function(...A){let M=S(()=>u(A));return function(k,P){if(v)for(let W of k)v.setParent(W,P)}(A,M),M},t.toDisposable=S,t.disposeOnReturn=function(A){let M=new C;try{A(M)}finally{M.dispose()}};let l=n(3058),p=n(9087),g=n(2608),d=n(8841),_=n(4218),v=null;class o{constructor(){this.livingDisposables=new Map}static{this.idx=0}getDisposableData(A){let M=this.livingDisposables.get(A);return M||(M={parent:null,source:null,isSingleton:!1,value:A,idx:o.idx++},this.livingDisposables.set(A,M)),M}trackDisposable(A){let M=this.getDisposableData(A);M.source||(M.source=Error().stack)}setParent(A,M){this.getDisposableData(A).parent=M}markAsDisposed(A){this.livingDisposables.delete(A)}markAsSingleton(A){this.getDisposableData(A).isSingleton=!0}getRootParent(A,M){let k=M.get(A);if(k)return k;let P=A.parent?this.getRootParent(this.getDisposableData(A.parent),M):A;return M.set(A,P),P}getTrackedDisposables(){let A=new Map;return[...this.livingDisposables.entries()].filter(([,M])=>M.source!==null&&!this.getRootParent(M,A).isSingleton).flatMap(([M])=>M)}computeLeakingDisposables(A=10,M){let k;if(M)k=M;else{let F=new Map,b=[...this.livingDisposables.values()].filter((L)=>L.source!==null&&!this.getRootParent(L,F).isSingleton);if(b.length===0)return;let x=new Set(b.map((L)=>L.value));if(k=b.filter((L)=>!(L.parent&&x.has(L.parent))),k.length===0)throw Error("There are cyclic diposable chains!")}if(!k)return;function P(F){let b=F.source.split(`
11
+ `))}}class m extends Error{constructor(k,P){super(k),this.name="ListenerLeakError",this.stack=P}}t.ListenerLeakError=m;class u extends Error{constructor(k,P){super(k),this.name="ListenerRefusalError",this.stack=P}}t.ListenerRefusalError=u;let w=0;class C{constructor(k){this.value=k,this.id=w++}}class T{constructor(k){this._size=0,this._options=k,this._leakageMon=i>0||this._options?.leakWarningThreshold?new S(k?.onListenerError??l.onUnexpectedError,this._options?.leakWarningThreshold??i):void 0,this._perfMon=this._options?._profName?new o(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(k,P,W)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let x=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],L=new u(`${b}. HINT: Stack shows most frequent listener (${x[1]}-times)`,x[0]);return(this._options?.onListenerError||l.onUnexpectedError)(L),g.Disposable.None}if(this._disposed)return g.Disposable.None;P&&(k=k.bind(P));let j=new C(k),q;this._leakageMon&&this._size>=Math.ceil(0.2*this._leakageMon.threshold)&&(j.stack=h.create(),q=this._leakageMon.check(j.stack,this._size+1)),this._listeners?this._listeners instanceof C?(this._deliveryQueue??=new B,this._listeners=[this._listeners,j]):this._listeners.push(j):(this._options?.onWillAddFirstListener?.(this),this._listeners=j,this._options?.onDidAddFirstListener?.(this)),this._size++;let F=(0,g.toDisposable)(()=>{q?.(),this._removeListener(j)});return W instanceof g.DisposableStore?W.add(F):Array.isArray(W)&&W.push(F),F},this._event}_removeListener(k){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1)return this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),void(this._size=0);let P=this._listeners,W=P.indexOf(k);if(W===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,P[W]=void 0;let j=this._deliveryQueue.current===this;if(2*this._size<=P.length){let q=0;for(let F=0;F<P.length;F++)P[F]?P[q++]=P[F]:j&&(this._deliveryQueue.end--,q<this._deliveryQueue.i&&this._deliveryQueue.i--);P.length=q}}_deliver(k,P){if(!k)return;let W=this._options?.onListenerError||l.onUnexpectedError;if(W)try{k.value(P)}catch(j){W(j)}else k.value(P)}_deliverQueue(k){let P=k.current._listeners;for(;k.i<k.end;)this._deliver(P[k.i++],k.value);k.reset()}fire(k){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof C)this._deliver(this._listeners,k);else{let P=this._deliveryQueue;P.enqueue(this,k,this._listeners.length),this._deliverQueue(P)}this._perfMon?.stop()}hasListeners(){return this._size>0}}t.Emitter=T,t.createEventDeliveryQueue=()=>new B;class B{constructor(){this.i=-1,this.end=0}enqueue(k,P,W){this.i=0,this.end=W,this.current=k,this.value=P}reset(){this.i=this.end,this.current=void 0,this.value=void 0}}t.AsyncEmitter=class extends T{async fireAsync(k,P,W){if(this._listeners)for(this._asyncDeliveryQueue||(this._asyncDeliveryQueue=new d.LinkedList),((j,q)=>{if(j instanceof C)q(j);else for(let F=0;F<j.length;F++){let b=j[F];b&&q(b)}})(this._listeners,(j)=>this._asyncDeliveryQueue.push([j.value,k]));this._asyncDeliveryQueue.size>0&&!P.isCancellationRequested;){let[j,q]=this._asyncDeliveryQueue.shift(),F=[],b={...q,token:P,waitUntil:(x)=>{if(Object.isFrozen(F))throw Error("waitUntil can NOT be called asynchronous");W&&(x=W(x,j)),F.push(x)}};try{j(b)}catch(x){(0,l.onUnexpectedError)(x);continue}Object.freeze(F),await Promise.allSettled(F).then((x)=>{for(let L of x)L.status==="rejected"&&(0,l.onUnexpectedError)(L.reason)})}}};class O extends T{get isPaused(){return this._isPaused!==0}constructor(k){super(k),this._isPaused=0,this._eventQueue=new d.LinkedList,this._mergeFn=k?.merge}pause(){this._isPaused++}resume(){if(this._isPaused!==0&&--this._isPaused==0)if(this._mergeFn){if(this._eventQueue.size>0){let k=Array.from(this._eventQueue);this._eventQueue.clear(),super.fire(this._mergeFn(k))}}else for(;!this._isPaused&&this._eventQueue.size!==0;)super.fire(this._eventQueue.shift())}fire(k){this._size&&(this._isPaused!==0?this._eventQueue.push(k):super.fire(k))}}t.PauseableEmitter=O,t.DebounceEmitter=class extends O{constructor(k){super(k),this._delay=k.delay??100}fire(k){this._handle||(this.pause(),this._handle=setTimeout(()=>{this._handle=void 0,this.resume()},this._delay)),super.fire(k)}},t.MicrotaskEmitter=class extends T{constructor(k){super(k),this._queuedEvents=[],this._mergeFn=k?.merge}fire(k){this.hasListeners()&&(this._queuedEvents.push(k),this._queuedEvents.length===1&&queueMicrotask(()=>{this._mergeFn?super.fire(this._mergeFn(this._queuedEvents)):this._queuedEvents.forEach((P)=>super.fire(P)),this._queuedEvents=[]}))}};class A{constructor(){this.hasListeners=!1,this.events=[],this.emitter=new T({onWillAddFirstListener:()=>this.onFirstListenerAdd(),onDidRemoveLastListener:()=>this.onLastListenerRemove()})}get event(){return this.emitter.event}add(k){let P={event:k,listener:null};return this.events.push(P),this.hasListeners&&this.hook(P),(0,g.toDisposable)((0,p.createSingleCallFunction)(()=>{this.hasListeners&&this.unhook(P);let W=this.events.indexOf(P);this.events.splice(W,1)}))}onFirstListenerAdd(){this.hasListeners=!0,this.events.forEach((k)=>this.hook(k))}onLastListenerRemove(){this.hasListeners=!1,this.events.forEach((k)=>this.unhook(k))}hook(k){k.listener=k.event((P)=>this.emitter.fire(P))}unhook(k){k.listener?.dispose(),k.listener=null}dispose(){this.emitter.dispose();for(let k of this.events)k.listener?.dispose();this.events=[]}}t.EventMultiplexer=A,t.DynamicListEventMultiplexer=class{constructor(k,P,W,j){this._store=new g.DisposableStore;let q=this._store.add(new A),F=this._store.add(new g.DisposableMap);function b(x){F.set(x,q.add(j(x)))}for(let x of k)b(x);this._store.add(P((x)=>{b(x)})),this._store.add(W((x)=>{F.deleteAndDispose(x)})),this.event=q.event}dispose(){this._store.dispose()}},t.EventBufferer=class{constructor(){this.data=[]}wrapEvent(k,P,W){return(j,q,F)=>k((b)=>{let x=this.data[this.data.length-1];if(!P)return void(x?x.buffers.push(()=>j.call(q,b)):j.call(q,b));let L=x;L?(L.items??=[],L.items.push(b),L.buffers.length===0&&x.buffers.push(()=>{L.reducedResult??=W?L.items.reduce(P,W):L.items.reduce(P),j.call(q,L.reducedResult)})):j.call(q,P(W,b))},void 0,F)}bufferEvents(k){let P={buffers:[]};this.data.push(P);let W=k();return this.data.pop(),P.buffers.forEach((j)=>j()),W}},t.Relay=class{constructor(){this.listening=!1,this.inputEvent=v.None,this.inputEventListener=g.Disposable.None,this.emitter=new T({onDidAddFirstListener:()=>{this.listening=!0,this.inputEventListener=this.inputEvent(this.emitter.fire,this.emitter)},onDidRemoveLastListener:()=>{this.listening=!1,this.inputEventListener.dispose()}}),this.event=this.emitter.event}set input(k){this.inputEvent=k,this.listening&&(this.inputEventListener.dispose(),this.inputEventListener=k(this.emitter.fire,this.emitter))}dispose(){this.inputEventListener.dispose(),this.emitter.dispose()}},t.ValueWithChangeEvent=class{static const(k){return new M(k)}constructor(k){this._value=k,this._onDidChange=new T,this.onDidChange=this._onDidChange.event}get value(){return this._value}set value(k){k!==this._value&&(this._value=k,this._onDidChange.fire(void 0))}};class M{constructor(k){this.value=k,this.onDidChange=v.None}}},8841:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSingleCallFunction=function(n,l){let p=this,g,d=!1;return function(){if(d)return g;if(d=!0,l)try{g=n.apply(p,arguments)}finally{l()}else g=n.apply(p,arguments);return g}}},4218:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Iterable=void 0,function(l){function p(_){return _&&typeof _=="object"&&typeof _[Symbol.iterator]=="function"}l.is=p;let g=Object.freeze([]);function*d(_){yield _}l.empty=function(){return g},l.single=d,l.wrap=function(_){return p(_)?_:d(_)},l.from=function(_){return _||g},l.reverse=function*(_){for(let v=_.length-1;v>=0;v--)yield _[v]},l.isEmpty=function(_){return!_||_[Symbol.iterator]().next().done===!0},l.first=function(_){return _[Symbol.iterator]().next().value},l.some=function(_,v){let o=0;for(let i of _)if(v(i,o++))return!0;return!1},l.find=function(_,v){for(let o of _)if(v(o))return o},l.filter=function*(_,v){for(let o of _)v(o)&&(yield o)},l.map=function*(_,v){let o=0;for(let i of _)yield v(i,o++)},l.flatMap=function*(_,v){let o=0;for(let i of _)yield*v(i,o++)},l.concat=function*(..._){for(let v of _)yield*v},l.reduce=function(_,v,o){let i=o;for(let S of _)i=v(i,S);return i},l.slice=function*(_,v,o=_.length){for(v<0&&(v+=_.length),o<0?o+=_.length:o>_.length&&(o=_.length);v<o;v++)yield _[v]},l.consume=function(_,v=Number.POSITIVE_INFINITY){let o=[];if(v===0)return[o,_];let i=_[Symbol.iterator]();for(let S=0;S<v;S++){let h=i.next();if(h.done)return[o,l.empty()];o.push(h.value)}return[o,{[Symbol.iterator]:()=>i}]},l.asyncToArray=async function(_){let v=[];for await(let o of _)v.push(o);return Promise.resolve(v)}}(n||(t.Iterable=n={}))},7150:(y,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DisposableMap=t.ImmortalReference=t.AsyncReferenceCollection=t.ReferenceCollection=t.SafeDisposable=t.RefCountedDisposable=t.MandatoryMutableDisposable=t.MutableDisposable=t.Disposable=t.DisposableStore=t.DisposableTracker=void 0,t.setDisposableTracker=function(A){v=A},t.trackDisposable=i,t.markAsDisposed=S,t.markAsSingleton=function(A){return v?.markAsSingleton(A),A},t.isDisposable=m,t.dispose=u,t.disposeIfDisposable=function(A){for(let M of A)m(M)&&M.dispose();return[]},t.combinedDisposable=function(...A){let M=w(()=>u(A));return function(k,P){if(v)for(let W of k)v.setParent(W,P)}(A,M),M},t.toDisposable=w,t.disposeOnReturn=function(A){let M=new C;try{A(M)}finally{M.dispose()}};let l=n(3058),p=n(9087),g=n(2608),d=n(8841),_=n(4218),v=null;class o{constructor(){this.livingDisposables=new Map}static{this.idx=0}getDisposableData(A){let M=this.livingDisposables.get(A);return M||(M={parent:null,source:null,isSingleton:!1,value:A,idx:o.idx++},this.livingDisposables.set(A,M)),M}trackDisposable(A){let M=this.getDisposableData(A);M.source||(M.source=Error().stack)}setParent(A,M){this.getDisposableData(A).parent=M}markAsDisposed(A){this.livingDisposables.delete(A)}markAsSingleton(A){this.getDisposableData(A).isSingleton=!0}getRootParent(A,M){let k=M.get(A);if(k)return k;let P=A.parent?this.getRootParent(this.getDisposableData(A.parent),M):A;return M.set(A,P),P}getTrackedDisposables(){let A=new Map;return[...this.livingDisposables.entries()].filter(([,M])=>M.source!==null&&!this.getRootParent(M,A).isSingleton).flatMap(([M])=>M)}computeLeakingDisposables(A=10,M){let k;if(M)k=M;else{let F=new Map,b=[...this.livingDisposables.values()].filter((L)=>L.source!==null&&!this.getRootParent(L,F).isSingleton);if(b.length===0)return;let x=new Set(b.map((L)=>L.value));if(k=b.filter((L)=>!(L.parent&&x.has(L.parent))),k.length===0)throw Error("There are cyclic diposable chains!")}if(!k)return;function P(F){let b=F.source.split(`
12
12
  `).map((x)=>x.trim().replace("at ","")).filter((x)=>x!=="");return function(x,L){for(;x.length>0&&L.some((E)=>typeof E=="string"?E===x[0]:x[0].match(E));)x.shift()}(b,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),b.reverse()}let W=new g.SetMap;for(let F of k){let b=P(F);for(let x=0;x<=b.length;x++)W.add(b.slice(0,x).join(`
13
- `),F)}k.sort((0,l.compareBy)((F)=>F.idx,l.numberComparator));let z="",q=0;for(let F of k.slice(0,A)){q++;let b=P(F),x=[];for(let L=0;L<b.length;L++){let E=b[L];E=`(shared with ${W.get(b.slice(0,L+1).join(`
13
+ `),F)}k.sort((0,l.compareBy)((F)=>F.idx,l.numberComparator));let j="",q=0;for(let F of k.slice(0,A)){q++;let b=P(F),x=[];for(let L=0;L<b.length;L++){let E=b[L];E=`(shared with ${W.get(b.slice(0,L+1).join(`
14
14
  `)).size}/${k.length} leaks) at ${E}`;let D=W.get(b.slice(0,L).join(`
15
- `)),H=(0,p.groupBy)([...D].map((I)=>P(I)[L]),(I)=>I);delete H[b[L]];for(let[I,N]of Object.entries(H))x.unshift(` - stacktraces of ${N.length} other leaks continue with ${I}`);x.unshift(E)}z+=`
15
+ `)),H=(0,p.groupBy)([...D].map((I)=>P(I)[L]),(I)=>I);delete H[b[L]];for(let[I,N]of Object.entries(H))x.unshift(` - stacktraces of ${N.length} other leaks continue with ${I}`);x.unshift(E)}j+=`
16
16
 
17
17
 
18
18
  ==================== Leaking disposable ${q}/${k.length}: ${F.value.constructor.name} ====================
@@ -20,23 +20,23 @@ ${x.join(`
20
20
  `)}
21
21
  ============================================================
22
22
 
23
- `}return k.length>A&&(z+=`
23
+ `}return k.length>A&&(j+=`
24
24
 
25
25
 
26
26
  ... and ${k.length-A} more leaking disposables
27
27
 
28
- `),{leaks:k,details:z}}}function i(A){return v?.trackDisposable(A),A}function w(A){v?.markAsDisposed(A)}function h(A,M){v?.setParent(A,M)}function m(A){return typeof A=="object"&&A!==null&&typeof A.dispose=="function"&&A.dispose.length===0}function u(A){if(_.Iterable.is(A)){let M=[];for(let k of A)if(k)try{k.dispose()}catch(P){M.push(P)}if(M.length===1)throw M[0];if(M.length>1)throw AggregateError(M,"Encountered errors while disposing of store");return Array.isArray(A)?[]:A}if(A)return A.dispose(),A}function S(A){let M=i({dispose:(0,d.createSingleCallFunction)(()=>{w(M),A()})});return M}t.DisposableTracker=o;class C{static{this.DISABLE_DISPOSED_WARNING=!1}constructor(){this._toDispose=new Set,this._isDisposed=!1,i(this)}dispose(){this._isDisposed||(w(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{u(this._toDispose)}finally{this._toDispose.clear()}}add(A){if(!A)return A;if(A===this)throw Error("Cannot register a disposable on itself!");return h(A,this),this._isDisposed?C.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(A),A}delete(A){if(A){if(A===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(A),A.dispose()}}deleteAndLeak(A){A&&this._toDispose.has(A)&&(this._toDispose.delete(A),h(A,null))}}t.DisposableStore=C;class T{static{this.None=Object.freeze({dispose(){}})}constructor(){this._store=new C,i(this),h(this._store,this)}dispose(){w(this),this._store.dispose()}_register(A){if(A===this)throw Error("Cannot register a disposable on itself!");return this._store.add(A)}}t.Disposable=T;class B{constructor(){this._isDisposed=!1,i(this)}get value(){return this._isDisposed?void 0:this._value}set value(A){this._isDisposed||A===this._value||(this._value?.dispose(),A&&h(A,this),this._value=A)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,w(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let A=this._value;return this._value=void 0,A&&h(A,null),A}}t.MutableDisposable=B,t.MandatoryMutableDisposable=class{constructor(A){this._disposable=new B,this._isDisposed=!1,this._disposable.value=A}get value(){return this._disposable.value}set value(A){this._isDisposed||A===this._disposable.value||(this._disposable.value=A)}dispose(){this._isDisposed=!0,this._disposable.dispose()}},t.RefCountedDisposable=class{constructor(A){this._disposable=A,this._counter=1}acquire(){return this._counter++,this}release(){return--this._counter==0&&this._disposable.dispose(),this}},t.SafeDisposable=class{constructor(){this.dispose=()=>{},this.unset=()=>{},this.isset=()=>!1,i(this)}set(A){let M=A;return this.unset=()=>M=void 0,this.isset=()=>M!==void 0,this.dispose=()=>{M&&(M(),M=void 0,w(this))},this}},t.ReferenceCollection=class{constructor(){this.references=new Map}acquire(A,...M){let k=this.references.get(A);k||(k={counter:0,object:this.createReferencedObject(A,...M)},this.references.set(A,k));let{object:P}=k,W=(0,d.createSingleCallFunction)(()=>{--k.counter==0&&(this.destroyReferencedObject(A,k.object),this.references.delete(A))});return k.counter++,{object:P,dispose:W}}},t.AsyncReferenceCollection=class{constructor(A){this.referenceCollection=A}async acquire(A,...M){let k=this.referenceCollection.acquire(A,...M);try{return{object:await k.object,dispose:()=>k.dispose()}}catch(P){throw k.dispose(),P}}},t.ImmortalReference=class{constructor(A){this.object=A}dispose(){}};class O{constructor(){this._store=new Map,this._isDisposed=!1,i(this)}dispose(){w(this),this._isDisposed=!0,this.clearAndDisposeAll()}clearAndDisposeAll(){if(this._store.size)try{u(this._store.values())}finally{this._store.clear()}}has(A){return this._store.has(A)}get size(){return this._store.size}get(A){return this._store.get(A)}set(A,M,k=!1){this._isDisposed&&console.warn(Error("Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!").stack),k||this._store.get(A)?.dispose(),this._store.set(A,M)}deleteAndDispose(A){this._store.get(A)?.dispose(),this._store.delete(A)}deleteAndLeak(A){let M=this._store.get(A);return this._store.delete(A),M}keys(){return this._store.keys()}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}}t.DisposableMap=O},6317:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkedList=void 0;class n{static{this.Undefined=new n(void 0)}constructor(p){this.element=p,this.next=n.Undefined,this.prev=n.Undefined}}class l{constructor(){this._first=n.Undefined,this._last=n.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===n.Undefined}clear(){let p=this._first;for(;p!==n.Undefined;){let g=p.next;p.prev=n.Undefined,p.next=n.Undefined,p=g}this._first=n.Undefined,this._last=n.Undefined,this._size=0}unshift(p){return this._insert(p,!1)}push(p){return this._insert(p,!0)}_insert(p,g){let d=new n(p);if(this._first===n.Undefined)this._first=d,this._last=d;else if(g){let v=this._last;this._last=d,d.prev=v,v.next=d}else{let v=this._first;this._first=d,d.next=v,v.prev=d}this._size+=1;let _=!1;return()=>{_||(_=!0,this._remove(d))}}shift(){if(this._first!==n.Undefined){let p=this._first.element;return this._remove(this._first),p}}pop(){if(this._last!==n.Undefined){let p=this._last.element;return this._remove(this._last),p}}_remove(p){if(p.prev!==n.Undefined&&p.next!==n.Undefined){let g=p.prev;g.next=p.next,p.next.prev=g}else p.prev===n.Undefined&&p.next===n.Undefined?(this._first=n.Undefined,this._last=n.Undefined):p.next===n.Undefined?(this._last=this._last.prev,this._last.next=n.Undefined):p.prev===n.Undefined&&(this._first=this._first.next,this._first.prev=n.Undefined);this._size-=1}*[Symbol.iterator](){let p=this._first;for(;p!==n.Undefined;)yield p.element,p=p.next}}t.LinkedList=l},2608:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SetMap=t.BidirectionalMap=t.CounterSet=t.Touch=void 0,t.getOrSet=function(l,p,g){let d=l.get(p);return d===void 0&&(d=g,l.set(p,d)),d},t.mapToString=function(l){let p=[];return l.forEach((g,d)=>{p.push(`${d} => ${g}`)}),`Map(${l.size}) {${p.join(", ")}}`},t.setToString=function(l){let p=[];return l.forEach((g)=>{p.push(g)}),`Set(${l.size}) {${p.join(", ")}}`},t.mapsStrictEqualIgnoreOrder=function(l,p){if(l===p)return!0;if(l.size!==p.size)return!1;for(let[g,d]of l)if(!p.has(g)||p.get(g)!==d)return!1;for(let[g]of p)if(!l.has(g))return!1;return!0},function(l){l[l.None=0]="None",l[l.AsOld=1]="AsOld",l[l.AsNew=2]="AsNew"}(n||(t.Touch=n={})),t.CounterSet=class{constructor(){this.map=new Map}add(l){return this.map.set(l,(this.map.get(l)||0)+1),this}delete(l){let p=this.map.get(l)||0;return p!==0&&(p--,p===0?this.map.delete(l):this.map.set(l,p),!0)}has(l){return this.map.has(l)}},t.BidirectionalMap=class{constructor(l){if(this._m1=new Map,this._m2=new Map,l)for(let[p,g]of l)this.set(p,g)}clear(){this._m1.clear(),this._m2.clear()}set(l,p){this._m1.set(l,p),this._m2.set(p,l)}get(l){return this._m1.get(l)}getKey(l){return this._m2.get(l)}delete(l){let p=this._m1.get(l);return p!==void 0&&(this._m1.delete(l),this._m2.delete(p),!0)}forEach(l,p){this._m1.forEach((g,d)=>{l.call(p,g,d,this)})}keys(){return this._m1.keys()}values(){return this._m1.values()}},t.SetMap=class{constructor(){this.map=new Map}add(l,p){let g=this.map.get(l);g||(g=new Set,this.map.set(l,g)),g.add(p)}delete(l,p){let g=this.map.get(l);g&&(g.delete(p),g.size===0&&this.map.delete(l))}forEach(l,p){let g=this.map.get(l);g&&g.forEach(p)}get(l){return this.map.get(l)||new Set}}},9725:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StopWatch=void 0;let n=globalThis.performance&&typeof globalThis.performance.now=="function";class l{static create(p){return new l(p)}constructor(p){this._now=n&&p===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}}t.StopWatch=l}},r={};function s(y){var t=r[y];if(t!==void 0)return t.exports;var n=r[y]={exports:{}};return e[y].call(n.exports,n,n.exports,s),n.exports}var c={};(()=>{var y=c;Object.defineProperty(y,"__esModule",{value:!0}),y.Terminal=void 0;let t=s(5101),n=s(6097),l=s(4335),p=s(5856),g=s(3027),d=s(7150),_=["cols","rows"];class v extends d.Disposable{constructor(o){super(),this._core=this._register(new p.Terminal(o)),this._addonManager=this._register(new g.AddonManager),this._publicOptions={...this._core.options};let i=(h)=>this._core.options[h],w=(h,m)=>{this._checkReadonlyOptions(h),this._core.options[h]=m};for(let h in this._core.options){Object.defineProperty(this._publicOptions,h,{get:()=>this._core.options[h],set:(u)=>{this._checkReadonlyOptions(h),this._core.options[h]=u}});let m={get:i.bind(this,h),set:w.bind(this,h)};Object.defineProperty(this._publicOptions,h,m)}}_checkReadonlyOptions(o){if(_.includes(o))throw Error(`Option "${o}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.options.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onLineFeed(){return this._core.onLineFeed}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get parser(){return this._checkProposedApi(),this._parser||(this._parser=new n.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._checkProposedApi(),this._buffer||(this._buffer=this._register(new t.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let o=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:o.applicationCursorKeys,applicationKeypadMode:o.applicationKeypad,bracketedPasteMode:o.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:o.origin,reverseWraparoundMode:o.reverseWraparound,sendFocusMode:o.sendFocus,synchronizedOutputMode:o.synchronizedOutput,wraparoundMode:o.wraparound}}get options(){return this._publicOptions}set options(o){for(let i in o)this._publicOptions[i]=o[i]}input(o,i=!0){this._core.input(o,i)}resize(o,i){this._verifyIntegers(o,i),this._core.resize(o,i)}registerMarker(o=0){return this._checkProposedApi(),this._verifyIntegers(o),this._core.addMarker(o)}addMarker(o){return this.registerMarker(o)}dispose(){super.dispose()}scrollLines(o){this._verifyIntegers(o),this._core.scrollLines(o)}scrollPages(o){this._verifyIntegers(o),this._core.scrollPages(o)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(o){this._verifyIntegers(o),this._core.scrollToLine(o)}clear(){this._core.clear()}write(o,i){this._core.write(o,i)}writeln(o,i){this._core.write(o),this._core.write(`\r
29
- `,i)}reset(){this._core.reset()}loadAddon(o){this._addonManager.loadAddon(this,o)}_verifyIntegers(...o){for(let i of o)if(i===1/0||isNaN(i)||i%1!=0)throw Error("This API only accepts integers")}}y.Terminal=v})();var f=Rr;for(var a in c)f[a]=c[a];c.__esModule&&Object.defineProperty(f,"__esModule",{value:!0})})()});if(!Bun.semver.satisfies(Bun.version,">=1.4.0"))console.error(`Accompany: Bun ${"1.4.0"} \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\uFF08\u3044\u307E\u306E Bun: ${Bun.version}\uFF09\u3002
30
- `+"`bun upgrade` \u3067 Bun \u3092\u4E0A\u3052\u308B\u304B\u3001Bun \u306E\u8981\u3089\u306A\u3044\u5B9F\u884C\u30D5\u30A1\u30A4\u30EB\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044: "+"https://github.com/itsuki-yamada/accompany/releases"),process.exit(1);var De=(e)=>("server"in e.env)?e.env.server:e.env;var nt=(e)=>{let r=e.split("/");if(r[0]==="")r.shift();return r},Vt=(e)=>{let{groups:r,path:s}=Ds(e),c=nt(s);return Ms(c,r)},Ds=(e)=>{let r=[];return e=e.replace(/\{[^}]+\}/g,(s,c)=>{let f=`@${c}`;return r.push([f,s]),f}),{groups:r,path:e}},Ms=(e,r)=>{for(let s=r.length-1;s>=0;s--){let[c]=r[s];for(let f=e.length-1;f>=0;f--)if(e[f].includes(c)){e[f]=e[f].replace(c,r[s][1]);break}}return e},Me={},Qt=(e,r)=>{if(e==="*")return"*";let s=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(s){let c=`${e}#${r}`;if(!Me[c])if(s[2])Me[c]=r&&r[0]!==":"&&r[0]!=="*"?[c,s[1],new RegExp(`^${s[2]}(?=/${r})`)]:[e,s[1],new RegExp(`^${s[2]}$`)];else Me[c]=[e,s[1],!0];return Me[c]}return null},Kt=(e,r)=>{try{return r(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,(s)=>{try{return r(s)}catch{return s}})}},Yt=(e)=>Kt(e,decodeURI),ot=(e)=>{let r=e.url,s=r.indexOf("/",r.indexOf(":")+4),c=s;for(;c<r.length;c++){let f=r.charCodeAt(c);if(f===37){let a=r.indexOf("?",c),y=r.indexOf("#",c),t=a===-1?y===-1?void 0:y:y===-1?a:Math.min(a,y),n=r.slice(s,t);return Yt(n.includes("%25")?n.replace(/%25/g,"%2525"):n)}else if(f===63||f===35)break}return r.slice(s,c)};var Jt=(e)=>{let r=ot(e);return r.length>1&&r.at(-1)==="/"?r.slice(0,-1):r},fe=(e,r,...s)=>{if(s.length)r=fe(r,...s);return`${e?.[0]==="/"?"":"/"}${e}${r==="/"?"":`${e?.at(-1)==="/"?"":"/"}${r?.[0]==="/"?r.slice(1):r}`}`},Pe=(e)=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let r=e.split("/"),s=[],c="";return r.forEach((f)=>{if(f!==""&&!/\:/.test(f))c+="/"+f;else if(/\:/.test(f))if(f.charCodeAt(f.length-1)===63){if(s.length===0&&c==="")s.push("/");else s.push(c);let a=f.slice(0,-1);c+="/"+a,s.push(c)}else c+="/"+f}),s.filter((f,a,y)=>y.indexOf(f)===a)},Oe=(e)=>e.indexOf("%")!==-1?Kt(e,Ps):e,it=(e)=>{if(e.indexOf("+")!==-1)e=e.replace(/\+/g," ");return Oe(e)},Zt=(e,r,s)=>{let c=e.indexOf("#",8);if(c!==-1)e=e.slice(0,c);let f;if(!s&&r&&r.indexOf("%")===-1&&r.indexOf("+")===-1){let t=e.indexOf("?",8),n=t;if(n===-1)return;if(!e.startsWith(r,n+1))n=e.indexOf(`&${r}`,n+1);while(n!==-1){let l=e.charCodeAt(n+r.length+1);if(l===61||l===38||isNaN(l)){if(n>t&&/(?:^|&)[^=&]*[%+]/.test(e.slice(t+1,n)))break;if(l===61){let p=n+r.length+2,g=e.indexOf("&",p);return it(e.slice(p,g===-1?void 0:g))}return""}n=e.indexOf(`&${r}`,n+1)}if(f=/[%+]/.test(e),!f)return}let a=Object.create(null);f??=/[%+]/.test(e);let y=e.indexOf("?",8);while(y!==-1){let t=e.indexOf("&",y+1),n=e.indexOf("=",y);if(n>t&&t!==-1)n=-1;let l=e.slice(y+1,n===-1?t===-1?void 0:t:n);if(f)l=it(l);if(y=t,l==="")continue;let p;if(n===-1)p="";else if(p=e.slice(n+1,t===-1?void 0:t),f)p=it(p);if(s){if(!(a[l]&&Array.isArray(a[l])))a[l]=[];a[l].push(p)}else a[l]??=p}return r?a[r]:a},er=Zt,tr=(e,r)=>Zt(e,r,!0),Ps=decodeURIComponent;var Os={br:".br",zstd:".zst",gzip:".gz"},Bn=Object.keys(Os);var rr=["get","post","put","delete","options","patch","query"],Ie="Can not add a route since the matcher is already built.",He=class extends Error{};var at="__COMPOSED_HANDLER";var sr="x-hono-disable-ssg",Zn=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[sr]:"true"}})}catch{return null}})();var ir={Stringify:1,BeforeStream:2,Stream:3},nr=(e,r)=>{let s=new String(e);return s.isEscaped=!0,s.callbacks=r,s};var ct=async(e,r,s,c,f)=>{if(typeof e==="object"&&!(e instanceof String)){if(!(e instanceof Promise))e=e.toString();if(e instanceof Promise)e=await e}let a=e.callbacks;if(!a?.length)return Promise.resolve(e);if(f)f[0]+=e;else f=[e];let y=Promise.all(a.map((t)=>t({phase:r,buffer:f,context:c}))).then((t)=>Promise.all(t.filter(Boolean).map((n)=>ct(n,r,!1,c,f))).then(()=>f[0]));if(s)return nr(await y,a);else return y};var{write:jo}=Bun;var or=class{#e;constructor(e){this.#e=e,this.raw=e.raw,this.url=e.url?new URL(e.url):null,this.protocol=e.protocol??null}send(e,r){this.#e.send(e,r??{})}raw;binaryType="arraybuffer";get readyState(){return this.#e.readyState}url;protocol;close(e,r){this.#e.close(e,r)}},ar=(e)=>new MessageEvent("message",{data:e}),cr=(e)=>(...r)=>{if(typeof r[0]==="function"){let[s,c]=r;return async function(a,y){let t=await e(a,await s(a),c);if(t)return t;await y()}}else{let[s,c,f]=r;return(async()=>{let a=await e(s,c,f);if(!a)throw Error("Failed to upgrade WebSocket");return a})()}};var ht=(e)=>new or({send:(r,s)=>{e.send(r,s?.compress)},raw:e,readyState:e.readyState,url:e.data.url,protocol:e.data.protocol,close(r,s){e.close(r,s)}}),Ne=cr((e,r)=>{let s=De(e);if(!s)throw TypeError("env has to include the 2nd argument of fetch.");if(s.upgrade(e.req.raw,{data:{events:r,url:new URL(e.req.url),protocol:e.req.header("sec-websocket-protocol")?.split(",")[0]?.trim()??""}}))return new Response(null)}),lt={open(e){let r=e.data.events;if(r.onOpen)r.onOpen(new Event("open"),ht(e))},close(e,r,s){let c=e.data.events;if(c.onClose)c.onClose(new CloseEvent("close",{code:r,reason:s}),ht(e))},message(e,r){let s=e.data.events;if(s.onMessage){let c=typeof r==="string"?r:r.buffer;s.onMessage(ar(c),ht(e))}}};var ut=class extends Error{res;status;constructor(e=500,r){super(r?.message,{cause:r?.cause});this.res=r?.res,this.status=e}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};var hr=Symbol();var lr=(e,r)=>new Response(e,{headers:{"Content-Type":r.replace(/^[^;]+/,(s)=>s.toLowerCase())}}).formData();var Fs=1e4,Fe=(e)=>("headers"in e),dr=async(e,r=Object.create(null))=>{let{all:s=!1,dot:c=!1}=r,f=(Fe(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(f==="multipart/form-data"||f==="application/x-www-form-urlencoded")return Ws(e,{all:s,dot:c});return{}};async function Ws(e,r){if(!Fe(e)&&e.bodyCache.formData)return ur(await e.bodyCache.formData,r);let s=Fe(e)?e.headers:e.raw.headers,c=await e.arrayBuffer(),f=lr(c,s.get("Content-Type")||"");if(!Fe(e))e.bodyCache.formData=f;let a=await f;if(a)return ur(a,r);return{}}function ur(e,r){let s=Object.create(null),c={count:0};if(e.forEach((f,a)=>{if(!(r.all||a.endsWith("[]")))s[a]=f;else Us(s,a,f)}),r.dot)Object.entries(s).forEach(([f,a])=>{if(f.includes("."))$s(s,f,a,c),delete s[f]});return s}var Us=(e,r,s)=>{if(e[r]!==void 0)if(Array.isArray(e[r]))e[r].push(s);else e[r]=[e[r],s];else if(!r.endsWith("[]"))e[r]=s;else e[r]=[s]},$s=(e,r,s,c)=>{if(/(?:^|\.)__proto__\./.test(r))return;let f=e,a=r.split(".",34);if(a.length>33)fr();a.forEach((y,t)=>{if(t===a.length-1)f[y]=s;else{if(!f[y]||typeof f[y]!=="object"||Array.isArray(f[y])||f[y]instanceof File){if(c.count++>=Fs)fr();f[y]=Object.create(null)}f=f[y]}})},fr=()=>{throw Error("Nesting limit exceeded")};var pr=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,r="/",s=[[]]){this.raw=e,this.path=r,this.#t=s}param(e){return e?this.#r(e):this.#n()}#r(e){let r=this.#t[0][this.routeIndex]?.[1][e],s=this.#s(r);return s&&Oe(s)}#n(){let e={},r=Object.keys(this.#t[0][this.routeIndex]?.[1]??{});for(let s of r){let c=this.#s(this.#t[0][this.routeIndex][1][s]);if(c!==void 0)e[s]=Oe(c)}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return er(this.url,e)}queries(e){return tr(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let r=Object.create(null);return this.raw.headers.forEach((s,c)=>{r[c]=s}),r}async parseBody(e){return dr(this,e)}#i=(e)=>{let{bodyCache:r,raw:s}=this,c=r[e];if(c)return c;for(let f in r)return r[f].then((a)=>{if(f==="json")a=JSON.stringify(a);let y=f==="formData"?void 0:s.headers.get("content-type");return new Response(a,{headers:y?{"Content-Type":y}:void 0})[e]()});return r[e]=s[e]()};json(){return this.#i("text").then((e)=>JSON.parse(e))}text(){return this.#i("text")}arrayBuffer(){return this.#i("arrayBuffer")}bytes(){return this.#i("arrayBuffer").then((e)=>new Uint8Array(e))}blob(){return this.#i("blob")}formData(){return this.#i("formData")}addValidatedData(e,r){(this.#e??={})[e]=r}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[hr](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};var zs="text/plain; charset=UTF-8",ft=(e,r)=>({"Content-Type":e,...r}),we=(e,r)=>new Response(e,r),dt=class{#e;#t;env={};#r;finalized=!1;error;#n;#s;#i;#l;#c;#h;#a;#u;#f;constructor(e,r){if(this.#e=e,r)this.#s=r.executionCtx,this.env=r.env,this.#h=r.notFoundHandler,this.#f=r.path,this.#u=r.matchResult}get req(){return this.#t??=new pr(this.#e,this.#f,this.#u),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;else throw Error("This context has no ExecutionContext")}get res(){return this.#i||=we(null,{headers:this.#a??=new Headers})}set res(e){if(this.#i&&e){e=we(e.body,e);for(let[r,s]of this.#i.headers.entries()){if(r==="content-type")continue;if(r==="set-cookie"){let c=this.#i.headers.getSetCookie();e.headers.delete("set-cookie");for(let f of c)e.headers.append("set-cookie",f)}else e.headers.set(r,s)}}this.#i=e,this.finalized=!0}render=(...e)=>(this.#c??=(r)=>this.html(r),this.#c(...e));setLayout=(e)=>this.#l=e;getLayout=()=>this.#l;setRenderer=(e)=>{this.#c=e};header=(e,r,s)=>{if(this.finalized)this.#i=we(this.#i.body,this.#i);let c=this.#i?this.#i.headers:this.#a??=new Headers;if(r===void 0)c.delete(e);else if(s?.append)c.append(e,r);else c.set(e,r)};status=(e)=>{this.#n=e};set=(e,r)=>{this.#r??=new Map,this.#r.set(e,r)};get=(e)=>this.#r?this.#r.get(e):void 0;get var(){if(!this.#r)return{};return Object.fromEntries(this.#r)}#o(e,r,s){let c=this.#i?new Headers(this.#i.headers):this.#a;if(typeof r==="object"&&r.headers){c??=new Headers;for(let[a,y]of new Headers(r.headers))if(a==="set-cookie")c.append(a,y);else c.set(a,y)}if(s){if(!c){let a=0;for(let y in s)if(++a>1||typeof s[y]!=="string"){c=new Headers;break}}if(c)for(let a in s){let y=s[a];if(typeof y==="string")c.set(a,y);else{c.delete(a);for(let t of y)c.append(a,t)}}}let f=typeof r==="number"?r:r?.status??this.#n;return we(e,{status:f,headers:c??s})}newResponse=(...e)=>this.#o(...e);body=(e,r,s)=>this.#o(e,r,s);text=(e,r,s)=>!this.#a&&!this.#n&&!r&&!s&&!this.finalized?new Response(e):this.#o(e,r,ft(zs,s));json=(e,r,s)=>this.#o(JSON.stringify(e),r,ft("application/json",s));html=(e,r,s)=>{let c=(f)=>this.#o(f,r,ft("text/html; charset=UTF-8",s));return typeof e==="object"?ct(e,ir.Stringify,!1,{}).then(c):c(e)};redirect=(e,r)=>{let s=String(e);return this.header("Location",!/[^\x00-\xFF]/.test(s)?s:encodeURI(s)),this.newResponse(null,r??302)};notFound=()=>(this.#h??=()=>we(),this.#h(this))};var pt=(e,r,s)=>(c,f)=>{let a=-1;return y(0);async function y(t){if(t<=a)throw Error("next() called multiple times");a=t;let n,l=!1,p;if(e[t])p=e[t][0][0],c.req.routeIndex=t;else p=t===e.length&&f||void 0;if(p)try{n=await p(c,()=>y(t+1))}catch(g){if(g instanceof Error&&r)c.error=g,n=await r(g,c),l=!0;else throw g}else if(c.finalized===!1&&s)n=await s(c);if(n&&(c.finalized===!1||l))c.res=n;return c}};var js=(e)=>e.text("404 Not Found",404),_r=(e,r)=>{if("getResponse"in e){let s=e.getResponse();return r.newResponse(s.body,s)}return console.error(e),r.text("Internal Server Error",500)},gr=class e{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(r={}){[...rr,"all"].forEach((f)=>{this[f]=(a,...y)=>{let t=f.toUpperCase();if(typeof a==="string")this.#e=a;else this.#n(t,this.#e,a);return y.forEach((n)=>{this.#n(t,this.#e,n)}),this}}),this.on=(f,a,...y)=>{for(let t of[a].flat()){this.#e=t;for(let n of[f].flat()){let l=n.toUpperCase();for(let p of y)this.#n(l,this.#e,p)}}return this},this.use=(f,...a)=>{if(typeof f==="string")this.#e=f;else this.#e="*",a.unshift(f);return a.forEach((y)=>{this.#n("ALL",this.#e,y)}),this};let{strict:s,...c}=r;Object.assign(this,c),this.getPath=s??!0?r.getPath??ot:Jt}#t(){let r=new e({router:this.router,getPath:this.getPath});return r.errorHandler=this.errorHandler,r.#r=this.#r,r.routes=this.routes,r}#r=js;errorHandler=_r;route(r,s){let c=this.basePath(r);return s.routes.map((f)=>{let a;if(s.errorHandler===_r)a=f.handler;else a=async(y,t)=>(await pt([],s.errorHandler)(y,()=>f.handler(y,t))).res,a[at]=f.handler;c.#n(f.method,f.path,a,f.basePath)}),this}basePath(r){let s=this.#t();return s._basePath=fe(this._basePath,r),s}onError=(r)=>(this.errorHandler=r,this);notFound=(r)=>(this.#r=r,this);mount(r,s,c){let f,a;if(c)if(typeof c==="function")a=c;else if(a=c.optionHandler,c.replaceRequest===!1)f=(n)=>n;else f=c.replaceRequest;let y=a?(n)=>{let l=a(n);return Array.isArray(l)?l:[l]}:(n)=>{let l=void 0;try{l=n.executionCtx}catch{}return[n.env,l]};f||=(()=>{let n=fe(this._basePath,r),l=n==="/"?0:n.length;return(p)=>{let g=new URL(p.url);return g.pathname=this.getPath(p).slice(l)||"/",new Request(g,p)}})();let t=async(n,l)=>{let p=await s(f(n.req.raw),...y(n));if(p)return p;await l()};return this.#n("ALL",fe(r,"*"),t),this}#n(r,s,c,f){s=fe(this._basePath,s);let a={basePath:f!==void 0?fe(this._basePath,f):this._basePath,path:s,method:r,handler:c};this.router.add(r,s,[c,a]),this.routes.push(a)}#s(r,s){if(r instanceof Error)return this.errorHandler(r,s);throw r}#i(r,s,c,f){if(f==="HEAD")return(async()=>new Response(null,await this.#i(r,s,c,"GET")))();let a=this.getPath(r,{env:c}),y=this.router.match(f,a),t=new dt(r,{path:a,matchResult:y,env:c,executionCtx:s,notFoundHandler:this.#r});if(y[0].length===1){let l;try{l=y[0][0][0][0](t,async()=>{t.res=await this.#r(t)})}catch(p){return this.#s(p,t)}return l instanceof Promise?l.then((p)=>p||(t.finalized?t.res:this.#r(t))).catch((p)=>this.#s(p,t)):l??this.#r(t)}let n=pt(y[0],this.errorHandler,this.#r);return(async()=>{try{let l=await n(t);if(!l.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,t)}})()}fetch=(r,...s)=>this.#i(r,s[1],s[0],r.method);request=(r,s,c,f)=>{if(r instanceof Request)return this.fetch(s?new Request(r,s):r,c,f);return r=r.toString(),this.fetch(new Request(/^https?:\/\//.test(r)?r:`http://localhost${fe("/",r)}`,s),c,f)};fire=()=>{addEventListener("fetch",(r)=>{r.respondWith(this.#i(r.request,r,void 0,r.request.method))})}};var Q=()=>Object.create(null);var We=[];function _t(e,r){let s=this.buildAllMatchers(),c=(f,a)=>{let y=s[f]||s.ALL,t=y[2][a];if(t)return t;let n=a.match(y[0]);if(!n)return[[],We];let l=n.indexOf("",1);return[y[1][l],n]};return this.match=c,c(e,r)}var gt="[^/]+";var mt="(?:|/.*)",de=Symbol(),mr=new Set(".\\+*[^]$()");function Gs(e,r){if(e.length===1)return r.length===1?e<r?-1:1:-1;if(r.length===1)return 1;if(e===".*"||e==="(?:|/.*)")return r==="(?:|/.*)"?-1:1;else if(r===".*"||r==="(?:|/.*)")return-1;if(e==="[^/]+")return 1;else if(r==="[^/]+")return-1;return e.length===r.length?e<r?-1:1:r.length-e.length}var vr=class e{#e;#t;#r=Q();insert(r,s,c,f,a){let y=this;for(let t=0,n=r.length;t<n;t++){let l=r[t],p=l.length===1?l==="*"?t===n-1?["","",".*"]:["","",gt]:null:l==="/*"?["","",mt]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),g;if(p){let d=p[1],_=p[2]||"[^/]+";if(d&&p[2]){if(_===".*")throw de;if(_=_.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(_))throw de;if(_.length===1&&mr.has(_))throw de}if(g=y.#r[_],!g){if(_!==".*"&&_!=="(?:|/.*)"){for(let v in y.#r)if((_.length>1||v.length>1)&&v!==".*"&&v!=="(?:|/.*)")throw de}g=y.#r[_]=new e}if(d!=="")g.#t??=f.varIndex++,c.push([d,g.#t])}else if(g=y.#r[l],!g){for(let d in y.#r)if(d.length>1&&d!==".*"&&d!=="(?:|/.*)")throw de;g=y.#r[l]=new e}y=g}if(y.#e!==void 0)throw de;y.#e=a?-1:s}buildRegExpStr(){let r=Object.keys(this.#r).sort(Gs).map((s)=>{let c=this.#r[s],f=c.buildRegExpStr();return f===""?"":(typeof c.#t==="number"?`(${s})@${c.#t}`:mr.has(s)?`\\${s}`:s)+f}).filter(Boolean);if(typeof this.#e==="number"&&this.#e!==-1)r.unshift(`#${this.#e}`);if(r.length===0)return"";if(r.length===1)return r[0];return"(?:"+r.join("|")+")"}};var vt=class{#e={varIndex:0};#t=new vr;#r=0;paths=Q();insert(e,r){if(r){this.#t.insert(e.split(""),0,[],this.#e,!0);return}let s=[],c=[],f=e;for(let y=0;;){let t=!1;if(f=f.replace(/\{[^}]+\}/g,(n)=>{let l=`@\\${y}`;return c[y]=[l,n],y++,t=!0,l}),!t)break}let a=f.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let y=c.length-1;y>=0;y--){let[t]=c[y];for(let n=a.length-1;n>=0;n--)if(a[n].indexOf(t)!==-1){a[n]=a[n].replace(t,c[y][1]);break}}this.#t.insert(a,this.#r,s,this.#e,!1),this.paths[e]=[this.#r++,s]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let r=0,s=[],c=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(f,a,y)=>{if(a!==void 0)return s[++r]=Number(a),"$()";if(y!==void 0)return c[Number(y)]=++r,"";return""}),[new RegExp(`^${e}`),s,c]}};var yr=Q();function br(e){return yr[e]??=new RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(r,s)=>s?`\\${s}`:r==="/*"?mt:r==="*"?".*":`/:${gt}`)}$`)}function Ue(e,r){for(let s of Object.keys(e).sort((c,f)=>f.length-c.length))if(br(s).test(r))return[...e[s]]}var $e=class{name="RegExpRouter";#e;#t;#r;constructor(){this.#e={["ALL"]:Q()},this.#t={["ALL"]:Q()},this.#r={["ALL"]:new vt}}#n(e,r){try{this.#r[e].insert(r,!/\*|\/:/.test(r))}catch(s){throw s===de?new He(r):s}}add(e,r,s){let c=this.#e,f=this.#t;if(!c)throw Error(Ie);if(!c[e]){this.#r[e]=new vt;for(let t of[c,f]){t[e]=Q();for(let n in t.ALL)t[e][n]=[...t.ALL[n]],this.#n(e,n)}}if(r==="/*")r="*";let a=e==="ALL"?Object.keys(c):[e];if(/\*$/.test(r)){let t=br(r);for(let n of a)if(!c[n][r])this.#n(n,r),c[n][r]=Ue(c[n],r)||Ue(c.ALL,r)||[];for(let n of[c,f])for(let l of a)for(let p in n[l])t.test(p)&&n[l][p].push([s,r]);return}let y=Pe(r)||[r];for(let t of y)for(let n of a){if(!f[n][t])this.#n(n,t),f[n][t]=Ue(c[n],t)||Ue(c.ALL,t)||[];f[n][t].push([s,t])}}match=_t;buildAllMatchers(){let e=Q();for(let r of Object.keys(this.#t))e[r]=this.#s(r);return this.#e=this.#t=this.#r=void 0,yr=Q(),e}#s(e){let r=this.#e[e],s=this.#t[e],c=this.#r[e],f=Q(),a=[],[y,t,n]=c.buildRegExp();for(let l of[r,s])for(let p in l){let g=l[p],d=c.paths[p];if(!d){f[p]=[g.map(([_])=>[_,Q()]),We];continue}a[d[0]]=g.map(([_,v])=>[_,c.paths[v][1].reduceRight((o,[i],w)=>(o[i]=n[d[1][w][1]],o),Q())])}return[y,t.map((l)=>a[l]),f]}};var Sr=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,r,s){if(!this.#t)throw Error(Ie);this.#t.push([e,r,s])}match(e,r){if(!this.#t)throw Error("Fatal error");let s=this.#e,c=this.#t,f=s.length,a=0,y;for(;a<f;a++){let t=s[a];try{for(let n=0,l=c.length;n<l;n++)t.add(...c[n]);y=t.match(e,r)}catch(n){if(n instanceof He)continue;throw n}this.match=t.match.bind(t),this.#e=[t],this.#t=void 0;break}if(a===f)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,y}get activeRouter(){if(this.#t||this.#e.length!==1)throw Error("No active router has been determined yet.");return this.#e[0]}};var yt=Q(),qs=0,wr=class e{#e=[];#t=Q();#r=[];#n;#s=yt;insert(r,s,c){let f=this,a=Vt(s),y=new Set,t=0;for(let n of a){let l=a[++t],p=Qt(n,l)||(l===void 0&&n&&n.indexOf("*")===n.length-1?n:null),g=Array.isArray(p),d=g?p[0]:p||n,_=f.#t[d]||=new e;if(p&&!_.#n)_.#n=p,f.#r.push(_);if(f=_,g)y.add(p[1])}f.#e.push({[r]:{handler:c,possibleKeys:[...y],score:++qs}})}#i(r,s,c,f,a){for(let y=0,t=s.#e.length;y<t;y++){let n=s.#e[y],l=n[c]||n.ALL;if(l){l.params=Q(),r.push(l);for(let p=0,g=l.possibleKeys.length;p<g;p++){let d=l.possibleKeys[p];l.params[d]=a?.[d]&&!p?a[d]:f[d]??a?.[d]}}}}search(r,s){let c=[];this.#s=yt;let f=[this],a=nt(s),y=[],t=a.length,n=null;for(let l=0;l<t;l++){let p=a[l],g=l===t-1,d=[];for(let v=0,o=f.length;v<o;v++){let i=f[v],w=i.#t[p];if(w)if(w.#s=i.#s,g){if(w.#t["*"])this.#i(c,w.#t["*"],r,i.#s);this.#i(c,w,r,i.#s)}else d.push(w);for(let h of i.#r){let m=h.#n,u=i.#s===yt?{}:{...i.#s};if(typeof m==="string"){if(m==="*"||p.startsWith(m.slice(0,-1))){if(this.#i(c,h,r,i.#s),m==="*")h.#s=u,d.push(h)}continue}let[,S,C]=m;if(!p&&C===!0)continue;if(C!==!0){if(!n){n=[];let O=s[0]==="/"?1:0;for(let A=0;A<t;A++)n[A]=O,O+=a[A].length+1}let T=s.slice(n[l]),B=C.exec(T);if(B){if(!Object.hasOwn(u,S))u[S]=B[0];if(this.#i(c,h,r,i.#s,u),B[0].length===T.length&&h.#t["*"])this.#i(c,h.#t["*"],r,i.#s,u);for(let O in h.#t){h.#s=u;let A=B[0].match(/\//g)?.length??0;(y[A]||=[]).push(h);break}continue}}if(C===!0||C.test(p)){if(!Object.hasOwn(u,S))u[S]=p;if(g){if(this.#i(c,h,r,u,i.#s),h.#t["*"])this.#i(c,h.#t["*"],r,u,i.#s)}else h.#s=u,d.push(h)}}}let _=y.shift();f=_?d.concat(_):d}if(c[1])c.sort((l,p)=>l.score-p.score);return[c.map(({handler:l,params:p})=>[l,p])]}};var bt=class{name="TrieRouter";#e=new wr;add(e,r,s){for(let c of Pe(r)||[r])this.#e.insert(e,c,s)}match(e,r){return this.#e.search(e,r)}};var ze=class extends gr{constructor(e={}){super(e);this.router=e.router??new Sr({routers:[new $e,new bt]})}};var Xs="Payload Too Large",Cr=(e)=>{let r=e.onError||(()=>{let c=new Response(Xs,{status:413});throw new ut(413,{res:c})}),s=e.maxSize;return async function(f,a){if(!f.req.raw.body)return a();let y=f.req.raw.headers.has("transfer-encoding");if(f.req.raw.headers.has("content-length")&&!y)return parseInt(f.req.raw.headers.get("content-length")||"0",10)>s?r(f):a();let t=0,n=[],l=f.req.raw.body.getReader();for(;;){let{done:g,value:d}=await l.read();if(g)break;if(t+=d.length,t>s)return r(f);n.push(d)}let p={body:new ReadableStream({start(g){for(let d of n)g.enqueue(d);g.close()}}),duplex:"half"};return f.req.raw=new Request(f.req.raw,p),a()}};var xr=(e)=>e;var K=0,Y=0,J=0,V=0,te;((e)=>{function r(f,a,y,t){return t!==void 0?`#${_e(f)}${_e(a)}${_e(y)}${_e(t)}`:`#${_e(f)}${_e(a)}${_e(y)}`}e.toCss=r;function s(f,a,y,t=255){return(f<<24|a<<16|y<<8|t)>>>0}e.toRgba=s;function c(f,a,y,t){return{css:e.toCss(f,a,y,t),rgba:e.toRgba(f,a,y,t)}}e.toColor=c})(te||={});var Vs;((e)=>{function r(n,l){if(V=(l.rgba&255)/255,V===1)return{css:l.css,rgba:l.rgba};let p=l.rgba>>24&255,g=l.rgba>>16&255,d=l.rgba>>8&255,_=n.rgba>>24&255,v=n.rgba>>16&255,o=n.rgba>>8&255;K=_+Math.round((p-_)*V),Y=v+Math.round((g-v)*V),J=o+Math.round((d-o)*V);let i=te.toCss(K,Y,J),w=te.toRgba(K,Y,J);return{css:i,rgba:w}}e.blend=r;function s(n){return(n.rgba&255)===255}e.isOpaque=s;function c(n,l,p){let g=je.ensureContrastRatio(n.rgba,l.rgba,p);if(g)return te.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=c;function f(n){let l=(n.rgba|255)>>>0;return[K,Y,J]=je.toChannels(l),{css:te.toCss(K,Y,J),rgba:l}}e.opaque=f;function a(n,l){return V=Math.round(l*255),[K,Y,J]=je.toChannels(n.rgba),{css:te.toCss(K,Y,J,V),rgba:te.toRgba(K,Y,J,V)}}e.opacity=a;function y(n,l){return V=n.rgba&255,a(n,V*l/255)}e.multiplyOpacity=y;function t(n){return[n.rgba>>24&255,n.rgba>>16&255,n.rgba>>8&255]}e.toColorRGB=t})(Vs||={});var Z;((e)=>{let r,s;try{let f=document.createElement("canvas");f.width=1,f.height=1;let a=f.getContext("2d",{willReadFrequently:!0});a&&(r=a,r.globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}function c(f){if(f.match(/#[\da-f]{3,8}/i))switch(f.length){case 4:return K=parseInt(f.slice(1,2).repeat(2),16),Y=parseInt(f.slice(2,3).repeat(2),16),J=parseInt(f.slice(3,4).repeat(2),16),te.toColor(K,Y,J);case 5:return K=parseInt(f.slice(1,2).repeat(2),16),Y=parseInt(f.slice(2,3).repeat(2),16),J=parseInt(f.slice(3,4).repeat(2),16),V=parseInt(f.slice(4,5).repeat(2),16),te.toColor(K,Y,J,V);case 7:return{css:f,rgba:(parseInt(f.slice(1),16)<<8|255)>>>0};case 9:return{css:f,rgba:parseInt(f.slice(1),16)>>>0}}let a=f.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return K=parseInt(a[1]),Y=parseInt(a[2]),J=parseInt(a[3]),V=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),te.toColor(K,Y,J,V);if(!r||!s)throw Error("css.toColor: Unsupported css format");if(r.fillStyle=s,r.fillStyle=f,typeof r.fillStyle!="string")throw Error("css.toColor: Unsupported css format");if(r.fillRect(0,0,1,1),[K,Y,J,V]=r.getImageData(0,0,1,1).data,V!==255)throw Error("css.toColor: Unsupported css format");return{rgba:te.toRgba(K,Y,J,V),css:f}}e.toColor=c})(Z||={});var re;((e)=>{function r(c){return s(c>>16&255,c>>8&255,c&255)}e.relativeLuminance=r;function s(c,f,a){let y=c/255,t=f/255,n=a/255,l=y<=0.03928?y/12.92:Math.pow((y+0.055)/1.055,2.4),p=t<=0.03928?t/12.92:Math.pow((t+0.055)/1.055,2.4),g=n<=0.03928?n/12.92:Math.pow((n+0.055)/1.055,2.4);return l*0.2126+p*0.7152+g*0.0722}e.relativeLuminance2=s})(re||={});var je;((e)=>{function r(y,t){if(V=(t&255)/255,V===1)return t;let n=t>>24&255,l=t>>16&255,p=t>>8&255,g=y>>24&255,d=y>>16&255,_=y>>8&255;return K=g+Math.round((n-g)*V),Y=d+Math.round((l-d)*V),J=_+Math.round((p-_)*V),te.toRgba(K,Y,J)}e.blend=r;function s(y,t,n){let l=re.relativeLuminance(y>>8),p=re.relativeLuminance(t>>8);if(le(l,p)<n){if(p<l){let _=c(y,t,n),v=le(l,re.relativeLuminance(_>>8));if(v<n){let o=f(y,t,n),i=le(l,re.relativeLuminance(o>>8));return v>i?_:o}return _}let g=f(y,t,n),d=le(l,re.relativeLuminance(g>>8));if(d<n){let _=c(y,t,n),v=le(l,re.relativeLuminance(_>>8));return d>v?g:_}return g}}e.ensureContrastRatio=s;function c(y,t,n){let l=y>>24&255,p=y>>16&255,g=y>>8&255,d=t>>24&255,_=t>>16&255,v=t>>8&255,o=le(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));for(;o<n&&(d>0||_>0||v>0);)d-=Math.max(0,Math.ceil(d*0.1)),_-=Math.max(0,Math.ceil(_*0.1)),v-=Math.max(0,Math.ceil(v*0.1)),o=le(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));return(d<<24|_<<16|v<<8|255)>>>0}e.reduceLuminance=c;function f(y,t,n){let l=y>>24&255,p=y>>16&255,g=y>>8&255,d=t>>24&255,_=t>>16&255,v=t>>8&255,o=le(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));for(;o<n&&(d<255||_<255||v<255);)d=Math.min(255,d+Math.ceil((255-d)*0.1)),_=Math.min(255,_+Math.ceil((255-_)*0.1)),v=Math.min(255,v+Math.ceil((255-v)*0.1)),o=le(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));return(d<<24|_<<16|v<<8|255)>>>0}e.increaseLuminance=f;function a(y){return[y>>24&255,y>>16&255,y>>8&255,y&255]}e.toChannels=a})(je||={});function _e(e){let r=e.toString(16);return r.length<2?"0"+r:r}function le(e,r){return e<r?(r+0.05)/(e+0.05):(e+0.05)/(r+0.05)}var Qs=Object.freeze((()=>{let e=[Z.toColor("#2e3436"),Z.toColor("#cc0000"),Z.toColor("#4e9a06"),Z.toColor("#c4a000"),Z.toColor("#3465a4"),Z.toColor("#75507b"),Z.toColor("#06989a"),Z.toColor("#d3d7cf"),Z.toColor("#555753"),Z.toColor("#ef2929"),Z.toColor("#8ae234"),Z.toColor("#fce94f"),Z.toColor("#729fcf"),Z.toColor("#ad7fa8"),Z.toColor("#34e2e2"),Z.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let c=r[s/36%6|0],f=r[s/6%6|0],a=r[s%6];e.push({css:te.toCss(c,f,a),rgba:te.toRgba(c,f,a)})}for(let s=0;s<24;s++){let c=8+s*10;e.push({css:te.toCss(c,c,c),rgba:te.toRgba(c,c,c)})}return e})());function Er(e,r,s){return Math.max(r,Math.min(e,s))}function Ks(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var Ar=class{constructor(e){this._buffer=e}serialize(e,r){let s=this._buffer.getNullCell(),c=this._buffer.getNullCell(),f=s,a=e.start.y,y=e.end.y,t=e.start.x,n=e.end.x;this._beforeSerialize(y-a,a,y);for(let l=a;l<=y;l++){let p=this._buffer.getLine(l);if(p){let g=l===e.start.y?t:0,d=l===e.end.y?n:p.length;for(let _=g;_<d;_++){let v=p.getCell(_,f===s?c:s);if(!v){console.warn(`Can't get cell at row=${l}, col=${_}`);continue}this._nextCell(v,f,l,_),f=v}}this._rowEnd(l,l===y)}return this._afterSerialize(),this._serializeString(r)}_nextCell(e,r,s,c){}_rowEnd(e,r){}_beforeSerialize(e,r,s){}_afterSerialize(){}_serializeString(e){return""}};function kr(e,r){return e.getFgColorMode()===r.getFgColorMode()&&e.getFgColor()===r.getFgColor()}function ue(e,r){return e.getBgColorMode()===r.getBgColorMode()&&e.getBgColor()===r.getBgColor()}function Lr(e,r){return e.isInverse()===r.isInverse()&&e.isBold()===r.isBold()&&e.isUnderline()===r.isUnderline()&&e.isOverline()===r.isOverline()&&e.isBlink()===r.isBlink()&&e.isInvisible()===r.isInvisible()&&e.isItalic()===r.isItalic()&&e.isDim()===r.isDim()&&e.isStrikethrough()===r.isStrikethrough()}var Ys=class extends Ar{constructor(e,r){super(e);this._terminal=r,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,r,s){this._allRows=Array(e),this._lastContentCursorRow=r,this._lastCursorRow=r,this._firstRow=r}_rowEnd(e,r){this._nullCellCount>0&&!ue(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let s="";if(!r){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let c=this._buffer.getLine(e),f=this._buffer.getLine(e+1);if(!f.isWrapped)s=`\r
31
- `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{s="";let a=c.getCell(c.length-1,this._thisRowLastChar),y=c.getCell(c.length-2,this._thisRowLastSecondChar),t=f.getCell(0,this._nextRowFirstChar),n=t.getWidth()>1,l=!1;(t.getChars()&&n?this._nullCellCount<=1:this._nullCellCount<=0)&&((a.getChars()||a.getWidth()===0)&&ue(a,t)&&(l=!0),n&&(y.getChars()||y.getWidth()===0)&&ue(a,t)&&ue(y,t)&&(l=!0)),l||(s="-".repeat(this._nullCellCount+1),s+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(s+="\x1B[A",s+=`\x1B[${c.length-this._nullCellCount}C`,s+=`\x1B[${this._nullCellCount}X`,s+=`\x1B[${c.length-this._nullCellCount}D`,s+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(e,r){let s=[],c=!kr(e,r),f=!ue(e,r),a=!Lr(e,r);if(c||f||a)if(e.isAttributeDefault())r.isAttributeDefault()||s.push(0);else{if(c){let y=e.getFgColor();e.isFgRGB()?s.push(38,2,y>>>16&255,y>>>8&255,y&255):e.isFgPalette()?y>=16?s.push(38,5,y):s.push(y&8?90+(y&7):30+(y&7)):s.push(39)}if(f){let y=e.getBgColor();e.isBgRGB()?s.push(48,2,y>>>16&255,y>>>8&255,y&255):e.isBgPalette()?y>=16?s.push(48,5,y):s.push(y&8?100+(y&7):40+(y&7)):s.push(49)}a&&(e.isInverse()!==r.isInverse()&&s.push(e.isInverse()?7:27),e.isBold()!==r.isBold()&&s.push(e.isBold()?1:22),e.isUnderline()!==r.isUnderline()&&s.push(e.isUnderline()?4:24),e.isOverline()!==r.isOverline()&&s.push(e.isOverline()?53:55),e.isBlink()!==r.isBlink()&&s.push(e.isBlink()?5:25),e.isInvisible()!==r.isInvisible()&&s.push(e.isInvisible()?8:28),e.isItalic()!==r.isItalic()&&s.push(e.isItalic()?3:23),e.isDim()!==r.isDim()&&s.push(e.isDim()?2:22),e.isStrikethrough()!==r.isStrikethrough()&&s.push(e.isStrikethrough()?9:29))}return s}_nextCell(e,r,s,c){if(e.getWidth()===0)return;let f=e.getChars()==="",a=this._diffStyle(e,this._cursorStyle);if(f?!ue(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(ue(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=c,this._currentRow+=`\x1B[${a.join(";")}m`;let y=this._buffer.getLine(s);y!==void 0&&(y.getCell(c,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=c)}f?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(ue(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=c+e.getWidth())}_serializeString(e){let r=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(r=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let a=0;a<r;a++)s+=this._allRows[a],a+1<r&&(s+=this._allRowSeparators[a]);if(!e){let a=this._buffer.baseY+this._buffer.cursorY,y=this._buffer.cursorX,t=a!==this._lastCursorRow||y!==this._lastCursorCol,n=(l)=>{l>0?s+=`\x1B[${l}C`:l<0&&(s+=`\x1B[${-l}D`)};t&&(((l)=>{l>0?s+=`\x1B[${l}B`:l<0&&(s+=`\x1B[${-l}A`)})(a-this._lastCursorRow),n(y-this._lastCursorCol))}let c=this._terminal._core._inputHandler._curAttrData,f=this._diffStyle(c,this._cursorStyle);return f.length>0&&(s+=`\x1B[${f.join(";")}m`),s}},Tr=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,r,s){let c=r.length,f=s===void 0?c:Er(s+e.rows,0,c);return this._serializeBufferByRange(e,r,{start:c-f,end:c-1},!1)}_serializeBufferByRange(e,r,s,c){return new Ys(r,e).serialize({start:{x:0,y:typeof s.start=="number"?s.start:s.start.line},end:{x:e.cols,y:typeof s.end=="number"?s.end:s.end.line}},c)}_serializeBufferAsHTML(e,r){let s=e.buffer.active,c=new Js(s,e,r),f=r.onlySelection??!1,a=r.range;if(a)return c.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!f){let t=s.length,n=r.scrollback,l=n===void 0?t:Er(n+e.rows,0,t);return c.serialize({start:{x:0,y:t-l},end:{x:e.cols,y:t-1}})}let y=this._terminal?.getSelectionPosition();return y!==void 0?c.serialize({start:{x:y.start.x,y:y.start.y},end:{x:y.end.x,y:y.end.y}}):""}_serializeModes(e){let r="",s=e.modes;if(s.applicationCursorKeysMode&&(r+="\x1B[?1h"),s.applicationKeypadMode&&(r+="\x1B[?66h"),s.bracketedPasteMode&&(r+="\x1B[?2004h"),s.insertMode&&(r+="\x1B[4h"),s.originMode&&(r+="\x1B[?6h"),s.reverseWraparoundMode&&(r+="\x1B[?45h"),s.sendFocusMode&&(r+="\x1B[?1004h"),s.wraparoundMode===!1&&(r+="\x1B[?7l"),s.mouseTrackingMode!=="none")switch(s.mouseTrackingMode){case"x10":r+="\x1B[?9h";break;case"vt200":r+="\x1B[?1000h";break;case"drag":r+="\x1B[?1002h";break;case"any":r+="\x1B[?1003h";break}return r}serialize(e){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");let r=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let s=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);r+=`\x1B[?1049h\x1B[H${s}`}return e?.excludeModes||(r+=this._serializeModes(this._terminal)),r}serializeAsHTML(e){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},Js=class extends Ar{constructor(e,r,s){super(e);this._terminal=r,this._options=s,this._currentRow="",this._htmlContent="",r._core._themeService?this._ansiColors=r._core._themeService.colors.ansi:this._ansiColors=Qs}_padStart(e,r,s){return r=r>>0,s=s??" ",e.length>r?e:(r-=e.length,r>s.length&&(s+=s.repeat(r/s.length)),s.slice(0,r)+e)}_beforeSerialize(e,r,s){this._htmlContent+="<html><body><!--StartFragment--><pre>";let c="#000000",f="#ffffff";(this._options.includeGlobalBackground??!1)&&(c=this._terminal.options.theme?.foreground??"#ffffff",f=this._terminal.options.theme?.background??"#000000");let a=[];a.push("color: "+c+";"),a.push("background-color: "+f+";"),a.push("font-family: "+this._terminal.options.fontFamily+";"),a.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+a.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(e,r){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,r){let s=r?e.getFgColor():e.getBgColor();if(r?e.isFgRGB():e.isBgRGB())return"#"+[s>>16&255,s>>8&255,s&255].map((c)=>this._padStart(c.toString(16),2,"0")).join("");if(r?e.isFgPalette():e.isBgPalette())return this._ansiColors[s].css}_diffStyle(e,r){let s=[],c=!kr(e,r),f=!ue(e,r),a=!Lr(e,r);if(c||f||a){let y=this._getHexColor(e,!0);y&&s.push("color: "+y+";");let t=this._getHexColor(e,!1);return t&&s.push("background-color: "+t+";"),e.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&s.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?s.push("text-decoration: overline underline;"):e.isUnderline()?s.push("text-decoration: underline;"):e.isOverline()&&s.push("text-decoration: overline;"),e.isBlink()&&s.push("text-decoration: blink;"),e.isInvisible()&&s.push("visibility: hidden;"),e.isItalic()&&s.push("font-style: italic;"),e.isDim()&&s.push("opacity: 0.5;"),e.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(e,r,s,c){if(e.getWidth()===0)return;let f=e.getChars()==="",a=this._diffStyle(e,r);a&&(this._currentRow+=a.length===0?"</span><span>":"</span><span style='"+a.join(" ")+"'>"),f?this._currentRow+=" ":this._currentRow+=Ks(e.getChars())}_serializeString(){return this._htmlContent}};var Ir=Rs(Br(),1);var Zs=/\x1b\[M[\s\S]{3}|\x1b\[[0-?]*[ -\/]*[@-~]|\x1bO[\s\S]|\x1b[\]P_^X][\s\S]*?(?:\x07|\x1b\\)/g;function ei(e){return/[\r\x20-\x7e\u00a0-\uffff]/.test(e.replace(Zs,""))}class St{onChange;status="idle";lastInput=0;burstStart;idleTimer;disposed=!1;constructor(e){this.onChange=e}input(e){if(!ei(e))return;this.lastInput=Date.now()}output(){let e=Date.now();if(this.disposed||e-this.lastInput<200)return;if(this.burstStart===void 0&&e-this.lastInput>2000)return;if(this.burstStart??=e,clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>this.settle(),2000),this.status==="idle"&&e-this.burstStart>=1000)this.set("working")}reset(){clearTimeout(this.idleTimer),this.lastInput=0,this.burstStart=void 0,this.status="idle"}dispose(){this.disposed=!0,clearTimeout(this.idleTimer)}settle(){this.burstStart=void 0,this.set("idle")}set(e){if(this.status===e)return;this.status=e,this.onChange(e)}}async function Ge(e,r){let s=Bun.spawn(e,{stdout:"pipe",stderr:"ignore"}),c,f=new Promise((a,y)=>{c=setTimeout(()=>{s.kill(),y(Error(`${e[0]} timed out`))},r)});try{let a=Promise.all([new Response(s.stdout).text(),s.exited]).then(([y])=>y);return await Promise.race([a,f])}finally{clearTimeout(c)}}var ti=new Set(["claude","codex","gemini","opencode","aider","cursor-agent","copilot","qwen","amp"]),ri=/^(node|nodejs|bun|deno|python[\d.]*)$/,Dr=(e)=>e.slice(e.lastIndexOf("/")+1).replace(/\.(js|mjs|cjs|ts|py)$/,"");function wt(e){let r=e.trim().split(/\s+/),s=Dr(r[0]??"");if(ri.test(s)){let c=r.slice(1).find((f)=>!f.startsWith("-"));s=c?Dr(c):""}return ti.has(s)}var si=2000;function Mr(e){return Ge(["ps",...e],si)}async function qe(e,r){try{if(r??=(await Mr(["-o","tty=","-p",String(e)])).trim(),!r||r.startsWith("?"))return;let s=(await Mr(["-ww","-o","pgid=,tpgid=,args=","-t",r])).split(`
32
- `).map((a)=>a.trim().match(/^(\d+)\s+(-?\d+)\s+(.*)$/)).filter((a)=>a!==null).map(([,a,y,t])=>({pgid:Number(a),tpgid:Number(y),args:t})),c=s[0]?.tpgid;if(c===void 0||c<=0)return;let f=s.some((a)=>a.pgid===c&&wt(a.args));return{tty:r,foreground:{pgid:c,agent:f}}}catch{return}}class Ct{terminal;trimmed;integrated=!1;last;running;constructor(e,r){this.terminal=e;this.trimmed=r;e.parser.registerOscHandler(133,(s)=>{if(this.integrated=!0,e.buffer.active.type!=="normal")return!1;let c=s.split(";")[0];if(c==="C")this.running?.marker.dispose(),this.running=this.here();else if((c==="D"||c==="A")&&this.running){let f=this.here();if(f)this.setLast({start:this.running,end:f});else this.running.marker.dispose();this.running=void 0}return!1}),e.parser.registerEscHandler({final:"c"},()=>(this.setLast(void 0),this.running?.marker.dispose(),this.running=void 0,!1))}lastOutput(){let e=this.unavailable(),r=this.last;if(e||!r)return{unavailable:e??"no-command"};let s=r.start.marker.isDisposed?{x:0,y:0}:{x:r.start.x,y:r.start.marker.line},c={x:r.end.x,y:r.end.marker.line},f=this.terminal.buffer.normal,a="";for(let t=s.y;t<=c.y;t++){let n=t===s.y?s.x:0;if(t===c.y&&c.x===0&&t>s.y)break;let l=f.getLine(t);if(!l)break;if(t>s.y&&!l.isWrapped)a+=`
28
+ `),{leaks:k,details:j}}}function i(A){return v?.trackDisposable(A),A}function S(A){v?.markAsDisposed(A)}function h(A,M){v?.setParent(A,M)}function m(A){return typeof A=="object"&&A!==null&&typeof A.dispose=="function"&&A.dispose.length===0}function u(A){if(_.Iterable.is(A)){let M=[];for(let k of A)if(k)try{k.dispose()}catch(P){M.push(P)}if(M.length===1)throw M[0];if(M.length>1)throw AggregateError(M,"Encountered errors while disposing of store");return Array.isArray(A)?[]:A}if(A)return A.dispose(),A}function w(A){let M=i({dispose:(0,d.createSingleCallFunction)(()=>{S(M),A()})});return M}t.DisposableTracker=o;class C{static{this.DISABLE_DISPOSED_WARNING=!1}constructor(){this._toDispose=new Set,this._isDisposed=!1,i(this)}dispose(){this._isDisposed||(S(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{u(this._toDispose)}finally{this._toDispose.clear()}}add(A){if(!A)return A;if(A===this)throw Error("Cannot register a disposable on itself!");return h(A,this),this._isDisposed?C.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(A),A}delete(A){if(A){if(A===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(A),A.dispose()}}deleteAndLeak(A){A&&this._toDispose.has(A)&&(this._toDispose.delete(A),h(A,null))}}t.DisposableStore=C;class T{static{this.None=Object.freeze({dispose(){}})}constructor(){this._store=new C,i(this),h(this._store,this)}dispose(){S(this),this._store.dispose()}_register(A){if(A===this)throw Error("Cannot register a disposable on itself!");return this._store.add(A)}}t.Disposable=T;class B{constructor(){this._isDisposed=!1,i(this)}get value(){return this._isDisposed?void 0:this._value}set value(A){this._isDisposed||A===this._value||(this._value?.dispose(),A&&h(A,this),this._value=A)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,S(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let A=this._value;return this._value=void 0,A&&h(A,null),A}}t.MutableDisposable=B,t.MandatoryMutableDisposable=class{constructor(A){this._disposable=new B,this._isDisposed=!1,this._disposable.value=A}get value(){return this._disposable.value}set value(A){this._isDisposed||A===this._disposable.value||(this._disposable.value=A)}dispose(){this._isDisposed=!0,this._disposable.dispose()}},t.RefCountedDisposable=class{constructor(A){this._disposable=A,this._counter=1}acquire(){return this._counter++,this}release(){return--this._counter==0&&this._disposable.dispose(),this}},t.SafeDisposable=class{constructor(){this.dispose=()=>{},this.unset=()=>{},this.isset=()=>!1,i(this)}set(A){let M=A;return this.unset=()=>M=void 0,this.isset=()=>M!==void 0,this.dispose=()=>{M&&(M(),M=void 0,S(this))},this}},t.ReferenceCollection=class{constructor(){this.references=new Map}acquire(A,...M){let k=this.references.get(A);k||(k={counter:0,object:this.createReferencedObject(A,...M)},this.references.set(A,k));let{object:P}=k,W=(0,d.createSingleCallFunction)(()=>{--k.counter==0&&(this.destroyReferencedObject(A,k.object),this.references.delete(A))});return k.counter++,{object:P,dispose:W}}},t.AsyncReferenceCollection=class{constructor(A){this.referenceCollection=A}async acquire(A,...M){let k=this.referenceCollection.acquire(A,...M);try{return{object:await k.object,dispose:()=>k.dispose()}}catch(P){throw k.dispose(),P}}},t.ImmortalReference=class{constructor(A){this.object=A}dispose(){}};class O{constructor(){this._store=new Map,this._isDisposed=!1,i(this)}dispose(){S(this),this._isDisposed=!0,this.clearAndDisposeAll()}clearAndDisposeAll(){if(this._store.size)try{u(this._store.values())}finally{this._store.clear()}}has(A){return this._store.has(A)}get size(){return this._store.size}get(A){return this._store.get(A)}set(A,M,k=!1){this._isDisposed&&console.warn(Error("Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!").stack),k||this._store.get(A)?.dispose(),this._store.set(A,M)}deleteAndDispose(A){this._store.get(A)?.dispose(),this._store.delete(A)}deleteAndLeak(A){let M=this._store.get(A);return this._store.delete(A),M}keys(){return this._store.keys()}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}}t.DisposableMap=O},6317:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkedList=void 0;class n{static{this.Undefined=new n(void 0)}constructor(p){this.element=p,this.next=n.Undefined,this.prev=n.Undefined}}class l{constructor(){this._first=n.Undefined,this._last=n.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===n.Undefined}clear(){let p=this._first;for(;p!==n.Undefined;){let g=p.next;p.prev=n.Undefined,p.next=n.Undefined,p=g}this._first=n.Undefined,this._last=n.Undefined,this._size=0}unshift(p){return this._insert(p,!1)}push(p){return this._insert(p,!0)}_insert(p,g){let d=new n(p);if(this._first===n.Undefined)this._first=d,this._last=d;else if(g){let v=this._last;this._last=d,d.prev=v,v.next=d}else{let v=this._first;this._first=d,d.next=v,v.prev=d}this._size+=1;let _=!1;return()=>{_||(_=!0,this._remove(d))}}shift(){if(this._first!==n.Undefined){let p=this._first.element;return this._remove(this._first),p}}pop(){if(this._last!==n.Undefined){let p=this._last.element;return this._remove(this._last),p}}_remove(p){if(p.prev!==n.Undefined&&p.next!==n.Undefined){let g=p.prev;g.next=p.next,p.next.prev=g}else p.prev===n.Undefined&&p.next===n.Undefined?(this._first=n.Undefined,this._last=n.Undefined):p.next===n.Undefined?(this._last=this._last.prev,this._last.next=n.Undefined):p.prev===n.Undefined&&(this._first=this._first.next,this._first.prev=n.Undefined);this._size-=1}*[Symbol.iterator](){let p=this._first;for(;p!==n.Undefined;)yield p.element,p=p.next}}t.LinkedList=l},2608:(y,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.SetMap=t.BidirectionalMap=t.CounterSet=t.Touch=void 0,t.getOrSet=function(l,p,g){let d=l.get(p);return d===void 0&&(d=g,l.set(p,d)),d},t.mapToString=function(l){let p=[];return l.forEach((g,d)=>{p.push(`${d} => ${g}`)}),`Map(${l.size}) {${p.join(", ")}}`},t.setToString=function(l){let p=[];return l.forEach((g)=>{p.push(g)}),`Set(${l.size}) {${p.join(", ")}}`},t.mapsStrictEqualIgnoreOrder=function(l,p){if(l===p)return!0;if(l.size!==p.size)return!1;for(let[g,d]of l)if(!p.has(g)||p.get(g)!==d)return!1;for(let[g]of p)if(!l.has(g))return!1;return!0},function(l){l[l.None=0]="None",l[l.AsOld=1]="AsOld",l[l.AsNew=2]="AsNew"}(n||(t.Touch=n={})),t.CounterSet=class{constructor(){this.map=new Map}add(l){return this.map.set(l,(this.map.get(l)||0)+1),this}delete(l){let p=this.map.get(l)||0;return p!==0&&(p--,p===0?this.map.delete(l):this.map.set(l,p),!0)}has(l){return this.map.has(l)}},t.BidirectionalMap=class{constructor(l){if(this._m1=new Map,this._m2=new Map,l)for(let[p,g]of l)this.set(p,g)}clear(){this._m1.clear(),this._m2.clear()}set(l,p){this._m1.set(l,p),this._m2.set(p,l)}get(l){return this._m1.get(l)}getKey(l){return this._m2.get(l)}delete(l){let p=this._m1.get(l);return p!==void 0&&(this._m1.delete(l),this._m2.delete(p),!0)}forEach(l,p){this._m1.forEach((g,d)=>{l.call(p,g,d,this)})}keys(){return this._m1.keys()}values(){return this._m1.values()}},t.SetMap=class{constructor(){this.map=new Map}add(l,p){let g=this.map.get(l);g||(g=new Set,this.map.set(l,g)),g.add(p)}delete(l,p){let g=this.map.get(l);g&&(g.delete(p),g.size===0&&this.map.delete(l))}forEach(l,p){let g=this.map.get(l);g&&g.forEach(p)}get(l){return this.map.get(l)||new Set}}},9725:(y,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StopWatch=void 0;let n=globalThis.performance&&typeof globalThis.performance.now=="function";class l{static create(p){return new l(p)}constructor(p){this._now=n&&p===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}}t.StopWatch=l}},r={};function s(y){var t=r[y];if(t!==void 0)return t.exports;var n=r[y]={exports:{}};return e[y].call(n.exports,n,n.exports,s),n.exports}var c={};(()=>{var y=c;Object.defineProperty(y,"__esModule",{value:!0}),y.Terminal=void 0;let t=s(5101),n=s(6097),l=s(4335),p=s(5856),g=s(3027),d=s(7150),_=["cols","rows"];class v extends d.Disposable{constructor(o){super(),this._core=this._register(new p.Terminal(o)),this._addonManager=this._register(new g.AddonManager),this._publicOptions={...this._core.options};let i=(h)=>this._core.options[h],S=(h,m)=>{this._checkReadonlyOptions(h),this._core.options[h]=m};for(let h in this._core.options){Object.defineProperty(this._publicOptions,h,{get:()=>this._core.options[h],set:(u)=>{this._checkReadonlyOptions(h),this._core.options[h]=u}});let m={get:i.bind(this,h),set:S.bind(this,h)};Object.defineProperty(this._publicOptions,h,m)}}_checkReadonlyOptions(o){if(_.includes(o))throw Error(`Option "${o}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.options.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onLineFeed(){return this._core.onLineFeed}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get parser(){return this._checkProposedApi(),this._parser||(this._parser=new n.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new l.UnicodeApi(this._core)}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._checkProposedApi(),this._buffer||(this._buffer=this._register(new t.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let o=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:o.applicationCursorKeys,applicationKeypadMode:o.applicationKeypad,bracketedPasteMode:o.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:o.origin,reverseWraparoundMode:o.reverseWraparound,sendFocusMode:o.sendFocus,synchronizedOutputMode:o.synchronizedOutput,wraparoundMode:o.wraparound}}get options(){return this._publicOptions}set options(o){for(let i in o)this._publicOptions[i]=o[i]}input(o,i=!0){this._core.input(o,i)}resize(o,i){this._verifyIntegers(o,i),this._core.resize(o,i)}registerMarker(o=0){return this._checkProposedApi(),this._verifyIntegers(o),this._core.addMarker(o)}addMarker(o){return this.registerMarker(o)}dispose(){super.dispose()}scrollLines(o){this._verifyIntegers(o),this._core.scrollLines(o)}scrollPages(o){this._verifyIntegers(o),this._core.scrollPages(o)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(o){this._verifyIntegers(o),this._core.scrollToLine(o)}clear(){this._core.clear()}write(o,i){this._core.write(o,i)}writeln(o,i){this._core.write(o),this._core.write(`\r
29
+ `,i)}reset(){this._core.reset()}loadAddon(o){this._addonManager.loadAddon(this,o)}_verifyIntegers(...o){for(let i of o)if(i===1/0||isNaN(i)||i%1!=0)throw Error("This API only accepts integers")}}y.Terminal=v})();var f=Dr;for(var a in c)f[a]=c[a];c.__esModule&&Object.defineProperty(f,"__esModule",{value:!0})})()});if(!Bun.semver.satisfies(Bun.version,">=1.4.0"))console.error(`Accompany: Bun ${"1.4.0"} \u4EE5\u4E0A\u304C\u5FC5\u8981\u3067\u3059\uFF08\u3044\u307E\u306E Bun: ${Bun.version}\uFF09\u3002
30
+ `+"`bun upgrade` \u3067 Bun \u3092\u4E0A\u3052\u308B\u304B\u3001Bun \u306E\u8981\u3089\u306A\u3044\u5B9F\u884C\u30D5\u30A1\u30A4\u30EB\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044: "+"https://github.com/itsuki-yamada/accompany/releases"),process.exit(1);var De=(e)=>("server"in e.env)?e.env.server:e.env;var ot=(e)=>{let r=e.split("/");if(r[0]==="")r.shift();return r},Kt=(e)=>{let{groups:r,path:s}=Is(e),c=ot(s);return Hs(c,r)},Is=(e)=>{let r=[];return e=e.replace(/\{[^}]+\}/g,(s,c)=>{let f=`@${c}`;return r.push([f,s]),f}),{groups:r,path:e}},Hs=(e,r)=>{for(let s=r.length-1;s>=0;s--){let[c]=r[s];for(let f=e.length-1;f>=0;f--)if(e[f].includes(c)){e[f]=e[f].replace(c,r[s][1]);break}}return e},Me={},Yt=(e,r)=>{if(e==="*")return"*";let s=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(s){let c=`${e}#${r}`;if(!Me[c])if(s[2])Me[c]=r&&r[0]!==":"&&r[0]!=="*"?[c,s[1],new RegExp(`^${s[2]}(?=/${r})`)]:[e,s[1],new RegExp(`^${s[2]}$`)];else Me[c]=[e,s[1],!0];return Me[c]}return null},Jt=(e,r)=>{try{return r(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,(s)=>{try{return r(s)}catch{return s}})}},Zt=(e)=>Jt(e,decodeURI),at=(e)=>{let r=e.url,s=r.indexOf("/",r.indexOf(":")+4),c=s;for(;c<r.length;c++){let f=r.charCodeAt(c);if(f===37){let a=r.indexOf("?",c),y=r.indexOf("#",c),t=a===-1?y===-1?void 0:y:y===-1?a:Math.min(a,y),n=r.slice(s,t);return Zt(n.includes("%25")?n.replace(/%25/g,"%2525"):n)}else if(f===63||f===35)break}return r.slice(s,c)};var er=(e)=>{let r=at(e);return r.length>1&&r.at(-1)==="/"?r.slice(0,-1):r},fe=(e,r,...s)=>{if(s.length)r=fe(r,...s);return`${e?.[0]==="/"?"":"/"}${e}${r==="/"?"":`${e?.at(-1)==="/"?"":"/"}${r?.[0]==="/"?r.slice(1):r}`}`},Pe=(e)=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let r=e.split("/"),s=[],c="";return r.forEach((f)=>{if(f!==""&&!/\:/.test(f))c+="/"+f;else if(/\:/.test(f))if(f.charCodeAt(f.length-1)===63){if(s.length===0&&c==="")s.push("/");else s.push(c);let a=f.slice(0,-1);c+="/"+a,s.push(c)}else c+="/"+f}),s.filter((f,a,y)=>y.indexOf(f)===a)},Oe=(e)=>e.indexOf("%")!==-1?Jt(e,Ns):e,nt=(e)=>{if(e.indexOf("+")!==-1)e=e.replace(/\+/g," ");return Oe(e)},tr=(e,r,s)=>{let c=e.indexOf("#",8);if(c!==-1)e=e.slice(0,c);let f;if(!s&&r&&r.indexOf("%")===-1&&r.indexOf("+")===-1){let t=e.indexOf("?",8),n=t;if(n===-1)return;if(!e.startsWith(r,n+1))n=e.indexOf(`&${r}`,n+1);while(n!==-1){let l=e.charCodeAt(n+r.length+1);if(l===61||l===38||isNaN(l)){if(n>t&&/(?:^|&)[^=&]*[%+]/.test(e.slice(t+1,n)))break;if(l===61){let p=n+r.length+2,g=e.indexOf("&",p);return nt(e.slice(p,g===-1?void 0:g))}return""}n=e.indexOf(`&${r}`,n+1)}if(f=/[%+]/.test(e),!f)return}let a=Object.create(null);f??=/[%+]/.test(e);let y=e.indexOf("?",8);while(y!==-1){let t=e.indexOf("&",y+1),n=e.indexOf("=",y);if(n>t&&t!==-1)n=-1;let l=e.slice(y+1,n===-1?t===-1?void 0:t:n);if(f)l=nt(l);if(y=t,l==="")continue;let p;if(n===-1)p="";else if(p=e.slice(n+1,t===-1?void 0:t),f)p=nt(p);if(s){if(!(a[l]&&Array.isArray(a[l])))a[l]=[];a[l].push(p)}else a[l]??=p}return r?a[r]:a},rr=tr,sr=(e,r)=>tr(e,r,!0),Ns=decodeURIComponent;var Fs={br:".br",zstd:".zst",gzip:".gz"},Fn=Object.keys(Fs);var ir=["get","post","put","delete","options","patch","query"],Ie="Can not add a route since the matcher is already built.",He=class extends Error{};var ct="__COMPOSED_HANDLER";var nr="x-hono-disable-ssg",ao=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[nr]:"true"}})}catch{return null}})();var or={Stringify:1,BeforeStream:2,Stream:3},ar=(e,r)=>{let s=new String(e);return s.isEscaped=!0,s.callbacks=r,s};var lt=async(e,r,s,c,f)=>{if(typeof e==="object"&&!(e instanceof String)){if(!(e instanceof Promise))e=e.toString();if(e instanceof Promise)e=await e}let a=e.callbacks;if(!a?.length)return Promise.resolve(e);if(f)f[0]+=e;else f=[e];let y=Promise.all(a.map((t)=>t({phase:r,buffer:f,context:c}))).then((t)=>Promise.all(t.filter(Boolean).map((n)=>lt(n,r,!1,c,f))).then(()=>f[0]));if(s)return ar(await y,a);else return y};var{write:Jo}=Bun;var cr=class{#e;constructor(e){this.#e=e,this.raw=e.raw,this.url=e.url?new URL(e.url):null,this.protocol=e.protocol??null}send(e,r){this.#e.send(e,r??{})}raw;binaryType="arraybuffer";get readyState(){return this.#e.readyState}url;protocol;close(e,r){this.#e.close(e,r)}},lr=(e)=>new MessageEvent("message",{data:e}),hr=(e)=>(...r)=>{if(typeof r[0]==="function"){let[s,c]=r;return async function(a,y){let t=await e(a,await s(a),c);if(t)return t;await y()}}else{let[s,c,f]=r;return(async()=>{let a=await e(s,c,f);if(!a)throw Error("Failed to upgrade WebSocket");return a})()}};var ht=(e)=>new cr({send:(r,s)=>{e.send(r,s?.compress)},raw:e,readyState:e.readyState,url:e.data.url,protocol:e.data.protocol,close(r,s){e.close(r,s)}}),Ne=hr((e,r)=>{let s=De(e);if(!s)throw TypeError("env has to include the 2nd argument of fetch.");if(s.upgrade(e.req.raw,{data:{events:r,url:new URL(e.req.url),protocol:e.req.header("sec-websocket-protocol")?.split(",")[0]?.trim()??""}}))return new Response(null)}),ut={open(e){let r=e.data.events;if(r.onOpen)r.onOpen(new Event("open"),ht(e))},close(e,r,s){let c=e.data.events;if(c.onClose)c.onClose(new CloseEvent("close",{code:r,reason:s}),ht(e))},message(e,r){let s=e.data.events;if(s.onMessage){let c=typeof r==="string"?r:r.buffer;s.onMessage(lr(c),ht(e))}}};var ft=class extends Error{res;status;constructor(e=500,r){super(r?.message,{cause:r?.cause});this.res=r?.res,this.status=e}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};var ur=Symbol();var fr=(e,r)=>new Response(e,{headers:{"Content-Type":r.replace(/^[^;]+/,(s)=>s.toLowerCase())}}).formData();var js=1e4,Fe=(e)=>("headers"in e),_r=async(e,r=Object.create(null))=>{let{all:s=!1,dot:c=!1}=r,f=(Fe(e)?e.headers:e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(f==="multipart/form-data"||f==="application/x-www-form-urlencoded")return zs(e,{all:s,dot:c});return{}};async function zs(e,r){if(!Fe(e)&&e.bodyCache.formData)return dr(await e.bodyCache.formData,r);let s=Fe(e)?e.headers:e.raw.headers,c=await e.arrayBuffer(),f=fr(c,s.get("Content-Type")||"");if(!Fe(e))e.bodyCache.formData=f;let a=await f;if(a)return dr(a,r);return{}}function dr(e,r){let s=Object.create(null),c={count:0};if(e.forEach((f,a)=>{if(!(r.all||a.endsWith("[]")))s[a]=f;else Gs(s,a,f)}),r.dot)Object.entries(s).forEach(([f,a])=>{if(f.includes("."))qs(s,f,a,c),delete s[f]});return s}var Gs=(e,r,s)=>{if(e[r]!==void 0)if(Array.isArray(e[r]))e[r].push(s);else e[r]=[e[r],s];else if(!r.endsWith("[]"))e[r]=s;else e[r]=[s]},qs=(e,r,s,c)=>{if(/(?:^|\.)__proto__\./.test(r))return;let f=e,a=r.split(".",34);if(a.length>33)pr();a.forEach((y,t)=>{if(t===a.length-1)f[y]=s;else{if(!f[y]||typeof f[y]!=="object"||Array.isArray(f[y])||f[y]instanceof File){if(c.count++>=js)pr();f[y]=Object.create(null)}f=f[y]}})},pr=()=>{throw Error("Nesting limit exceeded")};var gr=class{raw;#e;#t;routeIndex=0;path;bodyCache={};constructor(e,r="/",s=[[]]){this.raw=e,this.path=r,this.#t=s}param(e){return e?this.#r(e):this.#n()}#r(e){let r=this.#t[0][this.routeIndex]?.[1][e],s=this.#s(r);return s&&Oe(s)}#n(){let e={},r=Object.keys(this.#t[0][this.routeIndex]?.[1]??{});for(let s of r){let c=this.#s(this.#t[0][this.routeIndex][1][s]);if(c!==void 0)e[s]=Oe(c)}return e}#s(e){return this.#t[1]?this.#t[1][e]:e}query(e){return rr(this.url,e)}queries(e){return sr(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let r=Object.create(null);return this.raw.headers.forEach((s,c)=>{r[c]=s}),r}async parseBody(e){return _r(this,e)}#i=(e)=>{let{bodyCache:r,raw:s}=this,c=r[e];if(c)return c;for(let f in r)return r[f].then((a)=>{if(f==="json")a=JSON.stringify(a);let y=f==="formData"?void 0:s.headers.get("content-type");return new Response(a,{headers:y?{"Content-Type":y}:void 0})[e]()});return r[e]=s[e]()};json(){return this.#i("text").then((e)=>JSON.parse(e))}text(){return this.#i("text")}arrayBuffer(){return this.#i("arrayBuffer")}bytes(){return this.#i("arrayBuffer").then((e)=>new Uint8Array(e))}blob(){return this.#i("blob")}formData(){return this.#i("formData")}addValidatedData(e,r){(this.#e??={})[e]=r}valid(e){return this.#e?.[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[ur](){return this.#t}get matchedRoutes(){return this.#t[0].map(([[,e]])=>e)}get routePath(){return this.#t[0].map(([[,e]])=>e)[this.routeIndex].path}};var Xs="text/plain; charset=UTF-8",dt=(e,r)=>({"Content-Type":e,...r}),Se=(e,r)=>new Response(e,r),pt=class{#e;#t;env={};#r;finalized=!1;error;#n;#s;#i;#h;#c;#l;#a;#u;#f;constructor(e,r){if(this.#e=e,r)this.#s=r.executionCtx,this.env=r.env,this.#l=r.notFoundHandler,this.#f=r.path,this.#u=r.matchResult}get req(){return this.#t??=new gr(this.#e,this.#f,this.#u),this.#t}get event(){if(this.#s&&"respondWith"in this.#s)return this.#s;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#s)return this.#s;else throw Error("This context has no ExecutionContext")}get res(){return this.#i||=Se(null,{headers:this.#a??=new Headers})}set res(e){if(this.#i&&e){e=Se(e.body,e);for(let[r,s]of this.#i.headers.entries()){if(r==="content-type")continue;if(r==="set-cookie"){let c=this.#i.headers.getSetCookie();e.headers.delete("set-cookie");for(let f of c)e.headers.append("set-cookie",f)}else e.headers.set(r,s)}}this.#i=e,this.finalized=!0}render=(...e)=>(this.#c??=(r)=>this.html(r),this.#c(...e));setLayout=(e)=>this.#h=e;getLayout=()=>this.#h;setRenderer=(e)=>{this.#c=e};header=(e,r,s)=>{if(this.finalized)this.#i=Se(this.#i.body,this.#i);let c=this.#i?this.#i.headers:this.#a??=new Headers;if(r===void 0)c.delete(e);else if(s?.append)c.append(e,r);else c.set(e,r)};status=(e)=>{this.#n=e};set=(e,r)=>{this.#r??=new Map,this.#r.set(e,r)};get=(e)=>this.#r?this.#r.get(e):void 0;get var(){if(!this.#r)return{};return Object.fromEntries(this.#r)}#o(e,r,s){let c=this.#i?new Headers(this.#i.headers):this.#a;if(typeof r==="object"&&r.headers){c??=new Headers;for(let[a,y]of new Headers(r.headers))if(a==="set-cookie")c.append(a,y);else c.set(a,y)}if(s){if(!c){let a=0;for(let y in s)if(++a>1||typeof s[y]!=="string"){c=new Headers;break}}if(c)for(let a in s){let y=s[a];if(typeof y==="string")c.set(a,y);else{c.delete(a);for(let t of y)c.append(a,t)}}}let f=typeof r==="number"?r:r?.status??this.#n;return Se(e,{status:f,headers:c??s})}newResponse=(...e)=>this.#o(...e);body=(e,r,s)=>this.#o(e,r,s);text=(e,r,s)=>!this.#a&&!this.#n&&!r&&!s&&!this.finalized?new Response(e):this.#o(e,r,dt(Xs,s));json=(e,r,s)=>this.#o(JSON.stringify(e),r,dt("application/json",s));html=(e,r,s)=>{let c=(f)=>this.#o(f,r,dt("text/html; charset=UTF-8",s));return typeof e==="object"?lt(e,or.Stringify,!1,{}).then(c):c(e)};redirect=(e,r)=>{let s=String(e);return this.header("Location",!/[^\x00-\xFF]/.test(s)?s:encodeURI(s)),this.newResponse(null,r??302)};notFound=()=>(this.#l??=()=>Se(),this.#l(this))};var _t=(e,r,s)=>(c,f)=>{let a=-1;return y(0);async function y(t){if(t<=a)throw Error("next() called multiple times");a=t;let n,l=!1,p;if(e[t])p=e[t][0][0],c.req.routeIndex=t;else p=t===e.length&&f||void 0;if(p)try{n=await p(c,()=>y(t+1))}catch(g){if(g instanceof Error&&r)c.error=g,n=await r(g,c),l=!0;else throw g}else if(c.finalized===!1&&s)n=await s(c);if(n&&(c.finalized===!1||l))c.res=n;return c}};var Vs=(e)=>e.text("404 Not Found",404),mr=(e,r)=>{if("getResponse"in e){let s=e.getResponse();return r.newResponse(s.body,s)}return console.error(e),r.text("Internal Server Error",500)},vr=class e{get;post;put;delete;options;patch;query;all;on;use;router;getPath;_basePath="/";#e="/";routes=[];constructor(r={}){[...ir,"all"].forEach((f)=>{this[f]=(a,...y)=>{let t=f.toUpperCase();if(typeof a==="string")this.#e=a;else this.#n(t,this.#e,a);return y.forEach((n)=>{this.#n(t,this.#e,n)}),this}}),this.on=(f,a,...y)=>{for(let t of[a].flat()){this.#e=t;for(let n of[f].flat()){let l=n.toUpperCase();for(let p of y)this.#n(l,this.#e,p)}}return this},this.use=(f,...a)=>{if(typeof f==="string")this.#e=f;else this.#e="*",a.unshift(f);return a.forEach((y)=>{this.#n("ALL",this.#e,y)}),this};let{strict:s,...c}=r;Object.assign(this,c),this.getPath=s??!0?r.getPath??at:er}#t(){let r=new e({router:this.router,getPath:this.getPath});return r.errorHandler=this.errorHandler,r.#r=this.#r,r.routes=this.routes,r}#r=Vs;errorHandler=mr;route(r,s){let c=this.basePath(r);return s.routes.map((f)=>{let a;if(s.errorHandler===mr)a=f.handler;else a=async(y,t)=>(await _t([],s.errorHandler)(y,()=>f.handler(y,t))).res,a[ct]=f.handler;c.#n(f.method,f.path,a,f.basePath)}),this}basePath(r){let s=this.#t();return s._basePath=fe(this._basePath,r),s}onError=(r)=>(this.errorHandler=r,this);notFound=(r)=>(this.#r=r,this);mount(r,s,c){let f,a;if(c)if(typeof c==="function")a=c;else if(a=c.optionHandler,c.replaceRequest===!1)f=(n)=>n;else f=c.replaceRequest;let y=a?(n)=>{let l=a(n);return Array.isArray(l)?l:[l]}:(n)=>{let l=void 0;try{l=n.executionCtx}catch{}return[n.env,l]};f||=(()=>{let n=fe(this._basePath,r),l=n==="/"?0:n.length;return(p)=>{let g=new URL(p.url);return g.pathname=this.getPath(p).slice(l)||"/",new Request(g,p)}})();let t=async(n,l)=>{let p=await s(f(n.req.raw),...y(n));if(p)return p;await l()};return this.#n("ALL",fe(r,"*"),t),this}#n(r,s,c,f){s=fe(this._basePath,s);let a={basePath:f!==void 0?fe(this._basePath,f):this._basePath,path:s,method:r,handler:c};this.router.add(r,s,[c,a]),this.routes.push(a)}#s(r,s){if(r instanceof Error)return this.errorHandler(r,s);throw r}#i(r,s,c,f){if(f==="HEAD")return(async()=>new Response(null,await this.#i(r,s,c,"GET")))();let a=this.getPath(r,{env:c}),y=this.router.match(f,a),t=new pt(r,{path:a,matchResult:y,env:c,executionCtx:s,notFoundHandler:this.#r});if(y[0].length===1){let l;try{l=y[0][0][0][0](t,async()=>{t.res=await this.#r(t)})}catch(p){return this.#s(p,t)}return l instanceof Promise?l.then((p)=>p||(t.finalized?t.res:this.#r(t))).catch((p)=>this.#s(p,t)):l??this.#r(t)}let n=_t(y[0],this.errorHandler,this.#r);return(async()=>{try{let l=await n(t);if(!l.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return l.res}catch(l){return this.#s(l,t)}})()}fetch=(r,...s)=>this.#i(r,s[1],s[0],r.method);request=(r,s,c,f)=>{if(r instanceof Request)return this.fetch(s?new Request(r,s):r,c,f);return r=r.toString(),this.fetch(new Request(/^https?:\/\//.test(r)?r:`http://localhost${fe("/",r)}`,s),c,f)};fire=()=>{addEventListener("fetch",(r)=>{r.respondWith(this.#i(r.request,r,void 0,r.request.method))})}};var Q=()=>Object.create(null);var We=[];function gt(e,r){let s=this.buildAllMatchers(),c=(f,a)=>{let y=s[f]||s.ALL,t=y[2][a];if(t)return t;let n=a.match(y[0]);if(!n)return[[],We];let l=n.indexOf("",1);return[y[1][l],n]};return this.match=c,c(e,r)}var mt="[^/]+";var vt="(?:|/.*)",de=Symbol(),yr=new Set(".\\+*[^]$()");function Qs(e,r){if(e.length===1)return r.length===1?e<r?-1:1:-1;if(r.length===1)return 1;if(e===".*"||e==="(?:|/.*)")return r==="(?:|/.*)"?-1:1;else if(r===".*"||r==="(?:|/.*)")return-1;if(e==="[^/]+")return 1;else if(r==="[^/]+")return-1;return e.length===r.length?e<r?-1:1:r.length-e.length}var br=class e{#e;#t;#r=Q();insert(r,s,c,f,a){let y=this;for(let t=0,n=r.length;t<n;t++){let l=r[t],p=l.length===1?l==="*"?t===n-1?["","",".*"]:["","",mt]:null:l==="/*"?["","",vt]:l.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),g;if(p){let d=p[1],_=p[2]||"[^/]+";if(d&&p[2]){if(_===".*")throw de;if(_=_.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(_))throw de;if(_.length===1&&yr.has(_))throw de}if(g=y.#r[_],!g){if(_!==".*"&&_!=="(?:|/.*)"){for(let v in y.#r)if((_.length>1||v.length>1)&&v!==".*"&&v!=="(?:|/.*)")throw de}g=y.#r[_]=new e}if(d!=="")g.#t??=f.varIndex++,c.push([d,g.#t])}else if(g=y.#r[l],!g){for(let d in y.#r)if(d.length>1&&d!==".*"&&d!=="(?:|/.*)")throw de;g=y.#r[l]=new e}y=g}if(y.#e!==void 0)throw de;y.#e=a?-1:s}buildRegExpStr(){let r=Object.keys(this.#r).sort(Qs).map((s)=>{let c=this.#r[s],f=c.buildRegExpStr();return f===""?"":(typeof c.#t==="number"?`(${s})@${c.#t}`:yr.has(s)?`\\${s}`:s)+f}).filter(Boolean);if(typeof this.#e==="number"&&this.#e!==-1)r.unshift(`#${this.#e}`);if(r.length===0)return"";if(r.length===1)return r[0];return"(?:"+r.join("|")+")"}};var yt=class{#e={varIndex:0};#t=new br;#r=0;paths=Q();insert(e,r){if(r){this.#t.insert(e.split(""),0,[],this.#e,!0);return}let s=[],c=[],f=e;for(let y=0;;){let t=!1;if(f=f.replace(/\{[^}]+\}/g,(n)=>{let l=`@\\${y}`;return c[y]=[l,n],y++,t=!0,l}),!t)break}let a=f.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let y=c.length-1;y>=0;y--){let[t]=c[y];for(let n=a.length-1;n>=0;n--)if(a[n].indexOf(t)!==-1){a[n]=a[n].replace(t,c[y][1]);break}}this.#t.insert(a,this.#r,s,this.#e,!1),this.paths[e]=[this.#r++,s]}buildRegExp(){let e=this.#t.buildRegExpStr();if(e==="")return[/^$/,[],[]];let r=0,s=[],c=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(f,a,y)=>{if(a!==void 0)return s[++r]=Number(a),"$()";if(y!==void 0)return c[Number(y)]=++r,"";return""}),[new RegExp(`^${e}`),s,c]}};var wr=Q();function Sr(e){return wr[e]??=new RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,(r,s)=>s?`\\${s}`:r==="/*"?vt:r==="*"?".*":`/:${mt}`)}$`)}function $e(e,r){for(let s of Object.keys(e).sort((c,f)=>f.length-c.length))if(Sr(s).test(r))return[...e[s]]}var Ue=class{name="RegExpRouter";#e;#t;#r;constructor(){this.#e={["ALL"]:Q()},this.#t={["ALL"]:Q()},this.#r={["ALL"]:new yt}}#n(e,r){try{this.#r[e].insert(r,!/\*|\/:/.test(r))}catch(s){throw s===de?new He(r):s}}add(e,r,s){let c=this.#e,f=this.#t;if(!c)throw Error(Ie);if(!c[e]){this.#r[e]=new yt;for(let t of[c,f]){t[e]=Q();for(let n in t.ALL)t[e][n]=[...t.ALL[n]],this.#n(e,n)}}if(r==="/*")r="*";let a=e==="ALL"?Object.keys(c):[e];if(/\*$/.test(r)){let t=Sr(r);for(let n of a)if(!c[n][r])this.#n(n,r),c[n][r]=$e(c[n],r)||$e(c.ALL,r)||[];for(let n of[c,f])for(let l of a)for(let p in n[l])t.test(p)&&n[l][p].push([s,r]);return}let y=Pe(r)||[r];for(let t of y)for(let n of a){if(!f[n][t])this.#n(n,t),f[n][t]=$e(c[n],t)||$e(c.ALL,t)||[];f[n][t].push([s,t])}}match=gt;buildAllMatchers(){let e=Q();for(let r of Object.keys(this.#t))e[r]=this.#s(r);return this.#e=this.#t=this.#r=void 0,wr=Q(),e}#s(e){let r=this.#e[e],s=this.#t[e],c=this.#r[e],f=Q(),a=[],[y,t,n]=c.buildRegExp();for(let l of[r,s])for(let p in l){let g=l[p],d=c.paths[p];if(!d){f[p]=[g.map(([_])=>[_,Q()]),We];continue}a[d[0]]=g.map(([_,v])=>[_,c.paths[v][1].reduceRight((o,[i],S)=>(o[i]=n[d[1][S][1]],o),Q())])}return[y,t.map((l)=>a[l]),f]}};var Cr=class{name="SmartRouter";#e=[];#t=[];constructor(e){this.#e=e.routers}add(e,r,s){if(!this.#t)throw Error(Ie);this.#t.push([e,r,s])}match(e,r){if(!this.#t)throw Error("Fatal error");let s=this.#e,c=this.#t,f=s.length,a=0,y;for(;a<f;a++){let t=s[a];try{for(let n=0,l=c.length;n<l;n++)t.add(...c[n]);y=t.match(e,r)}catch(n){if(n instanceof He)continue;throw n}this.match=t.match.bind(t),this.#e=[t],this.#t=void 0;break}if(a===f)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,y}get activeRouter(){if(this.#t||this.#e.length!==1)throw Error("No active router has been determined yet.");return this.#e[0]}};var bt=Q(),Ks=0,xr=class e{#e=[];#t=Q();#r=[];#n;#s=bt;insert(r,s,c){let f=this,a=Kt(s),y=new Set,t=0;for(let n of a){let l=a[++t],p=Yt(n,l)||(l===void 0&&n&&n.indexOf("*")===n.length-1?n:null),g=Array.isArray(p),d=g?p[0]:p||n,_=f.#t[d]||=new e;if(p&&!_.#n)_.#n=p,f.#r.push(_);if(f=_,g)y.add(p[1])}f.#e.push({[r]:{handler:c,possibleKeys:[...y],score:++Ks}})}#i(r,s,c,f,a){for(let y=0,t=s.#e.length;y<t;y++){let n=s.#e[y],l=n[c]||n.ALL;if(l){l.params=Q(),r.push(l);for(let p=0,g=l.possibleKeys.length;p<g;p++){let d=l.possibleKeys[p];l.params[d]=a?.[d]&&!p?a[d]:f[d]??a?.[d]}}}}search(r,s){let c=[];this.#s=bt;let f=[this],a=ot(s),y=[],t=a.length,n=null;for(let l=0;l<t;l++){let p=a[l],g=l===t-1,d=[];for(let v=0,o=f.length;v<o;v++){let i=f[v],S=i.#t[p];if(S)if(S.#s=i.#s,g){if(S.#t["*"])this.#i(c,S.#t["*"],r,i.#s);this.#i(c,S,r,i.#s)}else d.push(S);for(let h of i.#r){let m=h.#n,u=i.#s===bt?{}:{...i.#s};if(typeof m==="string"){if(m==="*"||p.startsWith(m.slice(0,-1))){if(this.#i(c,h,r,i.#s),m==="*")h.#s=u,d.push(h)}continue}let[,w,C]=m;if(!p&&C===!0)continue;if(C!==!0){if(!n){n=[];let O=s[0]==="/"?1:0;for(let A=0;A<t;A++)n[A]=O,O+=a[A].length+1}let T=s.slice(n[l]),B=C.exec(T);if(B){if(!Object.hasOwn(u,w))u[w]=B[0];if(this.#i(c,h,r,i.#s,u),B[0].length===T.length&&h.#t["*"])this.#i(c,h.#t["*"],r,i.#s,u);for(let O in h.#t){h.#s=u;let A=B[0].match(/\//g)?.length??0;(y[A]||=[]).push(h);break}continue}}if(C===!0||C.test(p)){if(!Object.hasOwn(u,w))u[w]=p;if(g){if(this.#i(c,h,r,u,i.#s),h.#t["*"])this.#i(c,h.#t["*"],r,u,i.#s)}else h.#s=u,d.push(h)}}}let _=y.shift();f=_?d.concat(_):d}if(c[1])c.sort((l,p)=>l.score-p.score);return[c.map(({handler:l,params:p})=>[l,p])]}};var wt=class{name="TrieRouter";#e=new xr;add(e,r,s){for(let c of Pe(r)||[r])this.#e.insert(e,c,s)}match(e,r){return this.#e.search(e,r)}};var je=class extends vr{constructor(e={}){super(e);this.router=e.router??new Cr({routers:[new Ue,new wt]})}};var Ys="Payload Too Large",Er=(e)=>{let r=e.onError||(()=>{let c=new Response(Ys,{status:413});throw new ft(413,{res:c})}),s=e.maxSize;return async function(f,a){if(!f.req.raw.body)return a();let y=f.req.raw.headers.has("transfer-encoding");if(f.req.raw.headers.has("content-length")&&!y)return parseInt(f.req.raw.headers.get("content-length")||"0",10)>s?r(f):a();let t=0,n=[],l=f.req.raw.body.getReader();for(;;){let{done:g,value:d}=await l.read();if(g)break;if(t+=d.length,t>s)return r(f);n.push(d)}let p={body:new ReadableStream({start(g){for(let d of n)g.enqueue(d);g.close()}}),duplex:"half"};return f.req.raw=new Request(f.req.raw,p),a()}};var Ar=(e)=>e;var K=0,Y=0,J=0,V=0,te;((e)=>{function r(f,a,y,t){return t!==void 0?`#${_e(f)}${_e(a)}${_e(y)}${_e(t)}`:`#${_e(f)}${_e(a)}${_e(y)}`}e.toCss=r;function s(f,a,y,t=255){return(f<<24|a<<16|y<<8|t)>>>0}e.toRgba=s;function c(f,a,y,t){return{css:e.toCss(f,a,y,t),rgba:e.toRgba(f,a,y,t)}}e.toColor=c})(te||={});var Js;((e)=>{function r(n,l){if(V=(l.rgba&255)/255,V===1)return{css:l.css,rgba:l.rgba};let p=l.rgba>>24&255,g=l.rgba>>16&255,d=l.rgba>>8&255,_=n.rgba>>24&255,v=n.rgba>>16&255,o=n.rgba>>8&255;K=_+Math.round((p-_)*V),Y=v+Math.round((g-v)*V),J=o+Math.round((d-o)*V);let i=te.toCss(K,Y,J),S=te.toRgba(K,Y,J);return{css:i,rgba:S}}e.blend=r;function s(n){return(n.rgba&255)===255}e.isOpaque=s;function c(n,l,p){let g=ze.ensureContrastRatio(n.rgba,l.rgba,p);if(g)return te.toColor(g>>24&255,g>>16&255,g>>8&255)}e.ensureContrastRatio=c;function f(n){let l=(n.rgba|255)>>>0;return[K,Y,J]=ze.toChannels(l),{css:te.toCss(K,Y,J),rgba:l}}e.opaque=f;function a(n,l){return V=Math.round(l*255),[K,Y,J]=ze.toChannels(n.rgba),{css:te.toCss(K,Y,J,V),rgba:te.toRgba(K,Y,J,V)}}e.opacity=a;function y(n,l){return V=n.rgba&255,a(n,V*l/255)}e.multiplyOpacity=y;function t(n){return[n.rgba>>24&255,n.rgba>>16&255,n.rgba>>8&255]}e.toColorRGB=t})(Js||={});var Z;((e)=>{let r,s;try{let f=document.createElement("canvas");f.width=1,f.height=1;let a=f.getContext("2d",{willReadFrequently:!0});a&&(r=a,r.globalCompositeOperation="copy",s=r.createLinearGradient(0,0,1,1))}catch{}function c(f){if(f.match(/#[\da-f]{3,8}/i))switch(f.length){case 4:return K=parseInt(f.slice(1,2).repeat(2),16),Y=parseInt(f.slice(2,3).repeat(2),16),J=parseInt(f.slice(3,4).repeat(2),16),te.toColor(K,Y,J);case 5:return K=parseInt(f.slice(1,2).repeat(2),16),Y=parseInt(f.slice(2,3).repeat(2),16),J=parseInt(f.slice(3,4).repeat(2),16),V=parseInt(f.slice(4,5).repeat(2),16),te.toColor(K,Y,J,V);case 7:return{css:f,rgba:(parseInt(f.slice(1),16)<<8|255)>>>0};case 9:return{css:f,rgba:parseInt(f.slice(1),16)>>>0}}let a=f.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return K=parseInt(a[1]),Y=parseInt(a[2]),J=parseInt(a[3]),V=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),te.toColor(K,Y,J,V);if(!r||!s)throw Error("css.toColor: Unsupported css format");if(r.fillStyle=s,r.fillStyle=f,typeof r.fillStyle!="string")throw Error("css.toColor: Unsupported css format");if(r.fillRect(0,0,1,1),[K,Y,J,V]=r.getImageData(0,0,1,1).data,V!==255)throw Error("css.toColor: Unsupported css format");return{rgba:te.toRgba(K,Y,J,V),css:f}}e.toColor=c})(Z||={});var re;((e)=>{function r(c){return s(c>>16&255,c>>8&255,c&255)}e.relativeLuminance=r;function s(c,f,a){let y=c/255,t=f/255,n=a/255,l=y<=0.03928?y/12.92:Math.pow((y+0.055)/1.055,2.4),p=t<=0.03928?t/12.92:Math.pow((t+0.055)/1.055,2.4),g=n<=0.03928?n/12.92:Math.pow((n+0.055)/1.055,2.4);return l*0.2126+p*0.7152+g*0.0722}e.relativeLuminance2=s})(re||={});var ze;((e)=>{function r(y,t){if(V=(t&255)/255,V===1)return t;let n=t>>24&255,l=t>>16&255,p=t>>8&255,g=y>>24&255,d=y>>16&255,_=y>>8&255;return K=g+Math.round((n-g)*V),Y=d+Math.round((l-d)*V),J=_+Math.round((p-_)*V),te.toRgba(K,Y,J)}e.blend=r;function s(y,t,n){let l=re.relativeLuminance(y>>8),p=re.relativeLuminance(t>>8);if(he(l,p)<n){if(p<l){let _=c(y,t,n),v=he(l,re.relativeLuminance(_>>8));if(v<n){let o=f(y,t,n),i=he(l,re.relativeLuminance(o>>8));return v>i?_:o}return _}let g=f(y,t,n),d=he(l,re.relativeLuminance(g>>8));if(d<n){let _=c(y,t,n),v=he(l,re.relativeLuminance(_>>8));return d>v?g:_}return g}}e.ensureContrastRatio=s;function c(y,t,n){let l=y>>24&255,p=y>>16&255,g=y>>8&255,d=t>>24&255,_=t>>16&255,v=t>>8&255,o=he(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));for(;o<n&&(d>0||_>0||v>0);)d-=Math.max(0,Math.ceil(d*0.1)),_-=Math.max(0,Math.ceil(_*0.1)),v-=Math.max(0,Math.ceil(v*0.1)),o=he(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));return(d<<24|_<<16|v<<8|255)>>>0}e.reduceLuminance=c;function f(y,t,n){let l=y>>24&255,p=y>>16&255,g=y>>8&255,d=t>>24&255,_=t>>16&255,v=t>>8&255,o=he(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));for(;o<n&&(d<255||_<255||v<255);)d=Math.min(255,d+Math.ceil((255-d)*0.1)),_=Math.min(255,_+Math.ceil((255-_)*0.1)),v=Math.min(255,v+Math.ceil((255-v)*0.1)),o=he(re.relativeLuminance2(d,_,v),re.relativeLuminance2(l,p,g));return(d<<24|_<<16|v<<8|255)>>>0}e.increaseLuminance=f;function a(y){return[y>>24&255,y>>16&255,y>>8&255,y&255]}e.toChannels=a})(ze||={});function _e(e){let r=e.toString(16);return r.length<2?"0"+r:r}function he(e,r){return e<r?(r+0.05)/(e+0.05):(e+0.05)/(r+0.05)}var Zs=Object.freeze((()=>{let e=[Z.toColor("#2e3436"),Z.toColor("#cc0000"),Z.toColor("#4e9a06"),Z.toColor("#c4a000"),Z.toColor("#3465a4"),Z.toColor("#75507b"),Z.toColor("#06989a"),Z.toColor("#d3d7cf"),Z.toColor("#555753"),Z.toColor("#ef2929"),Z.toColor("#8ae234"),Z.toColor("#fce94f"),Z.toColor("#729fcf"),Z.toColor("#ad7fa8"),Z.toColor("#34e2e2"),Z.toColor("#eeeeec")],r=[0,95,135,175,215,255];for(let s=0;s<216;s++){let c=r[s/36%6|0],f=r[s/6%6|0],a=r[s%6];e.push({css:te.toCss(c,f,a),rgba:te.toRgba(c,f,a)})}for(let s=0;s<24;s++){let c=8+s*10;e.push({css:te.toCss(c,c,c),rgba:te.toRgba(c,c,c)})}return e})());function kr(e,r,s){return Math.max(r,Math.min(e,s))}function ei(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var Lr=class{constructor(e){this._buffer=e}serialize(e,r){let s=this._buffer.getNullCell(),c=this._buffer.getNullCell(),f=s,a=e.start.y,y=e.end.y,t=e.start.x,n=e.end.x;this._beforeSerialize(y-a,a,y);for(let l=a;l<=y;l++){let p=this._buffer.getLine(l);if(p){let g=l===e.start.y?t:0,d=l===e.end.y?n:p.length;for(let _=g;_<d;_++){let v=p.getCell(_,f===s?c:s);if(!v){console.warn(`Can't get cell at row=${l}, col=${_}`);continue}this._nextCell(v,f,l,_),f=v}}this._rowEnd(l,l===y)}return this._afterSerialize(),this._serializeString(r)}_nextCell(e,r,s,c){}_rowEnd(e,r){}_beforeSerialize(e,r,s){}_afterSerialize(){}_serializeString(e){return""}};function Tr(e,r){return e.getFgColorMode()===r.getFgColorMode()&&e.getFgColor()===r.getFgColor()}function ue(e,r){return e.getBgColorMode()===r.getBgColorMode()&&e.getBgColor()===r.getBgColor()}function Rr(e,r){return e.isInverse()===r.isInverse()&&e.isBold()===r.isBold()&&e.isUnderline()===r.isUnderline()&&e.isOverline()===r.isOverline()&&e.isBlink()===r.isBlink()&&e.isInvisible()===r.isInvisible()&&e.isItalic()===r.isItalic()&&e.isDim()===r.isDim()&&e.isStrikethrough()===r.isStrikethrough()}var ti=class extends Lr{constructor(e,r){super(e);this._terminal=r,this._rowIndex=0,this._allRows=[],this._allRowSeparators=[],this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,r,s){this._allRows=Array(e),this._lastContentCursorRow=r,this._lastCursorRow=r,this._firstRow=r}_rowEnd(e,r){this._nullCellCount>0&&!ue(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let s="";if(!r){e-this._firstRow>=this._terminal.rows&&this._buffer.getLine(this._cursorStyleRow)?.getCell(this._cursorStyleCol,this._backgroundCell);let c=this._buffer.getLine(e),f=this._buffer.getLine(e+1);if(!f.isWrapped)s=`\r
31
+ `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{s="";let a=c.getCell(c.length-1,this._thisRowLastChar),y=c.getCell(c.length-2,this._thisRowLastSecondChar),t=f.getCell(0,this._nextRowFirstChar),n=t.getWidth()>1,l=!1;(t.getChars()&&n?this._nullCellCount<=1:this._nullCellCount<=0)&&((a.getChars()||a.getWidth()===0)&&ue(a,t)&&(l=!0),n&&(y.getChars()||y.getWidth()===0)&&ue(a,t)&&ue(y,t)&&(l=!0)),l||(s="-".repeat(this._nullCellCount+1),s+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(s+="\x1B[A",s+=`\x1B[${c.length-this._nullCellCount}C`,s+=`\x1B[${this._nullCellCount}X`,s+=`\x1B[${c.length-this._nullCellCount}D`,s+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=s,this._currentRow="",this._nullCellCount=0}_diffStyle(e,r){let s=[],c=!Tr(e,r),f=!ue(e,r),a=!Rr(e,r);if(c||f||a)if(e.isAttributeDefault())r.isAttributeDefault()||s.push(0);else{if(c){let y=e.getFgColor();e.isFgRGB()?s.push(38,2,y>>>16&255,y>>>8&255,y&255):e.isFgPalette()?y>=16?s.push(38,5,y):s.push(y&8?90+(y&7):30+(y&7)):s.push(39)}if(f){let y=e.getBgColor();e.isBgRGB()?s.push(48,2,y>>>16&255,y>>>8&255,y&255):e.isBgPalette()?y>=16?s.push(48,5,y):s.push(y&8?100+(y&7):40+(y&7)):s.push(49)}a&&(e.isInverse()!==r.isInverse()&&s.push(e.isInverse()?7:27),e.isBold()!==r.isBold()&&s.push(e.isBold()?1:22),e.isUnderline()!==r.isUnderline()&&s.push(e.isUnderline()?4:24),e.isOverline()!==r.isOverline()&&s.push(e.isOverline()?53:55),e.isBlink()!==r.isBlink()&&s.push(e.isBlink()?5:25),e.isInvisible()!==r.isInvisible()&&s.push(e.isInvisible()?8:28),e.isItalic()!==r.isItalic()&&s.push(e.isItalic()?3:23),e.isDim()!==r.isDim()&&s.push(e.isDim()?2:22),e.isStrikethrough()!==r.isStrikethrough()&&s.push(e.isStrikethrough()?9:29))}return s}_nextCell(e,r,s,c){if(e.getWidth()===0)return;let f=e.getChars()==="",a=this._diffStyle(e,this._cursorStyle);if(f?!ue(this._cursorStyle,e):a.length>0){this._nullCellCount>0&&(ue(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=c,this._currentRow+=`\x1B[${a.join(";")}m`;let y=this._buffer.getLine(s);y!==void 0&&(y.getCell(c,this._cursorStyle),this._cursorStyleRow=s,this._cursorStyleCol=c)}f?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(ue(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=s,this._lastContentCursorCol=this._lastCursorCol=c+e.getWidth())}_serializeString(e){let r=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(r=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let s="";for(let a=0;a<r;a++)s+=this._allRows[a],a+1<r&&(s+=this._allRowSeparators[a]);if(!e){let a=this._buffer.baseY+this._buffer.cursorY,y=this._buffer.cursorX,t=a!==this._lastCursorRow||y!==this._lastCursorCol,n=(l)=>{l>0?s+=`\x1B[${l}C`:l<0&&(s+=`\x1B[${-l}D`)};t&&(((l)=>{l>0?s+=`\x1B[${l}B`:l<0&&(s+=`\x1B[${-l}A`)})(a-this._lastCursorRow),n(y-this._lastCursorCol))}let c=this._terminal._core._inputHandler._curAttrData,f=this._diffStyle(c,this._cursorStyle);return f.length>0&&(s+=`\x1B[${f.join(";")}m`),s}},Br=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,r,s){let c=r.length,f=s===void 0?c:kr(s+e.rows,0,c);return this._serializeBufferByRange(e,r,{start:c-f,end:c-1},!1)}_serializeBufferByRange(e,r,s,c){return new ti(r,e).serialize({start:{x:0,y:typeof s.start=="number"?s.start:s.start.line},end:{x:e.cols,y:typeof s.end=="number"?s.end:s.end.line}},c)}_serializeBufferAsHTML(e,r){let s=e.buffer.active,c=new ri(s,e,r),f=r.onlySelection??!1,a=r.range;if(a)return c.serialize({start:{x:a.startCol,y:(a.startLine,a.startLine)},end:{x:e.cols,y:(a.endLine,a.endLine)}});if(!f){let t=s.length,n=r.scrollback,l=n===void 0?t:kr(n+e.rows,0,t);return c.serialize({start:{x:0,y:t-l},end:{x:e.cols,y:t-1}})}let y=this._terminal?.getSelectionPosition();return y!==void 0?c.serialize({start:{x:y.start.x,y:y.start.y},end:{x:y.end.x,y:y.end.y}}):""}_serializeModes(e){let r="",s=e.modes;if(s.applicationCursorKeysMode&&(r+="\x1B[?1h"),s.applicationKeypadMode&&(r+="\x1B[?66h"),s.bracketedPasteMode&&(r+="\x1B[?2004h"),s.insertMode&&(r+="\x1B[4h"),s.originMode&&(r+="\x1B[?6h"),s.reverseWraparoundMode&&(r+="\x1B[?45h"),s.sendFocusMode&&(r+="\x1B[?1004h"),s.wraparoundMode===!1&&(r+="\x1B[?7l"),s.mouseTrackingMode!=="none")switch(s.mouseTrackingMode){case"x10":r+="\x1B[?9h";break;case"vt200":r+="\x1B[?1000h";break;case"drag":r+="\x1B[?1002h";break;case"any":r+="\x1B[?1003h";break}return r}serialize(e){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");let r=e?.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e?.scrollback);if(!e?.excludeAltBuffer&&this._terminal.buffer.active.type==="alternate"){let s=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);r+=`\x1B[?1049h\x1B[H${s}`}return e?.excludeModes||(r+=this._serializeModes(this._terminal)),r}serializeAsHTML(e){if(!this._terminal)throw Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},ri=class extends Lr{constructor(e,r,s){super(e);this._terminal=r,this._options=s,this._currentRow="",this._htmlContent="",r._core._themeService?this._ansiColors=r._core._themeService.colors.ansi:this._ansiColors=Zs}_padStart(e,r,s){return r=r>>0,s=s??" ",e.length>r?e:(r-=e.length,r>s.length&&(s+=s.repeat(r/s.length)),s.slice(0,r)+e)}_beforeSerialize(e,r,s){this._htmlContent+="<html><body><!--StartFragment--><pre>";let c="#000000",f="#ffffff";(this._options.includeGlobalBackground??!1)&&(c=this._terminal.options.theme?.foreground??"#ffffff",f=this._terminal.options.theme?.background??"#000000");let a=[];a.push("color: "+c+";"),a.push("background-color: "+f+";"),a.push("font-family: "+this._terminal.options.fontFamily+";"),a.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+a.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(e,r){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,r){let s=r?e.getFgColor():e.getBgColor();if(r?e.isFgRGB():e.isBgRGB())return"#"+[s>>16&255,s>>8&255,s&255].map((c)=>this._padStart(c.toString(16),2,"0")).join("");if(r?e.isFgPalette():e.isBgPalette())return this._ansiColors[s].css}_diffStyle(e,r){let s=[],c=!Tr(e,r),f=!ue(e,r),a=!Rr(e,r);if(c||f||a){let y=this._getHexColor(e,!0);y&&s.push("color: "+y+";");let t=this._getHexColor(e,!1);return t&&s.push("background-color: "+t+";"),e.isInverse()&&s.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&s.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?s.push("text-decoration: overline underline;"):e.isUnderline()?s.push("text-decoration: underline;"):e.isOverline()&&s.push("text-decoration: overline;"),e.isBlink()&&s.push("text-decoration: blink;"),e.isInvisible()&&s.push("visibility: hidden;"),e.isItalic()&&s.push("font-style: italic;"),e.isDim()&&s.push("opacity: 0.5;"),e.isStrikethrough()&&s.push("text-decoration: line-through;"),s}}_nextCell(e,r,s,c){if(e.getWidth()===0)return;let f=e.getChars()==="",a=this._diffStyle(e,r);a&&(this._currentRow+=a.length===0?"</span><span>":"</span><span style='"+a.join(" ")+"'>"),f?this._currentRow+=" ":this._currentRow+=ei(e.getChars())}_serializeString(){return this._htmlContent}};var Wr=Ps(Mr(),1);var si=/\x1b\[M[\s\S]{3}|\x1b\[[0-?]*[ -\/]*[@-~]|\x1bO[\s\S]|\x1b[\]P_^X][\s\S]*?(?:\x07|\x1b\\)/g;function ii(e){return/[\r\x20-\x7e\u00a0-\uffff]/.test(e.replace(si,""))}class St{onChange;status="idle";lastInput=0;burstStart;idleTimer;disposed=!1;constructor(e){this.onChange=e}input(e){if(!ii(e))return;this.lastInput=Date.now()}output(){let e=Date.now();if(this.disposed||e-this.lastInput<200)return;if(this.burstStart===void 0&&e-this.lastInput>2000)return;if(this.burstStart??=e,clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>this.settle(),2000),this.status==="idle"&&e-this.burstStart>=1000)this.set("working")}reset(){clearTimeout(this.idleTimer),this.lastInput=0,this.burstStart=void 0,this.status="idle"}dispose(){this.disposed=!0,clearTimeout(this.idleTimer)}settle(){this.burstStart=void 0,this.set("idle")}set(e){if(this.status===e)return;this.status=e,this.onChange(e)}}async function Ge(e,r){let s=Bun.spawn(e,{stdout:"pipe",stderr:"ignore"}),c,f=new Promise((a,y)=>{c=setTimeout(()=>{s.kill(),y(Error(`${e[0]} timed out`))},r)});try{let a=Promise.all([new Response(s.stdout).text(),s.exited]).then(([y])=>y);return await Promise.race([a,f])}finally{clearTimeout(c)}}var ni=new Set(["claude","codex","gemini","opencode","aider","cursor-agent","copilot","qwen","amp"]),oi=/^(node|nodejs|bun|deno|python[\d.]*)$/,Pr=(e)=>e.slice(e.lastIndexOf("/")+1).replace(/\.(js|mjs|cjs|ts|py)$/,"");function Ct(e){let r=e.trim().split(/\s+/),s=Pr(r[0]??"");if(oi.test(s)){let c=r.slice(1).find((f)=>!f.startsWith("-"));s=c?Pr(c):""}return ni.has(s)}var ai=2000;function Or(e){return Ge(["ps",...e],ai)}async function qe(e,r){try{if(r??=(await Or(["-o","tty=","-p",String(e)])).trim(),!r||r.startsWith("?"))return;let s=(await Or(["-ww","-o","pgid=,tpgid=,args=","-t",r])).split(`
32
+ `).map((a)=>a.trim().match(/^(\d+)\s+(-?\d+)\s+(.*)$/)).filter((a)=>a!==null).map(([,a,y,t])=>({pgid:Number(a),tpgid:Number(y),args:t})),c=s[0]?.tpgid;if(c===void 0||c<=0)return;let f=s.some((a)=>a.pgid===c&&Ct(a.args));return{tty:r,foreground:{pgid:c,agent:f}}}catch{return}}class xt{terminal;trimmed;integrated=!1;last;running;constructor(e,r){this.terminal=e;this.trimmed=r;e.parser.registerOscHandler(133,(s)=>{if(this.integrated=!0,e.buffer.active.type!=="normal")return!1;let c=s.split(";")[0];if(c==="C")this.running?.marker.dispose(),this.running=this.here();else if((c==="D"||c==="A")&&this.running){let f=this.here();if(f)this.setLast({start:this.running,end:f});else this.running.marker.dispose();this.running=void 0}return!1}),e.parser.registerEscHandler({final:"c"},()=>(this.setLast(void 0),this.running?.marker.dispose(),this.running=void 0,!1))}lastOutput(){let e=this.unavailable(),r=this.last;if(e||!r)return{unavailable:e??"no-command"};let s=r.start.marker.isDisposed?{x:0,y:0}:{x:r.start.x,y:r.start.marker.line},c={x:r.end.x,y:r.end.marker.line},f=this.terminal.buffer.normal,a="";for(let t=s.y;t<=c.y;t++){let n=t===s.y?s.x:0;if(t===c.y&&c.x===0&&t>s.y)break;let l=f.getLine(t);if(!l)break;if(t>s.y&&!l.isWrapped)a+=`
33
33
  `;a+=l.translateToString(!0,n,t===c.y?c.x:void 0)}a=a.replace(/\n+$/,"");let y=a===""?0:a.split(`
34
- `).length;return{text:a,lines:y,start:s,end:c}}unavailable(){if(!this.integrated)return"no-integration";if(this.terminal.buffer.active.type!=="normal")return"alternate";if(!this.last||this.last.end.marker.isDisposed)return"no-command";return}state(){let e=this.trimmed.count,r=(f)=>f&&!f.marker.isDisposed?{x:f.x,y:f.marker.line+e}:void 0,s=r(this.last?.end),c=this.last?.start.marker.isDisposed?{x:0,y:e}:r(this.last?.start);return{integrated:this.integrated,last:c&&s?{start:c,end:s}:void 0,running:r(this.running)}}restore(e){if(this.integrated||=e.integrated,this.terminal.buffer.active.type!=="normal")return;if(!this.last&&e.last){let r=this.place(e.last.start),s=this.place(e.last.end);if(r&&s)this.setLast({start:r,end:s});else r?.marker.dispose(),s?.marker.dispose()}if(!this.running&&e.running)this.running=this.place(e.running)}setLast(e){this.last?.start.marker.dispose(),this.last?.end.marker.dispose(),this.last=e}here(){let e=this.terminal.registerMarker(0);return e&&{x:this.terminal.buffer.active.cursorX,marker:e}}place({x:e,y:r}){if(r<this.trimmed.count)return;let s=this.terminal.buffer.active,c=this.terminal.registerMarker(r-this.trimmed.count-(s.baseY+s.cursorY));return c&&{x:e,marker:c}}}import{readlink as ii,stat as ni}from"fs/promises";var oi=2000;async function xt(e){try{let r=process.platform==="linux"?await ii(`/proc/${e}/cwd`):await ai(e);return r&&(await ni(r)).isDirectory()?r:void 0}catch{return}}async function ai(e){return(await Ge(["lsof","-a","-p",String(e),"-d","cwd","-Fn"],oi)).split(`
35
- `).find((s)=>s.startsWith("n"))?.slice(1)}var Xe=1000;class Et{count;constructor(e,r=0){this.count=r;let s=e._core._bufferService.buffers,c,f,a=()=>{if(s.normal===c)return;f?.dispose(),c=s.normal,f=c.lines.onTrim((y)=>this.count+=y)};a(),s.onBufferActivate(a)}}var Ce={cols:512,rows:256};function ye({cols:e,rows:r}){return{cols:Math.min(e,Ce.cols),rows:Math.min(r,Ce.rows)}}var Pr=new TextEncoder,ci="\u2500\u2500 Accompany \u3092\u518D\u8D77\u52D5\u3057\u307E\u3057\u305F \u2500\u2500",hi=2000,li=500,ui=1500,fi=200,di=1000,pi=500;function _i(e){try{return process.kill(-e,0),!0}catch(r){return r.code==="EPERM"}}class At{command;onExit;onTitleChange;proc;listeners=new Set;size={cols:80,rows:24};requestedSizes=new Map;screen=new Ir.Terminal({...this.size,scrollback:Xe,allowProposedApi:!0});serializer=new Tr;trimmed=new Et(this.screen);marks=new Ct(this.screen,this.trimmed);cursorHidden=!1;mouseEncoding;title="";activity;onOutput;onStatus;foreground;tty;detectTimer;detecting=!1;detectAgain=!1;killed=!1;startTimer;hangingUp;unseen=!1;startDir;lastCwd;cwdCheckedAt=Number.NEGATIVE_INFINITY;cwdPgid;lastInputAt=Number.NEGATIVE_INFINITY;startedAsAgent;constructor(e,r=()=>{},s=()=>{},c=()=>{},{restored:f,onOutput:a=()=>{},cwd:y}={}){this.command=e;this.onExit=r;this.onTitleChange=s;if(this.startDir=y,this.startedAsAgent=wt(e.join(" ")),this.lastCwd=y,this.onOutput=a,this.onStatus=c,this.activity=new St((t)=>{if(this.unseen=t==="idle",this.foreground?.agent)c()}),this.screen.loadAddon(this.serializer),f)this.size={cols:f.cols,rows:f.rows},this.screen.resize(f.cols,f.rows),this.screen.write(`${f.scrollback}\x1B[0m\r
36
- \x1B[2m${ci}\x1B[0m\r
37
- `);this.screen.onTitleChange((t)=>{let n=gi(t);if(n===this.title)return;this.title=n,this.onTitleChange()});for(let[t,n]of[["h",!0],["l",!1]])this.screen.parser.registerCsiHandler({prefix:"?",final:t},(l)=>{if(l.includes(25))this.cursorHidden=!n;for(let p of[1006,1016])if(l.includes(p))this.mouseEncoding=n?p:void 0;return!1});this.screen.parser.registerEscHandler({final:"c"},()=>{if(this.cursorHidden=!1,this.mouseEncoding=void 0,this.title!=="")this.title="",this.onTitleChange();return!1})}attach(e){let r=[],s=!1,c=(f)=>s?e(f):r.push(f);if(this.listeners.add(c),this.screen.write("",()=>{e({type:"resize",size:this.size}),e({type:"trimmed",lines:this.trimmed.count}),e({type:"marks",...this.marks.state()});let f=this.serializer.serialize()+(this.cursorHidden?"\x1B[?25l":"")+(this.mouseEncoding?`\x1B[?${this.mouseEncoding}h`:"");if(f)e({type:"output",data:Pr.encode(f)});e({type:"restored"}),r.forEach(e),s=!0}),!this.proc&&!this.startTimer)this.startTimer=setTimeout(()=>this.start(),hi);return{resize:(f)=>{this.requestedSizes.set(c,f),this.fitToSmallest(),this.start()},detach:()=>{this.listeners.delete(c),this.requestedSizes.delete(c),this.fitToSmallest()}}}start(){if(clearTimeout(this.startTimer),this.proc||this.killed)return;this.proc=this.spawn((e)=>Bun.spawn(this.command,{cwd:e,terminal:{...this.size,data:(r,s)=>{this.screen.write(s),this.activity.output(),this.scheduleDetect(),this.broadcast({type:"output",data:s}),this.onOutput()}}})),this.proc.exited.then(()=>this.onExit())}spawn(e){if(this.startDir)try{return e(this.startDir)}catch{}return e()}async cwd(){let e=this.proc?.pid;if(e===void 0)return this.startDir;let r=await qe(e,this.tty);return(r&&await xt(r.foreground.pgid))??await xt(e)}async savedCwd({refresh:e=!1}={}){if(this.proc===void 0)return this.lastCwd;if(!e){let s=this.lastInputAt>=this.cwdCheckedAt-fi,c=this.foreground?.agent===!0&&this.foreground.pgid===this.cwdPgid;if(!s||c)return this.lastCwd}this.cwdCheckedAt=performance.now(),this.cwdPgid=this.foreground?.pgid;let r=await Promise.race([this.cwd(),Bun.sleep(ui).then(()=>{return})]);if(r)this.lastCwd=r;return this.lastCwd}write(e){this.lastInputAt=performance.now(),this.activity.input(e),this.scheduleDetect(),this.proc?.terminal?.write(e)}reset(){let e=Pr.encode("\x1Bc");this.screen.write(e),this.broadcast({type:"output",data:e})}snapshot(){return new Promise((e)=>this.screen.write("",()=>e({...this.size,scrollback:this.serializer.serialize({excludeAltBuffer:!0,excludeModes:!0})})))}get status(){if(!this.foreground?.agent)return;return this.activity.status==="idle"&&this.unseen?"done":this.activity.status}markSeen(){let e=this.status==="done";return this.unseen=!1,e}kill(){if(this.hangingUp)return this.hangingUp;this.killed=!0,clearTimeout(this.startTimer),clearTimeout(this.detectTimer),this.activity.dispose();let e=this.proc;if(!e||e.exitCode!==null||e.signalCode!==null)return this.hangingUp=Promise.resolve();let r=Bun.sleep(di);return this.hangingUp=(async()=>{let s=await Promise.race([qe(e.pid,this.tty),Bun.sleep(pi)]);if(e.exitCode!==null||e.signalCode!==null)return;let c=[...new Set([e.pid,s?.foreground.pgid])].filter((t)=>t!==void 0&&t>1);for(let t of c)try{process.kill(-t,"SIGHUP")}catch{}let f=c.filter((t)=>t!==e.pid),a=!1,y=(async()=>{await e.exited;while(!a&&f.some(_i))await Bun.sleep(20)})();await Promise.race([y,r]),a=!0})(),this.hangingUp}scheduleDetect(){if(this.detecting){this.detectAgain=!0;return}if(this.detectTimer||this.killed)return;this.detectTimer=setTimeout(()=>{this.detectTimer=void 0,this.detect()},li)}async detect(){let e=this.proc?.pid;if(e===void 0)return;this.detecting=!0,this.detectAgain=!1;let r;try{r=await qe(e,this.tty)}finally{if(this.detecting=!1,this.detectAgain)this.scheduleDetect()}if(this.killed||!r)return;this.tty=r.tty;let s=this.foreground,c=r.foreground;if(this.foreground=c,!c.agent){if(this.unseen=!1,s?.agent)this.onStatus();return}if(!s?.agent||s.pgid!==c.pgid){if(!this.startedAsAgent||c.pgid!==e)this.activity.reset(),this.unseen=!1;this.onStatus()}}fitToSmallest(){let e=[...this.requestedSizes.values()];if(e.length===0)return;let r=(c)=>{let f=e.map((t)=>t.fits[c]),a=e.flatMap((t)=>t.min?[t.min[c]]:[]),y=a.length>0?Math.min(...a):0;return Math.min(Math.max(...f),Math.max(Math.min(...f),y))},s=ye({cols:r("cols"),rows:r("rows")});if(s.cols===this.size.cols&&s.rows===this.size.rows)return;this.size=s,this.screen.resize(s.cols,s.rows),this.proc?.terminal?.resize(s.cols,s.rows),this.broadcast({type:"resize",size:s})}broadcast(e){this.listeners.forEach((r)=>r(e))}}var Or=256;function gi(e){let r=[...kt(e)];return r.length>Or?`${r.slice(0,Or-1).join("")}\u2026`:r.join("")}function kt(e){return e.replace(/[\u2028\u2029\u0085]/g," ").replace(/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu,"")}var Hr=32,mi=Hr*32,vi=new Intl.Segmenter(void 0,{granularity:"grapheme"}),yi=/[\p{Default_Ignorable_Code_Point}\s\u2800]/gu;function ge(e){let r=kt(e.slice(0,mi).replace(/[\t\n\v\f\r]/g," ")).replace(/\p{Cs}/gu,"").replace(/\s+/g," ").trim(),s=[...vi.segment(r)].slice(0,Hr).map((c)=>c.segment).join("").trim();return s.replace(yi,"")?s:void 0}function xe(e){return e.normalize("NFKC").replace(/[\p{Default_Ignorable_Code_Point}\p{M}]/gu,"")}var Nr={width:480,height:1080},Ee={width:1920,height:1080};function Ae(e){if(typeof e!=="object"||e===null)return;let{width:r,height:s}=e,c=(f,a)=>Number.isSafeInteger(f)&&f>=0&&f<=a;return c(r,Ee.width)&&c(s,Ee.height)?{width:r,height:s}:void 0}function Fr(e){let r=/^(\d+)x(\d+)$/.exec(e);return r?Ae({width:Number(r[1]),height:Number(r[2])}):void 0}var Ur=100;function Wr(e){return e.replace(/[^\P{Cc}\n\t]|\p{Cf}/gu,"")}function Lt(e,r){return[...e].slice(0,r).join("")}function Ve(e){if(typeof e.content!=="string"||typeof e.name!=="string")return;let r=Lt(Wr(e.content.replace(/\r\n?|[\u2028\u2029\u0085]/g,`
38
- `)),1e4).replace(/\n+$/,"");if(r.trim()==="")return;return{name:Lt(Wr(e.name.replace(/[\r\n\t\u2028\u2029\u0085]/g," ")).trim(),100)||Lt(r.trim().split(`
39
- `)[0],100),content:r,run:e.run===!0}}import{lstatSync as bi,mkdirSync as Si,mkdtempSync as wi,rmSync as Ci,writeFileSync as xi}from"fs";import{tmpdir as Ei}from"os";import{join as Tt}from"path";var jr=104857600;class Rt{root=$r();nextId=1;async save(e){let r=await Promise.all(e.map(async(f)=>new Uint8Array(await f.arrayBuffer()))),s=Tt(this.currentRoot(),String(this.nextId++));Si(s,{mode:448});let c=new Set;return e.map((f,a)=>{let y=zr(f.name);for(let n=2;c.has(y);n++)y=`${n}-${zr(f.name)}`;c.add(y);let t=Tt(s,y);return xi(t,r[a],{flag:"wx",mode:384}),t})}remove(){Ci(this.root,{recursive:!0,force:!0})}currentRoot(){if(!Ai(this.root))this.root=$r();return this.root}}function $r(){return wi(Tt(Ei(),"accompany-"))}function Ai(e){try{let r=bi(e);return r.isDirectory()&&r.uid===process.getuid?.()&&(r.mode&63)===0}catch{return!1}}function zr(e){let r=e.split(/[\\/]/).pop()??"";return Array.from(r.replace(/[\x00-\x1f\x7f]/g,"")).slice(-60).join("").replace(/^[.\s-]+/,"")||"file"}var ki=new Set(["localhost","127.0.0.1","[::1]"]),Gr=xr(async(e,r)=>{let s=e.req.header("Host")??"",c=e.req.header("Origin"),f=URL.parse(`http://${s}`)?.hostname??"";if(!ki.has(f)||c!==`http://${s}`)return e.text("Forbidden",403);await r()});function Li(e){let{cols:r,rows:s,minCols:c,minRows:f}=e,a=(t,n)=>Number.isSafeInteger(t)&&t>=n;if(!a(r,1)||!a(s,1))return;let y=ye({cols:r,rows:s});if(c===void 0&&f===void 0)return{fits:y};if(!a(c,0)||!a(f,0))return;return{fits:y,min:ye({cols:c,rows:f})}}var Ti=Xe+Ce.rows;function Ri(e){let{start:r,end:s}=e;if(r===void 0&&s===void 0)return null;let c=(t,n)=>Number.isSafeInteger(t)&&t>=0&&t<=n,f=(t)=>{let{x:n,y:l}=t??{};return c(n,Ce.cols)&&c(l,Number.MAX_SAFE_INTEGER)?{x:n,y:l}:void 0},a=f(r),y=f(s);if(!a||!y||a.y>y.y||a.y===y.y&&a.x>y.x)return;if(y.y-a.y>=Ti)return;return{start:a,end:y}}var Bi=1024;function Bt(e,r){let s=typeof r==="string"?r.length:r.byteLength;e.send(r,{compress:s>=Bi})}function pe(e){if(typeof e.tab==="string")return[e.tab];let{tabs:r}=e;return Array.isArray(r)&&r.every((s)=>typeof s==="string")?r:void 0}var Di=new Set(["left","right","bottom"]);function qr(e){try{return JSON.parse(String(e))}catch{return}}function Xr(e,r){let s=new ze;return s.use("/ws/*",Gr),s.use("/api/*",Gr),s.get("/ws/workspace",Ne(()=>{let c;return{onOpen:(f,a)=>{c=e.join((y)=>Bt(a,JSON.stringify(y)))},onMessage:(f)=>{let a=qr(f.data),y=typeof a?.terminal==="string"?a.terminal:void 0;if(a?.type==="split"&&(a.direction==="row"||a.direction==="column"))c?.split(String(a.terminal),a.direction);else if(a?.type==="move-tab"&&pe(a)&&Number.isSafeInteger(a.index)&&(a.group===void 0||a.group===null||typeof a.group==="string"))e.moveTab(pe(a),a.index,a.group);else if(a?.type==="new-group"&&pe(a))e.newGroup(pe(a));else if(a?.type==="add-to-group"&&pe(a)&&typeof a.group==="string")e.addToGroup(pe(a),a.group);else if(a?.type==="remove-from-group"&&pe(a))e.removeFromGroup(pe(a));else if(a?.type==="move-group"&&typeof a.group==="string"&&Number.isSafeInteger(a.index))e.moveGroup(a.group,a.index);else if(a?.type==="rename-group"&&typeof a.group==="string"&&typeof a.name==="string")e.renameGroup(a.group,ge(a.name));else if(a?.type==="recolor-group"&&typeof a.group==="string"&&typeof a.color==="string")e.recolorGroup(a.group,a.color);else if(a?.type==="ungroup"&&typeof a.group==="string")e.ungroup(a.group);else if(a?.type==="close-group"&&typeof a.group==="string")e.closeGroup(a.group);else if(a?.type==="rename-tab"&&typeof a.tab==="string"&&typeof a.name==="string")e.renameTab(a.tab,ge(a.name));else if(a?.type==="close")e.close(String(a.terminal));else if(a?.type==="resize-split"&&typeof a.ratio==="number")c?.resizeSplit(String(a.split),a.ratio);else if(a?.type==="swap-panes"&&typeof a.tab==="string"&&typeof a.with==="string")c?.swapPanes(a.tab,a.with);else if(a?.type==="flip-split"&&typeof a.split==="string")c?.flipSplit(a.split);else if(a?.type==="rotate-split"&&typeof a.split==="string")c?.rotateSplit(a.split);else if(a?.type==="new-tab")c?.newTab(y);else if(a?.type==="select-tab")c?.selectTab(String(a.tab));else if(a?.type==="add-to-view"&&(a.edge===void 0||Di.has(a.edge)))c?.addToView(String(a.tab),y,a.edge);else if(a?.type==="separate"&&typeof a.tab==="string")c?.separate(a.tab);else if(a?.type==="remove-from-view")c?.removeFromView(String(a.tab));else if(a?.type==="focus")c?.focus(String(a.terminal));else if(a?.type==="select"){let t=Ri(a);if(t!==void 0)c?.select(String(a.terminal),t??void 0)}else if(a?.type==="visibility")c?.visible(a.visible===!0);else if(a?.type==="name"&&typeof a.name==="string")c?.rename(ge(a.name));else if(a?.type==="follow")c?.follow(Number.isSafeInteger(a.member)?a.member:void 0);else if(a?.type==="scroll"&&Number.isSafeInteger(a.offset)&&a.offset>=0){let t=String(a.terminal);if(e.terminal(t))c?.scroll(t,a.offset)}else if(a?.type==="add-command"||a?.type==="update-command"){let t=Ve(a);if(!t)return;if(a.type==="add-command")e.addCommand(t);else e.updateCommand(String(a.id),t)}else if(a?.type==="remove-command")e.removeCommand(String(a.id));else if(a?.type==="set-min-window"){let t=Ae(a);if(t)e.setMinWindow(t)}},onClose:()=>c?.leave()}})),s.get("/ws/terminals/:id",async(c,f)=>e.terminal(c.req.param("id"))?f():c.text("Not Found",404),Ne((c)=>{let f=e.terminal(c.req.param("id")),a;return{onOpen:(y,t)=>{a=f.attach((n)=>n.type==="output"?Bt(t,n.data):Bt(t,JSON.stringify(n.type==="resize"?{type:"resize",...n.size}:n)))},onMessage:(y)=>{let t=qr(y.data);if(t?.type==="input"&&typeof t.data==="string")f.write(t.data);else if(t?.type==="reset")f.reset();else if(t?.type==="resize"){let n=Li(t);if(n)a?.resize(n)}},onClose:()=>a?.detach()}})),s.post("/api/uploads",Cr({maxSize:jr,onError:(c)=>c.text("Payload Too Large",413)}),async(c)=>{let a=(await c.req.formData().catch(()=>{return}))?.getAll("files").filter((y)=>y instanceof File)??[];if(a.length===0)return c.text("Bad Request",400);return c.json({paths:await r.save(a)})}),s}import{parseArgs as Jr}from"util";var Vr="0.27.1";import{basename as Pi}from"path";var Qe=["zsh","bash","fish"];function Qr(e){return Qe.includes(e)}function Kr(e=process.env.SHELL??""){return Pi(e)}var Oi={zsh:`# Accompany \u306E\u30B7\u30A7\u30EB\u306E\u7D71\u5408\uFF08OSC 133\uFF09\u3002~/.zshrc \u306B eval "$(accompany activate zsh)" \u3068\u66F8\u3044\u3066\u8AAD\u307F\u8FBC\u3080
34
+ `).length;return{text:a,lines:y,start:s,end:c}}unavailable(){if(!this.integrated)return"no-integration";if(this.terminal.buffer.active.type!=="normal")return"alternate";if(!this.last||this.last.end.marker.isDisposed)return"no-command";return}state(){let e=this.trimmed.count,r=(f)=>f&&!f.marker.isDisposed?{x:f.x,y:f.marker.line+e}:void 0,s=r(this.last?.end),c=this.last?.start.marker.isDisposed?{x:0,y:e}:r(this.last?.start);return{integrated:this.integrated,last:c&&s?{start:c,end:s}:void 0,running:r(this.running)}}restore(e){if(this.integrated||=e.integrated,this.terminal.buffer.active.type!=="normal")return;if(!this.last&&e.last){let r=this.place(e.last.start),s=this.place(e.last.end);if(r&&s)this.setLast({start:r,end:s});else r?.marker.dispose(),s?.marker.dispose()}if(!this.running&&e.running)this.running=this.place(e.running)}setLast(e){this.last?.start.marker.dispose(),this.last?.end.marker.dispose(),this.last=e}here(){let e=this.terminal.registerMarker(0);return e&&{x:this.terminal.buffer.active.cursorX,marker:e}}place({x:e,y:r}){if(r<this.trimmed.count)return;let s=this.terminal.buffer.active,c=this.terminal.registerMarker(r-this.trimmed.count-(s.baseY+s.cursorY));return c&&{x:e,marker:c}}}import{readlink as ci,stat as li}from"fs/promises";var hi=2000;async function Et(e){try{let r=process.platform==="linux"?await ci(`/proc/${e}/cwd`):await ui(e);return r&&(await li(r)).isDirectory()?r:void 0}catch{return}}async function ui(e){return(await Ge(["lsof","-a","-p",String(e),"-d","cwd","-Fn"],hi)).split(`
35
+ `).find((s)=>s.startsWith("n"))?.slice(1)}var Xe=1000;var At={foreground:"#cccccc",background:"#000000",cursor:"#ffffff"};function Ve(e){return[1,3,5].map((r)=>Number.parseInt(e.slice(r,r+2),16))}var fi=(()=>{let e=["#2e3436","#cc0000","#4e9a06","#c4a000","#3465a4","#75507b","#06989a","#d3d7cf","#555753","#ef2929","#8ae234","#fce94f","#729fcf","#ad7fa8","#34e2e2","#eeeeec"].map(Ve),r=[0,95,135,175,215,255];for(let s=0;s<216;s++)e.push([r[Math.floor(s/36)%6],r[Math.floor(s/6)%6],r[s%6]]);for(let s=0;s<24;s++)e.push([8+s*10,8+s*10,8+s*10]);return e})();function Ir([e,r,s]){let c=(f)=>f.toString(16).padStart(2,"0").repeat(2);return`rgb:${c(e)}/${c(r)}/${c(s)}`}var di={10:Ve(At.foreground),11:Ve(At.background),12:Ve(At.cursor)},pi=[4,10,11,12];function _i(e,r){let s=r.split(";"),c=[];if(e===4){let a=[];for(let y=0;y+1<s.length;y+=2){let[t,n]=[s[y],s[y+1]];if(n==="?"){let l=/^\d+$/.test(t)?fi[Number(t)]:void 0;if(l)c.push(`\x1B]4;${Number(t)};${Ir(l)}\x1B\\`)}else a.push(t,n)}if(!s.some((y,t)=>t%2===1&&y==="?"))return{replies:c,rest:r};return{replies:c,rest:a.length>0?a.join(";"):void 0}}if(s.forEach((a,y)=>{let t=di[e+y];if(a==="?"&&t)c.push(`\x1B]${e+y};${Ir(t)}\x1B\\`)}),!s.includes("?"))return{replies:c,rest:r};let f=s.map((a)=>a==="?"?"":a);return{replies:c,rest:f.some((a)=>a!=="")?f.join(";"):void 0}}function Hr(e,r){e.onData(r);for(let s of pi)e.parser.registerOscHandler(s,(c)=>(_i(s,c).replies.forEach(r),!1))}class kt{count;constructor(e,r=0){this.count=r;let s=e._core._bufferService.buffers,c,f,a=()=>{if(s.normal===c)return;f?.dispose(),c=s.normal,f=c.lines.onTrim((y)=>this.count+=y)};a(),s.onBufferActivate(a)}}var Ce={cols:512,rows:256};function ye({cols:e,rows:r}){return{cols:Math.min(e,Ce.cols),rows:Math.min(r,Ce.rows)}}var Nr=new TextEncoder,gi="\u2500\u2500 Accompany \u3092\u518D\u8D77\u52D5\u3057\u307E\u3057\u305F \u2500\u2500",mi=2000,vi=500,yi=1500,bi=200,wi=1000,Si=500;function Ci(e){try{return process.kill(-e,0),!0}catch(r){return r.code==="EPERM"}}class Lt{command;onExit;onTitleChange;proc;listeners=new Set;size={cols:80,rows:24};requestedSizes=new Map;screen=new Wr.Terminal({...this.size,scrollback:Xe,allowProposedApi:!0});serializer=new Br;trimmed=new kt(this.screen);marks=new xt(this.screen,this.trimmed);cursorHidden=!1;mouseEncoding;title="";activity;onOutput;onStatus;foreground;tty;detectTimer;detecting=!1;detectAgain=!1;killed=!1;startTimer;hangingUp;unseen=!1;startDir;lastCwd;cwdCheckedAt=Number.NEGATIVE_INFINITY;cwdPgid;lastInputAt=Number.NEGATIVE_INFINITY;startedAsAgent;constructor(e,r=()=>{},s=()=>{},c=()=>{},{restored:f,onOutput:a=()=>{},cwd:y}={}){this.command=e;this.onExit=r;this.onTitleChange=s;if(this.startDir=y,this.startedAsAgent=Ct(e.join(" ")),this.lastCwd=y,this.onOutput=a,this.onStatus=c,this.activity=new St((t)=>{if(this.unseen=t==="idle",this.foreground?.agent)c()}),this.screen.loadAddon(this.serializer),Hr(this.screen,(t)=>this.proc?.terminal?.write(t)),f)this.size={cols:f.cols,rows:f.rows},this.screen.resize(f.cols,f.rows),this.screen.write(`${f.scrollback}\x1B[0m\r
36
+ \x1B[2m${gi}\x1B[0m\r
37
+ `);this.screen.onTitleChange((t)=>{let n=xi(t);if(n===this.title)return;this.title=n,this.onTitleChange()});for(let[t,n]of[["h",!0],["l",!1]])this.screen.parser.registerCsiHandler({prefix:"?",final:t},(l)=>{if(l.includes(25))this.cursorHidden=!n;for(let p of[1006,1016])if(l.includes(p))this.mouseEncoding=n?p:void 0;return!1});this.screen.parser.registerEscHandler({final:"c"},()=>{if(this.cursorHidden=!1,this.mouseEncoding=void 0,this.title!=="")this.title="",this.onTitleChange();return!1})}attach(e){let r=[],s=!1,c=(f)=>s?e(f):r.push(f);if(this.listeners.add(c),this.screen.write("",()=>{e({type:"resize",size:this.size}),e({type:"trimmed",lines:this.trimmed.count}),e({type:"marks",...this.marks.state()});let f=this.serializer.serialize()+(this.cursorHidden?"\x1B[?25l":"")+(this.mouseEncoding?`\x1B[?${this.mouseEncoding}h`:"");if(f)e({type:"output",data:Nr.encode(f)});e({type:"restored"}),r.forEach(e),s=!0}),!this.proc&&!this.startTimer)this.startTimer=setTimeout(()=>this.start(),mi);return{resize:(f)=>{this.requestedSizes.set(c,f),this.fitToSmallest(),this.start()},detach:()=>{this.listeners.delete(c),this.requestedSizes.delete(c),this.fitToSmallest()}}}start(){if(clearTimeout(this.startTimer),this.proc||this.killed)return;this.proc=this.spawn((e)=>Bun.spawn(this.command,{cwd:e,terminal:{...this.size,data:(r,s)=>{this.screen.write(s),this.activity.output(),this.scheduleDetect(),this.broadcast({type:"output",data:s}),this.onOutput()}}})),this.proc.exited.then(()=>this.onExit())}spawn(e){if(this.startDir)try{return e(this.startDir)}catch{}return e()}async cwd(){let e=this.proc?.pid;if(e===void 0)return this.startDir;let r=await qe(e,this.tty);return(r&&await Et(r.foreground.pgid))??await Et(e)}async savedCwd({refresh:e=!1}={}){if(this.proc===void 0)return this.lastCwd;if(!e){let s=this.lastInputAt>=this.cwdCheckedAt-bi,c=this.foreground?.agent===!0&&this.foreground.pgid===this.cwdPgid;if(!s||c)return this.lastCwd}this.cwdCheckedAt=performance.now(),this.cwdPgid=this.foreground?.pgid;let r=await Promise.race([this.cwd(),Bun.sleep(yi).then(()=>{return})]);if(r)this.lastCwd=r;return this.lastCwd}write(e){this.lastInputAt=performance.now(),this.activity.input(e),this.scheduleDetect(),this.proc?.terminal?.write(e)}reset(){let e=Nr.encode("\x1Bc");this.screen.write(e),this.broadcast({type:"output",data:e})}snapshot(){return new Promise((e)=>this.screen.write("",()=>e({...this.size,scrollback:this.serializer.serialize({excludeAltBuffer:!0,excludeModes:!0})})))}get status(){if(!this.foreground?.agent)return;return this.activity.status==="idle"&&this.unseen?"done":this.activity.status}markSeen(){let e=this.status==="done";return this.unseen=!1,e}kill(){if(this.hangingUp)return this.hangingUp;this.killed=!0,clearTimeout(this.startTimer),clearTimeout(this.detectTimer),this.activity.dispose();let e=this.proc;if(!e||e.exitCode!==null||e.signalCode!==null)return this.hangingUp=Promise.resolve();let r=Bun.sleep(wi);return this.hangingUp=(async()=>{let s=await Promise.race([qe(e.pid,this.tty),Bun.sleep(Si)]);if(e.exitCode!==null||e.signalCode!==null)return;let c=[...new Set([e.pid,s?.foreground.pgid])].filter((t)=>t!==void 0&&t>1);for(let t of c)try{process.kill(-t,"SIGHUP")}catch{}let f=c.filter((t)=>t!==e.pid),a=!1,y=(async()=>{await e.exited;while(!a&&f.some(Ci))await Bun.sleep(20)})();await Promise.race([y,r]),a=!0})(),this.hangingUp}scheduleDetect(){if(this.detecting){this.detectAgain=!0;return}if(this.detectTimer||this.killed)return;this.detectTimer=setTimeout(()=>{this.detectTimer=void 0,this.detect()},vi)}async detect(){let e=this.proc?.pid;if(e===void 0)return;this.detecting=!0,this.detectAgain=!1;let r;try{r=await qe(e,this.tty)}finally{if(this.detecting=!1,this.detectAgain)this.scheduleDetect()}if(this.killed||!r)return;this.tty=r.tty;let s=this.foreground,c=r.foreground;if(this.foreground=c,!c.agent){if(this.unseen=!1,s?.agent)this.onStatus();return}if(!s?.agent||s.pgid!==c.pgid){if(!this.startedAsAgent||c.pgid!==e)this.activity.reset(),this.unseen=!1;this.onStatus()}}fitToSmallest(){let e=[...this.requestedSizes.values()];if(e.length===0)return;let r=(c)=>{let f=e.map((t)=>t.fits[c]),a=e.flatMap((t)=>t.min?[t.min[c]]:[]),y=a.length>0?Math.min(...a):0;return Math.min(Math.max(...f),Math.max(Math.min(...f),y))},s=ye({cols:r("cols"),rows:r("rows")});if(s.cols===this.size.cols&&s.rows===this.size.rows)return;this.size=s,this.screen.resize(s.cols,s.rows),this.proc?.terminal?.resize(s.cols,s.rows),this.broadcast({type:"resize",size:s})}broadcast(e){this.listeners.forEach((r)=>r(e))}}var Fr=256;function xi(e){let r=[...Tt(e)];return r.length>Fr?`${r.slice(0,Fr-1).join("")}\u2026`:r.join("")}function Tt(e){return e.replace(/[\u2028\u2029\u0085]/g," ").replace(/[\p{Cc}\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/gu,"")}var $r=32,Ei=$r*32,Ai=new Intl.Segmenter(void 0,{granularity:"grapheme"}),ki=/[\p{Default_Ignorable_Code_Point}\s\u2800]/gu;function ge(e){let r=Tt(e.slice(0,Ei).replace(/[\t\n\v\f\r]/g," ")).replace(/\p{Cs}/gu,"").replace(/\s+/g," ").trim(),s=[...Ai.segment(r)].slice(0,$r).map((c)=>c.segment).join("").trim();return s.replace(ki,"")?s:void 0}function xe(e){return e.normalize("NFKC").replace(/[\p{Default_Ignorable_Code_Point}\p{M}]/gu,"")}var Ur={width:480,height:1080},Ee={width:1920,height:1080};function Ae(e){if(typeof e!=="object"||e===null)return;let{width:r,height:s}=e,c=(f,a)=>Number.isSafeInteger(f)&&f>=0&&f<=a;return c(r,Ee.width)&&c(s,Ee.height)?{width:r,height:s}:void 0}function jr(e){let r=/^(\d+)x(\d+)$/.exec(e);return r?Ae({width:Number(r[1]),height:Number(r[2])}):void 0}var Gr=100;function zr(e){return e.replace(/[^\P{Cc}\n\t]|\p{Cf}/gu,"")}function Rt(e,r){return[...e].slice(0,r).join("")}function Qe(e){if(typeof e.content!=="string"||typeof e.name!=="string")return;let r=Rt(zr(e.content.replace(/\r\n?|[\u2028\u2029\u0085]/g,`
38
+ `)),1e4).replace(/\n+$/,"");if(r.trim()==="")return;return{name:Rt(zr(e.name.replace(/[\r\n\t\u2028\u2029\u0085]/g," ")).trim(),100)||Rt(r.trim().split(`
39
+ `)[0],100),content:r,run:e.run===!0}}import{lstatSync as Li,mkdirSync as Ti,mkdtempSync as Ri,rmSync as Bi,writeFileSync as Di}from"fs";import{tmpdir as Mi}from"os";import{join as Bt}from"path";var Vr=104857600;class Dt{root=qr();nextId=1;async save(e){let r=await Promise.all(e.map(async(f)=>new Uint8Array(await f.arrayBuffer()))),s=Bt(this.currentRoot(),String(this.nextId++));Ti(s,{mode:448});let c=new Set;return e.map((f,a)=>{let y=Xr(f.name);for(let n=2;c.has(y);n++)y=`${n}-${Xr(f.name)}`;c.add(y);let t=Bt(s,y);return Di(t,r[a],{flag:"wx",mode:384}),t})}remove(){Bi(this.root,{recursive:!0,force:!0})}currentRoot(){if(!Pi(this.root))this.root=qr();return this.root}}function qr(){return Ri(Bt(Mi(),"accompany-"))}function Pi(e){try{let r=Li(e);return r.isDirectory()&&r.uid===process.getuid?.()&&(r.mode&63)===0}catch{return!1}}function Xr(e){let r=e.split(/[\\/]/).pop()??"";return Array.from(r.replace(/[\x00-\x1f\x7f]/g,"")).slice(-60).join("").replace(/^[.\s-]+/,"")||"file"}var Oi=new Set(["localhost","127.0.0.1","[::1]"]),Qr=Ar(async(e,r)=>{let s=e.req.header("Host")??"",c=e.req.header("Origin"),f=URL.parse(`http://${s}`)?.hostname??"";if(!Oi.has(f)||c!==`http://${s}`)return e.text("Forbidden",403);await r()});function Ii(e){let{cols:r,rows:s,minCols:c,minRows:f}=e,a=(t,n)=>Number.isSafeInteger(t)&&t>=n;if(!a(r,1)||!a(s,1))return;let y=ye({cols:r,rows:s});if(c===void 0&&f===void 0)return{fits:y};if(!a(c,0)||!a(f,0))return;return{fits:y,min:ye({cols:c,rows:f})}}var Hi=Xe+Ce.rows;function Ni(e){let{start:r,end:s}=e;if(r===void 0&&s===void 0)return null;let c=(t,n)=>Number.isSafeInteger(t)&&t>=0&&t<=n,f=(t)=>{let{x:n,y:l}=t??{};return c(n,Ce.cols)&&c(l,Number.MAX_SAFE_INTEGER)?{x:n,y:l}:void 0},a=f(r),y=f(s);if(!a||!y||a.y>y.y||a.y===y.y&&a.x>y.x)return;if(y.y-a.y>=Hi)return;return{start:a,end:y}}var Fi=1024;function Mt(e,r){let s=typeof r==="string"?r.length:r.byteLength;e.send(r,{compress:s>=Fi})}function pe(e){if(typeof e.tab==="string")return[e.tab];let{tabs:r}=e;return Array.isArray(r)&&r.every((s)=>typeof s==="string")?r:void 0}var Wi=new Set(["left","right","bottom"]);function Kr(e){try{return JSON.parse(String(e))}catch{return}}function Yr(e,r){let s=new je;return s.use("/ws/*",Qr),s.use("/api/*",Qr),s.get("/ws/workspace",Ne(()=>{let c;return{onOpen:(f,a)=>{c=e.join((y)=>Mt(a,JSON.stringify(y)))},onMessage:(f)=>{let a=Kr(f.data),y=typeof a?.terminal==="string"?a.terminal:void 0;if(a?.type==="split"&&(a.direction==="row"||a.direction==="column"))c?.split(String(a.terminal),a.direction);else if(a?.type==="move-tab"&&pe(a)&&Number.isSafeInteger(a.index)&&(a.group===void 0||a.group===null||typeof a.group==="string"))e.moveTab(pe(a),a.index,a.group);else if(a?.type==="new-group"&&pe(a))e.newGroup(pe(a));else if(a?.type==="add-to-group"&&pe(a)&&typeof a.group==="string")e.addToGroup(pe(a),a.group);else if(a?.type==="remove-from-group"&&pe(a))e.removeFromGroup(pe(a));else if(a?.type==="move-group"&&typeof a.group==="string"&&Number.isSafeInteger(a.index))e.moveGroup(a.group,a.index);else if(a?.type==="rename-group"&&typeof a.group==="string"&&typeof a.name==="string")e.renameGroup(a.group,ge(a.name));else if(a?.type==="recolor-group"&&typeof a.group==="string"&&typeof a.color==="string")e.recolorGroup(a.group,a.color);else if(a?.type==="ungroup"&&typeof a.group==="string")e.ungroup(a.group);else if(a?.type==="close-group"&&typeof a.group==="string")e.closeGroup(a.group);else if(a?.type==="rename-tab"&&typeof a.tab==="string"&&typeof a.name==="string")e.renameTab(a.tab,ge(a.name));else if(a?.type==="close")e.close(String(a.terminal));else if(a?.type==="resize-split"&&typeof a.ratio==="number")c?.resizeSplit(String(a.split),a.ratio);else if(a?.type==="swap-panes"&&typeof a.tab==="string"&&typeof a.with==="string")c?.swapPanes(a.tab,a.with);else if(a?.type==="flip-split"&&typeof a.split==="string")c?.flipSplit(a.split);else if(a?.type==="rotate-split"&&typeof a.split==="string")c?.rotateSplit(a.split);else if(a?.type==="new-tab")c?.newTab(y);else if(a?.type==="select-tab")c?.selectTab(String(a.tab));else if(a?.type==="add-to-view"&&(a.edge===void 0||Wi.has(a.edge)))c?.addToView(String(a.tab),y,a.edge);else if(a?.type==="separate"&&typeof a.tab==="string")c?.separate(a.tab);else if(a?.type==="remove-from-view")c?.removeFromView(String(a.tab));else if(a?.type==="focus")c?.focus(String(a.terminal));else if(a?.type==="select"){let t=Ni(a);if(t!==void 0)c?.select(String(a.terminal),t??void 0)}else if(a?.type==="visibility")c?.visible(a.visible===!0);else if(a?.type==="name"&&typeof a.name==="string")c?.rename(ge(a.name));else if(a?.type==="follow")c?.follow(Number.isSafeInteger(a.member)?a.member:void 0);else if(a?.type==="scroll"&&Number.isSafeInteger(a.offset)&&a.offset>=0){let t=String(a.terminal);if(e.terminal(t))c?.scroll(t,a.offset)}else if(a?.type==="add-command"||a?.type==="update-command"){let t=Qe(a);if(!t)return;if(a.type==="add-command")e.addCommand(t);else e.updateCommand(String(a.id),t)}else if(a?.type==="remove-command")e.removeCommand(String(a.id));else if(a?.type==="set-min-window"){let t=Ae(a);if(t)e.setMinWindow(t)}},onClose:()=>c?.leave()}})),s.get("/ws/terminals/:id",async(c,f)=>e.terminal(c.req.param("id"))?f():c.text("Not Found",404),Ne((c)=>{let f=e.terminal(c.req.param("id")),a;return{onOpen:(y,t)=>{a=f.attach((n)=>n.type==="output"?Mt(t,n.data):Mt(t,JSON.stringify(n.type==="resize"?{type:"resize",...n.size}:n)))},onMessage:(y)=>{let t=Kr(y.data);if(t?.type==="input"&&typeof t.data==="string")f.write(t.data);else if(t?.type==="reset")f.reset();else if(t?.type==="resize"){let n=Ii(t);if(n)a?.resize(n)}},onClose:()=>a?.detach()}})),s.post("/api/uploads",Er({maxSize:Vr,onError:(c)=>c.text("Payload Too Large",413)}),async(c)=>{let a=(await c.req.formData().catch(()=>{return}))?.getAll("files").filter((y)=>y instanceof File)??[];if(a.length===0)return c.text("Bad Request",400);return c.json({paths:await r.save(a)})}),s}import{parseArgs as rs}from"util";var Jr="0.28.0";import{basename as Ui}from"path";var Ke=["zsh","bash","fish"];function Zr(e){return Ke.includes(e)}function es(e=process.env.SHELL??""){return Ui(e)}var ji={zsh:`# Accompany \u306E\u30B7\u30A7\u30EB\u306E\u7D71\u5408\uFF08OSC 133\uFF09\u3002~/.zshrc \u306B eval "$(accompany activate zsh)" \u3068\u66F8\u3044\u3066\u8AAD\u307F\u8FBC\u3080
40
40
  autoload -Uz add-zsh-hook
41
41
  _accompany_hook() {
42
42
  local code=$?
@@ -94,7 +94,7 @@ end
94
94
  function _accompany_hook --on-event fish_prompt --description 'Accompany: \u30D7\u30ED\u30F3\u30D7\u30C8\u306E\u59CB\u307E\u308A\uFF08OSC 133 A\uFF09'
95
95
  printf '\\e]133;A\\a'
96
96
  end
97
- `};function Yr(e){return Oi[e]}var Ke=`\u30B7\u30A7\u30EB\u306E\u7D71\u5408\u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8868\u793A\u3059\u308B
97
+ `};function ts(e){return ji[e]}var Ye=`\u30B7\u30A7\u30EB\u306E\u7D71\u5408\u306E\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8868\u793A\u3059\u308B
98
98
 
99
99
  \u8868\u793A\u3057\u305F\u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u3001\u30B7\u30A7\u30EB\u3067\u8A55\u4FA1\u3057\u3066\u4F7F\u3046\uFF08\u5B9F\u884C\u3059\u308B\u3060\u3051\u3067\u306F\u8868\u793A\u3059\u308B\u3060\u3051\uFF09\u3002
100
100
  \u30B7\u30A7\u30EB\u306E\u7D71\u5408\u3092\u5165\u308C\u308B\u3068\u3001\u30B3\u30DE\u30F3\u30C9\u306E\u533A\u5207\u308A\uFF08OSC 133\uFF09\u304C\u5206\u304B\u308A\u3001\u30BF\u30FC\u30DF\u30CA\u30EB\u306E\u53F3\u4E0B\u306E\u300C\u30B3\u30D4\u30FC\u300D\u3084\u53F3\u30AF\u30EA\u30C3\u30AF\u306E\u30E1\u30CB\u30E5\u30FC\u3067\u3001
@@ -110,12 +110,12 @@ end
110
110
  \u4F7F\u3044\u65B9: accompany activate [\u30B7\u30A7\u30EB]
111
111
 
112
112
  \u5F15\u6570:
113
- [\u30B7\u30A7\u30EB] \u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u51FA\u3059\u30B7\u30A7\u30EB\uFF08${Qe.join("\u30FB")}\uFF09\u3002\u7701\u304F\u3068 $SHELL \u304B\u3089\u6C7A\u3081\u308B
113
+ [\u30B7\u30A7\u30EB] \u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u51FA\u3059\u30B7\u30A7\u30EB\uFF08${Ke.join("\u30FB")}\uFF09\u3002\u7701\u304F\u3068 $SHELL \u304B\u3089\u6C7A\u3081\u308B
114
114
 
115
115
  \u30AA\u30D7\u30B7\u30E7\u30F3:
116
116
  -h, --help \u3053\u306E\u4F7F\u3044\u65B9\u3092\u8868\u793A\u3059\u308B
117
117
 
118
- activate \u3068\u3044\u3046\u540D\u524D\u306E\u30B3\u30DE\u30F3\u30C9\u3092\u6700\u521D\u306E\u30BF\u30FC\u30DF\u30CA\u30EB\u3067\u52D5\u304B\u3059\u3068\u304D\u306F\u3001accompany -- activate \u3068\u66F8\u304F`;var Dt=`\u4F7F\u3044\u65B9: accompany [\u30AA\u30D7\u30B7\u30E7\u30F3] [-- <\u30B3\u30DE\u30F3\u30C9...>]
118
+ activate \u3068\u3044\u3046\u540D\u524D\u306E\u30B3\u30DE\u30F3\u30C9\u3092\u6700\u521D\u306E\u30BF\u30FC\u30DF\u30CA\u30EB\u3067\u52D5\u304B\u3059\u3068\u304D\u306F\u3001accompany -- activate \u3068\u66F8\u304F`;var Pt=`\u4F7F\u3044\u65B9: accompany [\u30AA\u30D7\u30B7\u30E7\u30F3] [-- <\u30B3\u30DE\u30F3\u30C9...>]
119
119
 
120
120
  \u30D6\u30E9\u30A6\u30B6\u3067\u958B\u304F\u30BF\u30FC\u30DF\u30CA\u30EB\u3092\u3001\u30DA\u30A2\u30D7\u30ED\u30B0\u30E9\u30DF\u30F3\u30B0\u306E\u76F8\u624B\u3068\u5171\u6709\u3059\u308B\u3002
121
121
  -- \u306E\u3042\u3068\u306B\u66F8\u3044\u305F\u30B3\u30DE\u30F3\u30C9\u3092\u6700\u521D\u306E\u30BF\u30FC\u30DF\u30CA\u30EB\u3067\u52D5\u304B\u3059\uFF08\u7701\u7565\u3059\u308B\u3068 $SHELL\uFF09
@@ -130,15 +130,15 @@ activate \u3068\u3044\u3046\u540D\u524D\u306E\u30B3\u30DE\u30F3\u30C9\u3092\u670
130
130
  --min-window <\u5E45>x<\u9AD8\u3055> \u7AEF\u672B\u306E\u5927\u304D\u3055\u306E\u4E0B\u9650\u3092\u3001\u30A6\u30A3\u30F3\u30C9\u30A6\u306E\u5927\u304D\u3055\uFF08\u30D4\u30AF\u30BB\u30EB\uFF09\u3067\u6307\u5B9A\u3059\u308B\uFF08\u4F8B: 480x1080\u3002\u4FDD\u5B58\u306F\u3057\u306A\u3044\uFF09
131
131
  --allow-vscode-webview VS Code \u306E\u62E1\u5F35\u306E\u30D1\u30CD\u30EB\uFF08webview\uFF09\u306E\u4E2D\u306B\u57CB\u3081\u8FBC\u3080\u3053\u3068\u3092\u8A31\u3059\uFF08\u62E1\u5F35\u304C\u8D77\u52D5\u3059\u308B\u3068\u304D\u306B\u4ED8\u3051\u308B\uFF09
132
132
  -v, --version \u7248\u3092\u8868\u793A\u3059\u308B
133
- -h, --help \u3053\u306E\u4F7F\u3044\u65B9\u3092\u8868\u793A\u3059\u308B`;function Zr(e=process.argv.slice(2)){if(e[0]==="activate")Ii(e.slice(1));let r;try{r=Jr({args:e,options:{port:{type:"string",default:"3000"},fresh:{type:"boolean",default:!1},"min-window":{type:"string"},"allow-vscode-webview":{type:"boolean",default:!1},version:{type:"boolean",short:"v",default:!1},help:{type:"boolean",short:"h",default:!1}},allowPositionals:!0})}catch(c){console.error(`Accompany: ${es(c)}
133
+ -h, --help \u3053\u306E\u4F7F\u3044\u65B9\u3092\u8868\u793A\u3059\u308B`;function ss(e=process.argv.slice(2)){if(e[0]==="activate")zi(e.slice(1));let r;try{r=rs({args:e,options:{port:{type:"string",default:"3000"},fresh:{type:"boolean",default:!1},"min-window":{type:"string"},"allow-vscode-webview":{type:"boolean",default:!1},version:{type:"boolean",short:"v",default:!1},help:{type:"boolean",short:"h",default:!1}},allowPositionals:!0})}catch(c){console.error(`Accompany: ${is(c)}
134
134
 
135
- ${Dt}`),process.exit(1)}if(r.values.help)console.log(Dt),process.exit(0);if(r.values.version)console.log(`accompany ${Vr}`),process.exit(0);let s=r.values.port;if(!/^\d+$/.test(s)||Number(s)>ke)console.error(`Accompany: --port \u306F 0\u301C${ke} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${s}
135
+ ${Pt}`),process.exit(1)}if(r.values.help)console.log(Pt),process.exit(0);if(r.values.version)console.log(`accompany ${Jr}`),process.exit(0);let s=r.values.port;if(!/^\d+$/.test(s)||Number(s)>ke)console.error(`Accompany: --port \u306F 0\u301C${ke} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${s}
136
136
 
137
- ${Dt}`),process.exit(1);return r}var ke=65535;function Ii(e){let r;try{r=Jr({args:e,options:{help:{type:"boolean",short:"h",default:!1}},allowPositionals:!0})}catch(f){console.error(`Accompany: ${es(f)}
137
+ ${Pt}`),process.exit(1);return r}var ke=65535;function zi(e){let r;try{r=rs({args:e,options:{help:{type:"boolean",short:"h",default:!1}},allowPositionals:!0})}catch(f){console.error(`Accompany: ${is(f)}
138
138
 
139
- ${Ke}`),process.exit(1)}if(r.values.help)console.log(Ke),process.exit(0);if(r.positionals.length>1)console.error(`Accompany: activate \u306B\u6E21\u305B\u308B\u30B7\u30A7\u30EB\u306F 1 \u3064\u3067\u3059: ${r.positionals.join(" ")}
139
+ ${Ye}`),process.exit(1)}if(r.values.help)console.log(Ye),process.exit(0);if(r.positionals.length>1)console.error(`Accompany: activate \u306B\u6E21\u305B\u308B\u30B7\u30A7\u30EB\u306F 1 \u3064\u3067\u3059: ${r.positionals.join(" ")}
140
140
 
141
- ${Ke}`),process.exit(1);let s=r.positionals[0],c=s??Kr();if(!Qr(c)){let f=`\u5BFE\u5FDC\u3057\u3066\u3044\u308B\u30B7\u30A7\u30EB: ${Qe.join("\u30FB")}`;console.error(s===void 0?`Accompany: $SHELL\uFF08${process.env.SHELL??"\u672A\u8A2D\u5B9A"}\uFF09\u306E\u30B7\u30A7\u30EB\u306B\u306F\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002accompany activate zsh \u306E\u3088\u3046\u306B\u30B7\u30A7\u30EB\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${f}\uFF09`:`Accompany: \u77E5\u3089\u306A\u3044\u30B7\u30A7\u30EB\u3067\u3059: ${c}\uFF08${f}\uFF09`),process.exit(1)}process.stdout.write(Yr(c)),process.exit(0)}function es(e){let r=e instanceof Error?e.message:String(e),s=e?.code;if(s==="ERR_PARSE_ARGS_UNKNOWN_OPTION"){let c=r.match(/Unknown option '([^']+)'/)?.[1];if(c)return`\u77E5\u3089\u306A\u3044\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3059: ${c}`}if(s==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"){let c=r.match(/Option '(-[^\s']+)/)?.[1];if(c&&/argument missing|argument is ambiguous/.test(r))return`${c} \u306B\u306F\u5024\u304C\u8981\u308A\u307E\u3059`;if(c&&/does not take an argument/.test(r))return`${c} \u306F\u5024\u3092\u53D6\u308A\u307E\u305B\u3093`}return r}var ts=Xt("{\"index\":\"public/index.html\",\"files\":[{\"input\":\"public/index.html\",\"path\":\"./index-kg98xsze.js\",\"loader\":\"js\",\"isEntry\":true,\"headers\":{\"etag\":\"8xBJKD2Zvw4\",\"content-type\":\"text/javascript;charset=utf-8\"}},{\"input\":\"public/index.html\",\"path\":\"public/index.html\",\"loader\":\"html\",\"isEntry\":true,\"headers\":{\"etag\":\"_528PQCeSu0\",\"content-type\":\"text/html;charset=utf-8\"}},{\"input\":\"public/index.html\",\"path\":\"./index-e5af4q9z.css\",\"loader\":\"css\",\"isEntry\":true,\"headers\":{\"etag\":\"LgVqL2T3Cb8\",\"content-type\":\"text/css;charset=utf-8\"}},{\"input\":\"public/favicon.png\",\"path\":\"./favicon-0wwf4h3c.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"YHwcDyQxo4w\",\"content-type\":\"image/png\"}},{\"input\":\"public/apple-touch-icon.png\",\"path\":\"./apple-touch-icon-ehhpc4a9.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"LjHRtszkCok\",\"content-type\":\"image/png\"}}]}");import{createHash as Ni}from"crypto";import{chmodSync as Fi,mkdirSync as Wi,readFileSync as Ui,renameSync as $i,rmSync as rs,writeFileSync as zi}from"fs";import{homedir as ji}from"os";import{dirname as Gi,isAbsolute as is,join as Mt}from"path";var Le=["blue","red","yellow","green","pink","purple","cyan","grey"];function Ye(e){return typeof e==="string"&&Le.includes(e)}var ss=448,qi=384;function ns(e=process.env){if(e.ACCOMPANY_STATE_DIR)return e.ACCOMPANY_STATE_DIR;let r=e.XDG_STATE_HOME&&is(e.XDG_STATE_HOME)?e.XDG_STATE_HOME:Mt(ji(),".local","state");return Mt(r,"accompany")}class Pt{dir;file;constructor(e,r){this.dir=e;let s=Ni("sha256").update(r).digest("hex").slice(0,16);this.file=Mt(e,"sessions",`${s}.json`)}load(){let e;try{e=Ui(this.file,"utf8")}catch(r){if(r.code!=="ENOENT")console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F: ${r}`);return}try{let r=Xi(JSON.parse(e));if(!r)console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u306A\u3044\u305F\u3081\u3001\u65B0\u3057\u304F\u59CB\u3081\u307E\u3059: ${this.file}`);return r}catch(r){console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u3092\u8AAD\u3081\u306A\u3044\u305F\u3081\u3001\u65B0\u3057\u304F\u59CB\u3081\u307E\u3059: ${r}`)}}save(e){let r=Gi(this.file);for(let c of[this.dir,r])Wi(c,{recursive:!0,mode:ss}),Fi(c,ss);let s=`${this.file}.${process.pid}.tmp`;rs(s,{force:!0});try{zi(s,JSON.stringify(e),{mode:qi,flag:"wx"}),$i(s,this.file)}catch(c){throw rs(s,{force:!0}),c}}}function Xi(e){if(!ne(e)||!Array.isArray(e.tabs)||e.tabs.length===0)return;let r=e.version===2?Qi(e.tabs):e.version===1?Ki(e.tabs):void 0;if(!r)return;let s=ne(e.terminals)?e.terminals:{},c={};for(let l of r){let p=s[l];c[l]={...ne(p)&&Ji(p)?ye({cols:p.cols,rows:p.rows}):{cols:80,rows:24},scrollback:ne(p)&&typeof p.scrollback==="string"?p.scrollback:"",initial:ne(p)&&p.initial===!0,...ne(p)&&Yi(p.cwd)&&{cwd:p.cwd}}}let f=[];for(let l of Array.isArray(e.commands)?e.commands:[]){let p=ne(l)&&Je(l.id)&&Ve(l);if(p&&!f.some((g)=>g.id===l.id))f.push({id:l.id,...p})}let a=ne(e.names)?e.names:{},y={};for(let l of r){let p=typeof a[l]==="string"?ge(a[l]):void 0;if(p!==void 0)y[l]=p}let t=Vi(e.groups,r),n=Ae(e.minWindow);return{version:2,cwd:String(e.cwd??""),tabs:r,names:y,groups:t,terminals:c,commands:f,...n&&{minWindow:n}}}function Vi(e,r){let s=[],c=new Set;for(let f of Array.isArray(e)?e:[]){if(!ne(f)||!Je(f.id)||!Ye(f.color)||s.some((t)=>t.id===f.id))continue;let a=(Array.isArray(f.tabs)?f.tabs:[]).filter((t)=>typeof t==="string"&&r.includes(t)&&!c.has(t));if(a.length===0)continue;for(let t of a)c.add(t);let y=typeof f.name==="string"?ge(f.name):void 0;s.push({id:f.id,...y!==void 0&&{name:y},color:f.color,tabs:a})}return s}function Qi(e){let r=[];for(let s of e){if(!Je(s)||r.includes(s))return;r.push(s)}return r}function Ki(e){let r=new Set,s=[];for(let c of e)if(!ne(c)||!os(c.layout,r,s,0))return;return s}function os(e,r,s,c){if(!ne(e)||c>100)return!1;if(e.type==="terminal"){if(!Je(e.id)||r.has(e.id))return!1;return r.add(e.id),s.push(e.id),!0}if(e.type!=="split"||typeof e.id!=="string"||!/^split-[1-9]\d{0,8}$/.test(e.id))return!1;if(r.has(e.id))return!1;if(r.add(e.id),!Array.isArray(e.children)||e.children.length!==2)return!1;return e.children.every((f)=>os(f,r,s,c+1))}function ne(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Je(e){return typeof e==="string"&&/^[1-9]\d{0,8}$/.test(e)}function Yi(e){return typeof e==="string"&&is(e)&&!e.includes("\x00")}function Ji(e){let r=(s)=>Number.isSafeInteger(s)&&s>=1;return r(e.cols)&&r(e.rows)}import{isAbsolute as Zi,resolve as en}from"path";var tn=0.9;function ls({allowVscodeWebview:e=!1}={}){return`frame-ancestors 'self'${e?" vscode-webview: vscode-file:":""}`}async function us(e,r){let{files:s}=e;if(s?.some((f)=>!Zi(f.path)))return as(sn(s),r);let c=Bun.serve({hostname:"127.0.0.1",port:0,development:!1,reusePort:!1,routes:{"/":e},fetch:()=>new Response("Not Found",{status:404})});try{return await as(rn(c.url),r)}finally{c.stop(!0)}}async function as(e,r){let s=cs(await e("/"),r),c=new TextDecoder().decode(s.body),f=new Set([...c.matchAll(/(?:src|href)="(\/[^"]+)"/g)].map((y)=>y[1])),a={"/":hs(s)};for(let y of f){let t=cs(await e(y),r);if(!t.headers.has("cache-control"))t.headers.set("cache-control","public, max-age=31536000, immutable");a[y]=hs(t)}return a}function rn(e){return async(r)=>{let s=await fetch(new URL(r,e));if(!s.ok)throw Error(`\u753B\u9762\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u7528\u610F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r} (${s.status})`);return{body:new Uint8Array(await s.arrayBuffer()),headers:new Headers(s.headers)}}}function sn(e){return async(r)=>{let s=r==="/"?e.find((f)=>f.loader==="html"):e.find((f)=>f.loader!=="html"&&`/${f.path.replace(/^\.\//,"")}`===r);if(!s)throw Error(`\u753B\u9762\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u7528\u610F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r}\uFF08\u56FA\u3081\u305F JS \u306E\u4E00\u89A7\u306B\u306A\u3044\uFF09`);return{body:await Bun.file(en(import.meta.dir,s.path)).bytes(),headers:new Headers(s.headers)}}}function cs({body:e,headers:r},s){let c=new Headers(r);c.delete("content-length"),c.delete("date"),c.set("vary","Accept-Encoding"),c.set("content-security-policy",s);let f=Bun.gzipSync(e,{level:9});return{body:e,headers:c,gzip:f.byteLength<e.byteLength*tn?f:void 0}}function hs({body:e,gzip:r,headers:s}){let c=s.get("etag");return(f)=>{if(c&&f.headers.get("if-none-match")===c)return new Response(null,{status:304,headers:s});let a=/\bgzip\b/.test(f.headers.get("accept-encoding")??"");if(!r||!a)return new Response(e,{headers:s});let y=new Headers(s);return y.set("content-encoding","gzip"),new Response(r,{headers:y})}}var fs=3,ds=["#4fc3f7","#ffb74d","#81c784","#f06292","#ba68c8","#fff176"];class Ft{shellCommand;terminals=new Map;order=[];tabNames=new Map;groups=new Map;tabGroups=new Map;nextGroupId=1;members=new Map;views=new Map;chosenNames=new Map;visibleMembers=new Set;nextMemberId=1;nextId=1;nextSplitId=1;titlesQueued=!1;nextCommandId=1;stopping=!1;initialTerminal;commands=[];minWindow;savedMinWindow;onChange=()=>{};constructor(e,r,s,c){this.shellCommand=r;if(this.savedMinWindow=s?.minWindow,this.minWindow=c??s?.minWindow??Nr,!s){this.initialTerminal=this.createTerminal(e??r);return}for(let a of s.tabs){let y=s.terminals[a];if(y.initial)this.initialTerminal=a;let t=y.initial&&e!==void 0;this.addTerminal(a,t?e:r,y,t?void 0:y.cwd)}for(let[a,y]of Object.entries(s.names??{}))this.tabNames.set(a,y);for(let a of s.groups??[]){this.groups.set(a.id,{color:a.color,...a.name!==void 0&&{name:a.name}});for(let y of a.tabs)this.tabGroups.set(y,a.id)}this.nextGroupId=Math.max(0,...[...this.groups.keys()].map(Number))+1,this.normalizeGroups(),this.commands=s.commands;let f=(a)=>Math.max(0,...a.map(Number))+1;if(this.nextId=f(this.order),this.nextCommandId=f(this.commands.map((a)=>a.id)),e&&!this.initialTerminal)this.initialTerminal=this.createTerminal(e)}async snapshot(e,{refreshCwd:r=!1}={}){let s={};return await Promise.all([...this.terminals].map(async([c,f])=>{let[a,y]=await Promise.all([f.snapshot(),f.savedCwd({refresh:r})]);s[c]={...a,initial:c===this.initialTerminal,...y&&{cwd:y}}})),{version:2,cwd:e,tabs:[...this.order],names:Object.fromEntries(this.tabNames),groups:[...this.groups].map(([c,{name:f,color:a}])=>({id:c,...f!==void 0&&{name:f},color:a,tabs:this.order.filter((y)=>this.tabGroups.get(y)===c)})),terminals:s,commands:this.commands,...this.savedMinWindow&&{minWindow:this.savedMinWindow}}}terminal(e){return this.terminals.get(e)}join(e){let r=this.nextMemberId++,s={id:r,name:Ot(r),color:ds[(r-1)%ds.length],selections:{}};this.members.set(e,s);let c=this.initialTerminal&&this.terminals.has(this.initialTerminal)?this.initialTerminal:this.order[0];return this.views.set(s,{layout:oe(c),splits:[]}),e({type:"welcome",you:r}),e(this.tabsEvent()),e(Ht(this.views.get(s))),e(this.titlesEvent()),e({type:"status",statuses:this.statuses()}),e(this.commandsEvent()),e(this.minWindowEvent()),this.notifyPresence(),{newTab:async(f)=>{let a=f??s.terminal,y=a===void 0?void 0:await this.terminals.get(a)?.cwd();if(!this.views.has(s))return;let t=this.createTerminal(this.shellCommand,y);this.notifyTabs(),this.changeView(s,(n)=>({layout:oe(t),splits:ps(n)}))},split:async(f,a)=>{if(!this.canAdd(s))return;let y=await this.terminals.get(f)?.cwd();if(!this.canAdd(s))return;let t=this.createTerminal(this.shellCommand,y);this.notifyTabs();let n=this.changeView(s,(l)=>({...l,layout:this.placeBeside(l.layout,oe(t),f,a)}));if(n)this.gather(n.layout,t)},selectTab:(f)=>{if(!this.terminals.has(f))return;this.changeView(s,(a)=>{if(ee(a.layout).includes(f))return;let y=a.splits.find((n)=>ee(n).includes(f)),t=ps(a).filter((n)=>n!==y);return{layout:y??oe(f),splits:t}})},addToView:(f,a,y)=>{if(!this.terminals.has(f)||!this.canAdd(s))return;let t=this.changeView(s,(n)=>{if(ee(n.layout).includes(f))return;return{layout:y?on(n.layout,oe(f),y,`split-${this.nextSplitId++}`):this.placeBeside(n.layout,oe(f),a,"row"),splits:_s(n.splits,f)}});if(t)this.gather(t.layout,f)},removeFromView:(f)=>{this.changeView(s,(a)=>{let y=ee(a.layout);return y.length>1&&y.includes(f)?{...a,layout:Re(a.layout,f)}:void 0})},separate:(f)=>{this.changeView(s,(a)=>{let y=ee(a.layout);if(y.includes(f)){if(y.length<2)return;let n=s.terminal!==void 0&&y.includes(s.terminal)?s.terminal:f;return{...a,layout:oe(n)}}let t=a.splits.find((n)=>ee(n).includes(f));return t?{...a,splits:a.splits.filter((n)=>n!==t)}:void 0})},resizeSplit:(f,a)=>{this.changeView(s,(y)=>Ze(y,(t)=>me(t,f)?an(t,f,Math.min(0.9,Math.max(0.1,a))):void 0))},swapPanes:(f,a)=>{let y=this.changeView(s,(t)=>Ze(t,(n)=>{let l=ee(n);return f!==a&&l.includes(f)&&l.includes(a)?ms(n,f,a):void 0}));if(y)this.gatherSplitOf(y,(t)=>ee(t).includes(f))},flipSplit:(f)=>{let a=this.changeView(s,(y)=>Ze(y,(t)=>me(t,f)?et(t,f,(n)=>({...n,ratio:1-n.ratio,children:[n.children[1],n.children[0]]})):void 0));if(a)this.gatherSplitOf(a,(y)=>me(y,f)!==void 0)},rotateSplit:(f)=>{let a=this.changeView(s,(y)=>Ze(y,(t)=>me(t,f)?Te(et(t,f,(n)=>({...n,direction:n.direction==="row"?"column":"row"}))):void 0));if(a)this.gatherSplitOf(a,(y)=>me(y,f)!==void 0)},focus:(f)=>{s.terminal=f,this.notifyPresence(),this.updateSeen()},visible:(f)=>{if(f)this.visibleMembers.add(s);else this.visibleMembers.delete(s);this.updateSeen()},select:(f,a)=>{if(a&&this.terminals.has(f))s.selections[f]=a;else if(!a&&Object.hasOwn(s.selections,f))delete s.selections[f];else return;this.notifyPresence()},follow:(f)=>{let a=[...this.members.values()].find((t)=>t.id===f&&t!==s);if(s.following===a?.id)return;let y=s.following;if(s.following=a?.id,this.forgetScroll(y),this.notifyPresence(),a)this.setView(s,this.views.get(a))},scroll:(f,a)=>{if(s.scroll?.terminal===f&&s.scroll.offset===a)return;s.scroll={terminal:f,offset:a},this.notifyPresence()},rename:(f)=>{if(this.chosenNames.get(s)===f)return;if(f===void 0)this.chosenNames.delete(s);else this.chosenNames.set(s,f);this.notifyPresence()},leave:()=>{this.members.delete(e),this.views.delete(s),this.chosenNames.delete(s),this.visibleMembers.delete(s),this.members.forEach((f)=>{if(f.following===s.id)f.following=void 0}),this.forgetScroll(s.following),this.notifyPresence()}}}close(e){if(this.stopping)return;let r=this.order.indexOf(e);if(r<0||this.order.length===1)return;this.order.splice(r,1),this.removeTerminal(e);let s=this.order[Math.min(r,this.order.length-1)];this.notifyTabs();for(let[c,f]of this.members){let a=this.views.get(f);if(!a)continue;let y=ee(a.layout).includes(e),t=a.splits.some((g)=>ee(g).includes(e));if(!y&&!t)continue;let n=_s(a.splits,e),l=a.layout;if(y){let g=Re(a.layout,e),d=g?void 0:n.find((_)=>ee(_).includes(s));l=g??d??oe(s),n=n.filter((_)=>_!==d)}let p={layout:l,splits:n};this.views.set(f,p),c(Ht(p))}this.updateSeen()}moveTab(e,r,s){if(!this.validTabs(e))return;let c=this.order.filter((n)=>e.includes(n)),f=this.order.filter((n)=>!e.includes(n));if(!Number.isSafeInteger(r)||r<0||r>f.length)return;if(typeof s==="string"&&!this.groups.has(s))return;let a=r;if(typeof s==="string"){let n=f.flatMap((l,p)=>this.tabGroups.get(l)===s?[p]:[]);if(n.length>0)a=Math.min(Math.max(r,n[0]),n.at(-1)+1)}let y=[...f.slice(0,a),...c,...f.slice(a)];if(!(s!==void 0&&c.some((n)=>(this.tabGroups.get(n)??null)!==s))&&y.every((n,l)=>n===this.order[l]))return;this.order=y;for(let n of c)if(s===null)this.tabGroups.delete(n);else if(s!==void 0)this.tabGroups.set(n,s);this.notifyTabs()}newGroup(e){if(!this.validTabs(e))return;let r=new Set([...this.groups.values()].map((f)=>f.color)),s=Le.find((f)=>!r.has(f))??Le[this.groups.size%Le.length],c=String(this.nextGroupId++);this.groups.set(c,{color:s});for(let f of e)this.tabGroups.set(f,c);this.notifyTabs()}addToGroup(e,r){if(!this.validTabs(e)||!this.groups.has(r)||e.every((f)=>this.tabGroups.get(f)===r))return;let s=this.order.filter((f)=>e.includes(f));this.order=this.order.filter((f)=>!e.includes(f));let c=this.order.findLastIndex((f)=>this.tabGroups.get(f)===r);this.order.splice(c+1,0,...s);for(let f of s)this.tabGroups.set(f,r);this.notifyTabs()}removeFromGroup(e){if(!this.validTabs(e))return;let r=!1;for(let s of this.order.filter((c)=>e.includes(c)).reverse()){let c=this.tabGroups.get(s);if(c===void 0)continue;r=!0,this.tabGroups.delete(s);let f=this.order.indexOf(s);this.order.splice(f,1);let a=this.order.findLastIndex((y)=>this.tabGroups.get(y)===c);this.order.splice(a<0?f:a+1,0,s)}if(r)this.notifyTabs()}moveGroup(e,r){if(!this.groups.has(e))return;let s=this.order.filter((a)=>this.tabGroups.get(a)===e),c=this.order.filter((a)=>this.tabGroups.get(a)!==e);if(!Number.isSafeInteger(r)||r<0||r>c.length)return;let f=[...c.slice(0,r),...s,...c.slice(r)];if(f.every((a,y)=>a===this.order[y]))return;this.order=f,this.notifyTabs()}renameGroup(e,r){let s=this.groups.get(e);if(!s||s.name===r)return;if(r===void 0)delete s.name;else s.name=r;this.notifyTabs()}recolorGroup(e,r){let s=this.groups.get(e);if(!s||!Ye(r)||s.color===r)return;s.color=r,this.notifyTabs()}ungroup(e){if(!this.groups.delete(e))return;for(let[r,s]of this.tabGroups)if(s===e)this.tabGroups.delete(r);this.notifyTabs()}closeGroup(e){let r=this.order.filter((s)=>this.tabGroups.get(s)===e);if(r.length===0||r.length===this.order.length)return;for(let s of r)this.close(s)}renameTab(e,r){if(!this.terminals.has(e)||this.tabNames.get(e)===r)return;if(r===void 0)this.tabNames.delete(e);else this.tabNames.set(e,r);this.notifyTabs()}addCommand(e){if(this.commands.length>=Ur)return;this.commands.push({id:String(this.nextCommandId++),...e}),this.notifyCommands()}updateCommand(e,r){let s=this.commands.findIndex((c)=>c.id===e);if(s<0)return;this.commands[s]={id:e,...r},this.notifyCommands()}removeCommand(e){let r=this.commands.length;if(this.commands=this.commands.filter((s)=>s.id!==e),this.commands.length!==r)this.notifyCommands()}setMinWindow(e){if(this.savedMinWindow=e,e.width===this.minWindow.width&&e.height===this.minWindow.height)return this.onChange();this.minWindow=e;let r=this.minWindowEvent();this.members.forEach((s,c)=>c(r)),this.onChange()}async killAll(){this.stopping=!0,await Promise.all([...this.terminals.values()].map((e)=>e.kill()))}createTerminal(e,r){let s=String(this.nextId++);return this.addTerminal(s,e,void 0,r),s}addTerminal(e,r,s,c){this.order.push(e),this.terminals.set(e,new At(r,()=>this.close(e),()=>this.notifyTitles(),()=>this.notifyStatus(),{restored:s,onOutput:()=>this.onChange(),cwd:c}))}removeTerminal(e){this.terminals.get(e)?.kill(),this.terminals.delete(e),this.tabNames.delete(e),this.tabGroups.delete(e);let r=!1;for(let s of this.members.values()){if(!Object.hasOwn(s.selections,e))continue;delete s.selections[e],r=!0}if(r)this.notifyPresence()}canAdd(e){let r=this.views.get(e);return r!==void 0&&ee(r.layout).length<fs}validTabs(e){return e.length>0&&e.length<=fs&&new Set(e).size===e.length&&e.every((r)=>this.terminals.has(r))}placeBeside(e,r,s,c){let f=(a)=>({type:"split",id:`split-${this.nextSplitId++}`,direction:c,ratio:0.5,children:[a,r]});if(s===void 0||!ee(e).includes(s))return Te(f(e));return Te(gs(e,s,f(oe(s))))}changeView(e,r){let s=this.views.get(e),c=s&&r(s);if(!c)return;if(e.following!==void 0){let f=e.following;e.following=void 0,this.forgetScroll(f),this.notifyPresence()}return this.setView(e,c),c}gather(e,r){let s=ee(e);if(s.length<2)return;let c=this.order.find((n)=>s.includes(n)&&n!==r);if(c===void 0)return;let f=this.tabGroups.get(c),a=this.order.indexOf(c),y=[...this.order.slice(0,a).filter((n)=>!s.includes(n)),...s,...this.order.slice(a).filter((n)=>!s.includes(n))];if(s.every((n)=>this.tabGroups.get(n)===f)&&y.every((n,l)=>n===this.order[l]))return;this.order=y;for(let n of s)if(f===void 0)this.tabGroups.delete(n);else this.tabGroups.set(n,f);this.notifyTabs()}gatherSplitOf(e,r){let s=[e.layout,...e.splits].find(r);if(s)this.gather(s)}setView(e,r){let s=new Set,c=(f)=>{s.add(f),this.views.set(f,r);for(let[a,y]of this.members)if(y===f)a(Ht(r));for(let a of this.members.values())if(a.following===f.id&&!s.has(a))c(a)};c(e),this.updateSeen()}tabsEvent(){let e=(f)=>xe(f).replace(/\s/g,""),r=new Map(this.order.map((f)=>[f,e(this.tabNames.get(f)??It(f))])),s=this.order.map((f)=>{let a=this.tabNames.get(f);if(a===void 0)return{id:f,name:It(f)};let y=r.get(f),t=y.match(/^\u30BF\u30FC\u30DF\u30CA\u30EB(\d+)$/),n=t!==null&&t[1]!==f||/\(\u30BF\u30FC\u30DF\u30CA\u30EB\d+\)$/.test(y)||this.order.some((l)=>l!==f&&r.get(l)===y);return{id:f,name:n?`${a}\uFF08${It(f)}\uFF09`:a,custom:a}});for(let f of s){let a=this.tabGroups.get(f.id);if(a!==void 0)f.group=a}let c=[];for(let f of new Set(this.order.flatMap((a)=>this.tabGroups.get(a)??[]))){let{name:a,color:y}=this.groups.get(f);c.push({id:f,name:a??nn(f),...a!==void 0&&{custom:a},color:y})}return{type:"tabs",tabs:s,groups:c}}normalizeGroups(){for(let[c,f]of this.tabGroups)if(!this.groups.has(f)||!this.terminals.has(c))this.tabGroups.delete(c);let e=new Set(this.tabGroups.values());for(let c of this.groups.keys())if(!e.has(c))this.groups.delete(c);let r=new Set,s=[];for(let c of this.order){if(r.has(c))continue;let f=this.tabGroups.get(c),a=f===void 0?[c]:this.order.filter((y)=>this.tabGroups.get(y)===f);for(let y of a)r.add(y),s.push(y)}this.order=s}notifyTabs(){this.normalizeGroups();let e=this.tabsEvent();this.members.forEach((r,s)=>s(e)),this.onChange()}titlesEvent(){let e={};return this.terminals.forEach((r,s)=>{if(r.title)e[s]=r.title}),{type:"titles",titles:e}}notifyTitles(){if(this.titlesQueued)return;this.titlesQueued=!0,queueMicrotask(()=>{this.titlesQueued=!1;let e=this.titlesEvent();this.members.forEach((r,s)=>s(e))})}statuses(){let e={};return this.terminals.forEach((r,s)=>{if(r.status)e[s]=r.status}),e}notifyStatus(){this.clearSeen();let e=this.statuses();this.members.forEach((r,s)=>s({type:"status",statuses:e}))}updateSeen(){if(this.clearSeen())this.notifyStatus()}clearSeen(){let e=!1;for(let r of this.visibleMembers){let s=r.terminal,c=this.views.get(r)?.layout;if(s&&c&&ee(c).includes(s)&&this.terminals.get(s)?.markSeen())e=!0}return e}commandsEvent(){return{type:"commands",commands:this.commands}}minWindowEvent(){return{type:"min-window",...this.minWindow}}notifyCommands(){let e=this.commandsEvent();this.members.forEach((r,s)=>s(e)),this.onChange()}forgetScroll(e){let r=[...this.members.values()],s=r.find((c)=>c.id===e);if(s&&!r.some((c)=>c.following===e))s.scroll=void 0}updateNames(){let e=[...this.members.values()],r=(c)=>this.chosenNames.get(c)??Ot(c.id),s=new Map;for(let c of e)s.set(xe(r(c)),(s.get(xe(r(c)))??0)+1);for(let c of e){let f=r(c);c.name=s.get(xe(f))>1?`${f}\uFF08${Ot(c.id)}\uFF09`:f}}notifyPresence(){this.updateNames();let e=[...this.members.values()];this.members.forEach((r,s)=>s({type:"presence",members:e}))}}function Ot(e){return`\u53C2\u52A0\u8005 ${e}`}function It(e){return`\u30BF\u30FC\u30DF\u30CA\u30EB ${e}`}function nn(e){return`\u30B0\u30EB\u30FC\u30D7 ${e}`}function Ht(e){return{type:"view",layout:e.layout,splits:e.splits}}function ps(e){return e.layout.type==="split"?[...e.splits,e.layout]:e.splits}function _s(e,r){return e.flatMap((s)=>{if(!ee(s).includes(r))return[s];let c=Re(s,r);return c&&c.type==="split"?[c]:[]})}function Ze(e,r){let s=r(e.layout);if(s)return{...e,layout:s};for(let[c,f]of e.splits.entries()){let a=r(f);if(a)return{...e,splits:e.splits.with(c,a)}}return}function on(e,r,s,c){return Te({type:"split",id:c,direction:s==="bottom"?"column":"row",ratio:0.5,children:s==="left"?[r,e]:[e,r]})}function oe(e){return{type:"terminal",id:e}}function ee(e){return e.type==="terminal"?[e.id]:e.children.flatMap(ee)}function me(e,r){if(e.type==="terminal")return;return e.id===r?e:me(e.children[0],r)??me(e.children[1],r)}function Wt(e,r){return{...e,children:[r(e.children[0]),r(e.children[1])]}}function gs(e,r,s){if(e.type==="terminal")return e.id===r?s:e;return Wt(e,(c)=>gs(c,r,s))}function Re(e,r){if(e.type==="terminal")return e.id===r?void 0:e;let s=Re(e.children[0],r),c=Re(e.children[1],r);if(!s||!c)return s??c;return{...e,children:[s,c]}}function an(e,r,s){return et(e,r,(c)=>({...c,ratio:s}))}function et(e,r,s){if(e.type==="terminal")return e;if(e.id===r)return s(e);return Wt(e,(c)=>et(c,r,s))}function ms(e,r,s){if(e.type==="terminal")return e.id===r?oe(s):e.id===s?oe(r):e;return Wt(e,(c)=>ms(c,r,s))}function Te(e){if(e.type==="terminal")return e;let r=e.children.map(Te),[s,c]=r.map((f)=>Nt(f,e.direction));return{...e,ratio:s/(s+c),children:r}}function Nt(e,r){if(e.type==="terminal"||e.direction!==r)return 1;return Nt(e.children[0],r)+Nt(e.children[1],r)}var{values:st,positionals:vs}=Zr(),rt=st["min-window"],ys=rt===void 0?void 0:Fr(rt);if(rt!==void 0&&!ys)console.error(`Accompany: --min-window \u306F\u300C\u5E45x\u9AD8\u3055\u300D\uFF08\u4F8B: 480x1080\u3002\u5E45 0\u301C${Ee.width}\u3001\u9AD8\u3055 0\u301C${Ee.height} \u306E\u6574\u6570\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${rt}`),process.exit(1);var cn=[process.env.SHELL??"/bin/sh"],bs=process.cwd(),zt=new Pt(ns(),bs),Ss=st.fresh?void 0:zt.load(),Be=new Ft(vs.length>0?vs:void 0,cn,Ss,ys),jt=new Rt,hn=Xr(Be,jt),ws=10,ve=Number(st.port),ln=await us(ts,ls({allowVscodeWebview:st["allow-vscode-webview"]})),be;for(let e=ve;e<ve+ws&&e<=ke;e++)try{be=Bun.serve({hostname:"127.0.0.1",port:e,development:!1,reusePort:!1,routes:ln,fetch:hn.fetch,websocket:{...lt,perMessageDeflate:!0}});break}catch(r){if(r.code!=="EADDRINUSE")throw r}if(!be){let e=Math.min(ve+ws-1,ke);console.error(`Accompany: \u30DD\u30FC\u30C8 ${ve}\u301C${e} \u306F\u3059\u3079\u3066\u4F7F\u308F\u308C\u3066\u3044\u307E\u3059\u3002--port \u3067\u5225\u306E\u30DD\u30FC\u30C8\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`),await Be.killAll(),jt.remove(),process.exit(1)}if(be.port!==ve&&ve!==0)console.log(`Accompany: \u30DD\u30FC\u30C8 ${ve} \u306F\u4F7F\u308F\u308C\u3066\u3044\u308B\u306E\u3067\u3001${be.port} \u3067\u5F85\u3061\u53D7\u3051\u307E\u3059`);var Ut=!1;async function Cs({stopping:e=!1}={}){try{zt.save(await Be.snapshot(bs,{refreshCwd:e})),Ut=!1}catch(r){if(!Ut)console.warn(`Accompany: \u753B\u9762\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r}`);Ut=!0}}var un=1000,tt,$t=!1;Be.onChange=()=>{if(tt||$t)return;tt=setTimeout(()=>{tt=void 0,Cs()},un)};var fn=3000;for(let e of["SIGINT","SIGTERM","SIGHUP"])process.on(e,async()=>{if($t)return;$t=!0,clearTimeout(tt),await Promise.race([Cs({stopping:!0}),Bun.sleep(fn)]),await Be.killAll(),jt.remove(),process.exit(0)});console.log(`Accompany: http://${be.hostname}:${be.port}`);if(Ss)console.log(`\u524D\u56DE\u306E\u753B\u9762\u3092\u623B\u3057\u307E\u3057\u305F\uFF08\u65B0\u3057\u304F\u59CB\u3081\u308B\u3068\u304D\u306F --fresh \u3092\u4ED8\u3051\u3066\u8D77\u52D5\u3059\u308B\uFF09: ${zt.file}`);
141
+ ${Ye}`),process.exit(1);let s=r.positionals[0],c=s??es();if(!Zr(c)){let f=`\u5BFE\u5FDC\u3057\u3066\u3044\u308B\u30B7\u30A7\u30EB: ${Ke.join("\u30FB")}`;console.error(s===void 0?`Accompany: $SHELL\uFF08${process.env.SHELL??"\u672A\u8A2D\u5B9A"}\uFF09\u306E\u30B7\u30A7\u30EB\u306B\u306F\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002accompany activate zsh \u306E\u3088\u3046\u306B\u30B7\u30A7\u30EB\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08${f}\uFF09`:`Accompany: \u77E5\u3089\u306A\u3044\u30B7\u30A7\u30EB\u3067\u3059: ${c}\uFF08${f}\uFF09`),process.exit(1)}process.stdout.write(ts(c)),process.exit(0)}function is(e){let r=e instanceof Error?e.message:String(e),s=e?.code;if(s==="ERR_PARSE_ARGS_UNKNOWN_OPTION"){let c=r.match(/Unknown option '([^']+)'/)?.[1];if(c)return`\u77E5\u3089\u306A\u3044\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3059: ${c}`}if(s==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"){let c=r.match(/Option '(-[^\s']+)/)?.[1];if(c&&/argument missing|argument is ambiguous/.test(r))return`${c} \u306B\u306F\u5024\u304C\u8981\u308A\u307E\u3059`;if(c&&/does not take an argument/.test(r))return`${c} \u306F\u5024\u3092\u53D6\u308A\u307E\u305B\u3093`}return r}var ns=Qt("{\"index\":\"public/index.html\",\"files\":[{\"input\":\"public/index.html\",\"path\":\"./index-tg9wkazb.js\",\"loader\":\"js\",\"isEntry\":true,\"headers\":{\"etag\":\"WjBpfLNKX6s\",\"content-type\":\"text/javascript;charset=utf-8\"}},{\"input\":\"public/index.html\",\"path\":\"public/index.html\",\"loader\":\"html\",\"isEntry\":true,\"headers\":{\"etag\":\"7zs875MY4DE\",\"content-type\":\"text/html;charset=utf-8\"}},{\"input\":\"public/index.html\",\"path\":\"./index-e5af4q9z.css\",\"loader\":\"css\",\"isEntry\":true,\"headers\":{\"etag\":\"LgVqL2T3Cb8\",\"content-type\":\"text/css;charset=utf-8\"}},{\"input\":\"public/favicon.png\",\"path\":\"./favicon-0wwf4h3c.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"YHwcDyQxo4w\",\"content-type\":\"image/png\"}},{\"input\":\"public/apple-touch-icon.png\",\"path\":\"./apple-touch-icon-ehhpc4a9.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"LjHRtszkCok\",\"content-type\":\"image/png\"}}]}");import{createHash as qi}from"crypto";import{chmodSync as Xi,mkdirSync as Vi,readFileSync as Qi,renameSync as Ki,rmSync as os,writeFileSync as Yi}from"fs";import{homedir as Ji}from"os";import{dirname as Zi,isAbsolute as cs,join as Ot}from"path";var Le=["blue","red","yellow","green","pink","purple","cyan","grey"];function Je(e){return typeof e==="string"&&Le.includes(e)}var as=448,en=384;function ls(e=process.env){if(e.ACCOMPANY_STATE_DIR)return e.ACCOMPANY_STATE_DIR;let r=e.XDG_STATE_HOME&&cs(e.XDG_STATE_HOME)?e.XDG_STATE_HOME:Ot(Ji(),".local","state");return Ot(r,"accompany")}class It{dir;file;constructor(e,r){this.dir=e;let s=qi("sha256").update(r).digest("hex").slice(0,16);this.file=Ot(e,"sessions",`${s}.json`)}load(){let e;try{e=Qi(this.file,"utf8")}catch(r){if(r.code!=="ENOENT")console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F: ${r}`);return}try{let r=tn(JSON.parse(e));if(!r)console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u306A\u3044\u305F\u3081\u3001\u65B0\u3057\u304F\u59CB\u3081\u307E\u3059: ${this.file}`);return r}catch(r){console.warn(`Accompany: \u4FDD\u5B58\u3057\u305F\u753B\u9762\u3092\u8AAD\u3081\u306A\u3044\u305F\u3081\u3001\u65B0\u3057\u304F\u59CB\u3081\u307E\u3059: ${r}`)}}save(e){let r=Zi(this.file);for(let c of[this.dir,r])Vi(c,{recursive:!0,mode:as}),Xi(c,as);let s=`${this.file}.${process.pid}.tmp`;os(s,{force:!0});try{Yi(s,JSON.stringify(e),{mode:en,flag:"wx"}),Ki(s,this.file)}catch(c){throw os(s,{force:!0}),c}}}function tn(e){if(!ne(e)||!Array.isArray(e.tabs)||e.tabs.length===0)return;let r=e.version===2?sn(e.tabs):e.version===1?nn(e.tabs):void 0;if(!r)return;let s=ne(e.terminals)?e.terminals:{},c={};for(let l of r){let p=s[l];c[l]={...ne(p)&&an(p)?ye({cols:p.cols,rows:p.rows}):{cols:80,rows:24},scrollback:ne(p)&&typeof p.scrollback==="string"?p.scrollback:"",initial:ne(p)&&p.initial===!0,...ne(p)&&on(p.cwd)&&{cwd:p.cwd}}}let f=[];for(let l of Array.isArray(e.commands)?e.commands:[]){let p=ne(l)&&Ze(l.id)&&Qe(l);if(p&&!f.some((g)=>g.id===l.id))f.push({id:l.id,...p})}let a=ne(e.names)?e.names:{},y={};for(let l of r){let p=typeof a[l]==="string"?ge(a[l]):void 0;if(p!==void 0)y[l]=p}let t=rn(e.groups,r),n=Ae(e.minWindow);return{version:2,cwd:String(e.cwd??""),tabs:r,names:y,groups:t,terminals:c,commands:f,...n&&{minWindow:n}}}function rn(e,r){let s=[],c=new Set;for(let f of Array.isArray(e)?e:[]){if(!ne(f)||!Ze(f.id)||!Je(f.color)||s.some((t)=>t.id===f.id))continue;let a=(Array.isArray(f.tabs)?f.tabs:[]).filter((t)=>typeof t==="string"&&r.includes(t)&&!c.has(t));if(a.length===0)continue;for(let t of a)c.add(t);let y=typeof f.name==="string"?ge(f.name):void 0;s.push({id:f.id,...y!==void 0&&{name:y},color:f.color,tabs:a})}return s}function sn(e){let r=[];for(let s of e){if(!Ze(s)||r.includes(s))return;r.push(s)}return r}function nn(e){let r=new Set,s=[];for(let c of e)if(!ne(c)||!hs(c.layout,r,s,0))return;return s}function hs(e,r,s,c){if(!ne(e)||c>100)return!1;if(e.type==="terminal"){if(!Ze(e.id)||r.has(e.id))return!1;return r.add(e.id),s.push(e.id),!0}if(e.type!=="split"||typeof e.id!=="string"||!/^split-[1-9]\d{0,8}$/.test(e.id))return!1;if(r.has(e.id))return!1;if(r.add(e.id),!Array.isArray(e.children)||e.children.length!==2)return!1;return e.children.every((f)=>hs(f,r,s,c+1))}function ne(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ze(e){return typeof e==="string"&&/^[1-9]\d{0,8}$/.test(e)}function on(e){return typeof e==="string"&&cs(e)&&!e.includes("\x00")}function an(e){let r=(s)=>Number.isSafeInteger(s)&&s>=1;return r(e.cols)&&r(e.rows)}import{isAbsolute as cn,resolve as ln}from"path";var hn=0.9;function ps({allowVscodeWebview:e=!1}={}){return`frame-ancestors 'self'${e?" vscode-webview: vscode-file:":""}`}async function _s(e,r){let{files:s}=e;if(s?.some((f)=>!cn(f.path)))return us(fn(s),r);let c=Bun.serve({hostname:"127.0.0.1",port:0,development:!1,reusePort:!1,routes:{"/":e},fetch:()=>new Response("Not Found",{status:404})});try{return await us(un(c.url),r)}finally{c.stop(!0)}}async function us(e,r){let s=fs(await e("/"),r),c=new TextDecoder().decode(s.body),f=new Set([...c.matchAll(/(?:src|href)="(\/[^"]+)"/g)].map((y)=>y[1])),a={"/":ds(s)};for(let y of f){let t=fs(await e(y),r);if(!t.headers.has("cache-control"))t.headers.set("cache-control","public, max-age=31536000, immutable");a[y]=ds(t)}return a}function un(e){return async(r)=>{let s=await fetch(new URL(r,e));if(!s.ok)throw Error(`\u753B\u9762\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u7528\u610F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r} (${s.status})`);return{body:new Uint8Array(await s.arrayBuffer()),headers:new Headers(s.headers)}}}function fn(e){return async(r)=>{let s=r==="/"?e.find((f)=>f.loader==="html"):e.find((f)=>f.loader!=="html"&&`/${f.path.replace(/^\.\//,"")}`===r);if(!s)throw Error(`\u753B\u9762\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u7528\u610F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r}\uFF08\u56FA\u3081\u305F JS \u306E\u4E00\u89A7\u306B\u306A\u3044\uFF09`);return{body:await Bun.file(ln(import.meta.dir,s.path)).bytes(),headers:new Headers(s.headers)}}}function fs({body:e,headers:r},s){let c=new Headers(r);c.delete("content-length"),c.delete("date"),c.set("vary","Accept-Encoding"),c.set("content-security-policy",s);let f=Bun.gzipSync(e,{level:9});return{body:e,headers:c,gzip:f.byteLength<e.byteLength*hn?f:void 0}}function ds({body:e,gzip:r,headers:s}){let c=s.get("etag");return(f)=>{if(c&&f.headers.get("if-none-match")===c)return new Response(null,{status:304,headers:s});let a=/\bgzip\b/.test(f.headers.get("accept-encoding")??"");if(!r||!a)return new Response(e,{headers:s});let y=new Headers(s);return y.set("content-encoding","gzip"),new Response(r,{headers:y})}}var gs=3,ms=["#4fc3f7","#ffb74d","#81c784","#f06292","#ba68c8","#fff176"];class $t{shellCommand;terminals=new Map;order=[];tabNames=new Map;groups=new Map;tabGroups=new Map;nextGroupId=1;members=new Map;views=new Map;chosenNames=new Map;visibleMembers=new Set;nextMemberId=1;nextId=1;nextSplitId=1;titlesQueued=!1;nextCommandId=1;stopping=!1;initialTerminal;commands=[];minWindow;savedMinWindow;onChange=()=>{};constructor(e,r,s,c){this.shellCommand=r;if(this.savedMinWindow=s?.minWindow,this.minWindow=c??s?.minWindow??Ur,!s){this.initialTerminal=this.createTerminal(e??r);return}for(let a of s.tabs){let y=s.terminals[a];if(y.initial)this.initialTerminal=a;let t=y.initial&&e!==void 0;this.addTerminal(a,t?e:r,y,t?void 0:y.cwd)}for(let[a,y]of Object.entries(s.names??{}))this.tabNames.set(a,y);for(let a of s.groups??[]){this.groups.set(a.id,{color:a.color,...a.name!==void 0&&{name:a.name}});for(let y of a.tabs)this.tabGroups.set(y,a.id)}this.nextGroupId=Math.max(0,...[...this.groups.keys()].map(Number))+1,this.normalizeGroups(),this.commands=s.commands;let f=(a)=>Math.max(0,...a.map(Number))+1;if(this.nextId=f(this.order),this.nextCommandId=f(this.commands.map((a)=>a.id)),e&&!this.initialTerminal)this.initialTerminal=this.createTerminal(e)}async snapshot(e,{refreshCwd:r=!1}={}){let s={};return await Promise.all([...this.terminals].map(async([c,f])=>{let[a,y]=await Promise.all([f.snapshot(),f.savedCwd({refresh:r})]);s[c]={...a,initial:c===this.initialTerminal,...y&&{cwd:y}}})),{version:2,cwd:e,tabs:[...this.order],names:Object.fromEntries(this.tabNames),groups:[...this.groups].map(([c,{name:f,color:a}])=>({id:c,...f!==void 0&&{name:f},color:a,tabs:this.order.filter((y)=>this.tabGroups.get(y)===c)})),terminals:s,commands:this.commands,...this.savedMinWindow&&{minWindow:this.savedMinWindow}}}terminal(e){return this.terminals.get(e)}join(e){let r=this.nextMemberId++,s={id:r,name:Ht(r),color:ms[(r-1)%ms.length],selections:{}};this.members.set(e,s);let c=this.initialTerminal&&this.terminals.has(this.initialTerminal)?this.initialTerminal:this.order[0];return this.views.set(s,{layout:oe(c),splits:[]}),e({type:"welcome",you:r}),e(this.tabsEvent()),e(Ft(this.views.get(s))),e(this.titlesEvent()),e({type:"status",statuses:this.statuses()}),e(this.commandsEvent()),e(this.minWindowEvent()),this.notifyPresence(),{newTab:async(f)=>{let a=f??s.terminal,y=a===void 0?void 0:await this.terminals.get(a)?.cwd();if(!this.views.has(s))return;let t=this.createTerminal(this.shellCommand,y);this.notifyTabs(),this.changeView(s,(n)=>({layout:oe(t),splits:vs(n)}))},split:async(f,a)=>{if(!this.canAdd(s))return;let y=await this.terminals.get(f)?.cwd();if(!this.canAdd(s))return;let t=this.createTerminal(this.shellCommand,y);this.notifyTabs();let n=this.changeView(s,(l)=>({...l,layout:this.placeBeside(l.layout,oe(t),f,a)}));if(n)this.gather(n.layout,t)},selectTab:(f)=>{if(!this.terminals.has(f))return;this.changeView(s,(a)=>{if(ee(a.layout).includes(f))return;let y=a.splits.find((n)=>ee(n).includes(f)),t=vs(a).filter((n)=>n!==y);return{layout:y??oe(f),splits:t}})},addToView:(f,a,y)=>{if(!this.terminals.has(f)||!this.canAdd(s))return;let t=this.changeView(s,(n)=>{if(ee(n.layout).includes(f))return;return{layout:y?pn(n.layout,oe(f),y,`split-${this.nextSplitId++}`):this.placeBeside(n.layout,oe(f),a,"row"),splits:ys(n.splits,f)}});if(t)this.gather(t.layout,f)},removeFromView:(f)=>{this.changeView(s,(a)=>{let y=ee(a.layout);return y.length>1&&y.includes(f)?{...a,layout:Re(a.layout,f)}:void 0})},separate:(f)=>{this.changeView(s,(a)=>{let y=ee(a.layout);if(y.includes(f)){if(y.length<2)return;let n=s.terminal!==void 0&&y.includes(s.terminal)?s.terminal:f;return{...a,layout:oe(n)}}let t=a.splits.find((n)=>ee(n).includes(f));return t?{...a,splits:a.splits.filter((n)=>n!==t)}:void 0})},resizeSplit:(f,a)=>{this.changeView(s,(y)=>et(y,(t)=>me(t,f)?_n(t,f,Math.min(0.9,Math.max(0.1,a))):void 0))},swapPanes:(f,a)=>{let y=this.changeView(s,(t)=>et(t,(n)=>{let l=ee(n);return f!==a&&l.includes(f)&&l.includes(a)?ws(n,f,a):void 0}));if(y)this.gatherSplitOf(y,(t)=>ee(t).includes(f))},flipSplit:(f)=>{let a=this.changeView(s,(y)=>et(y,(t)=>me(t,f)?tt(t,f,(n)=>({...n,ratio:1-n.ratio,children:[n.children[1],n.children[0]]})):void 0));if(a)this.gatherSplitOf(a,(y)=>me(y,f)!==void 0)},rotateSplit:(f)=>{let a=this.changeView(s,(y)=>et(y,(t)=>me(t,f)?Te(tt(t,f,(n)=>({...n,direction:n.direction==="row"?"column":"row"}))):void 0));if(a)this.gatherSplitOf(a,(y)=>me(y,f)!==void 0)},focus:(f)=>{s.terminal=f,this.notifyPresence(),this.updateSeen()},visible:(f)=>{if(f)this.visibleMembers.add(s);else this.visibleMembers.delete(s);this.updateSeen()},select:(f,a)=>{if(a&&this.terminals.has(f))s.selections[f]=a;else if(!a&&Object.hasOwn(s.selections,f))delete s.selections[f];else return;this.notifyPresence()},follow:(f)=>{let a=[...this.members.values()].find((t)=>t.id===f&&t!==s);if(s.following===a?.id)return;let y=s.following;if(s.following=a?.id,this.forgetScroll(y),this.notifyPresence(),a)this.setView(s,this.views.get(a))},scroll:(f,a)=>{if(s.scroll?.terminal===f&&s.scroll.offset===a)return;s.scroll={terminal:f,offset:a},this.notifyPresence()},rename:(f)=>{if(this.chosenNames.get(s)===f)return;if(f===void 0)this.chosenNames.delete(s);else this.chosenNames.set(s,f);this.notifyPresence()},leave:()=>{this.members.delete(e),this.views.delete(s),this.chosenNames.delete(s),this.visibleMembers.delete(s),this.members.forEach((f)=>{if(f.following===s.id)f.following=void 0}),this.forgetScroll(s.following),this.notifyPresence()}}}close(e){if(this.stopping)return;let r=this.order.indexOf(e);if(r<0||this.order.length===1)return;this.order.splice(r,1),this.removeTerminal(e);let s=this.order[Math.min(r,this.order.length-1)];this.notifyTabs();for(let[c,f]of this.members){let a=this.views.get(f);if(!a)continue;let y=ee(a.layout).includes(e),t=a.splits.some((g)=>ee(g).includes(e));if(!y&&!t)continue;let n=ys(a.splits,e),l=a.layout;if(y){let g=Re(a.layout,e),d=g?void 0:n.find((_)=>ee(_).includes(s));l=g??d??oe(s),n=n.filter((_)=>_!==d)}let p={layout:l,splits:n};this.views.set(f,p),c(Ft(p))}this.updateSeen()}moveTab(e,r,s){if(!this.validTabs(e))return;let c=this.order.filter((n)=>e.includes(n)),f=this.order.filter((n)=>!e.includes(n));if(!Number.isSafeInteger(r)||r<0||r>f.length)return;if(typeof s==="string"&&!this.groups.has(s))return;let a=r;if(typeof s==="string"){let n=f.flatMap((l,p)=>this.tabGroups.get(l)===s?[p]:[]);if(n.length>0)a=Math.min(Math.max(r,n[0]),n.at(-1)+1)}let y=[...f.slice(0,a),...c,...f.slice(a)];if(!(s!==void 0&&c.some((n)=>(this.tabGroups.get(n)??null)!==s))&&y.every((n,l)=>n===this.order[l]))return;this.order=y;for(let n of c)if(s===null)this.tabGroups.delete(n);else if(s!==void 0)this.tabGroups.set(n,s);this.notifyTabs()}newGroup(e){if(!this.validTabs(e))return;let r=new Set([...this.groups.values()].map((f)=>f.color)),s=Le.find((f)=>!r.has(f))??Le[this.groups.size%Le.length],c=String(this.nextGroupId++);this.groups.set(c,{color:s});for(let f of e)this.tabGroups.set(f,c);this.notifyTabs()}addToGroup(e,r){if(!this.validTabs(e)||!this.groups.has(r)||e.every((f)=>this.tabGroups.get(f)===r))return;let s=this.order.filter((f)=>e.includes(f));this.order=this.order.filter((f)=>!e.includes(f));let c=this.order.findLastIndex((f)=>this.tabGroups.get(f)===r);this.order.splice(c+1,0,...s);for(let f of s)this.tabGroups.set(f,r);this.notifyTabs()}removeFromGroup(e){if(!this.validTabs(e))return;let r=!1;for(let s of this.order.filter((c)=>e.includes(c)).reverse()){let c=this.tabGroups.get(s);if(c===void 0)continue;r=!0,this.tabGroups.delete(s);let f=this.order.indexOf(s);this.order.splice(f,1);let a=this.order.findLastIndex((y)=>this.tabGroups.get(y)===c);this.order.splice(a<0?f:a+1,0,s)}if(r)this.notifyTabs()}moveGroup(e,r){if(!this.groups.has(e))return;let s=this.order.filter((a)=>this.tabGroups.get(a)===e),c=this.order.filter((a)=>this.tabGroups.get(a)!==e);if(!Number.isSafeInteger(r)||r<0||r>c.length)return;let f=[...c.slice(0,r),...s,...c.slice(r)];if(f.every((a,y)=>a===this.order[y]))return;this.order=f,this.notifyTabs()}renameGroup(e,r){let s=this.groups.get(e);if(!s||s.name===r)return;if(r===void 0)delete s.name;else s.name=r;this.notifyTabs()}recolorGroup(e,r){let s=this.groups.get(e);if(!s||!Je(r)||s.color===r)return;s.color=r,this.notifyTabs()}ungroup(e){if(!this.groups.delete(e))return;for(let[r,s]of this.tabGroups)if(s===e)this.tabGroups.delete(r);this.notifyTabs()}closeGroup(e){let r=this.order.filter((s)=>this.tabGroups.get(s)===e);if(r.length===0||r.length===this.order.length)return;for(let s of r)this.close(s)}renameTab(e,r){if(!this.terminals.has(e)||this.tabNames.get(e)===r)return;if(r===void 0)this.tabNames.delete(e);else this.tabNames.set(e,r);this.notifyTabs()}addCommand(e){if(this.commands.length>=Gr)return;this.commands.push({id:String(this.nextCommandId++),...e}),this.notifyCommands()}updateCommand(e,r){let s=this.commands.findIndex((c)=>c.id===e);if(s<0)return;this.commands[s]={id:e,...r},this.notifyCommands()}removeCommand(e){let r=this.commands.length;if(this.commands=this.commands.filter((s)=>s.id!==e),this.commands.length!==r)this.notifyCommands()}setMinWindow(e){if(this.savedMinWindow=e,e.width===this.minWindow.width&&e.height===this.minWindow.height)return this.onChange();this.minWindow=e;let r=this.minWindowEvent();this.members.forEach((s,c)=>c(r)),this.onChange()}async killAll(){this.stopping=!0,await Promise.all([...this.terminals.values()].map((e)=>e.kill()))}createTerminal(e,r){let s=String(this.nextId++);return this.addTerminal(s,e,void 0,r),s}addTerminal(e,r,s,c){this.order.push(e),this.terminals.set(e,new Lt(r,()=>this.close(e),()=>this.notifyTitles(),()=>this.notifyStatus(),{restored:s,onOutput:()=>this.onChange(),cwd:c}))}removeTerminal(e){this.terminals.get(e)?.kill(),this.terminals.delete(e),this.tabNames.delete(e),this.tabGroups.delete(e);let r=!1;for(let s of this.members.values()){if(!Object.hasOwn(s.selections,e))continue;delete s.selections[e],r=!0}if(r)this.notifyPresence()}canAdd(e){let r=this.views.get(e);return r!==void 0&&ee(r.layout).length<gs}validTabs(e){return e.length>0&&e.length<=gs&&new Set(e).size===e.length&&e.every((r)=>this.terminals.has(r))}placeBeside(e,r,s,c){let f=(a)=>({type:"split",id:`split-${this.nextSplitId++}`,direction:c,ratio:0.5,children:[a,r]});if(s===void 0||!ee(e).includes(s))return Te(f(e));return Te(bs(e,s,f(oe(s))))}changeView(e,r){let s=this.views.get(e),c=s&&r(s);if(!c)return;if(e.following!==void 0){let f=e.following;e.following=void 0,this.forgetScroll(f),this.notifyPresence()}return this.setView(e,c),c}gather(e,r){let s=ee(e);if(s.length<2)return;let c=this.order.find((n)=>s.includes(n)&&n!==r);if(c===void 0)return;let f=this.tabGroups.get(c),a=this.order.indexOf(c),y=[...this.order.slice(0,a).filter((n)=>!s.includes(n)),...s,...this.order.slice(a).filter((n)=>!s.includes(n))];if(s.every((n)=>this.tabGroups.get(n)===f)&&y.every((n,l)=>n===this.order[l]))return;this.order=y;for(let n of s)if(f===void 0)this.tabGroups.delete(n);else this.tabGroups.set(n,f);this.notifyTabs()}gatherSplitOf(e,r){let s=[e.layout,...e.splits].find(r);if(s)this.gather(s)}setView(e,r){let s=new Set,c=(f)=>{s.add(f),this.views.set(f,r);for(let[a,y]of this.members)if(y===f)a(Ft(r));for(let a of this.members.values())if(a.following===f.id&&!s.has(a))c(a)};c(e),this.updateSeen()}tabsEvent(){let e=(f)=>xe(f).replace(/\s/g,""),r=new Map(this.order.map((f)=>[f,e(this.tabNames.get(f)??Nt(f))])),s=this.order.map((f)=>{let a=this.tabNames.get(f);if(a===void 0)return{id:f,name:Nt(f)};let y=r.get(f),t=y.match(/^\u30BF\u30FC\u30DF\u30CA\u30EB(\d+)$/),n=t!==null&&t[1]!==f||/\(\u30BF\u30FC\u30DF\u30CA\u30EB\d+\)$/.test(y)||this.order.some((l)=>l!==f&&r.get(l)===y);return{id:f,name:n?`${a}\uFF08${Nt(f)}\uFF09`:a,custom:a}});for(let f of s){let a=this.tabGroups.get(f.id);if(a!==void 0)f.group=a}let c=[];for(let f of new Set(this.order.flatMap((a)=>this.tabGroups.get(a)??[]))){let{name:a,color:y}=this.groups.get(f);c.push({id:f,name:a??dn(f),...a!==void 0&&{custom:a},color:y})}return{type:"tabs",tabs:s,groups:c}}normalizeGroups(){for(let[c,f]of this.tabGroups)if(!this.groups.has(f)||!this.terminals.has(c))this.tabGroups.delete(c);let e=new Set(this.tabGroups.values());for(let c of this.groups.keys())if(!e.has(c))this.groups.delete(c);let r=new Set,s=[];for(let c of this.order){if(r.has(c))continue;let f=this.tabGroups.get(c),a=f===void 0?[c]:this.order.filter((y)=>this.tabGroups.get(y)===f);for(let y of a)r.add(y),s.push(y)}this.order=s}notifyTabs(){this.normalizeGroups();let e=this.tabsEvent();this.members.forEach((r,s)=>s(e)),this.onChange()}titlesEvent(){let e={};return this.terminals.forEach((r,s)=>{if(r.title)e[s]=r.title}),{type:"titles",titles:e}}notifyTitles(){if(this.titlesQueued)return;this.titlesQueued=!0,queueMicrotask(()=>{this.titlesQueued=!1;let e=this.titlesEvent();this.members.forEach((r,s)=>s(e))})}statuses(){let e={};return this.terminals.forEach((r,s)=>{if(r.status)e[s]=r.status}),e}notifyStatus(){this.clearSeen();let e=this.statuses();this.members.forEach((r,s)=>s({type:"status",statuses:e}))}updateSeen(){if(this.clearSeen())this.notifyStatus()}clearSeen(){let e=!1;for(let r of this.visibleMembers){let s=r.terminal,c=this.views.get(r)?.layout;if(s&&c&&ee(c).includes(s)&&this.terminals.get(s)?.markSeen())e=!0}return e}commandsEvent(){return{type:"commands",commands:this.commands}}minWindowEvent(){return{type:"min-window",...this.minWindow}}notifyCommands(){let e=this.commandsEvent();this.members.forEach((r,s)=>s(e)),this.onChange()}forgetScroll(e){let r=[...this.members.values()],s=r.find((c)=>c.id===e);if(s&&!r.some((c)=>c.following===e))s.scroll=void 0}updateNames(){let e=[...this.members.values()],r=(c)=>this.chosenNames.get(c)??Ht(c.id),s=new Map;for(let c of e)s.set(xe(r(c)),(s.get(xe(r(c)))??0)+1);for(let c of e){let f=r(c);c.name=s.get(xe(f))>1?`${f}\uFF08${Ht(c.id)}\uFF09`:f}}notifyPresence(){this.updateNames();let e=[...this.members.values()];this.members.forEach((r,s)=>s({type:"presence",members:e}))}}function Ht(e){return`\u53C2\u52A0\u8005 ${e}`}function Nt(e){return`\u30BF\u30FC\u30DF\u30CA\u30EB ${e}`}function dn(e){return`\u30B0\u30EB\u30FC\u30D7 ${e}`}function Ft(e){return{type:"view",layout:e.layout,splits:e.splits}}function vs(e){return e.layout.type==="split"?[...e.splits,e.layout]:e.splits}function ys(e,r){return e.flatMap((s)=>{if(!ee(s).includes(r))return[s];let c=Re(s,r);return c&&c.type==="split"?[c]:[]})}function et(e,r){let s=r(e.layout);if(s)return{...e,layout:s};for(let[c,f]of e.splits.entries()){let a=r(f);if(a)return{...e,splits:e.splits.with(c,a)}}return}function pn(e,r,s,c){return Te({type:"split",id:c,direction:s==="bottom"?"column":"row",ratio:0.5,children:s==="left"?[r,e]:[e,r]})}function oe(e){return{type:"terminal",id:e}}function ee(e){return e.type==="terminal"?[e.id]:e.children.flatMap(ee)}function me(e,r){if(e.type==="terminal")return;return e.id===r?e:me(e.children[0],r)??me(e.children[1],r)}function Ut(e,r){return{...e,children:[r(e.children[0]),r(e.children[1])]}}function bs(e,r,s){if(e.type==="terminal")return e.id===r?s:e;return Ut(e,(c)=>bs(c,r,s))}function Re(e,r){if(e.type==="terminal")return e.id===r?void 0:e;let s=Re(e.children[0],r),c=Re(e.children[1],r);if(!s||!c)return s??c;return{...e,children:[s,c]}}function _n(e,r,s){return tt(e,r,(c)=>({...c,ratio:s}))}function tt(e,r,s){if(e.type==="terminal")return e;if(e.id===r)return s(e);return Ut(e,(c)=>tt(c,r,s))}function ws(e,r,s){if(e.type==="terminal")return e.id===r?oe(s):e.id===s?oe(r):e;return Ut(e,(c)=>ws(c,r,s))}function Te(e){if(e.type==="terminal")return e;let r=e.children.map(Te),[s,c]=r.map((f)=>Wt(f,e.direction));return{...e,ratio:s/(s+c),children:r}}function Wt(e,r){if(e.type==="terminal"||e.direction!==r)return 1;return Wt(e.children[0],r)+Wt(e.children[1],r)}var{values:it,positionals:Ss}=ss(),st=it["min-window"],Cs=st===void 0?void 0:jr(st);if(st!==void 0&&!Cs)console.error(`Accompany: --min-window \u306F\u300C\u5E45x\u9AD8\u3055\u300D\uFF08\u4F8B: 480x1080\u3002\u5E45 0\u301C${Ee.width}\u3001\u9AD8\u3055 0\u301C${Ee.height} \u306E\u6574\u6570\uFF09\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044: ${st}`),process.exit(1);var gn=[process.env.SHELL??"/bin/sh"],xs=process.cwd(),Gt=new It(ls(),xs),Es=it.fresh?void 0:Gt.load(),Be=new $t(Ss.length>0?Ss:void 0,gn,Es,Cs),qt=new Dt,mn=Yr(Be,qt),As=10,ve=Number(it.port),vn=await _s(ns,ps({allowVscodeWebview:it["allow-vscode-webview"]})),be;for(let e=ve;e<ve+As&&e<=ke;e++)try{be=Bun.serve({hostname:"127.0.0.1",port:e,development:!1,reusePort:!1,routes:vn,fetch:mn.fetch,websocket:{...ut,perMessageDeflate:!0}});break}catch(r){if(r.code!=="EADDRINUSE")throw r}if(!be){let e=Math.min(ve+As-1,ke);console.error(`Accompany: \u30DD\u30FC\u30C8 ${ve}\u301C${e} \u306F\u3059\u3079\u3066\u4F7F\u308F\u308C\u3066\u3044\u307E\u3059\u3002--port \u3067\u5225\u306E\u30DD\u30FC\u30C8\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`),await Be.killAll(),qt.remove(),process.exit(1)}if(be.port!==ve&&ve!==0)console.log(`Accompany: \u30DD\u30FC\u30C8 ${ve} \u306F\u4F7F\u308F\u308C\u3066\u3044\u308B\u306E\u3067\u3001${be.port} \u3067\u5F85\u3061\u53D7\u3051\u307E\u3059`);var jt=!1;async function ks({stopping:e=!1}={}){try{Gt.save(await Be.snapshot(xs,{refreshCwd:e})),jt=!1}catch(r){if(!jt)console.warn(`Accompany: \u753B\u9762\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: ${r}`);jt=!0}}var yn=1000,rt,zt=!1;Be.onChange=()=>{if(rt||zt)return;rt=setTimeout(()=>{rt=void 0,ks()},yn)};var bn=3000;for(let e of["SIGINT","SIGTERM","SIGHUP"])process.on(e,async()=>{if(zt)return;zt=!0,clearTimeout(rt),await Promise.race([ks({stopping:!0}),Bun.sleep(bn)]),await Be.killAll(),qt.remove(),process.exit(0)});console.log(`Accompany: http://${be.hostname}:${be.port}`);if(Es)console.log(`\u524D\u56DE\u306E\u753B\u9762\u3092\u623B\u3057\u307E\u3057\u305F\uFF08\u65B0\u3057\u304F\u59CB\u3081\u308B\u3068\u304D\u306F --fresh \u3092\u4ED8\u3051\u3066\u8D77\u52D5\u3059\u308B\uFF09: ${Gt.file}`);
142
142
 
143
- //# debugId=F147A6BE6AF1DD0964756E2164756E21
143
+ //# debugId=7FE49E7EBE45D70A64756E2164756E21
144
144
  //# sourceMappingURL=/cli.js.map