agentrix 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentrix",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "CLI utility for serving the agentrix UI",
5
5
  "license": "MIT",
6
6
  "author": "Simon Skinner (vultuk) <talkto@simonskinner.me>",
@@ -38,7 +38,7 @@
38
38
  "agentrix": "bin/agentrix.js"
39
39
  },
40
40
  "scripts": {
41
- "test": "node --test --test-concurrency=1",
41
+ "test": "tsx --test --test-concurrency=1",
42
42
  "start": "node bin/agentrix.js",
43
43
  "dev": "node bin/agentrix.js",
44
44
  "dev:ui": "node scripts/ensure-ui-deps.js && bun run --filter agentrix-ui dev",
@@ -49,7 +49,11 @@
49
49
  "preview": "node scripts/ensure-ui-deps.js && bun run --filter agentrix-ui preview",
50
50
  "preview:ui": "node scripts/ensure-ui-deps.js && bun run --filter agentrix-ui preview",
51
51
  "typecheck": "tsc --noEmit",
52
- "watch": "tsc -p tsconfig.build.json --watch"
52
+ "watch": "tsc -p tsconfig.build.json --watch",
53
+ "lint": "eslint . --ext .ts,.tsx,.js --cache --max-warnings=0",
54
+ "lint:fix": "npm run lint -- --fix",
55
+ "format": "prettier --check .",
56
+ "format:fix": "prettier --write ."
53
57
  },
54
58
  "type": "module",
55
59
  "dependencies": {
@@ -70,10 +74,20 @@
70
74
  "@types/mime-types": "^3.0.1",
71
75
  "@types/node": "^24.10.0",
72
76
  "@types/ws": "^8.18.1",
77
+ "@eslint/js": "^9.17.0",
78
+ "eslint": "^9.17.0",
79
+ "eslint-config-prettier": "^10.0.1",
80
+ "eslint-plugin-import": "^2.31.0",
81
+ "eslint-plugin-jsx-a11y": "^6.10.0",
82
+ "eslint-plugin-react": "^7.37.2",
83
+ "eslint-plugin-react-hooks": "^5.0.0",
84
+ "globals": "^15.12.0",
85
+ "prettier": "^3.4.2",
73
86
  "esbuild-node-loader": "^0.8.0",
74
87
  "esbuild-register": "^3.6.0",
75
88
  "jsdom": "^27.1.0",
76
89
  "tsx": "^4.20.6",
77
- "typescript": "^5.9.3"
90
+ "typescript": "^5.9.3",
91
+ "typescript-eslint": "^8.15.0"
78
92
  }
79
93
  }
@@ -82,7 +82,7 @@ WARNING: This link could potentially be dangerous`)){const p=window.open();if(p)
82
82
  `:`
83
83
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(v){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),p.isLinux&&v&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(v){const C=this._getMouseBufferCoords(v),R=this._model.finalSelectionStart,I=this._model.finalSelectionEnd;return!!(R&&I&&C)&&this._areCoordsInSelection(C,R,I)}isCellInSelection(v,C){const R=this._model.finalSelectionStart,I=this._model.finalSelectionEnd;return!(!R||!I)&&this._areCoordsInSelection([v,C],R,I)}_areCoordsInSelection(v,C,R){return v[1]>C[1]&&v[1]<R[1]||C[1]===R[1]&&v[1]===C[1]&&v[0]>=C[0]&&v[0]<R[0]||C[1]<R[1]&&v[1]===R[1]&&v[0]<R[0]||C[1]<R[1]&&v[1]===C[1]&&v[0]>=C[0]}_selectWordAtCursor(v,C){var R,I;const w=(I=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||I===void 0?void 0:I.range;if(w)return this._model.selectionStart=[w.start.x-1,w.start.y-1],this._model.selectionStartLength=(0,g.getRangeLength)(w,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const P=this._getMouseBufferCoords(v);return!!P&&(this._selectWordAt(P,C),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(v,C){this._model.clearSelection(),v=Math.max(v,0),C=Math.min(C,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,v],this._model.selectionEnd=[this._bufferService.cols,C],this.refresh(),this._onSelectionChange.fire()}_handleTrim(v){this._model.handleTrim(v)&&this.refresh()}_getMouseBufferCoords(v){const C=this._mouseService.getCoords(v,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(C)return C[0]--,C[1]--,C[1]+=this._bufferService.buffer.ydisp,C}_getMouseEventScrollAmount(v){let C=(0,u.getCoordsRelativeToElement)(this._coreBrowserService.window,v,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return C>=0&&C<=R?0:(C>R&&(C-=R),C=Math.min(Math.max(C,-50),50),C/=50,C/Math.abs(C)+Math.round(14*C))}shouldForceSelection(v){return p.isMac?v.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:v.shiftKey}handleMouseDown(v){if(this._mouseDownTimeStamp=v.timeStamp,(v.button!==2||!this.hasSelection)&&v.button===0){if(!this._enabled){if(!this.shouldForceSelection(v))return;v.stopPropagation()}v.preventDefault(),this._dragScrollAmount=0,this._enabled&&v.shiftKey?this._handleIncrementalClick(v):v.detail===1?this._handleSingleClick(v):v.detail===2?this._handleDoubleClick(v):v.detail===3&&this._handleTripleClick(v),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(v){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(v))}_handleSingleClick(v){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(v)?3:0,this._model.selectionStart=this._getMouseBufferCoords(v),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const C=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);C&&C.length!==this._model.selectionStart[0]&&C.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(v){this._selectWordAtCursor(v,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(v){const C=this._getMouseBufferCoords(v);C&&(this._activeSelectionMode=2,this._selectLineAt(C[1]))}shouldColumnSelect(v){return v.altKey&&!(p.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(v){if(v.stopImmediatePropagation(),!this._model.selectionStart)return;const C=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(v),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(v),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const I=R.lines.get(this._model.selectionEnd[1]);I&&I.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}C&&C[0]===this._model.selectionEnd[0]&&C[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const v=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(v.ydisp+this._bufferService.rows,v.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=v.ydisp),this.refresh()}}_handleMouseUp(v){const C=v.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&C<500&&v.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(v,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const I=(0,m.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(I,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const v=this._model.finalSelectionStart,C=this._model.finalSelectionEnd,R=!(!v||!C||v[0]===C[0]&&v[1]===C[1]);R?v&&C&&(this._oldSelectionStart&&this._oldSelectionEnd&&v[0]===this._oldSelectionStart[0]&&v[1]===this._oldSelectionStart[1]&&C[0]===this._oldSelectionEnd[0]&&C[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(v,C,R)):this._oldHasSelection&&this._fireOnSelectionChange(v,C,R)}_fireOnSelectionChange(v,C,R){this._oldSelectionStart=v,this._oldSelectionEnd=C,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(v){this.clearSelection(),this._trimListener.dispose(),this._trimListener=v.activeBuffer.lines.onTrim(C=>this._handleTrim(C))}_convertViewportColToCharacterIndex(v,C){let R=C;for(let I=0;C>=I;I++){const w=v.loadCell(I,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:w>1&&C!==I&&(R+=w-1)}return R}setSelection(v,C,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[v,C],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(v){this._isClickInSelection(v)||(this._selectWordAtCursor(v,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(v,C,R=!0,I=!0){if(v[0]>=this._bufferService.cols)return;const w=this._bufferService.buffer,P=w.lines.get(v[1]);if(!P)return;const U=w.translateBufferLineToString(v[1],!1);let G=this._convertViewportColToCharacterIndex(P,v[0]),L=G;const F=v[0]-G;let O=0,M=0,A=0,B=0;if(U.charAt(G)===" "){for(;G>0&&U.charAt(G-1)===" ";)G--;for(;L<U.length&&U.charAt(L+1)===" ";)L++}else{let X=v[0],V=v[0];P.getWidth(X)===0&&(O++,X--),P.getWidth(V)===2&&(M++,V++);const J=P.getString(V).length;for(J>1&&(B+=J-1,L+=J-1);X>0&&G>0&&!this._isCharWordSeparator(P.loadCell(X-1,this._workCell));){P.loadCell(X-1,this._workCell);const x=this._workCell.getChars().length;this._workCell.getWidth()===0?(O++,X--):x>1&&(A+=x-1,G-=x-1),G--,X--}for(;V<P.length&&L+1<U.length&&!this._isCharWordSeparator(P.loadCell(V+1,this._workCell));){P.loadCell(V+1,this._workCell);const x=this._workCell.getChars().length;this._workCell.getWidth()===2?(M++,V++):x>1&&(B+=x-1,L+=x-1),L++,V++}}L++;let Y=G+F-O+A,k=Math.min(this._bufferService.cols,L-G+O+M-A-B);if(C||U.slice(G,L).trim()!==""){if(R&&Y===0&&P.getCodePoint(0)!==32){const X=w.lines.get(v[1]-1);if(X&&P.isWrapped&&X.getCodePoint(this._bufferService.cols-1)!==32){const V=this._getWordAt([this._bufferService.cols-1,v[1]-1],!1,!0,!1);if(V){const J=this._bufferService.cols-V.start;Y-=J,k+=J}}}if(I&&Y+k===this._bufferService.cols&&P.getCodePoint(this._bufferService.cols-1)!==32){const X=w.lines.get(v[1]+1);if(X!=null&&X.isWrapped&&X.getCodePoint(0)!==32){const V=this._getWordAt([0,v[1]+1],!1,!1,!0);V&&(k+=V.length)}}return{start:Y,length:k}}}_selectWordAt(v,C){const R=this._getWordAt(v,C);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,v[1]--;this._model.selectionStart=[R.start,v[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(v){const C=this._getWordAt(v,!0);if(C){let R=v[1];for(;C.start<0;)C.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;C.start+C.length>this._bufferService.cols;)C.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?C.start:C.start+C.length,R]}}_isCharWordSeparator(v){return v.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(v.getChars())>=0}_selectLineAt(v){const C=this._bufferService.buffer.getWrappedRangeForLine(v),R={start:{x:0,y:C.first},end:{x:this._bufferService.cols-1,y:C.last}};this._model.selectionStart=[0,C.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,g.getRangeLength)(R,this._bufferService.cols)}};s.SelectionService=N=c([d(3,b.IBufferService),d(4,b.ICoreService),d(5,E.IMouseService),d(6,b.IOptionsService),d(7,E.IRenderService),d(8,E.ICoreBrowserService)],N)},4725:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IThemeService=s.ICharacterJoinerService=s.ISelectionService=s.IRenderService=s.IMouseService=s.ICoreBrowserService=s.ICharSizeService=void 0;const c=l(8343);s.ICharSizeService=(0,c.createDecorator)("CharSizeService"),s.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),s.IMouseService=(0,c.createDecorator)("MouseService"),s.IRenderService=(0,c.createDecorator)("RenderService"),s.ISelectionService=(0,c.createDecorator)("SelectionService"),s.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),s.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(o,s,l){var c=this&&this.__decorate||function(N,v,C,R){var I,w=arguments.length,P=w<3?v:R===null?R=Object.getOwnPropertyDescriptor(v,C):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(N,v,C,R);else for(var U=N.length-1;U>=0;U--)(I=N[U])&&(P=(w<3?I(P):w>3?I(v,C,P):I(v,C))||P);return w>3&&P&&Object.defineProperty(v,C,P),P},d=this&&this.__param||function(N,v){return function(C,R){v(C,R,N)}};Object.defineProperty(s,"__esModule",{value:!0}),s.ThemeService=s.DEFAULT_ANSI_COLORS=void 0;const u=l(7239),m=l(8055),_=l(8460),E=l(844),S=l(2585),f=m.css.toColor("#ffffff"),p=m.css.toColor("#000000"),g=m.css.toColor("#ffffff"),h=m.css.toColor("#000000"),b={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};s.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const N=[m.css.toColor("#2e3436"),m.css.toColor("#cc0000"),m.css.toColor("#4e9a06"),m.css.toColor("#c4a000"),m.css.toColor("#3465a4"),m.css.toColor("#75507b"),m.css.toColor("#06989a"),m.css.toColor("#d3d7cf"),m.css.toColor("#555753"),m.css.toColor("#ef2929"),m.css.toColor("#8ae234"),m.css.toColor("#fce94f"),m.css.toColor("#729fcf"),m.css.toColor("#ad7fa8"),m.css.toColor("#34e2e2"),m.css.toColor("#eeeeec")],v=[0,95,135,175,215,255];for(let C=0;C<216;C++){const R=v[C/36%6|0],I=v[C/6%6|0],w=v[C%6];N.push({css:m.channels.toCss(R,I,w),rgba:m.channels.toRgba(R,I,w)})}for(let C=0;C<24;C++){const R=8+10*C;N.push({css:m.channels.toCss(R,R,R),rgba:m.channels.toRgba(R,R,R)})}return N})());let T=s.ThemeService=class extends E.Disposable{get colors(){return this._colors}constructor(N){super(),this._optionsService=N,this._contrastCache=new u.ColorContrastCache,this._halfContrastCache=new u.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:f,background:p,cursor:g,cursorAccent:h,selectionForeground:void 0,selectionBackgroundTransparent:b,selectionBackgroundOpaque:m.color.blend(p,b),selectionInactiveBackgroundTransparent:b,selectionInactiveBackgroundOpaque:m.color.blend(p,b),ansi:s.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this.register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}_setTheme(N={}){const v=this._colors;if(v.foreground=y(N.foreground,f),v.background=y(N.background,p),v.cursor=y(N.cursor,g),v.cursorAccent=y(N.cursorAccent,h),v.selectionBackgroundTransparent=y(N.selectionBackground,b),v.selectionBackgroundOpaque=m.color.blend(v.background,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundTransparent=y(N.selectionInactiveBackground,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundOpaque=m.color.blend(v.background,v.selectionInactiveBackgroundTransparent),v.selectionForeground=N.selectionForeground?y(N.selectionForeground,m.NULL_COLOR):void 0,v.selectionForeground===m.NULL_COLOR&&(v.selectionForeground=void 0),m.color.isOpaque(v.selectionBackgroundTransparent)&&(v.selectionBackgroundTransparent=m.color.opacity(v.selectionBackgroundTransparent,.3)),m.color.isOpaque(v.selectionInactiveBackgroundTransparent)&&(v.selectionInactiveBackgroundTransparent=m.color.opacity(v.selectionInactiveBackgroundTransparent,.3)),v.ansi=s.DEFAULT_ANSI_COLORS.slice(),v.ansi[0]=y(N.black,s.DEFAULT_ANSI_COLORS[0]),v.ansi[1]=y(N.red,s.DEFAULT_ANSI_COLORS[1]),v.ansi[2]=y(N.green,s.DEFAULT_ANSI_COLORS[2]),v.ansi[3]=y(N.yellow,s.DEFAULT_ANSI_COLORS[3]),v.ansi[4]=y(N.blue,s.DEFAULT_ANSI_COLORS[4]),v.ansi[5]=y(N.magenta,s.DEFAULT_ANSI_COLORS[5]),v.ansi[6]=y(N.cyan,s.DEFAULT_ANSI_COLORS[6]),v.ansi[7]=y(N.white,s.DEFAULT_ANSI_COLORS[7]),v.ansi[8]=y(N.brightBlack,s.DEFAULT_ANSI_COLORS[8]),v.ansi[9]=y(N.brightRed,s.DEFAULT_ANSI_COLORS[9]),v.ansi[10]=y(N.brightGreen,s.DEFAULT_ANSI_COLORS[10]),v.ansi[11]=y(N.brightYellow,s.DEFAULT_ANSI_COLORS[11]),v.ansi[12]=y(N.brightBlue,s.DEFAULT_ANSI_COLORS[12]),v.ansi[13]=y(N.brightMagenta,s.DEFAULT_ANSI_COLORS[13]),v.ansi[14]=y(N.brightCyan,s.DEFAULT_ANSI_COLORS[14]),v.ansi[15]=y(N.brightWhite,s.DEFAULT_ANSI_COLORS[15]),N.extendedAnsi){const C=Math.min(v.ansi.length-16,N.extendedAnsi.length);for(let R=0;R<C;R++)v.ansi[R+16]=y(N.extendedAnsi[R],s.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(N){this._restoreColor(N),this._onChangeColors.fire(this.colors)}_restoreColor(N){if(N!==void 0)switch(N){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[N]=this._restoreColors.ansi[N]}else for(let v=0;v<this._restoreColors.ansi.length;++v)this._colors.ansi[v]=this._restoreColors.ansi[v]}modifyColors(N){N(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function y(N,v){if(N!==void 0)try{return m.css.toColor(N)}catch{}return v}s.ThemeService=T=c([d(0,S.IOptionsService)],T)},6349:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CircularList=void 0;const c=l(8460),d=l(844);class u extends d.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(_){if(this._maxLength===_)return;const E=new Array(_);for(let S=0;S<Math.min(_,this.length);S++)E[S]=this._array[this._getCyclicIndex(S)];this._array=E,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let E=this._length;E<_;E++)this._array[E]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,E){this._array[this._getCyclicIndex(_)]=E}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,E,...S){if(E){for(let f=_;f<this._length-E;f++)this._array[this._getCyclicIndex(f)]=this._array[this._getCyclicIndex(f+E)];this._length-=E,this.onDeleteEmitter.fire({index:_,amount:E})}for(let f=this._length-1;f>=_;f--)this._array[this._getCyclicIndex(f+S.length)]=this._array[this._getCyclicIndex(f)];for(let f=0;f<S.length;f++)this._array[this._getCyclicIndex(_+f)]=S[f];if(S.length&&this.onInsertEmitter.fire({index:_,amount:S.length}),this._length+S.length>this._maxLength){const f=this._length+S.length-this._maxLength;this._startIndex+=f,this._length=this._maxLength,this.onTrimEmitter.fire(f)}else this._length+=S.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,E,S){if(!(E<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+S<0)throw new Error("Cannot shift elements in list beyond index 0");if(S>0){for(let p=E-1;p>=0;p--)this.set(_+p+S,this.get(_+p));const f=_+E+S-this._length;if(f>0)for(this._length+=f;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let f=0;f<E;f++)this.set(_+f+S,this.get(_+f))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}s.CircularList=u},1439:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.clone=void 0,s.clone=function l(c,d=5){if(typeof c!="object")return c;const u=Array.isArray(c)?[]:{};for(const m in c)u[m]=d<=1?c[m]:c[m]&&l(c[m],d-1);return u}},8055:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.contrastRatio=s.toPaddedHex=s.rgba=s.rgb=s.css=s.color=s.channels=s.NULL_COLOR=void 0;const c=l(6114);let d=0,u=0,m=0,_=0;var E,S,f,p,g;function h(T){const y=T.toString(16);return y.length<2?"0"+y:y}function b(T,y){return T<y?(y+.05)/(T+.05):(T+.05)/(y+.05)}s.NULL_COLOR={css:"#00000000",rgba:0},function(T){T.toCss=function(y,N,v,C){return C!==void 0?`#${h(y)}${h(N)}${h(v)}${h(C)}`:`#${h(y)}${h(N)}${h(v)}`},T.toRgba=function(y,N,v,C=255){return(y<<24|N<<16|v<<8|C)>>>0}}(E||(s.channels=E={})),function(T){function y(N,v){return _=Math.round(255*v),[d,u,m]=g.toChannels(N.rgba),{css:E.toCss(d,u,m,_),rgba:E.toRgba(d,u,m,_)}}T.blend=function(N,v){if(_=(255&v.rgba)/255,_===1)return{css:v.css,rgba:v.rgba};const C=v.rgba>>24&255,R=v.rgba>>16&255,I=v.rgba>>8&255,w=N.rgba>>24&255,P=N.rgba>>16&255,U=N.rgba>>8&255;return d=w+Math.round((C-w)*_),u=P+Math.round((R-P)*_),m=U+Math.round((I-U)*_),{css:E.toCss(d,u,m),rgba:E.toRgba(d,u,m)}},T.isOpaque=function(N){return(255&N.rgba)==255},T.ensureContrastRatio=function(N,v,C){const R=g.ensureContrastRatio(N.rgba,v.rgba,C);if(R)return g.toColor(R>>24&255,R>>16&255,R>>8&255)},T.opaque=function(N){const v=(255|N.rgba)>>>0;return[d,u,m]=g.toChannels(v),{css:E.toCss(d,u,m),rgba:v}},T.opacity=y,T.multiplyOpacity=function(N,v){return _=255&N.rgba,y(N,_*v/255)},T.toColorRGB=function(N){return[N.rgba>>24&255,N.rgba>>16&255,N.rgba>>8&255]}}(S||(s.color=S={})),function(T){let y,N;if(!c.isNode){const v=document.createElement("canvas");v.width=1,v.height=1;const C=v.getContext("2d",{willReadFrequently:!0});C&&(y=C,y.globalCompositeOperation="copy",N=y.createLinearGradient(0,0,1,1))}T.toColor=function(v){if(v.match(/#[\da-f]{3,8}/i))switch(v.length){case 4:return d=parseInt(v.slice(1,2).repeat(2),16),u=parseInt(v.slice(2,3).repeat(2),16),m=parseInt(v.slice(3,4).repeat(2),16),g.toColor(d,u,m);case 5:return d=parseInt(v.slice(1,2).repeat(2),16),u=parseInt(v.slice(2,3).repeat(2),16),m=parseInt(v.slice(3,4).repeat(2),16),_=parseInt(v.slice(4,5).repeat(2),16),g.toColor(d,u,m,_);case 7:return{css:v,rgba:(parseInt(v.slice(1),16)<<8|255)>>>0};case 9:return{css:v,rgba:parseInt(v.slice(1),16)>>>0}}const C=v.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return d=parseInt(C[1]),u=parseInt(C[2]),m=parseInt(C[3]),_=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),g.toColor(d,u,m,_);if(!y||!N)throw new Error("css.toColor: Unsupported css format");if(y.fillStyle=N,y.fillStyle=v,typeof y.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(y.fillRect(0,0,1,1),[d,u,m,_]=y.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:E.toRgba(d,u,m,_),css:v}}}(f||(s.css=f={})),function(T){function y(N,v,C){const R=N/255,I=v/255,w=C/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4))+.0722*(w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4))}T.relativeLuminance=function(N){return y(N>>16&255,N>>8&255,255&N)},T.relativeLuminance2=y}(p||(s.rgb=p={})),function(T){function y(v,C,R){const I=v>>24&255,w=v>>16&255,P=v>>8&255;let U=C>>24&255,G=C>>16&255,L=C>>8&255,F=b(p.relativeLuminance2(U,G,L),p.relativeLuminance2(I,w,P));for(;F<R&&(U>0||G>0||L>0);)U-=Math.max(0,Math.ceil(.1*U)),G-=Math.max(0,Math.ceil(.1*G)),L-=Math.max(0,Math.ceil(.1*L)),F=b(p.relativeLuminance2(U,G,L),p.relativeLuminance2(I,w,P));return(U<<24|G<<16|L<<8|255)>>>0}function N(v,C,R){const I=v>>24&255,w=v>>16&255,P=v>>8&255;let U=C>>24&255,G=C>>16&255,L=C>>8&255,F=b(p.relativeLuminance2(U,G,L),p.relativeLuminance2(I,w,P));for(;F<R&&(U<255||G<255||L<255);)U=Math.min(255,U+Math.ceil(.1*(255-U))),G=Math.min(255,G+Math.ceil(.1*(255-G))),L=Math.min(255,L+Math.ceil(.1*(255-L))),F=b(p.relativeLuminance2(U,G,L),p.relativeLuminance2(I,w,P));return(U<<24|G<<16|L<<8|255)>>>0}T.ensureContrastRatio=function(v,C,R){const I=p.relativeLuminance(v>>8),w=p.relativeLuminance(C>>8);if(b(I,w)<R){if(w<I){const G=y(v,C,R),L=b(I,p.relativeLuminance(G>>8));if(L<R){const F=N(v,C,R);return L>b(I,p.relativeLuminance(F>>8))?G:F}return G}const P=N(v,C,R),U=b(I,p.relativeLuminance(P>>8));if(U<R){const G=y(v,C,R);return U>b(I,p.relativeLuminance(G>>8))?P:G}return P}},T.reduceLuminance=y,T.increaseLuminance=N,T.toChannels=function(v){return[v>>24&255,v>>16&255,v>>8&255,255&v]},T.toColor=function(v,C,R,I){return{css:E.toCss(v,C,R,I),rgba:E.toRgba(v,C,R,I)}}}(g||(s.rgba=g={})),s.toPaddedHex=h,s.contrastRatio=b},8969:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CoreTerminal=void 0;const c=l(844),d=l(2585),u=l(4348),m=l(7866),_=l(744),E=l(7302),S=l(6975),f=l(8460),p=l(1753),g=l(1480),h=l(7994),b=l(9282),T=l(5435),y=l(5981),N=l(2660);let v=!1;class C extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new f.EventEmitter),this._onScroll.event(I=>{var w;(w=this._onScrollApi)===null||w===void 0||w.fire(I.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(I){for(const w in I)this.optionsService.options[w]=I[w]}constructor(I){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new f.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new f.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new f.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new f.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new f.EventEmitter),this._instantiationService=new u.InstantiationService,this.optionsService=this.register(new E.OptionsService(I)),this._instantiationService.setService(d.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(d.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(m.LogService)),this._instantiationService.setService(d.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(S.CoreService)),this._instantiationService.setService(d.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(p.CoreMouseService)),this._instantiationService.setService(d.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(g.UnicodeService)),this._instantiationService.setService(d.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(h.CharsetService),this._instantiationService.setService(d.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(N.OscLinkService),this._instantiationService.setService(d.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new T.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,f.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,f.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,f.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,f.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom())),this.register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this.register(this._bufferService.onScroll(w=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this.register(this._inputHandler.onScroll(w=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this.register(new y.WriteBuffer((w,P)=>this._inputHandler.parse(w,P))),this.register((0,f.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(I,w){this._writeBuffer.write(I,w)}writeSync(I,w){this._logService.logLevel<=d.LogLevelEnum.WARN&&!v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),v=!0),this._writeBuffer.writeSync(I,w)}resize(I,w){isNaN(I)||isNaN(w)||(I=Math.max(I,_.MINIMUM_COLS),w=Math.max(w,_.MINIMUM_ROWS),this._bufferService.resize(I,w))}scroll(I,w=!1){this._bufferService.scroll(I,w)}scrollLines(I,w,P){this._bufferService.scrollLines(I,w,P)}scrollPages(I){this.scrollLines(I*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(I){const w=I-this._bufferService.buffer.ydisp;w!==0&&this.scrollLines(w)}registerEscHandler(I,w){return this._inputHandler.registerEscHandler(I,w)}registerDcsHandler(I,w){return this._inputHandler.registerDcsHandler(I,w)}registerCsiHandler(I,w){return this._inputHandler.registerCsiHandler(I,w)}registerOscHandler(I,w){return this._inputHandler.registerOscHandler(I,w)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let I=!1;const w=this.optionsService.rawOptions.windowsPty;w&&w.buildNumber!==void 0&&w.buildNumber!==void 0?I=w.backend==="conpty"&&w.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(I=!0),I?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const I=[];I.push(this.onLineFeed(b.updateWindowsModeWrappedState.bind(null,this._bufferService))),I.push(this.registerCsiHandler({final:"H"},()=>((0,b.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)(()=>{for(const w of I)w.dispose()})}}}s.CoreTerminal=C},8460:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===l)return void this._listeners.splice(c,1)}}})),this._event}fire(l,c){const d=[];for(let u=0;u<this._listeners.length;u++)d.push(this._listeners[u]);for(let u=0;u<d.length;u++)d[u].call(void 0,l,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(l,c){return l(d=>c.fire(d))}},5435:function(o,s,l){var c=this&&this.__decorate||function(F,O,M,A){var B,Y=arguments.length,k=Y<3?O:A===null?A=Object.getOwnPropertyDescriptor(O,M):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(F,O,M,A);else for(var X=F.length-1;X>=0;X--)(B=F[X])&&(k=(Y<3?B(k):Y>3?B(O,M,k):B(O,M))||k);return Y>3&&k&&Object.defineProperty(O,M,k),k},d=this&&this.__param||function(F,O){return function(M,A){O(M,A,F)}};Object.defineProperty(s,"__esModule",{value:!0}),s.InputHandler=s.WindowsOptionsReportType=void 0;const u=l(2584),m=l(7116),_=l(2015),E=l(844),S=l(482),f=l(8437),p=l(8460),g=l(643),h=l(511),b=l(3734),T=l(2585),y=l(6242),N=l(6351),v=l(5941),C={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function I(F,O){if(F>24)return O.setWinLines||!1;switch(F){case 1:return!!O.restoreWin;case 2:return!!O.minimizeWin;case 3:return!!O.setWinPosition;case 4:return!!O.setWinSizePixels;case 5:return!!O.raiseWin;case 6:return!!O.lowerWin;case 7:return!!O.refreshWin;case 8:return!!O.setWinSizeChars;case 9:return!!O.maximizeWin;case 10:return!!O.fullscreenWin;case 11:return!!O.getWinState;case 13:return!!O.getWinPosition;case 14:return!!O.getWinSizePixels;case 15:return!!O.getScreenSizePixels;case 16:return!!O.getCellSizePixels;case 18:return!!O.getWinSizeChars;case 19:return!!O.getScreenSizeChars;case 20:return!!O.getIconTitle;case 21:return!!O.getWinTitle;case 22:return!!O.pushTitle;case 23:return!!O.popTitle;case 24:return!!O.setWinLines}return!1}var w;(function(F){F[F.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",F[F.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(w||(s.WindowsOptionsReportType=w={}));let P=0;class U extends E.Disposable{getAttrData(){return this._curAttrData}constructor(O,M,A,B,Y,k,X,V,J=new _.EscapeSequenceParser){super(),this._bufferService=O,this._charsetService=M,this._coreService=A,this._logService=B,this._optionsService=Y,this._oscLinkService=k,this._coreMouseService=X,this._unicodeService=V,this._parser=J,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new S.StringToUtf32,this._utf8Decoder=new S.Utf8ToUtf32,this._workCell=new h.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=f.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=f.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new p.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new p.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new p.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new p.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new p.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new p.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new p.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new p.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new p.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new p.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new p.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new p.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new p.EventEmitter),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 G(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._parser.setCsiHandlerFallback((x,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(x),params:H.toArray()})}),this._parser.setEscHandlerFallback(x=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(x)})}),this._parser.setExecuteHandlerFallback(x=>{this._logService.debug("Unknown EXECUTE code: ",{code:x})}),this._parser.setOscHandlerFallback((x,H,$)=>{this._logService.debug("Unknown OSC code: ",{identifier:x,action:H,data:$})}),this._parser.setDcsHandlerFallback((x,H,$)=>{H==="HOOK"&&($=$.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(x),action:H,payload:$})}),this._parser.setPrintHandler((x,H,$)=>this.print(x,H,$)),this._parser.registerCsiHandler({final:"@"},x=>this.insertChars(x)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},x=>this.scrollLeft(x)),this._parser.registerCsiHandler({final:"A"},x=>this.cursorUp(x)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},x=>this.scrollRight(x)),this._parser.registerCsiHandler({final:"B"},x=>this.cursorDown(x)),this._parser.registerCsiHandler({final:"C"},x=>this.cursorForward(x)),this._parser.registerCsiHandler({final:"D"},x=>this.cursorBackward(x)),this._parser.registerCsiHandler({final:"E"},x=>this.cursorNextLine(x)),this._parser.registerCsiHandler({final:"F"},x=>this.cursorPrecedingLine(x)),this._parser.registerCsiHandler({final:"G"},x=>this.cursorCharAbsolute(x)),this._parser.registerCsiHandler({final:"H"},x=>this.cursorPosition(x)),this._parser.registerCsiHandler({final:"I"},x=>this.cursorForwardTab(x)),this._parser.registerCsiHandler({final:"J"},x=>this.eraseInDisplay(x,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},x=>this.eraseInDisplay(x,!0)),this._parser.registerCsiHandler({final:"K"},x=>this.eraseInLine(x,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},x=>this.eraseInLine(x,!0)),this._parser.registerCsiHandler({final:"L"},x=>this.insertLines(x)),this._parser.registerCsiHandler({final:"M"},x=>this.deleteLines(x)),this._parser.registerCsiHandler({final:"P"},x=>this.deleteChars(x)),this._parser.registerCsiHandler({final:"S"},x=>this.scrollUp(x)),this._parser.registerCsiHandler({final:"T"},x=>this.scrollDown(x)),this._parser.registerCsiHandler({final:"X"},x=>this.eraseChars(x)),this._parser.registerCsiHandler({final:"Z"},x=>this.cursorBackwardTab(x)),this._parser.registerCsiHandler({final:"`"},x=>this.charPosAbsolute(x)),this._parser.registerCsiHandler({final:"a"},x=>this.hPositionRelative(x)),this._parser.registerCsiHandler({final:"b"},x=>this.repeatPrecedingCharacter(x)),this._parser.registerCsiHandler({final:"c"},x=>this.sendDeviceAttributesPrimary(x)),this._parser.registerCsiHandler({prefix:">",final:"c"},x=>this.sendDeviceAttributesSecondary(x)),this._parser.registerCsiHandler({final:"d"},x=>this.linePosAbsolute(x)),this._parser.registerCsiHandler({final:"e"},x=>this.vPositionRelative(x)),this._parser.registerCsiHandler({final:"f"},x=>this.hVPosition(x)),this._parser.registerCsiHandler({final:"g"},x=>this.tabClear(x)),this._parser.registerCsiHandler({final:"h"},x=>this.setMode(x)),this._parser.registerCsiHandler({prefix:"?",final:"h"},x=>this.setModePrivate(x)),this._parser.registerCsiHandler({final:"l"},x=>this.resetMode(x)),this._parser.registerCsiHandler({prefix:"?",final:"l"},x=>this.resetModePrivate(x)),this._parser.registerCsiHandler({final:"m"},x=>this.charAttributes(x)),this._parser.registerCsiHandler({final:"n"},x=>this.deviceStatus(x)),this._parser.registerCsiHandler({prefix:"?",final:"n"},x=>this.deviceStatusPrivate(x)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},x=>this.softReset(x)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},x=>this.setCursorStyle(x)),this._parser.registerCsiHandler({final:"r"},x=>this.setScrollRegion(x)),this._parser.registerCsiHandler({final:"s"},x=>this.saveCursor(x)),this._parser.registerCsiHandler({final:"t"},x=>this.windowOptions(x)),this._parser.registerCsiHandler({final:"u"},x=>this.restoreCursor(x)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},x=>this.insertColumns(x)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},x=>this.deleteColumns(x)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},x=>this.selectProtected(x)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},x=>this.requestMode(x,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},x=>this.requestMode(x,!1)),this._parser.setExecuteHandler(u.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(u.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(u.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(u.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(u.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(u.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(u.C1.IND,()=>this.index()),this._parser.setExecuteHandler(u.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(u.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new y.OscHandler(x=>(this.setTitle(x),this.setIconName(x),!0))),this._parser.registerOscHandler(1,new y.OscHandler(x=>this.setIconName(x))),this._parser.registerOscHandler(2,new y.OscHandler(x=>this.setTitle(x))),this._parser.registerOscHandler(4,new y.OscHandler(x=>this.setOrReportIndexedColor(x))),this._parser.registerOscHandler(8,new y.OscHandler(x=>this.setHyperlink(x))),this._parser.registerOscHandler(10,new y.OscHandler(x=>this.setOrReportFgColor(x))),this._parser.registerOscHandler(11,new y.OscHandler(x=>this.setOrReportBgColor(x))),this._parser.registerOscHandler(12,new y.OscHandler(x=>this.setOrReportCursorColor(x))),this._parser.registerOscHandler(104,new y.OscHandler(x=>this.restoreIndexedColor(x))),this._parser.registerOscHandler(110,new y.OscHandler(x=>this.restoreFgColor(x))),this._parser.registerOscHandler(111,new y.OscHandler(x=>this.restoreBgColor(x))),this._parser.registerOscHandler(112,new y.OscHandler(x=>this.restoreCursorColor(x))),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(const x in m.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:x},()=>this.selectCharset("("+x)),this._parser.registerEscHandler({intermediates:")",final:x},()=>this.selectCharset(")"+x)),this._parser.registerEscHandler({intermediates:"*",final:x},()=>this.selectCharset("*"+x)),this._parser.registerEscHandler({intermediates:"+",final:x},()=>this.selectCharset("+"+x)),this._parser.registerEscHandler({intermediates:"-",final:x},()=>this.selectCharset("-"+x)),this._parser.registerEscHandler({intermediates:".",final:x},()=>this.selectCharset("."+x)),this._parser.registerEscHandler({intermediates:"/",final:x},()=>this.selectCharset("/"+x));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(x=>(this._logService.error("Parsing error: ",x),x)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new N.DcsHandler((x,H)=>this.requestStatusString(x,H)))}_preserveStack(O,M,A,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=O,this._parseStack.cursorStartY=M,this._parseStack.decodedLength=A,this._parseStack.position=B}_logSlowResolvingAsync(O){this._logService.logLevel<=T.LogLevelEnum.WARN&&Promise.race([O,new Promise((M,A)=>setTimeout(()=>A("#SLOW_TIMEOUT"),5e3))]).catch(M=>{if(M!=="#SLOW_TIMEOUT")throw M;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(O,M){let A,B=this._activeBuffer.x,Y=this._activeBuffer.y,k=0;const X=this._parseStack.paused;if(X){if(A=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,M))return this._logSlowResolvingAsync(A),A;B=this._parseStack.cursorStartX,Y=this._parseStack.cursorStartY,this._parseStack.paused=!1,O.length>R&&(k=this._parseStack.position+R)}if(this._logService.logLevel<=T.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof O=="string"?` "${O}"`:` "${Array.prototype.map.call(O,V=>String.fromCharCode(V)).join("")}"`),typeof O=="string"?O.split("").map(V=>V.charCodeAt(0)):O),this._parseBuffer.length<O.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(O.length,R))),X||this._dirtyRowTracker.clearRange(),O.length>R)for(let V=k;V<O.length;V+=R){const J=V+R<O.length?V+R:O.length,x=typeof O=="string"?this._stringDecoder.decode(O.substring(V,J),this._parseBuffer):this._utf8Decoder.decode(O.subarray(V,J),this._parseBuffer);if(A=this._parser.parse(this._parseBuffer,x))return this._preserveStack(B,Y,x,V),this._logSlowResolvingAsync(A),A}else if(!X){const V=typeof O=="string"?this._stringDecoder.decode(O,this._parseBuffer):this._utf8Decoder.decode(O,this._parseBuffer);if(A=this._parser.parse(this._parseBuffer,V))return this._preserveStack(B,Y,V,0),this._logSlowResolvingAsync(A),A}this._activeBuffer.x===B&&this._activeBuffer.y===Y||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(O,M,A){let B,Y;const k=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,V=this._bufferService.cols,J=this._coreService.decPrivateModes.wraparound,x=this._coreService.modes.insertMode,H=this._curAttrData;let $=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&A-M>0&&$.getWidth(this._activeBuffer.x-1)===2&&$.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=M;W<A;++W){if(B=O[W],Y=this._unicodeService.wcwidth(B),B<127&&k){const re=k[String.fromCharCode(B)];re&&(B=re.charCodeAt(0))}if(X&&this._onA11yChar.fire((0,S.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),Y||!this._activeBuffer.x){if(this._activeBuffer.x+Y-1>=V){if(J){for(;this._activeBuffer.x<V;)$.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.extended);this._activeBuffer.x=0,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),$=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=V-1,Y===2)continue}if(x&&($.insertCells(this._activeBuffer.x,Y,this._activeBuffer.getNullCell(H),H),$.getWidth(V-1)===2&&$.setCellFromCodePoint(V-1,g.NULL_CELL_CODE,g.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),$.setCellFromCodePoint(this._activeBuffer.x++,B,Y,H.fg,H.bg,H.extended),Y>0)for(;--Y;)$.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else $.getWidth(this._activeBuffer.x-1)?$.addCodepointToCell(this._activeBuffer.x-1,B):$.addCodepointToCell(this._activeBuffer.x-2,B)}A-M>0&&($.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<V&&A-M>0&&$.getWidth(this._activeBuffer.x)===0&&!$.hasContent(this._activeBuffer.x)&&$.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(O,M){return O.final!=="t"||O.prefix||O.intermediates?this._parser.registerCsiHandler(O,M):this._parser.registerCsiHandler(O,A=>!I(A.params[0],this._optionsService.rawOptions.windowOptions)||M(A))}registerDcsHandler(O,M){return this._parser.registerDcsHandler(O,new N.DcsHandler(M))}registerEscHandler(O,M){return this._parser.registerEscHandler(O,M)}registerOscHandler(O,M){return this._parser.registerOscHandler(O,new y.OscHandler(M))}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(){var O;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&&(!((O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||O===void 0)&&O.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);M.hasWidth(this._activeBuffer.x)&&!M.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const O=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-O),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(O=this._bufferService.cols-1){this._activeBuffer.x=Math.min(O,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(O,M){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=O,this._activeBuffer.y=this._activeBuffer.scrollTop+M):(this._activeBuffer.x=O,this._activeBuffer.y=M),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(O,M){this._restrictCursor(),this._setCursor(this._activeBuffer.x+O,this._activeBuffer.y+M)}cursorUp(O){const M=this._activeBuffer.y-this._activeBuffer.scrollTop;return M>=0?this._moveCursor(0,-Math.min(M,O.params[0]||1)):this._moveCursor(0,-(O.params[0]||1)),!0}cursorDown(O){const M=this._activeBuffer.scrollBottom-this._activeBuffer.y;return M>=0?this._moveCursor(0,Math.min(M,O.params[0]||1)):this._moveCursor(0,O.params[0]||1),!0}cursorForward(O){return this._moveCursor(O.params[0]||1,0),!0}cursorBackward(O){return this._moveCursor(-(O.params[0]||1),0),!0}cursorNextLine(O){return this.cursorDown(O),this._activeBuffer.x=0,!0}cursorPrecedingLine(O){return this.cursorUp(O),this._activeBuffer.x=0,!0}cursorCharAbsolute(O){return this._setCursor((O.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(O){return this._setCursor(O.length>=2?(O.params[1]||1)-1:0,(O.params[0]||1)-1),!0}charPosAbsolute(O){return this._setCursor((O.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(O){return this._moveCursor(O.params[0]||1,0),!0}linePosAbsolute(O){return this._setCursor(this._activeBuffer.x,(O.params[0]||1)-1),!0}vPositionRelative(O){return this._moveCursor(0,O.params[0]||1),!0}hVPosition(O){return this.cursorPosition(O),!0}tabClear(O){const M=O.params[0];return M===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:M===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(O){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=O.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(O){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let M=O.params[0]||1;for(;M--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(O){const M=O.params[0];return M===1&&(this._curAttrData.bg|=536870912),M!==2&&M!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(O,M,A,B=!1,Y=!1){const k=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);k.replaceCells(M,A,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),Y),B&&(k.isWrapped=!1)}_resetBufferLine(O,M=!1){const A=this._activeBuffer.lines.get(this._activeBuffer.ybase+O);A&&(A.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),M),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+O),A.isWrapped=!1)}eraseInDisplay(O,M=!1){let A;switch(this._restrictCursor(this._bufferService.cols),O.params[0]){case 0:for(A=this._activeBuffer.y,this._dirtyRowTracker.markDirty(A),this._eraseInBufferLine(A++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);A<this._bufferService.rows;A++)this._resetBufferLine(A,M);this._dirtyRowTracker.markDirty(A);break;case 1:for(A=this._activeBuffer.y,this._dirtyRowTracker.markDirty(A),this._eraseInBufferLine(A,0,this._activeBuffer.x+1,!0,M),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(A+1).isWrapped=!1);A--;)this._resetBufferLine(A,M);this._dirtyRowTracker.markDirty(0);break;case 2:for(A=this._bufferService.rows,this._dirtyRowTracker.markDirty(A-1);A--;)this._resetBufferLine(A,M);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,0),this._onScroll.fire(0))}return!0}eraseInLine(O,M=!1){switch(this._restrictCursor(this._bufferService.cols),O.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,M);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,M);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,M)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(O){this._restrictCursor();let M=O.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,Y=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;M--;)this._activeBuffer.lines.splice(Y-1,1),this._activeBuffer.lines.splice(A,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(O){this._restrictCursor();let M=O.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const A=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;M--;)this._activeBuffer.lines.splice(A,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(O){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.insertCells(this._activeBuffer.x,O.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(O){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.deleteCells(this._activeBuffer.x,O.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(O){let M=O.params[0]||1;for(;M--;)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(O){let M=O.params[0]||1;for(;M--;)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(f.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(O){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=O.params[0]||1;for(let A=this._activeBuffer.scrollTop;A<=this._activeBuffer.scrollBottom;++A){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);B.deleteCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(O){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=O.params[0]||1;for(let A=this._activeBuffer.scrollTop;A<=this._activeBuffer.scrollBottom;++A){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);B.insertCells(0,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(O){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=O.params[0]||1;for(let A=this._activeBuffer.scrollTop;A<=this._activeBuffer.scrollBottom;++A){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);B.insertCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(O){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const M=O.params[0]||1;for(let A=this._activeBuffer.scrollTop;A<=this._activeBuffer.scrollBottom;++A){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);B.deleteCells(this._activeBuffer.x,M,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(O){this._restrictCursor();const M=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return M&&(M.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(O.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(O){if(!this._parser.precedingCodepoint)return!0;const M=O.params[0]||1,A=new Uint32Array(M);for(let B=0;B<M;++B)A[B]=this._parser.precedingCodepoint;return this.print(A,0,A.length),!0}sendDeviceAttributesPrimary(O){return O.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(u.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(u.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(O){return O.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(u.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(u.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(O.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(u.C0.ESC+"[>83;40003;0c")),!0}_is(O){return(this._optionsService.rawOptions.termName+"").indexOf(O)===0}setMode(O){for(let M=0;M<O.length;M++)switch(O.params[M]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(O){for(let M=0;M<O.length;M++)switch(O.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,m.DEFAULT_CHARSET),this._charsetService.setgCharset(1,m.DEFAULT_CHARSET),this._charsetService.setgCharset(2,m.DEFAULT_CHARSET),this._charsetService.setgCharset(3,m.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 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(O){for(let M=0;M<O.length;M++)switch(O.params[M]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(O){for(let M=0;M<O.length;M++)switch(O.params[M]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),O.params[M]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(O,M){const A=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:Y}=this._coreMouseService,k=this._coreService,{buffers:X,cols:V}=this._bufferService,{active:J,alt:x}=X,H=this._optionsService.rawOptions,$=de=>de?1:2,W=O.params[0];return re=W,ee=M?W===2?4:W===4?$(k.modes.insertMode):W===12?3:W===20?$(H.convertEol):0:W===1?$(A.applicationCursorKeys):W===3?H.windowOptions.setWinLines?V===80?2:V===132?1:0:0:W===6?$(A.origin):W===7?$(A.wraparound):W===8?3:W===9?$(B==="X10"):W===12?$(H.cursorBlink):W===25?$(!k.isCursorHidden):W===45?$(A.reverseWraparound):W===66?$(A.applicationKeypad):W===67?4:W===1e3?$(B==="VT200"):W===1002?$(B==="DRAG"):W===1003?$(B==="ANY"):W===1004?$(A.sendFocus):W===1005?4:W===1006?$(Y==="SGR"):W===1015?4:W===1016?$(Y==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?$(J===x):W===2004?$(A.bracketedPasteMode):0,k.triggerDataEvent(`${u.C0.ESC}[${M?"":"?"}${re};${ee}$y`),!0;var re,ee}_updateAttrColor(O,M,A,B,Y){return M===2?(O|=50331648,O&=-16777216,O|=b.AttributeData.fromColorRGB([A,B,Y])):M===5&&(O&=-50331904,O|=33554432|255&A),O}_extractColor(O,M,A){const B=[0,0,-1,0,0,0];let Y=0,k=0;do{if(B[k+Y]=O.params[M+k],O.hasSubParams(M+k)){const X=O.getSubParams(M+k);let V=0;do B[1]===5&&(Y=1),B[k+V+1+Y]=X[V];while(++V<X.length&&V+k+1+Y<B.length);break}if(B[1]===5&&k+Y>=2||B[1]===2&&k+Y>=5)break;B[1]&&(Y=1)}while(++k+M<O.length&&k+Y<B.length);for(let X=2;X<B.length;++X)B[X]===-1&&(B[X]=0);switch(B[0]){case 38:A.fg=this._updateAttrColor(A.fg,B[1],B[3],B[4],B[5]);break;case 48:A.bg=this._updateAttrColor(A.bg,B[1],B[3],B[4],B[5]);break;case 58:A.extended=A.extended.clone(),A.extended.underlineColor=this._updateAttrColor(A.extended.underlineColor,B[1],B[3],B[4],B[5])}return k}_processUnderline(O,M){M.extended=M.extended.clone(),(!~O||O>5)&&(O=1),M.extended.underlineStyle=O,M.fg|=268435456,O===0&&(M.fg&=-268435457),M.updateExtended()}_processSGR0(O){O.fg=f.DEFAULT_ATTR_DATA.fg,O.bg=f.DEFAULT_ATTR_DATA.bg,O.extended=O.extended.clone(),O.extended.underlineStyle=0,O.extended.underlineColor&=-67108864,O.updateExtended()}charAttributes(O){if(O.length===1&&O.params[0]===0)return this._processSGR0(this._curAttrData),!0;const M=O.length;let A;const B=this._curAttrData;for(let Y=0;Y<M;Y++)A=O.params[Y],A>=30&&A<=37?(B.fg&=-50331904,B.fg|=16777216|A-30):A>=40&&A<=47?(B.bg&=-50331904,B.bg|=16777216|A-40):A>=90&&A<=97?(B.fg&=-50331904,B.fg|=16777224|A-90):A>=100&&A<=107?(B.bg&=-50331904,B.bg|=16777224|A-100):A===0?this._processSGR0(B):A===1?B.fg|=134217728:A===3?B.bg|=67108864:A===4?(B.fg|=268435456,this._processUnderline(O.hasSubParams(Y)?O.getSubParams(Y)[0]:1,B)):A===5?B.fg|=536870912:A===7?B.fg|=67108864:A===8?B.fg|=1073741824:A===9?B.fg|=2147483648:A===2?B.bg|=134217728:A===21?this._processUnderline(2,B):A===22?(B.fg&=-134217729,B.bg&=-134217729):A===23?B.bg&=-67108865:A===24?(B.fg&=-268435457,this._processUnderline(0,B)):A===25?B.fg&=-536870913:A===27?B.fg&=-67108865:A===28?B.fg&=-1073741825:A===29?B.fg&=2147483647:A===39?(B.fg&=-67108864,B.fg|=16777215&f.DEFAULT_ATTR_DATA.fg):A===49?(B.bg&=-67108864,B.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):A===38||A===48||A===58?Y+=this._extractColor(O,Y,B):A===53?B.bg|=1073741824:A===55?B.bg&=-1073741825:A===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):A===100?(B.fg&=-67108864,B.fg|=16777215&f.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&f.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",A);return!0}deviceStatus(O){switch(O.params[0]){case 5:this._coreService.triggerDataEvent(`${u.C0.ESC}[0n`);break;case 6:const M=this._activeBuffer.y+1,A=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[${M};${A}R`)}return!0}deviceStatusPrivate(O){if(O.params[0]===6){const M=this._activeBuffer.y+1,A=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[?${M};${A}R`)}return!0}softReset(O){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=f.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(O){const M=O.params[0]||1;switch(M){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const A=M%2==1;return this._optionsService.options.cursorBlink=A,!0}setScrollRegion(O){const M=O.params[0]||1;let A;return(O.length<2||(A=O.params[1])>this._bufferService.rows||A===0)&&(A=this._bufferService.rows),A>M&&(this._activeBuffer.scrollTop=M-1,this._activeBuffer.scrollBottom=A-1,this._setCursor(0,0)),!0}windowOptions(O){if(!I(O.params[0],this._optionsService.rawOptions.windowOptions))return!0;const M=O.length>1?O.params[1]:0;switch(O.params[0]){case 14:M!==2&&this._onRequestWindowsOptionsReport.fire(w.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(w.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${u.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:M!==0&&M!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),M!==0&&M!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:M!==0&&M!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),M!==0&&M!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(O){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(O){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(O){return this._windowTitle=O,this._onTitleChange.fire(O),!0}setIconName(O){return this._iconName=O,!0}setOrReportIndexedColor(O){const M=[],A=O.split(";");for(;A.length>1;){const B=A.shift(),Y=A.shift();if(/^\d+$/.exec(B)){const k=parseInt(B);if(L(k))if(Y==="?")M.push({type:0,index:k});else{const X=(0,v.parseColor)(Y);X&&M.push({type:1,index:k,color:X})}}}return M.length&&this._onColor.fire(M),!0}setHyperlink(O){const M=O.split(";");return!(M.length<2)&&(M[1]?this._createHyperlink(M[0],M[1]):!M[0]&&this._finishHyperlink())}_createHyperlink(O,M){this._getCurrentLinkId()&&this._finishHyperlink();const A=O.split(":");let B;const Y=A.findIndex(k=>k.startsWith("id="));return Y!==-1&&(B=A[Y].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,uri:M}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(O,M){const A=O.split(";");for(let B=0;B<A.length&&!(M>=this._specialColors.length);++B,++M)if(A[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[M]}]);else{const Y=(0,v.parseColor)(A[B]);Y&&this._onColor.fire([{type:1,index:this._specialColors[M],color:Y}])}return!0}setOrReportFgColor(O){return this._setOrReportSpecialColor(O,0)}setOrReportBgColor(O){return this._setOrReportSpecialColor(O,1)}setOrReportCursorColor(O){return this._setOrReportSpecialColor(O,2)}restoreIndexedColor(O){if(!O)return this._onColor.fire([{type:2}]),!0;const M=[],A=O.split(";");for(let B=0;B<A.length;++B)if(/^\d+$/.exec(A[B])){const Y=parseInt(A[B]);L(Y)&&M.push({type:2,index:Y})}return M.length&&this._onColor.fire(M),!0}restoreFgColor(O){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(O){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(O){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,m.DEFAULT_CHARSET),!0}selectCharset(O){return O.length!==2?(this.selectDefaultCharset(),!0):(O[0]==="/"||this._charsetService.setgCharset(C[O[0]],m.CHARSETS[O[1]]||m.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){const O=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,O,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=f.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=f.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(O){return this._charsetService.setgLevel(O),!0}screenAlignmentPattern(){const O=new h.CellData;O.content=4194373,O.fg=this._curAttrData.fg,O.bg=this._curAttrData.bg,this._setCursor(0,0);for(let M=0;M<this._bufferService.rows;++M){const A=this._activeBuffer.ybase+this._activeBuffer.y+M,B=this._activeBuffer.lines.get(A);B&&(B.fill(O),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(O,M){const A=this._bufferService.buffer,B=this._optionsService.rawOptions;return(Y=>(this._coreService.triggerDataEvent(`${u.C0.ESC}${Y}${u.C0.ESC}\\`),!0))(O==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:O==='"p'?'P1$r61;1"p':O==="r"?`P1$r${A.scrollTop+1};${A.scrollBottom+1}r`:O==="m"?"P1$r0m":O===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(O,M){this._dirtyRowTracker.markRangeDirty(O,M)}}s.InputHandler=U;let G=class{constructor(F){this._bufferService=F,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(F){F<this.start?this.start=F:F>this.end&&(this.end=F)}markRangeDirty(F,O){F>O&&(P=F,F=O,O=P),F<this.start&&(this.start=F),O>this.end&&(this.end=O)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function L(F){return 0<=F&&F<256}G=c([d(0,T.IBufferService)],G)},844:(o,s)=>{function l(c){for(const d of c)d.dispose();c.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const d=this._disposables.indexOf(c);d!==-1&&this._disposables.splice(d,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var d;this._isDisposed||c===this._value||((d=this._value)===null||d===void 0||d.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},s.toDisposable=function(c){return{dispose:c}},s.disposeArray=l,s.getDisposeArrayDisposable=function(c){return{dispose:()=>l(c)}}},1505:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.FourKeyMap=s.TwoKeyMap=void 0;class l{constructor(){this._data={}}set(d,u,m){this._data[d]||(this._data[d]={}),this._data[d][u]=m}get(d,u){return this._data[d]?this._data[d][u]:void 0}clear(){this._data={}}}s.TwoKeyMap=l,s.FourKeyMap=class{constructor(){this._data=new l}set(c,d,u,m,_){this._data.get(c,d)||this._data.set(c,d,new l),this._data.get(c,d).set(u,m,_)}get(c,d,u,m){var _;return(_=this._data.get(c,d))===null||_===void 0?void 0:_.get(u,m)}clear(){this._data.clear()}}},6114:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.isChromeOS=s.isLinux=s.isWindows=s.isIphone=s.isIpad=s.isMac=s.getSafariVersion=s.isSafari=s.isLegacyEdge=s.isFirefox=s.isNode=void 0,s.isNode=typeof navigator>"u";const l=s.isNode?"node":navigator.userAgent,c=s.isNode?"node":navigator.platform;s.isFirefox=l.includes("Firefox"),s.isLegacyEdge=l.includes("Edge"),s.isSafari=/^((?!chrome|android).)*safari/i.test(l),s.getSafariVersion=function(){if(!s.isSafari)return 0;const d=l.match(/Version\/(\d+)/);return d===null||d.length<2?0:parseInt(d[1])},s.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),s.isIpad=c==="iPad",s.isIphone=c==="iPhone",s.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),s.isLinux=c.indexOf("Linux")>=0,s.isChromeOS=/\bCrOS\b/.test(l)},6106:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SortedList=void 0;let l=0;s.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(l=this._search(this._getKey(c)),this._array.splice(l,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const d=this._getKey(c);if(d===void 0||(l=this._search(d),l===-1)||this._getKey(this._array[l])!==d)return!1;do if(this._array[l]===c)return this._array.splice(l,1),!0;while(++l<this._array.length&&this._getKey(this._array[l])===d);return!1}*getKeyIterator(c){if(this._array.length!==0&&(l=this._search(c),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===c))do yield this._array[l];while(++l<this._array.length&&this._getKey(this._array[l])===c)}forEachByKey(c,d){if(this._array.length!==0&&(l=this._search(c),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===c))do d(this._array[l]);while(++l<this._array.length&&this._getKey(this._array[l])===c)}values(){return[...this._array].values()}_search(c){let d=0,u=this._array.length-1;for(;u>=d;){let m=d+u>>1;const _=this._getKey(this._array[m]);if(_>c)u=m-1;else{if(!(_<c)){for(;m>0&&this._getKey(this._array[m-1])===c;)m--;return m}d=m+1}}return d}}},7226:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DebouncedIdleTask=s.IdleTaskQueue=s.PriorityTaskQueue=void 0;const c=l(6114);class d{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),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(_){this._idleCallback=void 0;let E=0,S=0,f=_.timeRemaining(),p=0;for(;this._i<this._tasks.length;){if(E=Date.now(),this._tasks[this._i]()||this._i++,E=Math.max(1,Date.now()-E),S=Math.max(E,S),p=_.timeRemaining(),1.5*S>p)return f-E<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(f-E))}ms`),void this._start();f=p}this.clear()}}class u extends d{_requestCallback(_){return setTimeout(()=>_(this._createDeadline(16)))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const E=Date.now()+_;return{timeRemaining:()=>Math.max(0,E-Date.now())}}}s.PriorityTaskQueue=u,s.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends d{_requestCallback(m){return requestIdleCallback(m)}_cancelCallback(m){cancelIdleCallback(m)}}:u,s.DebouncedIdleTask=class{constructor(){this._queue=new s.IdleTaskQueue}set(m){this._queue.clear(),this._queue.enqueue(m)}flush(){this._queue.flush()}}},9282:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.updateWindowsModeWrappedState=void 0;const c=l(643);s.updateWindowsModeWrappedState=function(d){const u=d.buffer.lines.get(d.buffer.ybase+d.buffer.y-1),m=u==null?void 0:u.get(d.cols-1),_=d.buffer.lines.get(d.buffer.ybase+d.buffer.y);_&&m&&(_.isWrapped=m[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&m[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExtendedAttrs=s.AttributeData=void 0;class l{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(u){return[u>>>16&255,u>>>8&255,255&u]}static fromColorRGB(u){return(255&u[0])<<16|(255&u[1])<<8|255&u[2]}clone(){const u=new l;return u.fg=this.fg,u.bg=this.bg,u.extended=this.extended.clone(),u}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)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}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)==0}isBgDefault(){return(50331648&this.bg)==0}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)==50331648: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)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}s.AttributeData=l;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(u){this._ext=u}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(u){this._ext&=-469762049,this._ext|=u<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(u){this._ext&=-67108864,this._ext|=67108863&u}get urlId(){return this._urlId}set urlId(u){this._urlId=u}constructor(u=0,m=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=m}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}s.ExtendedAttrs=c},9092:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Buffer=s.MAX_BUFFER_SIZE=void 0;const c=l(6349),d=l(7226),u=l(3734),m=l(8437),_=l(4634),E=l(511),S=l(643),f=l(4863),p=l(7116);s.MAX_BUFFER_SIZE=4294967295,s.Buffer=class{constructor(g,h,b){this._hasScrollback=g,this._optionsService=h,this._bufferService=b,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=m.DEFAULT_ATTR_DATA.clone(),this.savedCharset=p.DEFAULT_CHARSET,this.markers=[],this._nullCell=E.CellData.fromCharData([0,S.NULL_CELL_CHAR,S.NULL_CELL_WIDTH,S.NULL_CELL_CODE]),this._whitespaceCell=E.CellData.fromCharData([0,S.WHITESPACE_CELL_CHAR,S.WHITESPACE_CELL_WIDTH,S.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new d.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(g){return g?(this._nullCell.fg=g.fg,this._nullCell.bg=g.bg,this._nullCell.extended=g.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell}getWhitespaceCell(g){return g?(this._whitespaceCell.fg=g.fg,this._whitespaceCell.bg=g.bg,this._whitespaceCell.extended=g.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell}getBlankLine(g,h){return new m.BufferLine(this._bufferService.cols,this.getNullCell(g),h)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const g=this.ybase+this.y-this.ydisp;return g>=0&&g<this._rows}_getCorrectBufferLength(g){if(!this._hasScrollback)return g;const h=g+this._optionsService.rawOptions.scrollback;return h>s.MAX_BUFFER_SIZE?s.MAX_BUFFER_SIZE:h}fillViewportRows(g){if(this.lines.length===0){g===void 0&&(g=m.DEFAULT_ATTR_DATA);let h=this._rows;for(;h--;)this.lines.push(this.getBlankLine(g))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(g,h){const b=this.getNullCell(m.DEFAULT_ATTR_DATA);let T=0;const y=this._getCorrectBufferLength(h);if(y>this.lines.maxLength&&(this.lines.maxLength=y),this.lines.length>0){if(this._cols<g)for(let v=0;v<this.lines.length;v++)T+=+this.lines.get(v).resize(g,b);let N=0;if(this._rows<h)for(let v=this._rows;v<h;v++)this.lines.length<h+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new m.BufferLine(g,b)):this.ybase>0&&this.lines.length<=this.ybase+this.y+N+1?(this.ybase--,N++,this.ydisp>0&&this.ydisp--):this.lines.push(new m.BufferLine(g,b)));else for(let v=this._rows;v>h;v--)this.lines.length>h+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(y<this.lines.maxLength){const v=this.lines.length-y;v>0&&(this.lines.trimStart(v),this.ybase=Math.max(this.ybase-v,0),this.ydisp=Math.max(this.ydisp-v,0),this.savedY=Math.max(this.savedY-v,0)),this.lines.maxLength=y}this.x=Math.min(this.x,g-1),this.y=Math.min(this.y,h-1),N&&(this.y+=N),this.savedX=Math.min(this.savedX,g-1),this.scrollTop=0}if(this.scrollBottom=h-1,this._isReflowEnabled&&(this._reflow(g,h),this._cols>g))for(let N=0;N<this.lines.length;N++)T+=+this.lines.get(N).resize(g,b);this._cols=g,this._rows=h,this._memoryCleanupQueue.clear(),T>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let g=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,g=!1);let h=0;for(;this._memoryCleanupPosition<this.lines.length;)if(h+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),h>100)return!0;return g}get _isReflowEnabled(){const g=this._optionsService.rawOptions.windowsPty;return g&&g.buildNumber?this._hasScrollback&&g.backend==="conpty"&&g.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(g,h){this._cols!==g&&(g>this._cols?this._reflowLarger(g,h):this._reflowSmaller(g,h))}_reflowLarger(g,h){const b=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,g,this.ybase+this.y,this.getNullCell(m.DEFAULT_ATTR_DATA));if(b.length>0){const T=(0,_.reflowLargerCreateNewLayout)(this.lines,b);(0,_.reflowLargerApplyNewLayout)(this.lines,T.layout),this._reflowLargerAdjustViewport(g,h,T.countRemoved)}}_reflowLargerAdjustViewport(g,h,b){const T=this.getNullCell(m.DEFAULT_ATTR_DATA);let y=b;for(;y-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<h&&this.lines.push(new m.BufferLine(g,T))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-b,0)}_reflowSmaller(g,h){const b=this.getNullCell(m.DEFAULT_ATTR_DATA),T=[];let y=0;for(let N=this.lines.length-1;N>=0;N--){let v=this.lines.get(N);if(!v||!v.isWrapped&&v.getTrimmedLength()<=g)continue;const C=[v];for(;v.isWrapped&&N>0;)v=this.lines.get(--N),C.unshift(v);const R=this.ybase+this.y;if(R>=N&&R<N+C.length)continue;const I=C[C.length-1].getTrimmedLength(),w=(0,_.reflowSmallerGetNewLineLengths)(C,this._cols,g),P=w.length-C.length;let U;U=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);const G=[];for(let B=0;B<P;B++){const Y=this.getBlankLine(m.DEFAULT_ATTR_DATA,!0);G.push(Y)}G.length>0&&(T.push({start:N+C.length+y,newLines:G}),y+=G.length),C.push(...G);let L=w.length-1,F=w[L];F===0&&(L--,F=w[L]);let O=C.length-P-1,M=I;for(;O>=0;){const B=Math.min(M,F);if(C[L]===void 0)break;if(C[L].copyCellsFrom(C[O],M-B,F-B,B,!0),F-=B,F===0&&(L--,F=w[L]),M-=B,M===0){O--;const Y=Math.max(O,0);M=(0,_.getWrappedLineTrimmedLength)(C,Y,this._cols)}}for(let B=0;B<C.length;B++)w[B]<g&&C[B].setCell(w[B],b);let A=P-U;for(;A-- >0;)this.ybase===0?this.y<h-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+y)-h&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+h-1)}if(T.length>0){const N=[],v=[];for(let L=0;L<this.lines.length;L++)v.push(this.lines.get(L));const C=this.lines.length;let R=C-1,I=0,w=T[I];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+y);let P=0;for(let L=Math.min(this.lines.maxLength-1,C+y-1);L>=0;L--)if(w&&w.start>R+P){for(let F=w.newLines.length-1;F>=0;F--)this.lines.set(L--,w.newLines[F]);L++,N.push({index:R+1,amount:w.newLines.length}),P+=w.newLines.length,w=T[++I]}else this.lines.set(L,v[R--]);let U=0;for(let L=N.length-1;L>=0;L--)N[L].index+=U,this.lines.onInsertEmitter.fire(N[L]),U+=N[L].amount;const G=Math.max(0,C+y-this.lines.maxLength);G>0&&this.lines.onTrimEmitter.fire(G)}}translateBufferLineToString(g,h,b=0,T){const y=this.lines.get(g);return y?y.translateToString(h,b,T):""}getWrappedRangeForLine(g){let h=g,b=g;for(;h>0&&this.lines.get(h).isWrapped;)h--;for(;b+1<this.lines.length&&this.lines.get(b+1).isWrapped;)b++;return{first:h,last:b}}setupTabStops(g){for(g!=null?this.tabs[g]||(g=this.prevStop(g)):(this.tabs={},g=0);g<this._cols;g+=this._optionsService.rawOptions.tabStopWidth)this.tabs[g]=!0}prevStop(g){for(g==null&&(g=this.x);!this.tabs[--g]&&g>0;);return g>=this._cols?this._cols-1:g<0?0:g}nextStop(g){for(g==null&&(g=this.x);!this.tabs[++g]&&g<this._cols;);return g>=this._cols?this._cols-1:g<0?0:g}clearMarkers(g){this._isClearing=!0;for(let h=0;h<this.markers.length;h++)this.markers[h].line===g&&(this.markers[h].dispose(),this.markers.splice(h--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let g=0;g<this.markers.length;g++)this.markers[g].dispose(),this.markers.splice(g--,1);this._isClearing=!1}addMarker(g){const h=new f.Marker(g);return this.markers.push(h),h.register(this.lines.onTrim(b=>{h.line-=b,h.line<0&&h.dispose()})),h.register(this.lines.onInsert(b=>{h.line>=b.index&&(h.line+=b.amount)})),h.register(this.lines.onDelete(b=>{h.line>=b.index&&h.line<b.index+b.amount&&h.dispose(),h.line>b.index&&(h.line-=b.amount)})),h.register(h.onDispose(()=>this._removeMarker(h))),h}_removeMarker(g){this._isClearing||this.markers.splice(this.markers.indexOf(g),1)}}},8437:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLine=s.DEFAULT_ATTR_DATA=void 0;const c=l(3734),d=l(511),u=l(643),m=l(482);s.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let _=0;class E{constructor(f,p,g=!1){this.isWrapped=g,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*f);const h=p||d.CellData.fromCharData([0,u.NULL_CELL_CHAR,u.NULL_CELL_WIDTH,u.NULL_CELL_CODE]);for(let b=0;b<f;++b)this.setCell(b,h);this.length=f}get(f){const p=this._data[3*f+0],g=2097151&p;return[this._data[3*f+1],2097152&p?this._combined[f]:g?(0,m.stringFromCodePoint)(g):"",p>>22,2097152&p?this._combined[f].charCodeAt(this._combined[f].length-1):g]}set(f,p){this._data[3*f+1]=p[u.CHAR_DATA_ATTR_INDEX],p[u.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[f]=p[1],this._data[3*f+0]=2097152|f|p[u.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*f+0]=p[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|p[u.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(f){return this._data[3*f+0]>>22}hasWidth(f){return 12582912&this._data[3*f+0]}getFg(f){return this._data[3*f+1]}getBg(f){return this._data[3*f+2]}hasContent(f){return 4194303&this._data[3*f+0]}getCodePoint(f){const p=this._data[3*f+0];return 2097152&p?this._combined[f].charCodeAt(this._combined[f].length-1):2097151&p}isCombined(f){return 2097152&this._data[3*f+0]}getString(f){const p=this._data[3*f+0];return 2097152&p?this._combined[f]:2097151&p?(0,m.stringFromCodePoint)(2097151&p):""}isProtected(f){return 536870912&this._data[3*f+2]}loadCell(f,p){return _=3*f,p.content=this._data[_+0],p.fg=this._data[_+1],p.bg=this._data[_+2],2097152&p.content&&(p.combinedData=this._combined[f]),268435456&p.bg&&(p.extended=this._extendedAttrs[f]),p}setCell(f,p){2097152&p.content&&(this._combined[f]=p.combinedData),268435456&p.bg&&(this._extendedAttrs[f]=p.extended),this._data[3*f+0]=p.content,this._data[3*f+1]=p.fg,this._data[3*f+2]=p.bg}setCellFromCodePoint(f,p,g,h,b,T){268435456&b&&(this._extendedAttrs[f]=T),this._data[3*f+0]=p|g<<22,this._data[3*f+1]=h,this._data[3*f+2]=b}addCodepointToCell(f,p){let g=this._data[3*f+0];2097152&g?this._combined[f]+=(0,m.stringFromCodePoint)(p):(2097151&g?(this._combined[f]=(0,m.stringFromCodePoint)(2097151&g)+(0,m.stringFromCodePoint)(p),g&=-2097152,g|=2097152):g=p|4194304,this._data[3*f+0]=g)}insertCells(f,p,g,h){if((f%=this.length)&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs),p<this.length-f){const b=new d.CellData;for(let T=this.length-f-p-1;T>=0;--T)this.setCell(f+p+T,this.loadCell(f+T,b));for(let T=0;T<p;++T)this.setCell(f+T,g)}else for(let b=f;b<this.length;++b)this.setCell(b,g);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs)}deleteCells(f,p,g,h){if(f%=this.length,p<this.length-f){const b=new d.CellData;for(let T=0;T<this.length-f-p;++T)this.setCell(f+T,this.loadCell(f+p+T,b));for(let T=this.length-p;T<this.length;++T)this.setCell(T,g)}else for(let b=f;b<this.length;++b)this.setCell(b,g);f&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs),this.getWidth(f)!==0||this.hasContent(f)||this.setCellFromCodePoint(f,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs)}replaceCells(f,p,g,h,b=!1){if(b)for(f&&this.getWidth(f-1)===2&&!this.isProtected(f-1)&&this.setCellFromCodePoint(f-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs),p<this.length&&this.getWidth(p-1)===2&&!this.isProtected(p)&&this.setCellFromCodePoint(p,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs);f<p&&f<this.length;)this.isProtected(f)||this.setCell(f,g),f++;else for(f&&this.getWidth(f-1)===2&&this.setCellFromCodePoint(f-1,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs),p<this.length&&this.getWidth(p-1)===2&&this.setCellFromCodePoint(p,0,1,(h==null?void 0:h.fg)||0,(h==null?void 0:h.bg)||0,(h==null?void 0:h.extended)||new c.ExtendedAttrs);f<p&&f<this.length;)this.setCell(f++,g)}resize(f,p){if(f===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const g=3*f;if(f>this.length){if(this._data.buffer.byteLength>=4*g)this._data=new Uint32Array(this._data.buffer,0,g);else{const h=new Uint32Array(g);h.set(this._data),this._data=h}for(let h=this.length;h<f;++h)this.setCell(h,p)}else{this._data=this._data.subarray(0,g);const h=Object.keys(this._combined);for(let T=0;T<h.length;T++){const y=parseInt(h[T],10);y>=f&&delete this._combined[y]}const b=Object.keys(this._extendedAttrs);for(let T=0;T<b.length;T++){const y=parseInt(b[T],10);y>=f&&delete this._extendedAttrs[y]}}return this.length=f,4*g*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const f=new Uint32Array(this._data.length);return f.set(this._data),this._data=f,1}return 0}fill(f,p=!1){if(p)for(let g=0;g<this.length;++g)this.isProtected(g)||this.setCell(g,f);else{this._combined={},this._extendedAttrs={};for(let g=0;g<this.length;++g)this.setCell(g,f)}}copyFrom(f){this.length!==f.length?this._data=new Uint32Array(f._data):this._data.set(f._data),this.length=f.length,this._combined={};for(const p in f._combined)this._combined[p]=f._combined[p];this._extendedAttrs={};for(const p in f._extendedAttrs)this._extendedAttrs[p]=f._extendedAttrs[p];this.isWrapped=f.isWrapped}clone(){const f=new E(0);f._data=new Uint32Array(this._data),f.length=this.length;for(const p in this._combined)f._combined[p]=this._combined[p];for(const p in this._extendedAttrs)f._extendedAttrs[p]=this._extendedAttrs[p];return f.isWrapped=this.isWrapped,f}getTrimmedLength(){for(let f=this.length-1;f>=0;--f)if(4194303&this._data[3*f+0])return f+(this._data[3*f+0]>>22);return 0}getNoBgTrimmedLength(){for(let f=this.length-1;f>=0;--f)if(4194303&this._data[3*f+0]||50331648&this._data[3*f+2])return f+(this._data[3*f+0]>>22);return 0}copyCellsFrom(f,p,g,h,b){const T=f._data;if(b)for(let N=h-1;N>=0;N--){for(let v=0;v<3;v++)this._data[3*(g+N)+v]=T[3*(p+N)+v];268435456&T[3*(p+N)+2]&&(this._extendedAttrs[g+N]=f._extendedAttrs[p+N])}else for(let N=0;N<h;N++){for(let v=0;v<3;v++)this._data[3*(g+N)+v]=T[3*(p+N)+v];268435456&T[3*(p+N)+2]&&(this._extendedAttrs[g+N]=f._extendedAttrs[p+N])}const y=Object.keys(f._combined);for(let N=0;N<y.length;N++){const v=parseInt(y[N],10);v>=p&&(this._combined[v-p+g]=f._combined[v])}}translateToString(f=!1,p=0,g=this.length){f&&(g=Math.min(g,this.getTrimmedLength()));let h="";for(;p<g;){const b=this._data[3*p+0],T=2097151&b;h+=2097152&b?this._combined[p]:T?(0,m.stringFromCodePoint)(T):u.WHITESPACE_CELL_CHAR,p+=b>>22||1}return h}}s.BufferLine=E},4841:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.getRangeLength=void 0,s.getRangeLength=function(l,c){if(l.start.y>l.end.y)throw new Error(`Buffer range end (${l.end.x}, ${l.end.y}) cannot be before start (${l.start.x}, ${l.start.y})`);return c*(l.end.y-l.start.y)+(l.end.x-l.start.x+1)}},4634:(o,s)=>{function l(c,d,u){if(d===c.length-1)return c[d].getTrimmedLength();const m=!c[d].hasContent(u-1)&&c[d].getWidth(u-1)===1,_=c[d+1].getWidth(0)===2;return m&&_?u-1:u}Object.defineProperty(s,"__esModule",{value:!0}),s.getWrappedLineTrimmedLength=s.reflowSmallerGetNewLineLengths=s.reflowLargerApplyNewLayout=s.reflowLargerCreateNewLayout=s.reflowLargerGetLinesToRemove=void 0,s.reflowLargerGetLinesToRemove=function(c,d,u,m,_){const E=[];for(let S=0;S<c.length-1;S++){let f=S,p=c.get(++f);if(!p.isWrapped)continue;const g=[c.get(S)];for(;f<c.length&&p.isWrapped;)g.push(p),p=c.get(++f);if(m>=S&&m<f){S+=g.length-1;continue}let h=0,b=l(g,h,d),T=1,y=0;for(;T<g.length;){const v=l(g,T,d),C=v-y,R=u-b,I=Math.min(C,R);g[h].copyCellsFrom(g[T],y,b,I,!1),b+=I,b===u&&(h++,b=0),y+=I,y===v&&(T++,y=0),b===0&&h!==0&&g[h-1].getWidth(u-1)===2&&(g[h].copyCellsFrom(g[h-1],u-1,b++,1,!1),g[h-1].setCell(u-1,_))}g[h].replaceCells(b,u,_);let N=0;for(let v=g.length-1;v>0&&(v>h||g[v].getTrimmedLength()===0);v--)N++;N>0&&(E.push(S+g.length-N),E.push(N)),S+=g.length-1}return E},s.reflowLargerCreateNewLayout=function(c,d){const u=[];let m=0,_=d[m],E=0;for(let S=0;S<c.length;S++)if(_===S){const f=d[++m];c.onDeleteEmitter.fire({index:S-E,amount:f}),S+=f-1,E+=f,_=d[++m]}else u.push(S);return{layout:u,countRemoved:E}},s.reflowLargerApplyNewLayout=function(c,d){const u=[];for(let m=0;m<d.length;m++)u.push(c.get(d[m]));for(let m=0;m<u.length;m++)c.set(m,u[m]);c.length=d.length},s.reflowSmallerGetNewLineLengths=function(c,d,u){const m=[],_=c.map((p,g)=>l(c,g,d)).reduce((p,g)=>p+g);let E=0,S=0,f=0;for(;f<_;){if(_-f<u){m.push(_-f);break}E+=u;const p=l(c,S,d);E>p&&(E-=p,S++);const g=c[S].getWidth(E-1)===2;g&&E--;const h=g?u-1:u;m.push(h),f+=h}return m},s.getWrappedLineTrimmedLength=l},5295:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferSet=void 0;const c=l(8460),d=l(844),u=l(9092);class m extends d.Disposable{constructor(E,S){super(),this._optionsService=E,this._bufferService=S,this._onBufferActivate=this.register(new c.EventEmitter),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 u.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new u.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(E){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(E),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(E,S){this._normal.resize(E,S),this._alt.resize(E,S),this.setupTabStops(E)}setupTabStops(E){this._normal.setupTabStops(E),this._alt.setupTabStops(E)}}s.BufferSet=m},511:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellData=void 0;const c=l(482),d=l(643),u=l(3734);class m extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(E){const S=new m;return S.setFromCharData(E),S}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(E){this.fg=E[d.CHAR_DATA_ATTR_INDEX],this.bg=0;let S=!1;if(E[d.CHAR_DATA_CHAR_INDEX].length>2)S=!0;else if(E[d.CHAR_DATA_CHAR_INDEX].length===2){const f=E[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=f&&f<=56319){const p=E[d.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=p&&p<=57343?this.content=1024*(f-55296)+p-56320+65536|E[d.CHAR_DATA_WIDTH_INDEX]<<22:S=!0}else S=!0}else this.content=E[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|E[d.CHAR_DATA_WIDTH_INDEX]<<22;S&&(this.combinedData=E[d.CHAR_DATA_CHAR_INDEX],this.content=2097152|E[d.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.CellData=m},643:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WHITESPACE_CELL_CODE=s.WHITESPACE_CELL_WIDTH=s.WHITESPACE_CELL_CHAR=s.NULL_CELL_CODE=s.NULL_CELL_WIDTH=s.NULL_CELL_CHAR=s.CHAR_DATA_CODE_INDEX=s.CHAR_DATA_WIDTH_INDEX=s.CHAR_DATA_CHAR_INDEX=s.CHAR_DATA_ATTR_INDEX=s.DEFAULT_EXT=s.DEFAULT_ATTR=s.DEFAULT_COLOR=void 0,s.DEFAULT_COLOR=0,s.DEFAULT_ATTR=256|s.DEFAULT_COLOR<<9,s.DEFAULT_EXT=0,s.CHAR_DATA_ATTR_INDEX=0,s.CHAR_DATA_CHAR_INDEX=1,s.CHAR_DATA_WIDTH_INDEX=2,s.CHAR_DATA_CODE_INDEX=3,s.NULL_CELL_CHAR="",s.NULL_CELL_WIDTH=1,s.NULL_CELL_CODE=0,s.WHITESPACE_CELL_CHAR=" ",s.WHITESPACE_CELL_WIDTH=1,s.WHITESPACE_CELL_CODE=32},4863:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Marker=void 0;const c=l(8460),d=l(844);class u{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=u._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,d.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}s.Marker=u,u._nextId=1},7116:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DEFAULT_CHARSET=s.CHARSETS=void 0,s.CHARSETS={},s.DEFAULT_CHARSET=s.CHARSETS.B,s.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},s.CHARSETS.A={"#":"£"},s.CHARSETS.B=void 0,s.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},s.CHARSETS.C=s.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},s.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},s.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},s.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},s.CHARSETS.E=s.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},s.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},s.CHARSETS.H=s.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(o,s)=>{var l,c,d;Object.defineProperty(s,"__esModule",{value:!0}),s.C1_ESCAPED=s.C1=s.C0=void 0,function(u){u.NUL="\0",u.SOH="",u.STX="",u.ETX="",u.EOT="",u.ENQ="",u.ACK="",u.BEL="\x07",u.BS="\b",u.HT=" ",u.LF=`
84
84
  `,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="",u.SI="",u.DLE="",u.DC1="",u.DC2="",u.DC3="",u.DC4="",u.NAK="",u.SYN="",u.ETB="",u.CAN="",u.EM="",u.SUB="",u.ESC="\x1B",u.FS="",u.GS="",u.RS="",u.US="",u.SP=" ",u.DEL=""}(l||(s.C0=l={})),function(u){u.PAD="€",u.HOP="",u.BPH="‚",u.NBH="ƒ",u.IND="„",u.NEL="…",u.SSA="†",u.ESA="‡",u.HTS="ˆ",u.HTJ="‰",u.VTS="Š",u.PLD="‹",u.PLU="Œ",u.RI="",u.SS2="Ž",u.SS3="",u.DCS="",u.PU1="‘",u.PU2="’",u.STS="“",u.CCH="”",u.MW="•",u.SPA="–",u.EPA="—",u.SOS="˜",u.SGCI="™",u.SCI="š",u.CSI="›",u.ST="œ",u.OSC="",u.PM="ž",u.APC="Ÿ"}(c||(s.C1=c={})),function(u){u.ST=`${l.ESC}\\`}(d||(s.C1_ESCAPED=d={}))},7399:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.evaluateKeyboardEvent=void 0;const c=l(2584),d={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};s.evaluateKeyboardEvent=function(u,m,_,E){const S={type:0,cancel:!1,key:void 0},f=(u.shiftKey?1:0)|(u.altKey?2:0)|(u.ctrlKey?4:0)|(u.metaKey?8:0);switch(u.keyCode){case 0:u.key==="UIKeyInputUpArrow"?S.key=m?c.C0.ESC+"OA":c.C0.ESC+"[A":u.key==="UIKeyInputLeftArrow"?S.key=m?c.C0.ESC+"OD":c.C0.ESC+"[D":u.key==="UIKeyInputRightArrow"?S.key=m?c.C0.ESC+"OC":c.C0.ESC+"[C":u.key==="UIKeyInputDownArrow"&&(S.key=m?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(u.altKey){S.key=c.C0.ESC+c.C0.DEL;break}S.key=c.C0.DEL;break;case 9:if(u.shiftKey){S.key=c.C0.ESC+"[Z";break}S.key=c.C0.HT,S.cancel=!0;break;case 13:S.key=u.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,S.cancel=!0;break;case 27:S.key=c.C0.ESC,u.altKey&&(S.key=c.C0.ESC+c.C0.ESC),S.cancel=!0;break;case 37:if(u.metaKey)break;f?(S.key=c.C0.ESC+"[1;"+(f+1)+"D",S.key===c.C0.ESC+"[1;3D"&&(S.key=c.C0.ESC+(_?"b":"[1;5D"))):S.key=m?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(u.metaKey)break;f?(S.key=c.C0.ESC+"[1;"+(f+1)+"C",S.key===c.C0.ESC+"[1;3C"&&(S.key=c.C0.ESC+(_?"f":"[1;5C"))):S.key=m?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(u.metaKey)break;f?(S.key=c.C0.ESC+"[1;"+(f+1)+"A",_||S.key!==c.C0.ESC+"[1;3A"||(S.key=c.C0.ESC+"[1;5A")):S.key=m?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(u.metaKey)break;f?(S.key=c.C0.ESC+"[1;"+(f+1)+"B",_||S.key!==c.C0.ESC+"[1;3B"||(S.key=c.C0.ESC+"[1;5B")):S.key=m?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:u.shiftKey||u.ctrlKey||(S.key=c.C0.ESC+"[2~");break;case 46:S.key=f?c.C0.ESC+"[3;"+(f+1)+"~":c.C0.ESC+"[3~";break;case 36:S.key=f?c.C0.ESC+"[1;"+(f+1)+"H":m?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:S.key=f?c.C0.ESC+"[1;"+(f+1)+"F":m?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:u.shiftKey?S.type=2:u.ctrlKey?S.key=c.C0.ESC+"[5;"+(f+1)+"~":S.key=c.C0.ESC+"[5~";break;case 34:u.shiftKey?S.type=3:u.ctrlKey?S.key=c.C0.ESC+"[6;"+(f+1)+"~":S.key=c.C0.ESC+"[6~";break;case 112:S.key=f?c.C0.ESC+"[1;"+(f+1)+"P":c.C0.ESC+"OP";break;case 113:S.key=f?c.C0.ESC+"[1;"+(f+1)+"Q":c.C0.ESC+"OQ";break;case 114:S.key=f?c.C0.ESC+"[1;"+(f+1)+"R":c.C0.ESC+"OR";break;case 115:S.key=f?c.C0.ESC+"[1;"+(f+1)+"S":c.C0.ESC+"OS";break;case 116:S.key=f?c.C0.ESC+"[15;"+(f+1)+"~":c.C0.ESC+"[15~";break;case 117:S.key=f?c.C0.ESC+"[17;"+(f+1)+"~":c.C0.ESC+"[17~";break;case 118:S.key=f?c.C0.ESC+"[18;"+(f+1)+"~":c.C0.ESC+"[18~";break;case 119:S.key=f?c.C0.ESC+"[19;"+(f+1)+"~":c.C0.ESC+"[19~";break;case 120:S.key=f?c.C0.ESC+"[20;"+(f+1)+"~":c.C0.ESC+"[20~";break;case 121:S.key=f?c.C0.ESC+"[21;"+(f+1)+"~":c.C0.ESC+"[21~";break;case 122:S.key=f?c.C0.ESC+"[23;"+(f+1)+"~":c.C0.ESC+"[23~";break;case 123:S.key=f?c.C0.ESC+"[24;"+(f+1)+"~":c.C0.ESC+"[24~";break;default:if(!u.ctrlKey||u.shiftKey||u.altKey||u.metaKey)if(_&&!E||!u.altKey||u.metaKey)!_||u.altKey||u.ctrlKey||u.shiftKey||!u.metaKey?u.key&&!u.ctrlKey&&!u.altKey&&!u.metaKey&&u.keyCode>=48&&u.key.length===1?S.key=u.key:u.key&&u.ctrlKey&&(u.key==="_"&&(S.key=c.C0.US),u.key==="@"&&(S.key=c.C0.NUL)):u.keyCode===65&&(S.type=1);else{const p=d[u.keyCode],g=p==null?void 0:p[u.shiftKey?1:0];if(g)S.key=c.C0.ESC+g;else if(u.keyCode>=65&&u.keyCode<=90){const h=u.ctrlKey?u.keyCode-64:u.keyCode+32;let b=String.fromCharCode(h);u.shiftKey&&(b=b.toUpperCase()),S.key=c.C0.ESC+b}else if(u.keyCode===32)S.key=c.C0.ESC+(u.ctrlKey?c.C0.NUL:" ");else if(u.key==="Dead"&&u.code.startsWith("Key")){let h=u.code.slice(3,4);u.shiftKey||(h=h.toLowerCase()),S.key=c.C0.ESC+h,S.cancel=!0}}else u.keyCode>=65&&u.keyCode<=90?S.key=String.fromCharCode(u.keyCode-64):u.keyCode===32?S.key=c.C0.NUL:u.keyCode>=51&&u.keyCode<=55?S.key=String.fromCharCode(u.keyCode-51+27):u.keyCode===56?S.key=c.C0.DEL:u.keyCode===219?S.key=c.C0.ESC:u.keyCode===220?S.key=c.C0.FS:u.keyCode===221&&(S.key=c.C0.GS)}return S}},482:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Utf8ToUtf32=s.StringToUtf32=s.utf32ToString=s.stringFromCodePoint=void 0,s.stringFromCodePoint=function(l){return l>65535?(l-=65536,String.fromCharCode(55296+(l>>10))+String.fromCharCode(l%1024+56320)):String.fromCharCode(l)},s.utf32ToString=function(l,c=0,d=l.length){let u="";for(let m=c;m<d;++m){let _=l[m];_>65535?(_-=65536,u+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):u+=String.fromCharCode(_)}return u},s.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,c){const d=l.length;if(!d)return 0;let u=0,m=0;if(this._interim){const _=l.charCodeAt(m++);56320<=_&&_<=57343?c[u++]=1024*(this._interim-55296)+_-56320+65536:(c[u++]=this._interim,c[u++]=_),this._interim=0}for(let _=m;_<d;++_){const E=l.charCodeAt(_);if(55296<=E&&E<=56319){if(++_>=d)return this._interim=E,u;const S=l.charCodeAt(_);56320<=S&&S<=57343?c[u++]=1024*(E-55296)+S-56320+65536:(c[u++]=E,c[u++]=S)}else E!==65279&&(c[u++]=E)}return u}},s.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,c){const d=l.length;if(!d)return 0;let u,m,_,E,S=0,f=0,p=0;if(this.interim[0]){let b=!1,T=this.interim[0];T&=(224&T)==192?31:(240&T)==224?15:7;let y,N=0;for(;(y=63&this.interim[++N])&&N<4;)T<<=6,T|=y;const v=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,C=v-N;for(;p<C;){if(p>=d)return 0;if(y=l[p++],(192&y)!=128){p--,b=!0;break}this.interim[N++]=y,T<<=6,T|=63&y}b||(v===2?T<128?p--:c[S++]=T:v===3?T<2048||T>=55296&&T<=57343||T===65279||(c[S++]=T):T<65536||T>1114111||(c[S++]=T)),this.interim.fill(0)}const g=d-4;let h=p;for(;h<d;){for(;!(!(h<g)||128&(u=l[h])||128&(m=l[h+1])||128&(_=l[h+2])||128&(E=l[h+3]));)c[S++]=u,c[S++]=m,c[S++]=_,c[S++]=E,h+=4;if(u=l[h++],u<128)c[S++]=u;else if((224&u)==192){if(h>=d)return this.interim[0]=u,S;if(m=l[h++],(192&m)!=128){h--;continue}if(f=(31&u)<<6|63&m,f<128){h--;continue}c[S++]=f}else if((240&u)==224){if(h>=d)return this.interim[0]=u,S;if(m=l[h++],(192&m)!=128){h--;continue}if(h>=d)return this.interim[0]=u,this.interim[1]=m,S;if(_=l[h++],(192&_)!=128){h--;continue}if(f=(15&u)<<12|(63&m)<<6|63&_,f<2048||f>=55296&&f<=57343||f===65279)continue;c[S++]=f}else if((248&u)==240){if(h>=d)return this.interim[0]=u,S;if(m=l[h++],(192&m)!=128){h--;continue}if(h>=d)return this.interim[0]=u,this.interim[1]=m,S;if(_=l[h++],(192&_)!=128){h--;continue}if(h>=d)return this.interim[0]=u,this.interim[1]=m,this.interim[2]=_,S;if(E=l[h++],(192&E)!=128){h--;continue}if(f=(7&u)<<18|(63&m)<<12|(63&_)<<6|63&E,f<65536||f>1114111)continue;c[S++]=f}}return S}}},225:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeV6=void 0;const l=[[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]],c=[[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]];let d;s.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 u=0;u<l.length;++u)d.fill(0,l[u][0],l[u][1]+1)}}wcwidth(u){return u<32?0:u<127?1:u<65536?d[u]:function(m,_){let E,S=0,f=_.length-1;if(m<_[0][0]||m>_[f][1])return!1;for(;f>=S;)if(E=S+f>>1,m>_[E][1])S=E+1;else{if(!(m<_[E][0]))return!0;f=E-1}return!1}(u,c)?0:u>=131072&&u<=196605||u>=196608&&u<=262141?2:1}}},5981:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WriteBuffer=void 0;const c=l(8460),d=l(844);class u extends d.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,E){if(E!==void 0&&this._syncCalls>E)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let S;for(this._isSyncWriting=!0;S=this._writeBuffer.shift();){this._action(S);const f=this._callbacks.shift();f&&f()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,E){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(E),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(E)}_innerWrite(_=0,E=!0){const S=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const f=this._writeBuffer[this._bufferOffset],p=this._action(f,E);if(p){const h=b=>Date.now()-S>=12?setTimeout(()=>this._innerWrite(0,b)):this._innerWrite(S,b);return void p.catch(b=>(queueMicrotask(()=>{throw b}),Promise.resolve(!1))).then(h)}const g=this._callbacks[this._bufferOffset];if(g&&g(),this._bufferOffset++,this._pendingData-=f.length,Date.now()-S>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}s.WriteBuffer=u},5941:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.toRgbString=s.parseColor=void 0;const l=/^([\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})$/,c=/^[\da-f]+$/;function d(u,m){const _=u.toString(16),E=_.length<2?"0"+_:_;switch(m){case 4:return _[0];case 8:return E;case 12:return(E+E).slice(0,3);default:return E+E}}s.parseColor=function(u){if(!u)return;let m=u.toLowerCase();if(m.indexOf("rgb:")===0){m=m.slice(4);const _=l.exec(m);if(_){const E=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/E*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/E*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/E*255)]}}else if(m.indexOf("#")===0&&(m=m.slice(1),c.exec(m)&&[3,6,9,12].includes(m.length))){const _=m.length/3,E=[0,0,0];for(let S=0;S<3;++S){const f=parseInt(m.slice(_*S,_*S+_),16);E[S]=_===1?f<<4:_===2?f:_===3?f>>4:f>>8}return E}},s.toRgbString=function(u,m=16){const[_,E,S]=u;return`rgb:${d(_,m)}/${d(E,m)}/${d(S,m)}`}},5770:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PAYLOAD_LIMIT=void 0,s.PAYLOAD_LIMIT=1e7},6351:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DcsHandler=s.DcsParser=void 0;const c=l(482),d=l(8742),u=l(5770),m=[];s.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=m,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}registerHandler(E,S){this._handlers[E]===void 0&&(this._handlers[E]=[]);const f=this._handlers[E];return f.push(S),{dispose:()=>{const p=f.indexOf(S);p!==-1&&f.splice(p,1)}}}clearHandler(E){this._handlers[E]&&delete this._handlers[E]}setHandlerFallback(E){this._handlerFb=E}reset(){if(this._active.length)for(let E=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;E>=0;--E)this._active[E].unhook(!1);this._stack.paused=!1,this._active=m,this._ident=0}hook(E,S){if(this.reset(),this._ident=E,this._active=this._handlers[E]||m,this._active.length)for(let f=this._active.length-1;f>=0;f--)this._active[f].hook(S);else this._handlerFb(this._ident,"HOOK",S)}put(E,S,f){if(this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].put(E,S,f);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(E,S,f))}unhook(E,S=!0){if(this._active.length){let f=!1,p=this._active.length-1,g=!1;if(this._stack.paused&&(p=this._stack.loopPosition-1,f=S,g=this._stack.fallThrough,this._stack.paused=!1),!g&&f===!1){for(;p>=0&&(f=this._active[p].unhook(E),f!==!0);p--)if(f instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=p,this._stack.fallThrough=!1,f;p--}for(;p>=0;p--)if(f=this._active[p].unhook(!1),f instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=p,this._stack.fallThrough=!0,f}else this._handlerFb(this._ident,"UNHOOK",E);this._active=m,this._ident=0}};const _=new d.Params;_.addParam(0),s.DcsHandler=class{constructor(E){this._handler=E,this._data="",this._params=_,this._hitLimit=!1}hook(E){this._params=E.length>1||E.params[0]?E.clone():_,this._data="",this._hitLimit=!1}put(E,S,f){this._hitLimit||(this._data+=(0,c.utf32ToString)(E,S,f),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(E){let S=!1;if(this._hitLimit)S=!1;else if(E&&(S=this._handler(this._data,this._params),S instanceof Promise))return S.then(f=>(this._params=_,this._data="",this._hitLimit=!1,f));return this._params=_,this._data="",this._hitLimit=!1,S}}},2015:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.EscapeSequenceParser=s.VT500_TRANSITION_TABLE=s.TransitionTable=void 0;const c=l(844),d=l(8742),u=l(6242),m=l(6351);class _{constructor(p){this.table=new Uint8Array(p)}setDefault(p,g){this.table.fill(p<<4|g)}add(p,g,h,b){this.table[g<<8|p]=h<<4|b}addMany(p,g,h,b){for(let T=0;T<p.length;T++)this.table[g<<8|p[T]]=h<<4|b}}s.TransitionTable=_;const E=160;s.VT500_TRANSITION_TABLE=function(){const f=new _(4095),p=Array.apply(null,Array(256)).map((N,v)=>v),g=(N,v)=>p.slice(N,v),h=g(32,127),b=g(0,24);b.push(25),b.push.apply(b,g(28,32));const T=g(0,14);let y;for(y in f.setDefault(1,0),f.addMany(h,0,2,0),T)f.addMany([24,26,153,154],y,3,0),f.addMany(g(128,144),y,3,0),f.addMany(g(144,152),y,3,0),f.add(156,y,0,0),f.add(27,y,11,1),f.add(157,y,4,8),f.addMany([152,158,159],y,0,7),f.add(155,y,11,3),f.add(144,y,11,9);return f.addMany(b,0,3,0),f.addMany(b,1,3,1),f.add(127,1,0,1),f.addMany(b,8,0,8),f.addMany(b,3,3,3),f.add(127,3,0,3),f.addMany(b,4,3,4),f.add(127,4,0,4),f.addMany(b,6,3,6),f.addMany(b,5,3,5),f.add(127,5,0,5),f.addMany(b,2,3,2),f.add(127,2,0,2),f.add(93,1,4,8),f.addMany(h,8,5,8),f.add(127,8,5,8),f.addMany([156,27,24,26,7],8,6,0),f.addMany(g(28,32),8,0,8),f.addMany([88,94,95],1,0,7),f.addMany(h,7,0,7),f.addMany(b,7,0,7),f.add(156,7,0,0),f.add(127,7,0,7),f.add(91,1,11,3),f.addMany(g(64,127),3,7,0),f.addMany(g(48,60),3,8,4),f.addMany([60,61,62,63],3,9,4),f.addMany(g(48,60),4,8,4),f.addMany(g(64,127),4,7,0),f.addMany([60,61,62,63],4,0,6),f.addMany(g(32,64),6,0,6),f.add(127,6,0,6),f.addMany(g(64,127),6,0,0),f.addMany(g(32,48),3,9,5),f.addMany(g(32,48),5,9,5),f.addMany(g(48,64),5,0,6),f.addMany(g(64,127),5,7,0),f.addMany(g(32,48),4,9,5),f.addMany(g(32,48),1,9,2),f.addMany(g(32,48),2,9,2),f.addMany(g(48,127),2,10,0),f.addMany(g(48,80),1,10,0),f.addMany(g(81,88),1,10,0),f.addMany([89,90,92],1,10,0),f.addMany(g(96,127),1,10,0),f.add(80,1,11,9),f.addMany(b,9,0,9),f.add(127,9,0,9),f.addMany(g(28,32),9,0,9),f.addMany(g(32,48),9,9,12),f.addMany(g(48,60),9,8,10),f.addMany([60,61,62,63],9,9,10),f.addMany(b,11,0,11),f.addMany(g(32,128),11,0,11),f.addMany(g(28,32),11,0,11),f.addMany(b,10,0,10),f.add(127,10,0,10),f.addMany(g(28,32),10,0,10),f.addMany(g(48,60),10,8,10),f.addMany([60,61,62,63],10,0,11),f.addMany(g(32,48),10,9,12),f.addMany(b,12,0,12),f.add(127,12,0,12),f.addMany(g(28,32),12,0,12),f.addMany(g(32,48),12,9,12),f.addMany(g(48,64),12,0,11),f.addMany(g(64,127),12,12,13),f.addMany(g(64,127),10,12,13),f.addMany(g(64,127),9,12,13),f.addMany(b,13,13,13),f.addMany(h,13,13,13),f.add(127,13,0,13),f.addMany([27,156,24,26],13,14,0),f.add(E,0,2,0),f.add(E,8,5,8),f.add(E,6,0,6),f.add(E,11,0,11),f.add(E,13,13,13),f}();class S extends c.Disposable{constructor(p=s.VT500_TRANSITION_TABLE){super(),this._transitions=p,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new d.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(g,h,b)=>{},this._executeHandlerFb=g=>{},this._csiHandlerFb=(g,h)=>{},this._escHandlerFb=g=>{},this._errorHandlerFb=g=>g,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,c.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this.register(new u.OscParser),this._dcsParser=this.register(new m.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(p,g=[64,126]){let h=0;if(p.prefix){if(p.prefix.length>1)throw new Error("only one byte as prefix supported");if(h=p.prefix.charCodeAt(0),h&&60>h||h>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(p.intermediates){if(p.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let T=0;T<p.intermediates.length;++T){const y=p.intermediates.charCodeAt(T);if(32>y||y>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");h<<=8,h|=y}}if(p.final.length!==1)throw new Error("final must be a single byte");const b=p.final.charCodeAt(0);if(g[0]>b||b>g[1])throw new Error(`final must be in range ${g[0]} .. ${g[1]}`);return h<<=8,h|=b,h}identToString(p){const g=[];for(;p;)g.push(String.fromCharCode(255&p)),p>>=8;return g.reverse().join("")}setPrintHandler(p){this._printHandler=p}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(p,g){const h=this._identifier(p,[48,126]);this._escHandlers[h]===void 0&&(this._escHandlers[h]=[]);const b=this._escHandlers[h];return b.push(g),{dispose:()=>{const T=b.indexOf(g);T!==-1&&b.splice(T,1)}}}clearEscHandler(p){this._escHandlers[this._identifier(p,[48,126])]&&delete this._escHandlers[this._identifier(p,[48,126])]}setEscHandlerFallback(p){this._escHandlerFb=p}setExecuteHandler(p,g){this._executeHandlers[p.charCodeAt(0)]=g}clearExecuteHandler(p){this._executeHandlers[p.charCodeAt(0)]&&delete this._executeHandlers[p.charCodeAt(0)]}setExecuteHandlerFallback(p){this._executeHandlerFb=p}registerCsiHandler(p,g){const h=this._identifier(p);this._csiHandlers[h]===void 0&&(this._csiHandlers[h]=[]);const b=this._csiHandlers[h];return b.push(g),{dispose:()=>{const T=b.indexOf(g);T!==-1&&b.splice(T,1)}}}clearCsiHandler(p){this._csiHandlers[this._identifier(p)]&&delete this._csiHandlers[this._identifier(p)]}setCsiHandlerFallback(p){this._csiHandlerFb=p}registerDcsHandler(p,g){return this._dcsParser.registerHandler(this._identifier(p),g)}clearDcsHandler(p){this._dcsParser.clearHandler(this._identifier(p))}setDcsHandlerFallback(p){this._dcsParser.setHandlerFallback(p)}registerOscHandler(p,g){return this._oscParser.registerHandler(p,g)}clearOscHandler(p){this._oscParser.clearHandler(p)}setOscHandlerFallback(p){this._oscParser.setHandlerFallback(p)}setErrorHandler(p){this._errorHandler=p}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.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(p,g,h,b,T){this._parseStack.state=p,this._parseStack.handlers=g,this._parseStack.handlerPos=h,this._parseStack.transition=b,this._parseStack.chunkPos=T}parse(p,g,h){let b,T=0,y=0,N=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,N=this._parseStack.chunkPos+1;else{if(h===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const v=this._parseStack.handlers;let C=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(h===!1&&C>-1){for(;C>=0&&(b=v[C](this._params),b!==!0);C--)if(b instanceof Promise)return this._parseStack.handlerPos=C,b}this._parseStack.handlers=[];break;case 4:if(h===!1&&C>-1){for(;C>=0&&(b=v[C](),b!==!0);C--)if(b instanceof Promise)return this._parseStack.handlerPos=C,b}this._parseStack.handlers=[];break;case 6:if(T=p[this._parseStack.chunkPos],b=this._dcsParser.unhook(T!==24&&T!==26,h),b)return b;T===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(T=p[this._parseStack.chunkPos],b=this._oscParser.end(T!==24&&T!==26,h),b)return b;T===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,N=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let v=N;v<g;++v){switch(T=p[v],y=this._transitions.table[this.currentState<<8|(T<160?T:E)],y>>4){case 2:for(let P=v+1;;++P){if(P>=g||(T=p[P])<32||T>126&&T<E){this._printHandler(p,v,P),v=P-1;break}if(++P>=g||(T=p[P])<32||T>126&&T<E){this._printHandler(p,v,P),v=P-1;break}if(++P>=g||(T=p[P])<32||T>126&&T<E){this._printHandler(p,v,P),v=P-1;break}if(++P>=g||(T=p[P])<32||T>126&&T<E){this._printHandler(p,v,P),v=P-1;break}}break;case 3:this._executeHandlers[T]?this._executeHandlers[T]():this._executeHandlerFb(T),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:v,code:T,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const C=this._csiHandlers[this._collect<<8|T];let R=C?C.length-1:-1;for(;R>=0&&(b=C[R](this._params),b!==!0);R--)if(b instanceof Promise)return this._preserveStack(3,C,R,y,v),b;R<0&&this._csiHandlerFb(this._collect<<8|T,this._params),this.precedingCodepoint=0;break;case 8:do switch(T){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(T-48)}while(++v<g&&(T=p[v])>47&&T<60);v--;break;case 9:this._collect<<=8,this._collect|=T;break;case 10:const I=this._escHandlers[this._collect<<8|T];let w=I?I.length-1:-1;for(;w>=0&&(b=I[w](),b!==!0);w--)if(b instanceof Promise)return this._preserveStack(4,I,w,y,v),b;w<0&&this._escHandlerFb(this._collect<<8|T),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|T,this._params);break;case 13:for(let P=v+1;;++P)if(P>=g||(T=p[P])===24||T===26||T===27||T>127&&T<E){this._dcsParser.put(p,v,P),v=P-1;break}break;case 14:if(b=this._dcsParser.unhook(T!==24&&T!==26),b)return this._preserveStack(6,[],0,y,v),b;T===27&&(y|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let P=v+1;;P++)if(P>=g||(T=p[P])<32||T>127&&T<E){this._oscParser.put(p,v,P),v=P-1;break}break;case 6:if(b=this._oscParser.end(T!==24&&T!==26),b)return this._preserveStack(5,[],0,y,v),b;T===27&&(y|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&y}}}s.EscapeSequenceParser=S},6242:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OscHandler=s.OscParser=void 0;const c=l(5770),d=l(482),u=[];s.OscParser=class{constructor(){this._state=0,this._active=u,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(m,_){this._handlers[m]===void 0&&(this._handlers[m]=[]);const E=this._handlers[m];return E.push(_),{dispose:()=>{const S=E.indexOf(_);S!==-1&&E.splice(S,1)}}}clearHandler(m){this._handlers[m]&&delete this._handlers[m]}setHandlerFallback(m){this._handlerFb=m}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=u}reset(){if(this._state===2)for(let m=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;m>=0;--m)this._active[m].end(!1);this._stack.paused=!1,this._active=u,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||u,this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].start();else this._handlerFb(this._id,"START")}_put(m,_,E){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(m,_,E);else this._handlerFb(this._id,"PUT",(0,d.utf32ToString)(m,_,E))}start(){this.reset(),this._state=1}put(m,_,E){if(this._state!==3){if(this._state===1)for(;_<E;){const S=m[_++];if(S===59){this._state=2,this._start();break}if(S<48||57<S)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+S-48}this._state===2&&E-_>0&&this._put(m,_,E)}}end(m,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let E=!1,S=this._active.length-1,f=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,E=_,f=this._stack.fallThrough,this._stack.paused=!1),!f&&E===!1){for(;S>=0&&(E=this._active[S].end(m),E!==!0);S--)if(E instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,E;S--}for(;S>=0;S--)if(E=this._active[S].end(!1),E instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,E}else this._handlerFb(this._id,"END",m);this._active=u,this._id=-1,this._state=0}}},s.OscHandler=class{constructor(m){this._handler=m,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(m,_,E){this._hitLimit||(this._data+=(0,d.utf32ToString)(m,_,E),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(m){let _=!1;if(this._hitLimit)_=!1;else if(m&&(_=this._handler(this._data),_ instanceof Promise))return _.then(E=>(this._data="",this._hitLimit=!1,E));return this._data="",this._hitLimit=!1,_}}},8742:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Params=void 0;const l=2147483647;class c{static fromArray(u){const m=new c;if(!u.length)return m;for(let _=Array.isArray(u[0])?1:0;_<u.length;++_){const E=u[_];if(Array.isArray(E))for(let S=0;S<E.length;++S)m.addSubParam(E[S]);else m.addParam(E)}return m}constructor(u=32,m=32){if(this.maxLength=u,this.maxSubParamsLength=m,m>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(u),this.length=0,this._subParams=new Int32Array(m),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(u),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const u=new c(this.maxLength,this.maxSubParamsLength);return u.params.set(this.params),u.length=this.length,u._subParams.set(this._subParams),u._subParamsLength=this._subParamsLength,u._subParamsIdx.set(this._subParamsIdx),u._rejectDigits=this._rejectDigits,u._rejectSubDigits=this._rejectSubDigits,u._digitIsSub=this._digitIsSub,u}toArray(){const u=[];for(let m=0;m<this.length;++m){u.push(this.params[m]);const _=this._subParamsIdx[m]>>8,E=255&this._subParamsIdx[m];E-_>0&&u.push(Array.prototype.slice.call(this._subParams,_,E))}return u}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(u){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=u>l?l:u}}addSubParam(u){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=u>l?l:u,this._subParamsIdx[this.length-1]++}}hasSubParams(u){return(255&this._subParamsIdx[u])-(this._subParamsIdx[u]>>8)>0}getSubParams(u){const m=this._subParamsIdx[u]>>8,_=255&this._subParamsIdx[u];return _-m>0?this._subParams.subarray(m,_):null}getSubParamsAll(){const u={};for(let m=0;m<this.length;++m){const _=this._subParamsIdx[m]>>8,E=255&this._subParamsIdx[m];E-_>0&&(u[m]=this._subParams.slice(_,E))}return u}addDigit(u){let m;if(this._rejectDigits||!(m=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,E=_[m-1];_[m-1]=~E?Math.min(10*E+u,l):u}}s.Params=c},5741:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.AddonManager=void 0,s.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let l=this._addons.length-1;l>=0;l--)this._addons[l].instance.dispose()}loadAddon(l,c){const d={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(d),c.dispose=()=>this._wrappedAddonDispose(d),c.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let c=-1;for(let d=0;d<this._addons.length;d++)if(this._addons[d]===l){c=d;break}if(c===-1)throw new Error("Could not dispose an addon that has not been loaded");l.isDisposed=!0,l.dispose.apply(l.instance),this._addons.splice(c,1)}}},8771:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferApiView=void 0;const c=l(3785),d=l(511);s.BufferApiView=class{constructor(u,m){this._buffer=u,this.type=m}init(u){return this._buffer=u,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(u){const m=this._buffer.lines.get(u);if(m)return new c.BufferLineApiView(m)}getNullCell(){return new d.CellData}}},3785:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLineApiView=void 0;const c=l(511);s.BufferLineApiView=class{constructor(d){this._line=d}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(d,u){if(!(d<0||d>=this._line.length))return u?(this._line.loadCell(d,u),u):this._line.loadCell(d,new c.CellData)}translateToString(d,u,m){return this._line.translateToString(d,u,m)}}},8285:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferNamespaceApi=void 0;const c=l(8771),d=l(8460),u=l(844);class m extends u.Disposable{constructor(E){super(),this._core=E,this._onBufferChange=this.register(new d.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.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 new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}s.BufferNamespaceApi=m},7975:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ParserApi=void 0,s.ParserApi=class{constructor(l){this._core=l}registerCsiHandler(l,c){return this._core.registerCsiHandler(l,d=>c(d.toArray()))}addCsiHandler(l,c){return this.registerCsiHandler(l,c)}registerDcsHandler(l,c){return this._core.registerDcsHandler(l,(d,u)=>c(d,u.toArray()))}addDcsHandler(l,c){return this.registerDcsHandler(l,c)}registerEscHandler(l,c){return this._core.registerEscHandler(l,c)}addEscHandler(l,c){return this.registerEscHandler(l,c)}registerOscHandler(l,c){return this._core.registerOscHandler(l,c)}addOscHandler(l,c){return this.registerOscHandler(l,c)}}},7090:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeApi=void 0,s.UnicodeApi=class{constructor(l){this._core=l}register(l){this._core.unicodeService.register(l)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(l){this._core.unicodeService.activeVersion=l}}},744:function(o,s,l){var c=this&&this.__decorate||function(f,p,g,h){var b,T=arguments.length,y=T<3?p:h===null?h=Object.getOwnPropertyDescriptor(p,g):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(f,p,g,h);else for(var N=f.length-1;N>=0;N--)(b=f[N])&&(y=(T<3?b(y):T>3?b(p,g,y):b(p,g))||y);return T>3&&y&&Object.defineProperty(p,g,y),y},d=this&&this.__param||function(f,p){return function(g,h){p(g,h,f)}};Object.defineProperty(s,"__esModule",{value:!0}),s.BufferService=s.MINIMUM_ROWS=s.MINIMUM_COLS=void 0;const u=l(8460),m=l(844),_=l(5295),E=l(2585);s.MINIMUM_COLS=2,s.MINIMUM_ROWS=1;let S=s.BufferService=class extends m.Disposable{get buffer(){return this.buffers.active}constructor(f){super(),this.isUserScrolling=!1,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(f.rawOptions.cols||0,s.MINIMUM_COLS),this.rows=Math.max(f.rawOptions.rows||0,s.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(f,this))}resize(f,p){this.cols=f,this.rows=p,this.buffers.resize(f,p),this._onResize.fire({cols:f,rows:p})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(f,p=!1){const g=this.buffer;let h;h=this._cachedBlankLine,h&&h.length===this.cols&&h.getFg(0)===f.fg&&h.getBg(0)===f.bg||(h=g.getBlankLine(f,p),this._cachedBlankLine=h),h.isWrapped=p;const b=g.ybase+g.scrollTop,T=g.ybase+g.scrollBottom;if(g.scrollTop===0){const y=g.lines.isFull;T===g.lines.length-1?y?g.lines.recycle().copyFrom(h):g.lines.push(h.clone()):g.lines.splice(T+1,0,h.clone()),y?this.isUserScrolling&&(g.ydisp=Math.max(g.ydisp-1,0)):(g.ybase++,this.isUserScrolling||g.ydisp++)}else{const y=T-b+1;g.lines.shiftElements(b+1,y-1,-1),g.lines.set(T,h.clone())}this.isUserScrolling||(g.ydisp=g.ybase),this._onScroll.fire(g.ydisp)}scrollLines(f,p,g){const h=this.buffer;if(f<0){if(h.ydisp===0)return;this.isUserScrolling=!0}else f+h.ydisp>=h.ybase&&(this.isUserScrolling=!1);const b=h.ydisp;h.ydisp=Math.max(Math.min(h.ydisp+f,h.ybase),0),b!==h.ydisp&&(p||this._onScroll.fire(h.ydisp))}};s.BufferService=S=c([d(0,E.IOptionsService)],S)},7994:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CharsetService=void 0,s.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(l){this.glevel=l,this.charset=this._charsets[l]}setgCharset(l,c){this._charsets[l]=c,this.glevel===l&&(this.charset=c)}}},1753:function(o,s,l){var c=this&&this.__decorate||function(h,b,T,y){var N,v=arguments.length,C=v<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,T):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(h,b,T,y);else for(var R=h.length-1;R>=0;R--)(N=h[R])&&(C=(v<3?N(C):v>3?N(b,T,C):N(b,T))||C);return v>3&&C&&Object.defineProperty(b,T,C),C},d=this&&this.__param||function(h,b){return function(T,y){b(T,y,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreMouseService=void 0;const u=l(2585),m=l(8460),_=l(844),E={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:h=>h.button!==4&&h.action===1&&(h.ctrl=!1,h.alt=!1,h.shift=!1,!0)},VT200:{events:19,restrict:h=>h.action!==32},DRAG:{events:23,restrict:h=>h.action!==32||h.button!==3},ANY:{events:31,restrict:h=>!0}};function S(h,b){let T=(h.ctrl?16:0)|(h.shift?4:0)|(h.alt?8:0);return h.button===4?(T|=64,T|=h.action):(T|=3&h.button,4&h.button&&(T|=64),8&h.button&&(T|=128),h.action===32?T|=32:h.action!==0||b||(T|=3)),T}const f=String.fromCharCode,p={DEFAULT:h=>{const b=[S(h,!1)+32,h.col+32,h.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1B[M${f(b[0])}${f(b[1])}${f(b[2])}`},SGR:h=>{const b=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${S(h,!0)};${h.col};${h.row}${b}`},SGR_PIXELS:h=>{const b=h.action===0&&h.button!==4?"m":"M";return`\x1B[<${S(h,!0)};${h.x};${h.y}${b}`}};let g=s.CoreMouseService=class extends _.Disposable{constructor(h,b){super(),this._bufferService=h,this._coreService=b,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new m.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const T of Object.keys(E))this.addProtocol(T,E[T]);for(const T of Object.keys(p))this.addEncoding(T,p[T]);this.reset()}addProtocol(h,b){this._protocols[h]=b}addEncoding(h,b){this._encodings[h]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(h){if(!this._protocols[h])throw new Error(`unknown protocol "${h}"`);this._activeProtocol=h,this._onProtocolChange.fire(this._protocols[h].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(h){if(!this._encodings[h])throw new Error(`unknown encoding "${h}"`);this._activeEncoding=h}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(h){if(h.col<0||h.col>=this._bufferService.cols||h.row<0||h.row>=this._bufferService.rows||h.button===4&&h.action===32||h.button===3&&h.action!==32||h.button!==4&&(h.action===2||h.action===3)||(h.col++,h.row++,h.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,h,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(h))return!1;const b=this._encodings[this._activeEncoding](h);return b&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=h,!0}explainEvents(h){return{down:!!(1&h),up:!!(2&h),drag:!!(4&h),move:!!(8&h),wheel:!!(16&h)}}_equalEvents(h,b,T){if(T){if(h.x!==b.x||h.y!==b.y)return!1}else if(h.col!==b.col||h.row!==b.row)return!1;return h.button===b.button&&h.action===b.action&&h.ctrl===b.ctrl&&h.alt===b.alt&&h.shift===b.shift}};s.CoreMouseService=g=c([d(0,u.IBufferService),d(1,u.ICoreService)],g)},6975:function(o,s,l){var c=this&&this.__decorate||function(g,h,b,T){var y,N=arguments.length,v=N<3?h:T===null?T=Object.getOwnPropertyDescriptor(h,b):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(g,h,b,T);else for(var C=g.length-1;C>=0;C--)(y=g[C])&&(v=(N<3?y(v):N>3?y(h,b,v):y(h,b))||v);return N>3&&v&&Object.defineProperty(h,b,v),v},d=this&&this.__param||function(g,h){return function(b,T){h(b,T,g)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreService=void 0;const u=l(1439),m=l(8460),_=l(844),E=l(2585),S=Object.freeze({insertMode:!1}),f=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let p=s.CoreService=class extends _.Disposable{constructor(g,h,b){super(),this._bufferService=g,this._logService=h,this._optionsService=b,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new m.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new m.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new m.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new m.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,u.clone)(S),this.decPrivateModes=(0,u.clone)(f)}reset(){this.modes=(0,u.clone)(S),this.decPrivateModes=(0,u.clone)(f)}triggerDataEvent(g,h=!1){if(this._optionsService.rawOptions.disableStdin)return;const b=this._bufferService.buffer;h&&this._optionsService.rawOptions.scrollOnUserInput&&b.ybase!==b.ydisp&&this._onRequestScrollToBottom.fire(),h&&this._onUserInput.fire(),this._logService.debug(`sending data "${g}"`,()=>g.split("").map(T=>T.charCodeAt(0))),this._onData.fire(g)}triggerBinaryEvent(g){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${g}"`,()=>g.split("").map(h=>h.charCodeAt(0))),this._onBinary.fire(g))}};s.CoreService=p=c([d(0,E.IBufferService),d(1,E.ILogService),d(2,E.IOptionsService)],p)},9074:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DecorationService=void 0;const c=l(8055),d=l(8460),u=l(844),m=l(6106);let _=0,E=0;class S extends u.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new m.SortedList(g=>g==null?void 0:g.marker.line),this._onDecorationRegistered=this.register(new d.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new d.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,u.toDisposable)(()=>this.reset()))}registerDecoration(g){if(g.marker.isDisposed)return;const h=new f(g);if(h){const b=h.marker.onDispose(()=>h.dispose());h.onDispose(()=>{h&&(this._decorations.delete(h)&&this._onDecorationRemoved.fire(h),b.dispose())}),this._decorations.insert(h),this._onDecorationRegistered.fire(h)}return h}reset(){for(const g of this._decorations.values())g.dispose();this._decorations.clear()}*getDecorationsAtCell(g,h,b){var T,y,N;let v=0,C=0;for(const R of this._decorations.getKeyIterator(h))v=(T=R.options.x)!==null&&T!==void 0?T:0,C=v+((y=R.options.width)!==null&&y!==void 0?y:1),g>=v&&g<C&&(!b||((N=R.options.layer)!==null&&N!==void 0?N:"bottom")===b)&&(yield R)}forEachDecorationAtCell(g,h,b,T){this._decorations.forEachByKey(h,y=>{var N,v,C;_=(N=y.options.x)!==null&&N!==void 0?N:0,E=_+((v=y.options.width)!==null&&v!==void 0?v:1),g>=_&&g<E&&(!b||((C=y.options.layer)!==null&&C!==void 0?C:"bottom")===b)&&T(y)})}}s.DecorationService=S;class f extends u.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(g){super(),this.options=g,this.onRenderEmitter=this.register(new d.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new d.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=g.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.InstantiationService=s.ServiceCollection=void 0;const c=l(2585),d=l(8343);class u{constructor(..._){this._entries=new Map;for(const[E,S]of _)this.set(E,S)}set(_,E){const S=this._entries.get(_);return this._entries.set(_,E),S}forEach(_){for(const[E,S]of this._entries.entries())_(E,S)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}s.ServiceCollection=u,s.InstantiationService=class{constructor(){this._services=new u,this._services.set(c.IInstantiationService,this)}setService(m,_){this._services.set(m,_)}getService(m){return this._services.get(m)}createInstance(m,..._){const E=(0,d.getServiceDependencies)(m).sort((p,g)=>p.index-g.index),S=[];for(const p of E){const g=this._services.get(p.id);if(!g)throw new Error(`[createInstance] ${m.name} depends on UNKNOWN service ${p.id}.`);S.push(g)}const f=E.length>0?E[0].index:_.length;if(_.length!==f)throw new Error(`[createInstance] First service dependency of ${m.name} at position ${f+1} conflicts with ${_.length} static arguments`);return new m(..._,...S)}}},7866:function(o,s,l){var c=this&&this.__decorate||function(f,p,g,h){var b,T=arguments.length,y=T<3?p:h===null?h=Object.getOwnPropertyDescriptor(p,g):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(f,p,g,h);else for(var N=f.length-1;N>=0;N--)(b=f[N])&&(y=(T<3?b(y):T>3?b(p,g,y):b(p,g))||y);return T>3&&y&&Object.defineProperty(p,g,y),y},d=this&&this.__param||function(f,p){return function(g,h){p(g,h,f)}};Object.defineProperty(s,"__esModule",{value:!0}),s.traceCall=s.setTraceLogger=s.LogService=void 0;const u=l(844),m=l(2585),_={trace:m.LogLevelEnum.TRACE,debug:m.LogLevelEnum.DEBUG,info:m.LogLevelEnum.INFO,warn:m.LogLevelEnum.WARN,error:m.LogLevelEnum.ERROR,off:m.LogLevelEnum.OFF};let E,S=s.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(f){super(),this._optionsService=f,this._logLevel=m.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),E=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(f){for(let p=0;p<f.length;p++)typeof f[p]=="function"&&(f[p]=f[p]())}_log(f,p,g){this._evalLazyOptionalParams(g),f.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+p,...g)}trace(f,...p){var g,h;this._logLevel<=m.LogLevelEnum.TRACE&&this._log((h=(g=this._optionsService.options.logger)===null||g===void 0?void 0:g.trace.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,f,p)}debug(f,...p){var g,h;this._logLevel<=m.LogLevelEnum.DEBUG&&this._log((h=(g=this._optionsService.options.logger)===null||g===void 0?void 0:g.debug.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.log,f,p)}info(f,...p){var g,h;this._logLevel<=m.LogLevelEnum.INFO&&this._log((h=(g=this._optionsService.options.logger)===null||g===void 0?void 0:g.info.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.info,f,p)}warn(f,...p){var g,h;this._logLevel<=m.LogLevelEnum.WARN&&this._log((h=(g=this._optionsService.options.logger)===null||g===void 0?void 0:g.warn.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.warn,f,p)}error(f,...p){var g,h;this._logLevel<=m.LogLevelEnum.ERROR&&this._log((h=(g=this._optionsService.options.logger)===null||g===void 0?void 0:g.error.bind(this._optionsService.options.logger))!==null&&h!==void 0?h:console.error,f,p)}};s.LogService=S=c([d(0,m.IOptionsService)],S),s.setTraceLogger=function(f){E=f},s.traceCall=function(f,p,g){if(typeof g.value!="function")throw new Error("not supported");const h=g.value;g.value=function(...b){if(E.logLevel!==m.LogLevelEnum.TRACE)return h.apply(this,b);E.trace(`GlyphRenderer#${h.name}(${b.map(y=>JSON.stringify(y)).join(", ")})`);const T=h.apply(this,b);return E.trace(`GlyphRenderer#${h.name} return`,T),T}}},7302:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OptionsService=s.DEFAULT_OPTIONS=void 0;const c=l(8460),d=l(844),u=l(6114);s.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:u.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const m=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends d.Disposable{constructor(S){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const f=Object.assign({},s.DEFAULT_OPTIONS);for(const p in S)if(p in f)try{const g=S[p];f[p]=this._sanitizeAndValidateOption(p,g)}catch(g){console.error(g)}this.rawOptions=f,this.options=Object.assign({},f),this._setupOptions()}onSpecificOptionChange(S,f){return this.onOptionChange(p=>{p===S&&f(this.rawOptions[S])})}onMultipleOptionChange(S,f){return this.onOptionChange(p=>{S.indexOf(p)!==-1&&f()})}_setupOptions(){const S=p=>{if(!(p in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${p}"`);return this.rawOptions[p]},f=(p,g)=>{if(!(p in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${p}"`);g=this._sanitizeAndValidateOption(p,g),this.rawOptions[p]!==g&&(this.rawOptions[p]=g,this._onOptionChange.fire(p))};for(const p in this.rawOptions){const g={get:S.bind(this,p),set:f.bind(this,p)};Object.defineProperty(this.options,p,g)}}_sanitizeAndValidateOption(S,f){switch(S){case"cursorStyle":if(f||(f=s.DEFAULT_OPTIONS[S]),!function(p){return p==="block"||p==="underline"||p==="bar"}(f))throw new Error(`"${f}" is not a valid value for ${S}`);break;case"wordSeparator":f||(f=s.DEFAULT_OPTIONS[S]);break;case"fontWeight":case"fontWeightBold":if(typeof f=="number"&&1<=f&&f<=1e3)break;f=m.includes(f)?f:s.DEFAULT_OPTIONS[S];break;case"cursorWidth":f=Math.floor(f);case"lineHeight":case"tabStopWidth":if(f<1)throw new Error(`${S} cannot be less than 1, value: ${f}`);break;case"minimumContrastRatio":f=Math.max(1,Math.min(21,Math.round(10*f)/10));break;case"scrollback":if((f=Math.min(f,4294967295))<0)throw new Error(`${S} cannot be less than 0, value: ${f}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(f<=0)throw new Error(`${S} cannot be less than or equal to 0, value: ${f}`);break;case"rows":case"cols":if(!f&&f!==0)throw new Error(`${S} must be numeric, value: ${f}`);break;case"windowsPty":f=f??{}}return f}}s.OptionsService=_},2660:function(o,s,l){var c=this&&this.__decorate||function(_,E,S,f){var p,g=arguments.length,h=g<3?E:f===null?f=Object.getOwnPropertyDescriptor(E,S):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")h=Reflect.decorate(_,E,S,f);else for(var b=_.length-1;b>=0;b--)(p=_[b])&&(h=(g<3?p(h):g>3?p(E,S,h):p(E,S))||h);return g>3&&h&&Object.defineProperty(E,S,h),h},d=this&&this.__param||function(_,E){return function(S,f){E(S,f,_)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkService=void 0;const u=l(2585);let m=s.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const E=this._bufferService.buffer;if(_.id===void 0){const b=E.addMarker(E.ybase+E.y),T={data:_,id:this._nextId++,lines:[b]};return b.onDispose(()=>this._removeMarkerFromLink(T,b)),this._dataByLinkId.set(T.id,T),T.id}const S=_,f=this._getEntryIdKey(S),p=this._entriesWithId.get(f);if(p)return this.addLineToLink(p.id,E.ybase+E.y),p.id;const g=E.addMarker(E.ybase+E.y),h={id:this._nextId++,key:this._getEntryIdKey(S),data:S,lines:[g]};return g.onDispose(()=>this._removeMarkerFromLink(h,g)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(_,E){const S=this._dataByLinkId.get(_);if(S&&S.lines.every(f=>f.line!==E)){const f=this._bufferService.buffer.addMarker(E);S.lines.push(f),f.onDispose(()=>this._removeMarkerFromLink(S,f))}}getLinkData(_){var E;return(E=this._dataByLinkId.get(_))===null||E===void 0?void 0:E.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,E){const S=_.lines.indexOf(E);S!==-1&&(_.lines.splice(S,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};s.OscLinkService=m=c([d(0,u.IBufferService)],m)},8343:(o,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createDecorator=s.getServiceDependencies=s.serviceRegistry=void 0;const l="di$target",c="di$dependencies";s.serviceRegistry=new Map,s.getServiceDependencies=function(d){return d[c]||[]},s.createDecorator=function(d){if(s.serviceRegistry.has(d))return s.serviceRegistry.get(d);const u=function(m,_,E){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(S,f,p){f[l]===f?f[c].push({id:S,index:p}):(f[c]=[{id:S,index:p}],f[l]=f)})(u,m,E)};return u.toString=()=>d,s.serviceRegistry.set(d,u),u}},2585:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IDecorationService=s.IUnicodeService=s.IOscLinkService=s.IOptionsService=s.ILogService=s.LogLevelEnum=s.IInstantiationService=s.ICharsetService=s.ICoreService=s.ICoreMouseService=s.IBufferService=void 0;const c=l(8343);var d;s.IBufferService=(0,c.createDecorator)("BufferService"),s.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),s.ICoreService=(0,c.createDecorator)("CoreService"),s.ICharsetService=(0,c.createDecorator)("CharsetService"),s.IInstantiationService=(0,c.createDecorator)("InstantiationService"),function(u){u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.OFF=5]="OFF"}(d||(s.LogLevelEnum=d={})),s.ILogService=(0,c.createDecorator)("LogService"),s.IOptionsService=(0,c.createDecorator)("OptionsService"),s.IOscLinkService=(0,c.createDecorator)("OscLinkService"),s.IUnicodeService=(0,c.createDecorator)("UnicodeService"),s.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(o,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeService=void 0;const c=l(8460),d=l(225);s.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const u=new d.UnicodeV6;this.register(u),this._active=u.version,this._activeProvider=u}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(u){if(!this._providers[u])throw new Error(`unknown Unicode version "${u}"`);this._active=u,this._activeProvider=this._providers[u],this._onChange.fire(u)}register(u){this._providers[u.version]=u}wcwidth(u){return this._activeProvider.wcwidth(u)}getStringCellWidth(u){let m=0;const _=u.length;for(let E=0;E<_;++E){let S=u.charCodeAt(E);if(55296<=S&&S<=56319){if(++E>=_)return m+this.wcwidth(S);const f=u.charCodeAt(E);56320<=f&&f<=57343?S=1024*(S-55296)+f-56320+65536:m+=this.wcwidth(f)}m+=this.wcwidth(S)}return m}}}},r={};function i(o){var s=r[o];if(s!==void 0)return s.exports;var l=r[o]={exports:{}};return n[o].call(l.exports,l,l.exports,i),l.exports}var a={};return(()=>{var o=a;Object.defineProperty(o,"__esModule",{value:!0}),o.Terminal=void 0;const s=i(9042),l=i(3236),c=i(844),d=i(5741),u=i(8285),m=i(7975),_=i(7090),E=["cols","rows"];class S extends c.Disposable{constructor(p){super(),this._core=this.register(new l.Terminal(p)),this._addonManager=this.register(new d.AddonManager),this._publicOptions=Object.assign({},this._core.options);const g=b=>this._core.options[b],h=(b,T)=>{this._checkReadonlyOptions(b),this._core.options[b]=T};for(const b in this._core.options){const T={get:g.bind(this,b),set:h.bind(this,b)};Object.defineProperty(this._publicOptions,b,T)}}_checkReadonlyOptions(p){if(E.includes(p))throw new Error(`Option "${p}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new m.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new u.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const p=this._core.coreService.decPrivateModes;let g="none";switch(this._core.coreMouseService.activeProtocol){case"X10":g="x10";break;case"VT200":g="vt200";break;case"DRAG":g="drag";break;case"ANY":g="any"}return{applicationCursorKeysMode:p.applicationCursorKeys,applicationKeypadMode:p.applicationKeypad,bracketedPasteMode:p.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:g,originMode:p.origin,reverseWraparoundMode:p.reverseWraparound,sendFocusMode:p.sendFocus,wraparoundMode:p.wraparound}}get options(){return this._publicOptions}set options(p){for(const g in p)this._publicOptions[g]=p[g]}blur(){this._core.blur()}focus(){this._core.focus()}resize(p,g){this._verifyIntegers(p,g),this._core.resize(p,g)}open(p){this._core.open(p)}attachCustomKeyEventHandler(p){this._core.attachCustomKeyEventHandler(p)}registerLinkProvider(p){return this._core.registerLinkProvider(p)}registerCharacterJoiner(p){return this._checkProposedApi(),this._core.registerCharacterJoiner(p)}deregisterCharacterJoiner(p){this._checkProposedApi(),this._core.deregisterCharacterJoiner(p)}registerMarker(p=0){return this._verifyIntegers(p),this._core.registerMarker(p)}registerDecoration(p){var g,h,b;return this._checkProposedApi(),this._verifyPositiveIntegers((g=p.x)!==null&&g!==void 0?g:0,(h=p.width)!==null&&h!==void 0?h:0,(b=p.height)!==null&&b!==void 0?b:0),this._core.registerDecoration(p)}hasSelection(){return this._core.hasSelection()}select(p,g,h){this._verifyIntegers(p,g,h),this._core.select(p,g,h)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(p,g){this._verifyIntegers(p,g),this._core.selectLines(p,g)}dispose(){super.dispose()}scrollLines(p){this._verifyIntegers(p),this._core.scrollLines(p)}scrollPages(p){this._verifyIntegers(p),this._core.scrollPages(p)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(p){this._verifyIntegers(p),this._core.scrollToLine(p)}clear(){this._core.clear()}write(p,g){this._core.write(p,g)}writeln(p,g){this._core.write(p),this._core.write(`\r
85
- `,g)}paste(p){this._core.paste(p)}refresh(p,g){this._verifyIntegers(p,g),this._core.refresh(p,g)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(p){this._addonManager.loadAddon(this,p)}static get strings(){return s}_verifyIntegers(...p){for(const g of p)if(g===1/0||isNaN(g)||g%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...p){for(const g of p)if(g&&(g===1/0||isNaN(g)||g%1!=0||g<0))throw new Error("This API only accepts positive integers")}}o.Terminal=S})(),a})())})(mD);var rP=mD.exports,gD={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(self,()=>(()=>{var n={};return(()=>{var r=n;Object.defineProperty(r,"__esModule",{value:!0}),r.FitAddon=void 0,r.FitAddon=class{activate(i){this._terminal=i}dispose(){}fit(){const i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;const a=this._terminal._core;this._terminal.rows===i.rows&&this._terminal.cols===i.cols||(a._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const i=this._terminal._core,a=i._renderService.dimensions;if(a.css.cell.width===0||a.css.cell.height===0)return;const o=this._terminal.options.scrollback===0?0:i.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),c=Math.max(0,parseInt(s.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),u=l-(parseInt(d.getPropertyValue("padding-top"))+parseInt(d.getPropertyValue("padding-bottom"))),m=c-(parseInt(d.getPropertyValue("padding-right"))+parseInt(d.getPropertyValue("padding-left")))-o;return{cols:Math.max(2,Math.floor(m/a.css.cell.width)),rows:Math.max(1,Math.floor(u/a.css.cell.height))}}}})(),n})())})(gD);var iP=gD.exports;class hD extends Error{constructor(t,n,r){super(t),this.status=n,this.statusText=r,this.name="ApiError"}}class ED extends hD{constructor(t="Authentication required"){super(t,401,"Unauthorized"),this.name="AuthenticationError"}}async function aP(e,t){try{const n=await e.json();if(n!=null&&n.error&&typeof n.error=="string")return n.error}catch{}return t}async function QE(e,t={}){const{credentials:n="include",errorPrefix:r="Request failed",...i}=t,a=await fetch(e,{...i,credentials:n});if(a.status===401)throw new ED;if(!a.ok){const o=await aP(a,`${r}: ${a.status}`);throw new hD(o,a.status,a.statusText)}return await a.json()}async function ma(e,t={}){return QE(e,{...t,method:"GET"})}async function As(e,t,n={}){return QE(e,{...n,method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:t?JSON.stringify(t):void 0})}async function SD(e,t,n={}){return QE(e,{...n,method:"DELETE",headers:{"Content-Type":"application/json",...n.headers},body:t?JSON.stringify(t):void 0})}function Yt(e){return e instanceof ED}async function sP(){return(await ma("/api/sessions",{errorPrefix:"Failed to fetch sessions"})).sessions||[]}async function oP(e,t,n,r=null,i=null){const a={org:e,repo:t,branch:n};r!=null&&(a.command=r),i!=null&&typeof i=="string"&&(a.prompt=i);const o=await As("/api/terminal/open",a,{errorPrefix:"Failed to open terminal"});return{sessionId:o&&o.sessionId?o.sessionId:null,created:o&&typeof o.created=="boolean"?o.created:!1,log:o&&typeof o.log=="string"?o.log:""}}function lP({onAuthExpired:e,onSessionRemoved:t}={}){const[n,r]=D.useState("disconnected"),[i,a]=D.useState(null),o=D.useRef(null),s=D.useRef(null),l=D.useRef(null),c=D.useRef(null),d=D.useRef(null),u=D.useRef(!1),m=D.useRef(!1),_=D.useRef(new Map),E=D.useRef(new Map),S=D.useCallback(()=>{if(!(!s.current||!l.current)&&(l.current.fit(),c.current&&c.current.readyState===WebSocket.OPEN)){const{cols:T,rows:y}=s.current;c.current.send(JSON.stringify({type:"resize",cols:T,rows:y}))}},[]),f=D.useCallback(()=>{if(c.current){try{c.current.close()}catch{}c.current=null}},[]),p=D.useCallback(()=>{if(s.current){try{s.current.dispose()}catch{}s.current=null}l.current=null,o.current&&(o.current.innerHTML="")},[]),g=D.useCallback(T=>{if(p(),!o.current)return;const y=new rP.Terminal({allowTransparency:!0,convertEol:!0,cursorBlink:!0,fontFamily:"JetBrains Mono, Menlo, Consolas, monospace",fontSize:13,theme:{background:"#111111",foreground:"#f4f4f5",cursor:"#f4f4f5"},scrollback:8e3}),N=new iP.FitAddon;y.loadAddon(N),s.current=y,l.current=N,y.open(o.current),y.focus(),T&&y.write(T),y.onData(v=>{c.current&&c.current.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"input",data:v}))}),y.onResize(({cols:v,rows:C})=>{c.current&&c.current.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"resize",cols:v,rows:C}))}),requestAnimationFrame(()=>{S(),y.focus()})},[p,S]),h=D.useCallback(T=>{if(!T)return;const N=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/terminal/socket?sessionId=${encodeURIComponent(T)}`,v=new WebSocket(N);c.current=v,v.addEventListener("open",()=>{r("connected"),S()}),v.addEventListener("message",C=>{let R;try{R=JSON.parse(C.data)}catch{return}if(R.type==="output")R.reset&&s.current&&(s.current.reset(),S()),s.current&&R.chunk&&s.current.write(R.chunk);else if(R.type==="exit"){m.current=!0,r("closed");const I=E.current.get(T);I&&(_.current.delete(I),E.current.delete(T),t&&t(I))}else if(R.type==="init")!u.current&&R.log&&s.current&&s.current.write(R.log),u.current=!1,R.closed&&(m.current=!0,r("closed"));else if(R.type==="error"){console.error(R.message||"Terminal connection error"),r("error");const I=E.current.get(T);I&&(_.current.delete(I),E.current.delete(T),t&&t(I))}}),v.addEventListener("close",()=>{m.current?r("closed"):r("disconnected")}),v.addEventListener("error",()=>{r("error")})},[S,t]),b=D.useCallback(async(T,y={})=>{const{command:N,prompt:v}=y;if(f(),!T){p(),a(null),r("disconnected");return}r("connecting"),m.current=!1,u.current=!0;try{const C=await oP(T.org,T.repo,T.branch,N||null,v||null),R=C.sessionId,I=C.created;if(!R)throw new Error("Invalid session response");a(R);const w=`${T.org}::${T.repo}::${T.branch}`,P=_.current.get(w);P&&P!==R&&E.current.delete(P),_.current.set(w,R),E.current.set(R,w);const U=C.log||"";return g(U),h(R),{sessionId:R,created:I}}catch(C){throw Yt(C)?(e&&e(),new Error("AUTH_REQUIRED")):(console.error("Failed to open terminal session",C),p(),a(null),r("error"),C)}},[h,f,p,g,e]);return D.useEffect(()=>()=>{f(),p(),d.current&&d.current.disconnect()},[f,p]),D.useEffect(()=>{if(!o.current)return;const T=new ResizeObserver(()=>{S()});return T.observe(o.current),d.current=T,()=>T.disconnect()},[S]),{terminalContainerRef:o,terminalStatus:n,sessionId:i,sessionMapRef:_,sessionKeyByIdRef:E,openTerminal:b,disposeSocket:f,disposeTerminal:p,sendResize:S}}function cP(){const e=D.useRef(new Set),t=D.useRef(new Map),[n,r]=D.useState(()=>new Map),i=D.useRef(new Map),[a,o]=D.useState(()=>new Map),s=D.useRef(new Map),l=D.useRef([]),c=D.useRef(null),d=D.useCallback(()=>{if(typeof window>"u"||typeof window.Notification!="function"){l.current=[];return}if(window.Notification.permission!=="granted")return;const p=l.current;l.current=[],p.forEach(({title:g,options:h})=>{try{new window.Notification(g,h)}catch{}})},[]),u=D.useCallback(p=>{const g=l.current,h=g.findIndex(b=>b.key===p.key);h>=0?l.current=[...g.slice(0,h),p,...g.slice(h+1)]:l.current=[...g,p]},[]),m=D.useCallback(()=>{if(typeof window>"u"||typeof window.Notification!="function")return l.current=[],Promise.resolve("denied");const p=window.Notification.permission;if(p==="granted"||p==="denied")return p==="granted"?d():l.current=[],Promise.resolve(p);if(c.current)return c.current;try{const g=window.Notification.requestPermission(),h=g instanceof Promise?g:Promise.resolve(g);return c.current=h.then(b=>(c.current=null,b==="granted"?d():l.current=[],b)).catch(()=>(c.current=null,l.current=[],"denied")),c.current}catch{return l.current=[],Promise.resolve("denied")}},[d]),_=D.useCallback((p,g,h,b)=>{if(typeof window>"u"||typeof window.Notification!="function")return;const T="Worktree idle",y={body:`${g}/${h}: ${b} work has finished.`,tag:p},N=window.Notification.permission;if(N==="granted"){d();try{new window.Notification(T,y)}catch{}return}N!=="denied"&&(u({key:p,title:T,options:y}),m())},[u,d,m]),E=D.useCallback(p=>{if(p){if(e.current.delete(p),t.current.has(p)){const g=new Map(t.current);g.delete(p),t.current=g,r(new Map(g))}if(i.current.has(p)){const g=new Map(i.current);g.delete(p),i.current=g,o(new Map(g))}if(l.current.length>0){const g=l.current.filter(h=>h.key!==p);g.length!==l.current.length&&(l.current=g)}}},[o,r]),S=D.useCallback(p=>{const g=t.current,h=i.current,b=s.current,T=new Map,y=new Map;Array.isArray(p)&&p.forEach(R=>{if(!R||typeof R!="object")return;const I=typeof R.org=="string"?R.org:null,w=typeof R.repo=="string"?R.repo:null,P=typeof R.branch=="string"?R.branch:null;if(!I||!w||!P)return;const U=`${I}::${w}::${P}`,G=!!R.idle,L=_D(R.lastActivityAt),F=y.get(U);if(!F){y.set(U,{org:I,repo:w,branch:P,idle:G,lastActivityAtMs:L});return}F.idle=F.idle&&G,ln(L)&&(!ln(F.lastActivityAtMs)||L>F.lastActivityAtMs)&&(F.lastActivityAtMs=L)});const N=new Set,v=new Map;y.forEach((R,I)=>{const w=ln(R.lastActivityAtMs)?R.lastActivityAtMs:null;N.add(I),v.set(I,{org:R.org,repo:R.repo,branch:R.branch,idle:R.idle,lastActivityAtMs:w,lastActivityAt:ln(w)?new Date(w).toISOString():null});const P=g.get(I),U=!!(P!=null&&P.idle),G=b.has(I)?b.get(I)??null:null,L=h.get(I),F=lh(R,L);if(R.branch!=="main"&&R.idle&&!F){const M=ln(w)?w:null,A=b.has(I),B=A&&G===M;T.set(I,M),(!U||!A||!B)&&_(I,R.org,R.repo,R.branch)}}),e.current=N,t.current=v,r(new Map(v)),s.current=T;const C=new Map;i.current.forEach((R,I)=>{const w=v.get(I);if(!w)return;const P=pD(R);if(!lh(w,P))return;const U=qo(w);ln(U)&&(P.lastSeenActivityMs=U),C.set(I,P)}),i.current=C,o(new Map(C))},[_]),f=D.useCallback((p,g,h)=>{const b=`${p}::${g}::${h}`,T=t.current.get(b);if(T&&T.idle){const y=new Map(i.current);y.set(b,KE(qo(T))),i.current=y,o(new Map(y))}},[]);return{knownSessionsRef:e,sessionMetadataRef:t,sessionMetadataSnapshot:n,setSessionMetadataSnapshot:r,idleAcknowledgementsRef:i,idleAcknowledgementsSnapshot:a,setIdleAcknowledgementsSnapshot:o,removeTrackedSession:E,syncKnownSessions:S,acknowledgeIdleSession:f}}function uP(e,t){const[n,r]=D.useState({}),i=e?t(e.org,e.repo,e.branch):null,a=i?n[i]:null,o=!!(a!=null&&a.open);D.useEffect(()=>{if(!e)return;const d=t(e.org,e.repo,e.branch);r(u=>u[d]?u:{...u,[d]:{open:!1,snapshot:null}})},[e,t]);const s=D.useCallback(d=>{i&&r(u=>{const m=u[i]||{open:!1,snapshot:null};return m.snapshot&&d&&m.snapshot.fetchedAt===d.fetchedAt?u:{...u,[i]:{...m,snapshot:d}}})},[i]),l=D.useCallback(()=>{if(!i)return;let d=!1;r(u=>{const m=u[i]||{open:!1,snapshot:null};return d=!m.open,{...u,[i]:{...m,open:d}}}),typeof window<"u"&&window.dispatchEvent(new CustomEvent("agentrix:git-sidebar-toggle",{detail:{worktree:i,open:d,timestamp:Date.now()}}))},[i]),c=D.useCallback(()=>{i&&r(d=>{const u=d[i]||{open:!1,snapshot:null};return u.open?{...d,[i]:{...u,open:!1}}:d})},[i]);return{gitSidebarState:n,gitSidebarKey:i,isGitSidebarOpen:o,handleGitStatusUpdate:s,toggleGitSidebar:l,closeGitSidebar:c}}async function dP(){return(await ma("/api/tasks",{errorPrefix:"Failed to fetch tasks"})).tasks||[]}function _P({onAuthExpired:e,onTaskComplete:t}={}){const[n,r]=D.useState([]),i=D.useRef(new Map),a=D.useRef(new Map),o=D.useCallback(c=>{if(!c||typeof c!="object"||!c.id)return;const d=a.current.get(c.id);if(d){if(c.removed){a.current.delete(c.id);return}if(c.status==="failed"){a.current.delete(c.id);const u=c.error&&typeof c.error.message=="string"&&c.error.message||"Worktree creation failed. Check server logs for details.";console.error("Worktree task failed",c.error||u),window.alert(`Worktree creation failed: ${u}`);return}c.status==="succeeded"&&(t&&t(c,d),a.current.delete(c.id))}},[t]),s=D.useCallback(async()=>{try{const c=await dP(),d=new Map;c.forEach(m=>{m&&m.id&&d.set(m.id,m)}),i.current=d;const u=Array.from(d.values()).sort((m,_)=>{const E=Date.parse((m==null?void 0:m.updatedAt)||(m==null?void 0:m.createdAt)||"")||0;return(Date.parse((_==null?void 0:_.updatedAt)||(_==null?void 0:_.createdAt)||"")||0)-E});r(u),c.forEach(m=>o(m))}catch(c){if(Yt(c)){e&&e();return}console.error("Failed to load tasks",c)}},[e,o]),l=D.useCallback(c=>{if(!c||typeof c!="object")return;const d=new Map(i.current),u=_=>{if(!(!_||typeof _!="object"||!_.id)){if(_.removed){d.delete(_.id),a.current.delete(_.id);return}d.set(_.id,_),o(_)}};if(Array.isArray(c.tasks))c.tasks.forEach(_=>{u(_)});else if(c.task)u(c.task);else return;i.current=d;const m=Array.from(d.values()).sort((_,E)=>{const S=Date.parse((_==null?void 0:_.updatedAt)||(_==null?void 0:_.createdAt)||"")||0;return(Date.parse((E==null?void 0:E.updatedAt)||(E==null?void 0:E.createdAt)||"")||0)-S});r(m)},[o]);return{tasks:n,setTasks:r,taskMapRef:i,pendingLaunchesRef:a,loadTasks:s,applyTaskUpdate:l,processPendingTask:o}}function pP({getWorktreeKey:e,getCommandForLaunch:t,sessionMapRef:n,knownSessionsRef:r,openTerminalForWorktreeRef:i,activeWorktreeRef:a,clearDashboardPolling:o,setActiveRepoDashboard:s,setDashboardError:l,setIsDashboardLoading:c,setActiveWorktree:d,setPendingWorktreeAction:u,setIsMobileMenuOpen:m,closePromptModal:_,closeWorktreeModal:E,pendingLaunchesRef:S}){return{processPendingTask:D.useCallback((p,g)=>{if(!p||typeof p!="object"||!p.id)return;const h=g||(S?S.current.get(p.id):null);if(!h)return;if(p.removed){S&&S.current.delete(p.id);return}if(p.status==="failed"){S&&S.current.delete(p.id);const w=p.error&&typeof p.error.message=="string"&&p.error.message||"Worktree creation failed. Check server logs for details.";console.error("Worktree task failed",p.error||w),window.alert(`Worktree creation failed: ${w}`);return}if(p.status!=="succeeded")return;S&&S.current.delete(p.id);const b=i.current;if(typeof b!="function")return;const y=[p!=null&&p.result&&typeof p.result.branch=="string"?p.result.branch.trim():"",p!=null&&p.metadata&&typeof p.metadata.branch=="string"?p.metadata.branch.trim():"",h.requestedBranch?h.requestedBranch.trim():""].find(w=>w);if(!y){window.alert("Worktree creation completed but branch name could not be determined.");return}const N={org:h.org,repo:h.repo,branch:y},v=a.current;s(null),o(),l(null),c(!1),d(N);const C=e(N.org,N.repo,N.branch),R=n.current.has(C)||r.current.has(C),I=h.kind==="prompt"?h.command:R?null:t(h.launchOption,h.dangerousMode);(async()=>{try{h.kind==="prompt"?await b(N,{command:h.command,prompt:h.promptValue}):I?await b(N,{command:I}):await b(N),u(null)}catch(w){if(w&&w.message==="AUTH_REQUIRED"){d(v||null);return}h.kind==="prompt"?(console.error("Failed to launch prompt workspace",w),window.alert("Failed to launch the selected agent. Check server logs for details."),u(N)):R?window.alert("Failed to reconnect to the existing session."):(console.error("Failed to launch the selected option",w),window.alert("Failed to launch the selected option. Check server logs for details."),u(N)),d(v||null);return}h.kind==="prompt"?_():E(),m(!1)})()},[e,t,n,r,i,a,o,s,l,c,d,u,m,_,E])}}async function bD(){return(await ma("/api/repos",{errorPrefix:"Failed to fetch repositories"})).data||{}}async function mP(e,t=""){const n=await As("/api/repos",{url:e,initCommand:t},{errorPrefix:"Failed to add repository"});return{data:n.data||{},repo:n.repo||null}}async function fP(e,t){const n=new URLSearchParams({org:e,repo:t});return(await ma(`/api/repos/dashboard?${n.toString()}`,{errorPrefix:"Failed to load repository dashboard"})).data||null}async function gP(e,t){return(await SD("/api/repos",{org:e,repo:t},{errorPrefix:"Failed to delete repository"})).data||{}}async function hP(e,t,n){return(await As("/api/repos/init-command",{org:e,repo:t,initCommand:n},{errorPrefix:"Failed to update init command"})).data||{}}async function EP(){return(await ma("/api/commands",{errorPrefix:"Failed to fetch commands"})).commands||null}function vD({callback:e,interval:t,enabled:n=!0,pauseWhenHidden:r=!1,disableWhenRealtime:i=!1,isRealtimeConnected:a=!1}){const o=D.useRef(e),s=D.useRef(!1);D.useEffect(()=>{o.current=e},[e]),D.useEffect(()=>{if(!n||!t||i&&a)return()=>{};let l=null,c=!1;const d=()=>typeof document>"u"||document.visibilityState!=="hidden",u=async()=>{if(!(c||s.current)&&!(r&&!d())&&o.current){s.current=!0;try{await o.current()}catch(_){console.error("Polling callback error:",_)}finally{s.current=!1}}};l=window.setInterval(u,t);let m=null;return r&&typeof document<"u"&&(m=()=>{d()&&u()},document.addEventListener("visibilitychange",m)),()=>{c=!0,l!==null&&window.clearInterval(l),m&&typeof document<"u"&&document.removeEventListener("visibilitychange",m)}},[t,n,r,i,a])}function SP({onAuthExpired:e,onSessionRemoved:t,sessionMapRef:n,sessionKeyByIdRef:r,isRealtimeConnected:i=!1,setActiveRepoDashboard:a}={}){const[o,s]=D.useState({}),[l,c]=D.useState(null),d=D.useCallback(E=>!E||typeof E!="object"?{}:Object.fromEntries(Object.entries(E).map(([S,f])=>{const p=Object.entries(f||{}).map(([g,h])=>{const b=h&&typeof h=="object"&&!Array.isArray(h)?h:{},y=(Array.isArray(b.branches)?b.branches:Array.isArray(h)?h:[]).filter(v=>typeof v=="string"&&v.trim().length>0).map(v=>v.trim()),N=typeof b.initCommand=="string"?b.initCommand.trim():"";return[g,{branches:y,initCommand:N}]});return[S,Object.fromEntries(p)]})),[]),u=D.useCallback(E=>{const S=d(E);s(S),c(f=>{var h;if(!f)return f;const p=((h=S==null?void 0:S[f.org])==null?void 0:h[f.repo])||{};return(Array.isArray(p.branches)?p.branches:[]).includes(f.branch)&&f.branch!=="main"?f:null}),a&&a(f=>{var h;if(!f)return f;const p=((h=S==null?void 0:S[f.org])==null?void 0:h[f.repo])||{};return(Array.isArray(p.branches)?p.branches:[]).includes("main")?f:null}),n&&r&&t&&n.current.forEach((f,p)=>{var N;const[g,h,b]=p.split("::"),T=((N=S==null?void 0:S[g])==null?void 0:N[h])||{};(Array.isArray(T.branches)?T.branches:[]).includes(b)||(n.current.delete(p),r.current.delete(f),t(p))})},[d,n,r,t,a]),m=D.useCallback(async()=>{try{const E=await bD();u(E)}catch(E){if(Yt(E)){e&&e();return}console.error("Failed to load repositories",E)}},[u,e]),_=D.useCallback((E,S)=>{var p;const f=(p=o==null?void 0:o[E])==null?void 0:p[S];return f&&typeof f.initCommand=="string"?f.initCommand:""},[o]);return D.useEffect(()=>{m()},[m]),vD({callback:m,interval:WE,pauseWhenHidden:!0,disableWhenRealtime:!0,isRealtimeConnected:i}),{data:o,setData:s,activeWorktree:l,setActiveWorktree:c,refreshRepositories:m,applyDataUpdate:u,getRepoInitCommandValue:_}}function bP({onAuthExpired:e}={}){const[t,n]=D.useState(null),[r,i]=D.useState(null),[a,o]=D.useState(null),[s,l]=D.useState(!1),c=D.useRef(new Map),d=D.useRef({timerId:null,controller:null}),u=D.useCallback(()=>{d.current.timerId!==null&&typeof window<"u"&&window.clearInterval(d.current.timerId),d.current.controller&&d.current.controller.abort(),d.current={timerId:null,controller:null}},[]),m=D.useCallback(async(E,S,{showLoading:f=!0}={})=>{if(!E||!S)return null;f&&l(!0),d.current.controller&&d.current.controller.abort();const p=new AbortController;d.current.controller=p;try{const g=await fP(E,S);if(g){const h=`${E}::${S}`;c.current.set(h,g),i(g),o(null)}else o("Unexpected response from server");return g}catch(g){return p.signal.aborted?null:Yt(g)?(e&&e(),null):(o((g==null?void 0:g.message)||"Failed to load dashboard metrics"),null)}finally{d.current.controller===p&&(d.current.controller=null),f&&l(!1)}},[e]),_=D.useCallback(()=>{t&&m(t.org,t.repo,{showLoading:!0})},[t,m]);return D.useEffect(()=>{if(!t){u(),l(!1),o(null),i(null);return}const{org:E,repo:S}=t,f=`${E}::${S}`,p=c.current.get(f);p&&(i(p),o(null)),m(E,S,{showLoading:!p})},[t,m]),vD({callback:D.useCallback(async()=>{t&&await m(t.org,t.repo,{showLoading:!1})},[t,m]),interval:j1,enabled:t!==null,pauseWhenHidden:!0}),{activeRepoDashboard:t,setActiveRepoDashboard:n,dashboardData:r,setDashboardData:i,dashboardError:a,setDashboardError:o,isDashboardLoading:s,setIsDashboardLoading:l,dashboardCacheRef:c,dashboardPollingRef:d,clearDashboardPolling:u,refreshDashboard:_,fetchRepositoryDashboard:m}}function vP({onRepos:e,onSessions:t,onTasks:n,onConnect:r,onDisconnect:i}={}){if(typeof window>"u"||typeof window.EventSource>"u")return typeof i=="function"&&i(),()=>{};let a=!1,o=null,s=null,l=2e3;function c(){s!==null&&typeof window<"u"&&window.clearTimeout(s),s=null}function d(){if(a||s!==null)return;const p=Math.min(l,3e4);s=window.setTimeout(()=>{s=null,l=Math.min(p*2,3e4),f()},p)}function u(p){if(typeof e=="function")try{const g=JSON.parse(p.data);e(g)}catch(g){console.error("Failed to parse repos event",g)}}function m(p){if(typeof t=="function")try{const g=JSON.parse(p.data);t(g)}catch(g){console.error("Failed to parse sessions event",g)}}function _(p){if(typeof n=="function")try{const g=JSON.parse(p.data);n(g)}catch(g){console.error("Failed to parse tasks event",g)}}function E(){l=2e3,typeof r=="function"&&r()}function S(){typeof i=="function"&&i()}function f(){if(a)return;if(o){try{o.close()}catch{}o=null}const p=new EventSource("/api/events");o=p,p.addEventListener("open",E),p.addEventListener("repos:update",u),p.addEventListener("sessions:update",m),p.addEventListener("tasks:update",_),p.addEventListener("error",()=>{if(S(),o===p){try{p.close()}catch{}o=null}c(),d()})}return f(),()=>{if(a=!0,c(),o){try{o.close()}catch{}o=null}}}function TP({onRepos:e,onSessions:t,onTasks:n,onConnect:r,onDisconnect:i}){const[a,o]=D.useState(!1);return D.useEffect(()=>vP({onRepos:l=>{e&&e(l)},onSessions:l=>{t&&t(l)},onTasks:l=>{n&&n(l)},onConnect:()=>{o(!0),r&&r()},onDisconnect:()=>{o(!1),i&&i()}}),[e,t,n,r,i]),{isConnected:a}}function ba(e,t){if(typeof e=="string"){const n=e.trim();if(n)return n}return t}function yP({onAuthExpired:e}={}){const[t,n]=D.useState(Di);D.useEffect(()=>{let i=!1;return(async()=>{try{const o=await EP();if(!o||typeof o!="object")return;const s={codex:ba(o.codex,Di.codex),codexDangerous:ba(o.codexDangerous,Di.codexDangerous),claude:ba(o.claude,Di.claude),claudeDangerous:ba(o.claudeDangerous,Di.claudeDangerous),cursor:ba(o.cursor??o.ide,Di.cursor),vscode:ba(o.vscode,Di.vscode)};i||n(s)}catch(o){if(Yt(o)){e&&e();return}console.error("Failed to load command configuration",o)}})(),()=>{i=!0}},[e]);const r=D.useCallback((i,a=!1)=>{switch(i){case"codex":return a?t.codexDangerous:t.codex;case"claude":return a?t.claudeDangerous:t.claude;case"ide":case"cursor":return t.cursor;case"vscode":return t.vscode;default:return}},[t]);return{commandConfig:t,getCommandForLaunch:r}}function CP({onAuthExpired:e,onDataUpdate:t,onDeleteComplete:n}={}){const[r,i]=D.useState(!1),[a,o]=D.useState(!1),s=D.useCallback(async(d,u)=>{i(!0);try{const m=await mP(d,u);return t&&t(m.data),m}catch(m){throw Yt(m)?(e&&e(),m):(console.error("Failed to clone repository",m),window.alert("Failed to clone repository. Check server logs for details."),m)}finally{i(!1)}},[e,t]),l=D.useCallback(async(d,u,m)=>{o(!0);try{const _=await gP(d,u);t&&t(_),m&&m(),n&&n(d,u)}catch(_){if(Yt(_)){e&&e();return}console.error("Failed to delete repository",_),window.alert("Failed to delete repository. Check server logs for details.")}finally{o(!1)}},[e,t,n]),c=D.useCallback(async(d,u,m)=>{try{const _=await hP(d,u,m);return t&&t(_),_}catch(_){throw Yt(_)&&e&&e(),_}},[e,t]);return{isAddingRepo:r,isDeletingRepo:a,addRepository:s,deleteRepository:l,updateInitCommand:c}}async function RP(e,t,n=null,r=null){const i={org:e,repo:t};n&&(i.branch=n),r&&(i.prompt=r);const a=await As("/api/worktrees",i,{errorPrefix:"Failed to create worktree"});return{taskId:a&&typeof a.taskId=="string"?a.taskId:"",data:a}}async function NP(e,t,n){return(await SD("/api/worktrees",{org:e,repo:t,branch:n},{errorPrefix:"Failed to delete worktree"})).data||{}}function OP({onAuthExpired:e,onDataUpdate:t,onDeleteComplete:n}={}){const[r,i]=D.useState(!1),[a,o]=D.useState(!1),[s,l]=D.useState(!1),c=D.useCallback(async(u,m,_,E)=>{const S=E!==null;S?l(!0):i(!0);try{return await RP(u,m,_,E)}catch(f){throw Yt(f)?(e&&e(),f):(console.error("Failed to create worktree",f),window.alert("Failed to create worktree. Check server logs for details."),f)}finally{S?l(!1):i(!1)}},[e]),d=D.useCallback(async(u,m,_)=>{o(!0);try{const E=await NP(u,m,_);t&&t(E),n&&n(u,m,_)}catch(E){if(Yt(E)){e&&e();return}console.error("Failed to remove worktree",E),window.alert("Failed to remove worktree. Check server logs for details.")}finally{o(!1)}},[e,t,n]);return{isCreatingWorktree:r,isDeletingWorktree:a,isCreatingPromptWorktree:s,createWorktree:c,deleteWorktree:d}}async function AP(e,t){const n=new URLSearchParams({org:e,repo:t});return(await ma(`/api/plans?${n.toString()}`,{errorPrefix:"Failed to fetch plans"})).plans||[]}async function IP(e,t,n){const r=new URLSearchParams({org:e,repo:t,planId:n});return(await ma(`/api/plans/content?${r.toString()}`,{errorPrefix:"Failed to load plan"})).content||""}async function wP(e,t,n,r=!1,i=!1){const a=await As("/api/create-plan",{prompt:e,org:t,repo:n,rawPrompt:r,dangerousMode:i},{errorPrefix:"Failed to create plan from prompt"}),o=a&&typeof a.plan=="string"?a.plan:"";if(!o.trim())throw new Error("Server returned an empty plan. Check server logs for details.");return o}function DP({onAuthExpired:e}={}){const[t,n]=D.useState(!1),r=D.useCallback(async(o,s,l,{restorePromptOnError:c=!0,rawPrompt:d=!1,dangerousMode:u=!1,onPromptChange:m}={})=>{if(t)return;const _=typeof o=="string"?o:"";if(_.trim()){if(!s||!l){window.alert("Select a repository before creating a plan.");return}n(!0);try{m&&Zt.flushSync(()=>{m("")});const E=await wP(_,s,l,d,u);m&&Zt.flushSync(()=>{m(E)})}catch(E){if(Yt(E)){c&&m&&Zt.flushSync(()=>{m(o)}),e&&e();return}console.error("Failed to create plan",E),c&&m&&Zt.flushSync(()=>{m(o)}),window.alert("Failed to create plan. Check server logs for details.")}finally{n(!1)}}},[t,e]),i=D.useCallback(async(o,s,l)=>{if(!(!o||!s)){l(c=>({...c,selectedPlanId:s,content:"",contentLoading:!0,contentError:null}));try{const c=await IP(o.org,o.repo,s);l(d=>({...d,content:c,contentLoading:!1,contentError:null}))}catch(c){if(Yt(c)){e&&e(),l(d=>({...d,open:!1}));return}l(d=>({...d,contentLoading:!1,contentError:(c==null?void 0:c.message)||"Failed to load plan."}))}}},[e]),a=D.useCallback(async(o,s,l)=>{if(!o)return;const c={org:o.org,repo:o.repo,branch:o.branch};s({...ch(),open:!0,loading:!0,context:c});try{const d=await AP(c.org,c.repo);s(u=>({...u,loading:!1,error:null,plans:d,context:c})),d.length>0?await l(c,d[0].id):s(u=>({...u,selectedPlanId:null,content:""}))}catch(d){if(Yt(d)){e&&e(),s(u=>({...u,open:!1}));return}s(u=>({...u,loading:!1,error:(d==null?void 0:d.message)||"Failed to load plans."}))}},[e]);return{isCreatingPlan:t,createPlanFromPrompt:r,fetchPlanContent:i,openPlanHistory:a}}async function xP(e,t,n,r,i=null,a="changes",o=""){const s=await As("/api/git/diff",{org:e,repo:t,branch:n,path:r,previousPath:i,mode:a,status:o},{errorPrefix:"Failed to load diff"}),l=s&&typeof s=="object"?s:null;return{diff:l&&typeof l.diff=="string"?l.diff:"",path:(l==null?void 0:l.path)||r,previousPath:(l==null?void 0:l.previousPath)??i,mode:(l==null?void 0:l.mode)||a,status:(l==null?void 0:l.status)||o}}function MP({activeWorktree:e,onAuthExpired:t}){const n=D.useCallback(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches?"unified":"split",[]),r=D.useCallback(async(s,l)=>{if(!e||!s||!s.path)return;const d=(m=>m.kind==="staged"?"staged":m.kind==="untracked"?"untracked":m.kind==="conflict"?"unstaged":m.indexStatus&&m.indexStatus!==" "?"staged":"unstaged")(s),u={path:s.path,previousPath:s.previousPath||null,kind:s.kind||null,status:s.status||"",mode:d};l({open:!0,loading:!0,error:null,diff:"",file:u,view:n()});try{const m=await xP(e.org,e.repo,e.branch,s.path,s.previousPath||null,d,s.status||"");l(_=>({open:!0,loading:!1,error:null,diff:m&&typeof m.diff=="string"?m.diff:"",file:m&&typeof m=="object"?{path:m.path||u.path,previousPath:m.previousPath??u.previousPath,kind:u.kind,status:u.status,mode:m.mode||u.mode}:u,view:_.view||n()}))}catch(m){if(Yt(m)){t&&t(),l(_=>({..._,open:!1}));return}l(_=>({open:!0,loading:!1,error:m&&m.message?m.message:"Failed to load diff",diff:"",file:_.file||u,view:_.view||n()}))}},[e,t,n]),i=D.useCallback(s=>{s(l=>{if(!l.open)return l;const c=l.view==="split"?"unified":"split";return{...l,view:c}})},[]),a=D.useCallback(s=>{s(l=>l.open?{open:!1,loading:!1,error:null,diff:"",file:null,view:"split"}:l)},[]),o=D.useCallback(s=>{a(s)},[a]);return{openGitDiff:r,toggleDiffView:i,closeDiffModal:a,autoCloseDiff:o,resolveDefaultDiffView:n}}function LP({isRealtimeConnected:e,repositoryPollInterval:t,sessionPollInterval:n,onAuthExpired:r,onDataUpdate:i,onSessionsUpdate:a,onTasksLoad:o}){const s=D.useCallback(async()=>{try{const c=await bD();i&&i(c)}catch(c){if(Yt(c)){r&&r();return}console.error("Failed to load repositories",c)}},[i,r]),l=D.useCallback(async()=>{try{const c=await sP();a&&a(c)}catch(c){if(Yt(c)){r&&r();return}a&&a([])}},[r,a]);return D.useEffect(()=>{s()},[s]),D.useEffect(()=>{o&&o()},[o]),D.useEffect(()=>{e||(s(),l(),o&&o())},[e,l,o,s]),D.useEffect(()=>{if(e)return()=>{};if(Number.isNaN(t))return()=>{};let c=null,d=!1,u=!1;const m=()=>typeof document>"u"||document.visibilityState!=="hidden",_=()=>{d||u||!m()||(u=!0,s().catch(()=>{}).finally(()=>{u=!1}))};c=window.setInterval(_,t);const E=()=>{m()&&_()};return typeof document<"u"&&document.addEventListener("visibilitychange",E),()=>{d=!0,c!==null&&window.clearInterval(c),typeof document<"u"&&document.removeEventListener("visibilitychange",E)}},[e,s,t]),D.useEffect(()=>{l()},[l]),D.useEffect(()=>{if(e)return()=>{};const c=window.setInterval(()=>{l()},n);return()=>window.clearInterval(c)},[e,l,n]),{refreshRepositories:s,loadSessions:l}}function kP({getWorktreeKey:e,sessionMapRef:t,knownSessionsRef:n,sessionMetadataRef:r,idleAcknowledgementsRef:i,dashboardCacheRef:a,clearDashboardPolling:o,setPendingWorktreeAction:s,setActiveWorktree:l,setActiveRepoDashboard:c,setDashboardData:d,setDashboardError:u,setIsDashboardLoading:m,setIdleAcknowledgementsSnapshot:_,setIsMobileMenuOpen:E,disposeSocket:S,disposeTerminal:f,closeGitSidebar:p,loadSessions:g,openTerminalForWorktree:h}){return{handleWorktreeSelection:D.useCallback(async(T,y,N)=>{if(N==="main"){o(),s(null),l(null),S(),f(),p();const R=`${T}::${y}`,I=a.current.get(R);I?(d(I),u(null),m(!1)):(d(null),m(!0)),c({org:T,repo:y}),E(!1);return}o(),c(null),u(null),m(!1);const v={org:T,repo:y,branch:N},C=e(T,y,N);if(!t.current.has(C)&&!n.current.has(C)&&await g(),t.current.has(C)||n.current.has(C)){l(v);let R=!1,I;const w=r.current.get(C);if(w&&w.idle){I=i.current.has(C)?i.current.get(C):void 0;const P=new Map(i.current);P.set(C,KE(qo(w))),i.current=P,_(new Map(P)),R=!0}try{await h(v),s(null)}catch(P){if(R){const U=new Map(i.current);I===void 0?U.delete(C):U.set(C,I),i.current=U,_(new Map(U))}if(P&&P.message==="AUTH_REQUIRED")return;window.alert("Failed to reconnect to the existing session.")}}else s(v),E(!1)},[o,p,S,f,e,g,h,t,n,r,i,a,s,l,c,d,u,m,_,E])}}function PP({mobileMenuButtonRef:e}){const[t,n]=D.useState(!1),[r,i]=D.useState(null),a=D.useRef({}),o=D.useCallback(()=>{Zt.flushSync(()=>{n(!1)}),e.current&&e.current.focus()},[e]),s=D.useCallback(d=>{i(u=>u===d?null:d)},[]),l=D.useCallback(()=>{i(null)},[]),c=D.useCallback(d=>u=>{u?a.current[d]=u:delete a.current[d]},[]);return D.useEffect(()=>{if(!t)return;const d=u=>{u.key==="Escape"&&(u.preventDefault(),o())};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o]),D.useEffect(()=>{if(!r)return;const d=m=>{const _=m.target,E=a.current[r]||null;E&&_ instanceof Node&&E.contains(_)||l()},u=m=>{m.key==="Escape"&&(m.preventDefault(),l())};return document.addEventListener("mousedown",d),document.addEventListener("touchstart",d),window.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d),window.removeEventListener("keydown",u)}},[r,l]),{isMobileMenuOpen:t,setIsMobileMenuOpen:n,closeMobileMenu:o,openActionMenu:r,toggleActionMenu:s,getActionMenuRef:c}}/**
85
+ `,g)}paste(p){this._core.paste(p)}refresh(p,g){this._verifyIntegers(p,g),this._core.refresh(p,g)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(p){this._addonManager.loadAddon(this,p)}static get strings(){return s}_verifyIntegers(...p){for(const g of p)if(g===1/0||isNaN(g)||g%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...p){for(const g of p)if(g&&(g===1/0||isNaN(g)||g%1!=0||g<0))throw new Error("This API only accepts positive integers")}}o.Terminal=S})(),a})())})(mD);var rP=mD.exports,gD={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(self,()=>(()=>{var n={};return(()=>{var r=n;Object.defineProperty(r,"__esModule",{value:!0}),r.FitAddon=void 0,r.FitAddon=class{activate(i){this._terminal=i}dispose(){}fit(){const i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;const a=this._terminal._core;this._terminal.rows===i.rows&&this._terminal.cols===i.cols||(a._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const i=this._terminal._core,a=i._renderService.dimensions;if(a.css.cell.width===0||a.css.cell.height===0)return;const o=this._terminal.options.scrollback===0?0:i.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),c=Math.max(0,parseInt(s.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),u=l-(parseInt(d.getPropertyValue("padding-top"))+parseInt(d.getPropertyValue("padding-bottom"))),m=c-(parseInt(d.getPropertyValue("padding-right"))+parseInt(d.getPropertyValue("padding-left")))-o;return{cols:Math.max(2,Math.floor(m/a.css.cell.width)),rows:Math.max(1,Math.floor(u/a.css.cell.height))}}}})(),n})())})(gD);var iP=gD.exports;class hD extends Error{constructor(t,n,r){super(t),this.status=n,this.statusText=r,this.name="ApiError"}}class ED extends hD{constructor(t="Authentication required"){super(t,401,"Unauthorized"),this.name="AuthenticationError"}}async function aP(e,t){try{const n=await e.json();if(n!=null&&n.error&&typeof n.error=="string")return n.error}catch{}return t}async function QE(e,t={}){const{credentials:n="include",errorPrefix:r="Request failed",...i}=t,a=await fetch(e,{...i,credentials:n});if(a.status===401)throw new ED;if(!a.ok){const o=await aP(a,`${r}: ${a.status}`);throw new hD(o,a.status,a.statusText)}return await a.json()}async function ma(e,t={}){return QE(e,{...t,method:"GET"})}async function As(e,t,n={}){return QE(e,{...n,method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:t?JSON.stringify(t):void 0})}async function SD(e,t,n={}){return QE(e,{...n,method:"DELETE",headers:{"Content-Type":"application/json",...n.headers},body:t?JSON.stringify(t):void 0})}function Yt(e){return e instanceof ED}async function sP(){return(await ma("/api/sessions",{errorPrefix:"Failed to fetch sessions"})).sessions||[]}async function oP(e,t,n,r=null,i=null){const a={org:e,repo:t,branch:n};r!=null&&(a.command=r),i!=null&&typeof i=="string"&&(a.prompt=i);const o=await As("/api/terminal/open",a,{errorPrefix:"Failed to open terminal"});return{sessionId:o&&o.sessionId?o.sessionId:null,created:o&&typeof o.created=="boolean"?o.created:!1,log:o&&typeof o.log=="string"?o.log:""}}function lP({onAuthExpired:e,onSessionRemoved:t}={}){const[n,r]=D.useState("disconnected"),[i,a]=D.useState(null),o=D.useRef(null),s=D.useRef(null),l=D.useRef(null),c=D.useRef(null),d=D.useRef(null),u=D.useRef(!1),m=D.useRef(!1),_=D.useRef(new Map),E=D.useRef(new Map),S=D.useCallback(()=>{if(!(!s.current||!l.current)&&(l.current.fit(),c.current&&c.current.readyState===WebSocket.OPEN)){const{cols:T,rows:y}=s.current;c.current.send(JSON.stringify({type:"resize",cols:T,rows:y}))}},[]),f=D.useCallback(()=>{if(c.current){try{c.current.close()}catch{}c.current=null}},[]),p=D.useCallback(()=>{if(s.current){try{s.current.dispose()}catch{}s.current=null}l.current=null,o.current&&(o.current.innerHTML="")},[]),g=D.useCallback(T=>{if(p(),!o.current)return;const y=new rP.Terminal({allowTransparency:!0,convertEol:!0,cursorBlink:!0,fontFamily:"JetBrains Mono, Menlo, Consolas, monospace",fontSize:13,theme:{background:"#111111",foreground:"#f4f4f5",cursor:"#f4f4f5"},scrollback:8e3}),N=new iP.FitAddon;y.loadAddon(N),s.current=y,l.current=N,y.open(o.current),y.focus(),T&&y.write(T),y.onData(v=>{c.current&&c.current.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"input",data:v}))}),y.onResize(({cols:v,rows:C})=>{c.current&&c.current.readyState===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"resize",cols:v,rows:C}))}),requestAnimationFrame(()=>{S(),y.focus()})},[p,S]),h=D.useCallback(T=>{if(!T)return;const N=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/api/terminal/socket?sessionId=${encodeURIComponent(T)}`,v=new WebSocket(N);c.current=v,v.addEventListener("open",()=>{r("connected"),S()}),v.addEventListener("message",C=>{let R;try{R=JSON.parse(C.data)}catch{return}if(R.type==="output")R.reset&&s.current&&(s.current.reset(),S()),s.current&&R.chunk&&s.current.write(R.chunk);else if(R.type==="exit"){m.current=!0,r("closed");const I=E.current.get(T);I&&(_.current.delete(I),E.current.delete(T),t&&t(I))}else if(R.type==="init")!u.current&&R.log&&s.current&&s.current.write(R.log),u.current=!1,R.closed&&(m.current=!0,r("closed"));else if(R.type==="error"){console.error(R.message||"Terminal connection error"),r("error");const I=E.current.get(T);I&&(_.current.delete(I),E.current.delete(T),t&&t(I))}}),v.addEventListener("close",()=>{m.current?r("closed"):r("disconnected")}),v.addEventListener("error",()=>{r("error")})},[S,t]),b=D.useCallback(async(T,y={})=>{const{command:N,prompt:v}=y;if(f(),!T){p(),a(null),r("disconnected");return}r("connecting"),m.current=!1,u.current=!0;try{const C=await oP(T.org,T.repo,T.branch,N||null,v||null),R=C.sessionId,I=C.created;if(!R)throw new Error("Invalid session response");a(R);const w=`${T.org}::${T.repo}::${T.branch}`,P=_.current.get(w);P&&P!==R&&E.current.delete(P),_.current.set(w,R),E.current.set(R,w);const U=C.log||"";return g(U),h(R),{sessionId:R,created:I}}catch(C){throw Yt(C)?(e&&e(),new Error("AUTH_REQUIRED")):(console.error("Failed to open terminal session",C),p(),a(null),r("error"),C)}},[h,f,p,g,e]);return D.useEffect(()=>()=>{f(),p(),d.current&&d.current.disconnect()},[f,p]),D.useEffect(()=>{if(!o.current)return;const T=new ResizeObserver(()=>{S()});return T.observe(o.current),d.current=T,()=>T.disconnect()},[S]),{terminalContainerRef:o,terminalStatus:n,sessionId:i,sessionMapRef:_,sessionKeyByIdRef:E,openTerminal:b,disposeSocket:f,disposeTerminal:p,sendResize:S}}function cP(){const e=D.useRef(new Set),t=D.useRef(new Map),[n,r]=D.useState(()=>new Map),i=D.useRef(new Map),[a,o]=D.useState(()=>new Map),s=D.useRef(new Map),l=D.useRef([]),c=D.useRef(null),d=D.useCallback(()=>{if(typeof window>"u"||typeof window.Notification!="function"){l.current=[];return}if(window.Notification.permission!=="granted")return;const p=l.current;l.current=[],p.forEach(({title:g,options:h})=>{try{new window.Notification(g,h)}catch{}})},[]),u=D.useCallback(p=>{const g=l.current,h=g.findIndex(b=>b.key===p.key);h>=0?l.current=[...g.slice(0,h),p,...g.slice(h+1)]:l.current=[...g,p]},[]),m=D.useCallback(()=>{if(typeof window>"u"||typeof window.Notification!="function")return l.current=[],Promise.resolve("denied");const p=window.Notification.permission;if(p==="granted"||p==="denied")return p==="granted"?d():l.current=[],Promise.resolve(p);if(c.current)return c.current;try{const g=window.Notification.requestPermission(),h=g instanceof Promise?g:Promise.resolve(g);return c.current=h.then(b=>(c.current=null,b==="granted"?d():l.current=[],b)).catch(()=>(c.current=null,l.current=[],"denied")),c.current}catch{return l.current=[],Promise.resolve("denied")}},[d]),_=D.useCallback((p,g,h,b)=>{if(typeof window>"u"||typeof window.Notification!="function")return;const T="Worktree idle",y={body:`${g}/${h}: ${b} work has finished.`,tag:p},N=window.Notification.permission;if(N==="granted"){d();try{new window.Notification(T,y)}catch{}return}N!=="denied"&&(u({key:p,title:T,options:y}),m())},[u,d,m]),E=D.useCallback(p=>{if(p){if(e.current.delete(p),t.current.has(p)){const g=new Map(t.current);g.delete(p),t.current=g,r(new Map(g))}if(i.current.has(p)){const g=new Map(i.current);g.delete(p),i.current=g,o(new Map(g))}if(l.current.length>0){const g=l.current.filter(h=>h.key!==p);g.length!==l.current.length&&(l.current=g)}}},[o,r]),S=D.useCallback(p=>{const g=t.current,h=i.current,b=s.current,T=new Map,y=new Map;Array.isArray(p)&&p.forEach(R=>{if(!R||typeof R!="object")return;const I=typeof R.org=="string"?R.org:null,w=typeof R.repo=="string"?R.repo:null,P=typeof R.branch=="string"?R.branch:null;if(!I||!w||!P)return;const U=`${I}::${w}::${P}`,G=!!R.idle,L=_D(R.lastActivityAt),F=y.get(U);if(!F){y.set(U,{org:I,repo:w,branch:P,idle:G,lastActivityAtMs:L});return}F.idle=F.idle&&G,ln(L)&&(!ln(F.lastActivityAtMs)||L>F.lastActivityAtMs)&&(F.lastActivityAtMs=L)});const N=new Set,v=new Map;y.forEach((R,I)=>{const w=ln(R.lastActivityAtMs)?R.lastActivityAtMs:null;N.add(I),v.set(I,{org:R.org,repo:R.repo,branch:R.branch,idle:R.idle,lastActivityAtMs:w,lastActivityAt:ln(w)?new Date(w).toISOString():null});const P=g.get(I),U=!!(P!=null&&P.idle),G=b.has(I)?b.get(I)??null:null,L=h.get(I),F=lh(R,L);if(R.branch!=="main"&&R.idle&&!F){const M=ln(w)?w:null,A=b.has(I),B=A&&G===M;T.set(I,M),(!U||!A||!B)&&_(I,R.org,R.repo,R.branch)}}),e.current=N,t.current=v,r(new Map(v)),s.current=T;const C=new Map;i.current.forEach((R,I)=>{const w=v.get(I);if(!w)return;const P=pD(R);if(!lh(w,P))return;const U=qo(w);ln(U)&&(P.lastSeenActivityMs=U),C.set(I,P)}),i.current=C,o(new Map(C))},[_]),f=D.useCallback((p,g,h)=>{const b=`${p}::${g}::${h}`,T=t.current.get(b);if(T&&T.idle){const y=new Map(i.current);y.set(b,KE(qo(T))),i.current=y,o(new Map(y))}},[]);return{knownSessionsRef:e,sessionMetadataRef:t,sessionMetadataSnapshot:n,setSessionMetadataSnapshot:r,idleAcknowledgementsRef:i,idleAcknowledgementsSnapshot:a,setIdleAcknowledgementsSnapshot:o,removeTrackedSession:E,syncKnownSessions:S,acknowledgeIdleSession:f}}function uP(e,t){const[n,r]=D.useState({}),i=e?t(e.org,e.repo,e.branch):null,a=i?n[i]:null,o=!!(a!=null&&a.open);D.useEffect(()=>{if(!e)return;const d=t(e.org,e.repo,e.branch);r(u=>u[d]?u:{...u,[d]:{open:!1,snapshot:null}})},[e,t]);const s=D.useCallback(d=>{i&&r(u=>{const m=u[i]||{open:!1,snapshot:null};return m.snapshot&&d&&m.snapshot.fetchedAt===d.fetchedAt?u:{...u,[i]:{...m,snapshot:d}}})},[i]),l=D.useCallback(()=>{if(!i)return;let d=!1;r(u=>{const m=u[i]||{open:!1,snapshot:null};return d=!m.open,{...u,[i]:{...m,open:d}}}),typeof window<"u"&&window.dispatchEvent(new CustomEvent("agentrix:git-sidebar-toggle",{detail:{worktree:i,open:d,timestamp:Date.now()}}))},[i]),c=D.useCallback(()=>{i&&r(d=>{const u=d[i]||{open:!1,snapshot:null};return u.open?{...d,[i]:{...u,open:!1}}:d})},[i]);return{gitSidebarState:n,gitSidebarKey:i,isGitSidebarOpen:o,handleGitStatusUpdate:s,toggleGitSidebar:l,closeGitSidebar:c}}async function dP(){return(await ma("/api/tasks",{errorPrefix:"Failed to fetch tasks"})).tasks||[]}function _P({onAuthExpired:e,onTaskComplete:t}={}){const[n,r]=D.useState([]),i=D.useRef(new Map),a=D.useRef(new Map),o=D.useCallback(c=>{if(!c||typeof c!="object"||!c.id)return;const d=a.current.get(c.id);if(d){if(c.removed){a.current.delete(c.id);return}if(c.status==="failed"){a.current.delete(c.id);const u=c.error&&typeof c.error.message=="string"&&c.error.message||"Worktree creation failed. Check server logs for details.";console.error("Worktree task failed",c.error||u),window.alert(`Worktree creation failed: ${u}`);return}c.status==="succeeded"&&(t&&t(c,d),a.current.delete(c.id))}},[t]),s=D.useCallback(async()=>{try{const c=await dP(),d=new Map;c.forEach(m=>{m&&m.id&&d.set(m.id,m)}),i.current=d;const u=Array.from(d.values()).sort((m,_)=>{const E=Date.parse((m==null?void 0:m.updatedAt)||(m==null?void 0:m.createdAt)||"")||0;return(Date.parse((_==null?void 0:_.updatedAt)||(_==null?void 0:_.createdAt)||"")||0)-E});r(u),c.forEach(m=>o(m))}catch(c){if(Yt(c)){e&&e();return}console.error("Failed to load tasks",c)}},[e,o]),l=D.useCallback(c=>{if(!c||typeof c!="object")return;const d=new Map(i.current),u=_=>{if(!(!_||typeof _!="object"||!_.id)){if(_.removed){d.delete(_.id),a.current.delete(_.id);return}d.set(_.id,_),o(_)}};if(Array.isArray(c.tasks))c.tasks.forEach(_=>{u(_)});else if(c.task)u(c.task);else return;i.current=d;const m=Array.from(d.values()).sort((_,E)=>{const S=Date.parse((_==null?void 0:_.updatedAt)||(_==null?void 0:_.createdAt)||"")||0;return(Date.parse((E==null?void 0:E.updatedAt)||(E==null?void 0:E.createdAt)||"")||0)-S});r(m)},[o]);return{tasks:n,setTasks:r,taskMapRef:i,pendingLaunchesRef:a,loadTasks:s,applyTaskUpdate:l,processPendingTask:o}}function pP({getWorktreeKey:e,getCommandForLaunch:t,sessionMapRef:n,knownSessionsRef:r,openTerminalForWorktreeRef:i,activeWorktreeRef:a,clearDashboardPolling:o,setActiveRepoDashboard:s,setDashboardError:l,setIsDashboardLoading:c,setActiveWorktree:d,setPendingWorktreeAction:u,setIsMobileMenuOpen:m,closePromptModal:_,closeWorktreeModal:E,pendingLaunchesRef:S}){return{processPendingTask:D.useCallback((p,g)=>{if(!p||typeof p!="object"||!p.id)return;const h=g||(S?S.current.get(p.id):null);if(!h)return;if(p.removed){S&&S.current.delete(p.id);return}if(p.status==="failed"){S&&S.current.delete(p.id);const w=p.error&&typeof p.error.message=="string"&&p.error.message||"Worktree creation failed. Check server logs for details.";console.error("Worktree task failed",p.error||w),window.alert(`Worktree creation failed: ${w}`);return}if(p.status!=="succeeded")return;S&&S.current.delete(p.id);const b=i.current;if(typeof b!="function")return;const y=[p!=null&&p.result&&typeof p.result.branch=="string"?p.result.branch.trim():"",p!=null&&p.metadata&&typeof p.metadata.branch=="string"?p.metadata.branch.trim():"",h.requestedBranch?h.requestedBranch.trim():""].find(w=>w);if(!y){window.alert("Worktree creation completed but branch name could not be determined.");return}const N={org:h.org,repo:h.repo,branch:y},v=a.current;s(null),o(),l(null),c(!1),d(N);const C=e(N.org,N.repo,N.branch),R=n.current.has(C)||r.current.has(C),I=h.kind==="prompt"?h.command:R?null:t(h.launchOption,h.dangerousMode);(async()=>{try{h.kind==="prompt"?await b(N,{command:h.command,prompt:h.promptValue}):I?await b(N,{command:I}):await b(N),u(null)}catch(w){if(w&&w.message==="AUTH_REQUIRED"){d(v||null);return}h.kind==="prompt"?(console.error("Failed to launch prompt workspace",w),window.alert("Failed to launch the selected agent. Check server logs for details."),u(N)):R?window.alert("Failed to reconnect to the existing session."):(console.error("Failed to launch the selected option",w),window.alert("Failed to launch the selected option. Check server logs for details."),u(N)),d(v||null);return}h.kind==="prompt"?_():E(),m(!1)})()},[e,t,n,r,i,a,o,s,l,c,d,u,m,_,E])}}async function bD(){return(await ma("/api/repos",{errorPrefix:"Failed to fetch repositories"})).data||{}}async function mP(e,t=""){const n=await As("/api/repos",{url:e,initCommand:t},{errorPrefix:"Failed to add repository"});return{data:n.data||{},repo:n.repo||null}}async function fP(e,t){const n=new URLSearchParams({org:e,repo:t});return(await ma(`/api/repos/dashboard?${n.toString()}`,{errorPrefix:"Failed to load repository dashboard"})).data||null}async function gP(e,t){return(await SD("/api/repos",{org:e,repo:t},{errorPrefix:"Failed to delete repository"})).data||{}}async function hP(e,t,n){return(await As("/api/repos/init-command",{org:e,repo:t,initCommand:n},{errorPrefix:"Failed to update init command"})).data||{}}async function EP(){return(await ma("/api/commands",{errorPrefix:"Failed to fetch commands"})).commands||null}function vD({callback:e,interval:t,enabled:n=!0,pauseWhenHidden:r=!1,disableWhenRealtime:i=!1,isRealtimeConnected:a=!1}){const o=D.useRef(e),s=D.useRef(!1);D.useEffect(()=>{o.current=e},[e]),D.useEffect(()=>{if(!n||!t||i&&a)return()=>{};let l=null,c=!1;const d=()=>typeof document>"u"||document.visibilityState!=="hidden",u=async()=>{if(!(c||s.current)&&!(r&&!d())&&o.current){s.current=!0;try{await o.current()}catch(_){console.error("Polling callback error:",_)}finally{s.current=!1}}};l=window.setInterval(u,t);let m=null;return r&&typeof document<"u"&&(m=()=>{d()&&u()},document.addEventListener("visibilitychange",m)),()=>{c=!0,l!==null&&window.clearInterval(l),m&&typeof document<"u"&&document.removeEventListener("visibilitychange",m)}},[t,n,r,i,a])}function SP({onAuthExpired:e,onSessionRemoved:t,sessionMapRef:n,sessionKeyByIdRef:r,isRealtimeConnected:i=!1,setActiveRepoDashboard:a}={}){const[o,s]=D.useState({}),[l,c]=D.useState(null),d=D.useCallback(E=>!E||typeof E!="object"?{}:Object.fromEntries(Object.entries(E).map(([S,f])=>{const p=Object.entries(f||{}).map(([g,h])=>{const b=h&&typeof h=="object"&&!Array.isArray(h)?h:{},y=(Array.isArray(b.branches)?b.branches:Array.isArray(h)?h:[]).filter(v=>typeof v=="string"&&v.trim().length>0).map(v=>v.trim()),N=typeof b.initCommand=="string"?b.initCommand.trim():"";return[g,{branches:y,initCommand:N}]});return[S,Object.fromEntries(p)]})),[]),u=D.useCallback(E=>{const S=d(E);s(S),c(f=>{var h;if(!f)return f;const p=((h=S==null?void 0:S[f.org])==null?void 0:h[f.repo])||{};return(Array.isArray(p.branches)?p.branches:[]).includes(f.branch)&&f.branch!=="main"?f:null}),a&&a(f=>{var h;if(!f)return f;const p=((h=S==null?void 0:S[f.org])==null?void 0:h[f.repo])||{};return(Array.isArray(p.branches)?p.branches:[]).includes("main")?f:null}),n&&r&&t&&n.current.forEach((f,p)=>{var N;const[g,h,b]=p.split("::"),T=((N=S==null?void 0:S[g])==null?void 0:N[h])||{};(Array.isArray(T.branches)?T.branches:[]).includes(b)||(n.current.delete(p),r.current.delete(f),t(p))})},[d,n,r,t,a]),m=D.useCallback(async()=>{try{const E=await bD();u(E)}catch(E){if(Yt(E)){e&&e();return}console.error("Failed to load repositories",E)}},[u,e]),_=D.useCallback((E,S)=>{var p;const f=(p=o==null?void 0:o[E])==null?void 0:p[S];return f&&typeof f.initCommand=="string"?f.initCommand:""},[o]);return D.useEffect(()=>{m()},[m]),vD({callback:m,interval:WE,pauseWhenHidden:!0,disableWhenRealtime:!0,isRealtimeConnected:i}),{data:o,setData:s,activeWorktree:l,setActiveWorktree:c,refreshRepositories:m,applyDataUpdate:u,getRepoInitCommandValue:_}}function bP({onAuthExpired:e}={}){const[t,n]=D.useState(null),[r,i]=D.useState(null),[a,o]=D.useState(null),[s,l]=D.useState(!1),c=D.useRef(new Map),d=D.useRef({timerId:null,controller:null}),u=D.useCallback(()=>{d.current.timerId!==null&&typeof window<"u"&&window.clearInterval(d.current.timerId),d.current.controller&&d.current.controller.abort(),d.current={timerId:null,controller:null}},[]),m=D.useCallback(async(E,S,{showLoading:f=!0}={})=>{if(!E||!S)return null;f&&l(!0),d.current.controller&&d.current.controller.abort();const p=new AbortController;d.current.controller=p;try{const g=await fP(E,S);if(g){const h=`${E}::${S}`;c.current.set(h,g),i(g),o(null)}else o("Unexpected response from server");return g}catch(g){return p.signal.aborted?null:Yt(g)?(e&&e(),null):(o((g==null?void 0:g.message)||"Failed to load dashboard metrics"),null)}finally{d.current.controller===p&&(d.current.controller=null),f&&l(!1)}},[e]),_=D.useCallback(()=>{t&&m(t.org,t.repo,{showLoading:!0})},[t,m]);return D.useEffect(()=>{if(!t){u(),l(!1),o(null),i(null);return}const{org:E,repo:S}=t,f=`${E}::${S}`,p=c.current.get(f);p&&(i(p),o(null)),m(E,S,{showLoading:!p})},[t,m]),vD({callback:D.useCallback(async()=>{t&&await m(t.org,t.repo,{showLoading:!1})},[t,m]),interval:j1,enabled:t!==null,pauseWhenHidden:!0}),{activeRepoDashboard:t,setActiveRepoDashboard:n,dashboardData:r,setDashboardData:i,dashboardError:a,setDashboardError:o,isDashboardLoading:s,setIsDashboardLoading:l,dashboardCacheRef:c,dashboardPollingRef:d,clearDashboardPolling:u,refreshDashboard:_,fetchRepositoryDashboard:m}}function vP({onRepos:e,onSessions:t,onTasks:n,onConnect:r,onDisconnect:i}={}){if(typeof window>"u"||typeof window.EventSource>"u")return typeof i=="function"&&i(),()=>{};let a=!1,o=null,s=null,l=2e3;function c(){s!==null&&typeof window<"u"&&window.clearTimeout(s),s=null}function d(){if(a||s!==null)return;const p=Math.min(l,3e4);s=window.setTimeout(()=>{s=null,l=Math.min(p*2,3e4),f()},p)}function u(p){if(typeof e=="function")try{const g=JSON.parse(p.data);e(g)}catch(g){console.error("Failed to parse repos event",g)}}function m(p){if(typeof t=="function")try{const g=JSON.parse(p.data);t(g)}catch(g){console.error("Failed to parse sessions event",g)}}function _(p){if(typeof n=="function")try{const g=JSON.parse(p.data);n(g)}catch(g){console.error("Failed to parse tasks event",g)}}function E(){l=2e3,typeof r=="function"&&r()}function S(){typeof i=="function"&&i()}function f(){if(a)return;if(o){try{o.close()}catch{}o=null}const p=new EventSource("/api/events");o=p,p.addEventListener("open",E),p.addEventListener("repos:update",u),p.addEventListener("sessions:update",m),p.addEventListener("tasks:update",_),p.addEventListener("error",()=>{if(S(),o===p){try{p.close()}catch{}o=null}c(),d()})}return f(),()=>{if(a=!0,c(),o){try{o.close()}catch{}o=null}}}function TP({onRepos:e,onSessions:t,onTasks:n,onConnect:r,onDisconnect:i}){const[a,o]=D.useState(!1);return D.useEffect(()=>vP({onRepos:l=>{e&&e(l)},onSessions:l=>{t&&t(l)},onTasks:l=>{n&&n(l)},onConnect:()=>{o(!0),r&&r()},onDisconnect:()=>{o(!1),i&&i()}}),[e,t,n,r,i]),{isConnected:a}}function ba(e,t){if(typeof e=="string"){const n=e.trim();if(n)return n}return t}function yP({onAuthExpired:e}={}){const[t,n]=D.useState(Di);D.useEffect(()=>{let i=!1;return(async()=>{try{const o=await EP();if(!o||typeof o!="object")return;const s={codex:ba(o.codex,Di.codex),codexDangerous:ba(o.codexDangerous,Di.codexDangerous),claude:ba(o.claude,Di.claude),claudeDangerous:ba(o.claudeDangerous,Di.claudeDangerous),cursor:ba(o.cursor??o.ide,Di.cursor),vscode:ba(o.vscode,Di.vscode)};i||n(s)}catch(o){if(Yt(o)){e&&e();return}console.error("Failed to load command configuration",o)}})(),()=>{i=!0}},[e]);const r=D.useCallback((i,a=!1)=>{switch(i){case"codex":return a?t.codexDangerous:t.codex;case"claude":return a?t.claudeDangerous:t.claude;case"ide":case"cursor":return t.cursor;case"vscode":return t.vscode;default:return}},[t]);return{commandConfig:t,getCommandForLaunch:r}}function CP({onAuthExpired:e,onDataUpdate:t,onDeleteComplete:n}={}){const[r,i]=D.useState(!1),[a,o]=D.useState(!1),s=D.useCallback(async(d,u)=>{i(!0);try{const m=await mP(d,u);return t&&t(m.data),m}catch(m){throw Yt(m)?(e&&e(),m):(console.error("Failed to clone repository",m),window.alert("Failed to clone repository. Check server logs for details."),m)}finally{i(!1)}},[e,t]),l=D.useCallback(async(d,u,m)=>{o(!0);try{const _=await gP(d,u);t&&t(_),m&&m(),n&&n(d,u)}catch(_){if(Yt(_)){e&&e();return}console.error("Failed to delete repository",_),window.alert("Failed to delete repository. Check server logs for details.")}finally{o(!1)}},[e,t,n]),c=D.useCallback(async(d,u,m)=>{try{const _=await hP(d,u,m);return t&&t(_),_}catch(_){throw Yt(_)&&e&&e(),_}},[e,t]);return{isAddingRepo:r,isDeletingRepo:a,addRepository:s,deleteRepository:l,updateInitCommand:c}}async function RP(e,t,n=null,r=null){const i={org:e,repo:t};n&&(i.branch=n),r&&(i.prompt=r);const a=await As("/api/worktrees",i,{errorPrefix:"Failed to create worktree"});return{taskId:a&&typeof a.taskId=="string"?a.taskId:"",data:a}}async function NP(e,t,n){return(await SD("/api/worktrees",{org:e,repo:t,branch:n},{errorPrefix:"Failed to delete worktree"})).data||{}}function OP({onAuthExpired:e,onDataUpdate:t,onDeleteComplete:n}={}){const[r,i]=D.useState(!1),[a,o]=D.useState(!1),[s,l]=D.useState(!1),c=D.useCallback(async(u,m,_,E)=>{const S=E!==null;S?l(!0):i(!0);try{return await RP(u,m,_,E)}catch(f){throw Yt(f)?(e&&e(),f):(console.error("Failed to create worktree",f),window.alert("Failed to create worktree. Check server logs for details."),f)}finally{S?l(!1):i(!1)}},[e]),d=D.useCallback(async(u,m,_)=>{o(!0);try{const E=await NP(u,m,_);t&&t(E),n&&n(u,m,_)}catch(E){if(Yt(E)){e&&e();return}console.error("Failed to remove worktree",E),window.alert("Failed to remove worktree. Check server logs for details.")}finally{o(!1)}},[e,t,n]);return{isCreatingWorktree:r,isDeletingWorktree:a,isCreatingPromptWorktree:s,createWorktree:c,deleteWorktree:d}}async function AP(e,t,n,r){const i=new URLSearchParams({org:e,repo:t,branch:n}),a=await ma(`/api/plans?${i.toString()}`,{errorPrefix:"Failed to fetch plans"});return Array.isArray(a==null?void 0:a.data)?a.data:[]}async function IP(e,t,n,r){var s;const i=new URLSearchParams({org:e,repo:t,branch:n,planId:r}),a=await ma(`/api/plans/content?${i.toString()}`,{errorPrefix:"Failed to load plan"}),o=(s=a==null?void 0:a.data)==null?void 0:s.content;return typeof o=="string"?o:""}async function wP(e,t,n,r=!1,i=!1){const a=await As("/api/create-plan",{prompt:e,org:t,repo:n,rawPrompt:r,dangerousMode:i},{errorPrefix:"Failed to create plan from prompt"}),o=a&&typeof a.plan=="string"?a.plan:"";if(!o.trim())throw new Error("Server returned an empty plan. Check server logs for details.");return o}function DP({onAuthExpired:e}={}){const[t,n]=D.useState(!1),r=D.useCallback(async(o,s,l,{restorePromptOnError:c=!0,rawPrompt:d=!1,dangerousMode:u=!1,onPromptChange:m}={})=>{if(t)return;const _=typeof o=="string"?o:"";if(_.trim()){if(!s||!l){window.alert("Select a repository before creating a plan.");return}n(!0);try{m&&Zt.flushSync(()=>{m("")});const E=await wP(_,s,l,d,u);m&&Zt.flushSync(()=>{m(E)})}catch(E){if(Yt(E)){c&&m&&Zt.flushSync(()=>{m(o)}),e&&e();return}console.error("Failed to create plan",E),c&&m&&Zt.flushSync(()=>{m(o)}),window.alert("Failed to create plan. Check server logs for details.")}finally{n(!1)}}},[t,e]),i=D.useCallback(async(o,s,l)=>{if(!(!o||!s)){l(c=>({...c,selectedPlanId:s,content:"",contentLoading:!0,contentError:null}));try{const c=await IP(o.org,o.repo,o.branch,s);l(d=>({...d,content:c,contentLoading:!1,contentError:null}))}catch(c){if(Yt(c)){e&&e(),l(d=>({...d,open:!1}));return}l(d=>({...d,contentLoading:!1,contentError:(c==null?void 0:c.message)||"Failed to load plan."}))}}},[e]),a=D.useCallback(async(o,s,l)=>{if(!o)return;const c={org:o.org,repo:o.repo,branch:o.branch};s({...ch(),open:!0,loading:!0,context:c});try{const d=await AP(c.org,c.repo,c.branch);s(u=>({...u,loading:!1,error:null,plans:d,context:c})),d.length>0?await l(c,d[0].id):s(u=>({...u,selectedPlanId:null,content:""}))}catch(d){if(Yt(d)){e&&e(),s(u=>({...u,open:!1}));return}s(u=>({...u,loading:!1,error:(d==null?void 0:d.message)||"Failed to load plans."}))}},[e]);return{isCreatingPlan:t,createPlanFromPrompt:r,fetchPlanContent:i,openPlanHistory:a}}async function xP(e,t,n,r,i=null,a="changes",o=""){const s=await As("/api/git/diff",{org:e,repo:t,branch:n,path:r,previousPath:i,mode:a,status:o},{errorPrefix:"Failed to load diff"}),l=s&&typeof s=="object"?s:null;return{diff:l&&typeof l.diff=="string"?l.diff:"",path:(l==null?void 0:l.path)||r,previousPath:(l==null?void 0:l.previousPath)??i,mode:(l==null?void 0:l.mode)||a,status:(l==null?void 0:l.status)||o}}function MP({activeWorktree:e,onAuthExpired:t}){const n=D.useCallback(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches?"unified":"split",[]),r=D.useCallback(async(s,l)=>{if(!e||!s||!s.path)return;const d=(m=>m.kind==="staged"?"staged":m.kind==="untracked"?"untracked":m.kind==="conflict"?"unstaged":m.indexStatus&&m.indexStatus!==" "?"staged":"unstaged")(s),u={path:s.path,previousPath:s.previousPath||null,kind:s.kind||null,status:s.status||"",mode:d};l({open:!0,loading:!0,error:null,diff:"",file:u,view:n()});try{const m=await xP(e.org,e.repo,e.branch,s.path,s.previousPath||null,d,s.status||"");l(_=>({open:!0,loading:!1,error:null,diff:m&&typeof m.diff=="string"?m.diff:"",file:m&&typeof m=="object"?{path:m.path||u.path,previousPath:m.previousPath??u.previousPath,kind:u.kind,status:u.status,mode:m.mode||u.mode}:u,view:_.view||n()}))}catch(m){if(Yt(m)){t&&t(),l(_=>({..._,open:!1}));return}l(_=>({open:!0,loading:!1,error:m&&m.message?m.message:"Failed to load diff",diff:"",file:_.file||u,view:_.view||n()}))}},[e,t,n]),i=D.useCallback(s=>{s(l=>{if(!l.open)return l;const c=l.view==="split"?"unified":"split";return{...l,view:c}})},[]),a=D.useCallback(s=>{s(l=>l.open?{open:!1,loading:!1,error:null,diff:"",file:null,view:"split"}:l)},[]),o=D.useCallback(s=>{a(s)},[a]);return{openGitDiff:r,toggleDiffView:i,closeDiffModal:a,autoCloseDiff:o,resolveDefaultDiffView:n}}function LP({isRealtimeConnected:e,repositoryPollInterval:t,sessionPollInterval:n,onAuthExpired:r,onDataUpdate:i,onSessionsUpdate:a,onTasksLoad:o}){const s=D.useCallback(async()=>{try{const c=await bD();i&&i(c)}catch(c){if(Yt(c)){r&&r();return}console.error("Failed to load repositories",c)}},[i,r]),l=D.useCallback(async()=>{try{const c=await sP();a&&a(c)}catch(c){if(Yt(c)){r&&r();return}a&&a([])}},[r,a]);return D.useEffect(()=>{s()},[s]),D.useEffect(()=>{o&&o()},[o]),D.useEffect(()=>{e||(s(),l(),o&&o())},[e,l,o,s]),D.useEffect(()=>{if(e)return()=>{};if(Number.isNaN(t))return()=>{};let c=null,d=!1,u=!1;const m=()=>typeof document>"u"||document.visibilityState!=="hidden",_=()=>{d||u||!m()||(u=!0,s().catch(()=>{}).finally(()=>{u=!1}))};c=window.setInterval(_,t);const E=()=>{m()&&_()};return typeof document<"u"&&document.addEventListener("visibilitychange",E),()=>{d=!0,c!==null&&window.clearInterval(c),typeof document<"u"&&document.removeEventListener("visibilitychange",E)}},[e,s,t]),D.useEffect(()=>{l()},[l]),D.useEffect(()=>{if(e)return()=>{};const c=window.setInterval(()=>{l()},n);return()=>window.clearInterval(c)},[e,l,n]),{refreshRepositories:s,loadSessions:l}}function kP({getWorktreeKey:e,sessionMapRef:t,knownSessionsRef:n,sessionMetadataRef:r,idleAcknowledgementsRef:i,dashboardCacheRef:a,clearDashboardPolling:o,setPendingWorktreeAction:s,setActiveWorktree:l,setActiveRepoDashboard:c,setDashboardData:d,setDashboardError:u,setIsDashboardLoading:m,setIdleAcknowledgementsSnapshot:_,setIsMobileMenuOpen:E,disposeSocket:S,disposeTerminal:f,closeGitSidebar:p,loadSessions:g,openTerminalForWorktree:h}){return{handleWorktreeSelection:D.useCallback(async(T,y,N)=>{if(N==="main"){o(),s(null),l(null),S(),f(),p();const R=`${T}::${y}`,I=a.current.get(R);I?(d(I),u(null),m(!1)):(d(null),m(!0)),c({org:T,repo:y}),E(!1);return}o(),c(null),u(null),m(!1);const v={org:T,repo:y,branch:N},C=e(T,y,N);if(!t.current.has(C)&&!n.current.has(C)&&await g(),t.current.has(C)||n.current.has(C)){l(v);let R=!1,I;const w=r.current.get(C);if(w&&w.idle){I=i.current.has(C)?i.current.get(C):void 0;const P=new Map(i.current);P.set(C,KE(qo(w))),i.current=P,_(new Map(P)),R=!0}try{await h(v),s(null)}catch(P){if(R){const U=new Map(i.current);I===void 0?U.delete(C):U.set(C,I),i.current=U,_(new Map(U))}if(P&&P.message==="AUTH_REQUIRED")return;window.alert("Failed to reconnect to the existing session.")}}else s(v),E(!1)},[o,p,S,f,e,g,h,t,n,r,i,a,s,l,c,d,u,m,_,E])}}function PP({mobileMenuButtonRef:e}){const[t,n]=D.useState(!1),[r,i]=D.useState(null),a=D.useRef({}),o=D.useCallback(()=>{Zt.flushSync(()=>{n(!1)}),e.current&&e.current.focus()},[e]),s=D.useCallback(d=>{i(u=>u===d?null:d)},[]),l=D.useCallback(()=>{i(null)},[]),c=D.useCallback(d=>u=>{u?a.current[d]=u:delete a.current[d]},[]);return D.useEffect(()=>{if(!t)return;const d=u=>{u.key==="Escape"&&(u.preventDefault(),o())};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o]),D.useEffect(()=>{if(!r)return;const d=m=>{const _=m.target,E=a.current[r]||null;E&&_ instanceof Node&&E.contains(_)||l()},u=m=>{m.key==="Escape"&&(m.preventDefault(),l())};return document.addEventListener("mousedown",d),document.addEventListener("touchstart",d),window.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d),window.removeEventListener("keydown",u)}},[r,l]),{isMobileMenuOpen:t,setIsMobileMenuOpen:n,closeMobileMenu:o,openActionMenu:r,toggleActionMenu:s,getActionMenuRef:c}}/**
86
86
  * @license lucide-react v0.378.0 - ISC
87
87
  *
88
88
  * This source code is licensed under the ISC license.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>agentrix</title>
7
- <script type="module" crossorigin src="/assets/index-DysBePFX.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-BI2EZLfU.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-CwB7gOl4.css">
9
9
  </head>
10
10
  <body class="bg-neutral-950">