@staff0rd/assist 0.388.4 → 0.388.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.
@@ -379,7 +379,7 @@ ${u.join(`
379
379
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),m5&&e&&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(e){let t=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,o=this._model.finalSelectionEnd;return!r||!o||!t?!1:this._areCoordsInSelection(t,r,o)}isCellInSelection(e,t){let r=this._model.finalSelectionStart,o=this._model.finalSelectionEnd;return!r||!o?!1:this._areCoordsInSelection([e,t],r,o)}_areCoordsInSelection(e,t,r){return e[1]>t[1]&&e[1]<r[1]||t[1]===r[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<r[0]||t[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||t[1]<r[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=f9(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let o=this._getMouseBufferCoords(e);return o?(this._selectWordAt(o,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=h5(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=r?0:(t>r&&(t-=r),t=Math.min(Math.max(t,-mk),mk),t/=mk,t/Math.abs(t)+Math.round(t*(ime-1)))}shouldForceSelection(e){return NT?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),sme)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(NT&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let o=r.lines.get(this._model.selectionEnd[1]);o&&o.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<nme&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let o=Xhe(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(o,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,r=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,t,r);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,r)}_fireOnSelectionChange(e,t,r){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let r=t;for(let o=0;t>=o;o++){let i=e.loadCell(o,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:i>1&&t!==o&&(r+=i-1)}return r}setSelection(e,t,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,r=!0,o=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,s=i.lines.get(e[1]);if(!s)return;let n=i.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(s,e[0]),l=a,c=e[0]-a,u=0,p=0,f=0,d=0;if(n.charAt(a)===" "){for(;a>0&&n.charAt(a-1)===" ";)a--;for(;l<n.length&&n.charAt(l+1)===" ";)l++}else{let S=e[0],y=e[0];s.getWidth(S)===0&&(u++,S--),s.getWidth(y)===2&&(p++,y++);let v=s.getString(y).length;for(v>1&&(d+=v-1,l+=v-1);S>0&&a>0&&!this._isCharWordSeparator(s.loadCell(S-1,this._workCell));){s.loadCell(S-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,S--):b>1&&(f+=b-1,a-=b-1),a--,S--}for(;y<s.length&&l+1<n.length&&!this._isCharWordSeparator(s.loadCell(y+1,this._workCell));){s.loadCell(y+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(p++,y++):b>1&&(d+=b-1,l+=b-1),l++,y++}}l++;let h=a+c-u+f,g=Math.min(this._bufferService.cols,l-a+u+p-f-d);if(!(!t&&n.slice(a,l).trim()==="")){if(r&&h===0&&s.getCodePoint(0)!==32){let S=i.lines.get(e[1]-1);if(S&&s.isWrapped&&S.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let v=this._bufferService.cols-y.start;h-=v,g+=v}}}if(o&&h+g===this._bufferService.cols&&s.getCodePoint(this._bufferService.cols-1)!==32){let S=i.lines.get(e[1]+1);if(S?.isWrapped&&S.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(g+=y.length)}}return{start:h,length:g}}}_selectWordAt(e,t){let r=this._getWordAt(e,t);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let r=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=f9(r,this._bufferService.cols)}};Xk=ur([de(3,ei),de(4,Vp),de(5,a5),de(6,ti),de(7,_l),de(8,bl)],Xk);var h9=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},m9=class{constructor(){this._color=new h9,this._css=new h9}setCss(e,t,r){this._css.set(e,t,r)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,r){this._color.set(e,t,r)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},zr=Object.freeze((()=>{let e=[Jt.toColor("#2e3436"),Jt.toColor("#cc0000"),Jt.toColor("#4e9a06"),Jt.toColor("#c4a000"),Jt.toColor("#3465a4"),Jt.toColor("#75507b"),Jt.toColor("#06989a"),Jt.toColor("#d3d7cf"),Jt.toColor("#555753"),Jt.toColor("#ef2929"),Jt.toColor("#8ae234"),Jt.toColor("#fce94f"),Jt.toColor("#729fcf"),Jt.toColor("#ad7fa8"),Jt.toColor("#34e2e2"),Jt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let r=0;r<216;r++){let o=t[r/36%6|0],i=t[r/6%6|0],s=t[r%6];e.push({css:kr.toCss(o,i,s),rgba:kr.toRgba(o,i,s)})}for(let r=0;r<24;r++){let o=8+r*10;e.push({css:kr.toCss(o,o,o),rgba:kr.toRgba(o,o,o)})}return e})()),Fp=Jt.toColor("#ffffff"),Sv=Jt.toColor("#000000"),g9=Jt.toColor("#ffffff"),y9=Sv,mv={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},cme=Fp,Zk=class extends ke{constructor(e){super(),this._optionsService=e,this._contrastCache=new m9,this._halfContrastCache=new m9,this._onChangeColors=this._register(new ne),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Fp,background:Sv,cursor:g9,cursorAccent:y9,selectionForeground:void 0,selectionBackgroundTransparent:mv,selectionBackgroundOpaque:Ut.blend(Sv,mv),selectionInactiveBackgroundTransparent:mv,selectionInactiveBackgroundOpaque:Ut.blend(Sv,mv),scrollbarSliderBackground:Ut.opacity(Fp,.2),scrollbarSliderHoverBackground:Ut.opacity(Fp,.4),scrollbarSliderActiveBackground:Ut.opacity(Fp,.5),overviewRulerBorder:Fp,ansi:zr.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=_t(e.foreground,Fp),t.background=_t(e.background,Sv),t.cursor=Ut.blend(t.background,_t(e.cursor,g9)),t.cursorAccent=Ut.blend(t.background,_t(e.cursorAccent,y9)),t.selectionBackgroundTransparent=_t(e.selectionBackground,mv),t.selectionBackgroundOpaque=Ut.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=_t(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ut.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?_t(e.selectionForeground,u9):void 0,t.selectionForeground===u9&&(t.selectionForeground=void 0),Ut.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ut.opacity(t.selectionBackgroundTransparent,.3)),Ut.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ut.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=_t(e.scrollbarSliderBackground,Ut.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=_t(e.scrollbarSliderHoverBackground,Ut.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=_t(e.scrollbarSliderActiveBackground,Ut.opacity(t.foreground,.5)),t.overviewRulerBorder=_t(e.overviewRulerBorder,cme),t.ansi=zr.slice(),t.ansi[0]=_t(e.black,zr[0]),t.ansi[1]=_t(e.red,zr[1]),t.ansi[2]=_t(e.green,zr[2]),t.ansi[3]=_t(e.yellow,zr[3]),t.ansi[4]=_t(e.blue,zr[4]),t.ansi[5]=_t(e.magenta,zr[5]),t.ansi[6]=_t(e.cyan,zr[6]),t.ansi[7]=_t(e.white,zr[7]),t.ansi[8]=_t(e.brightBlack,zr[8]),t.ansi[9]=_t(e.brightRed,zr[9]),t.ansi[10]=_t(e.brightGreen,zr[10]),t.ansi[11]=_t(e.brightYellow,zr[11]),t.ansi[12]=_t(e.brightBlue,zr[12]),t.ansi[13]=_t(e.brightMagenta,zr[13]),t.ansi[14]=_t(e.brightCyan,zr[14]),t.ansi[15]=_t(e.brightWhite,zr[15]),e.extendedAnsi){let r=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let o=0;o<r;o++)t.ansi[o+16]=_t(e.extendedAnsi[o],zr[o+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){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[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(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()}}};Zk=ur([de(0,ti)],Zk);function _t(e,t){if(e!==void 0)try{return Jt.toColor(e)}catch{}return t}var ume=class{constructor(...e){this._entries=new Map;for(let[t,r]of e)this.set(t,r)}set(e,t){let r=this._entries.get(e);return this._entries.set(e,t),r}forEach(e){for(let[t,r]of this._entries.entries())e(t,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},pme=class{constructor(){this._services=new ume,this._services.set(n5,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let r=Ade(e).sort((s,n)=>s.index-n.index),o=[];for(let s of r){let n=this._services.get(s.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${s.id._id}.`);o.push(n)}let i=r.length>0?r[0].index:t.length;if(t.length!==i)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...o)}},dme={trace:0,debug:1,info:2,warn:3,error:4,off:5},fme="xterm.js: ",Qk=class extends ke{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),hme=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=dme[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":fme)+t,...r)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Qk=ur([de(0,ti)],Qk);var hme,v9=class extends ke{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ne),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ne),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ne),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let r=0;r<Math.min(e,this.length);r++)t[r]=this._array[this._getCyclicIndex(r)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,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,t,...r){if(t){for(let o=e;o<this._length-t;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let o=this._length-1;o>=e;o--)this._array[this._getCyclicIndex(o+r.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<r.length;o++)this._array[this._getCyclicIndex(e+o)]=r[o];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let o=this._length+r.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,r){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let i=t-1;i>=0;i--)this.set(e+i+r,this.get(e+i));let o=e+t+r-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<t;o++)this.set(e+o+r,this.get(e+o))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},De=3,Er=Object.freeze(new Av),_T=0,gk=2,xv=class Lj{constructor(t,r,o=!1){this.isWrapped=o,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*De);let i=r||Ns.fromCharData([0,H9,1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let r=this._data[t*De+0],o=r&2097151;return[this._data[t*De+1],r&2097152?this._combined[t]:o?Yc(o):"",r>>22,r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):o]}set(t,r){this._data[t*De+1]=r[0],r[1].length>1?(this._combined[t]=r[1],this._data[t*De+0]=t|2097152|r[2]<<22):this._data[t*De+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(t){return this._data[t*De+0]>>22}hasWidth(t){return this._data[t*De+0]&12582912}getFg(t){return this._data[t*De+1]}getBg(t){return this._data[t*De+2]}hasContent(t){return this._data[t*De+0]&4194303}getCodePoint(t){let r=this._data[t*De+0];return r&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r&2097151}isCombined(t){return this._data[t*De+0]&2097152}getString(t){let r=this._data[t*De+0];return r&2097152?this._combined[t]:r&2097151?Yc(r&2097151):""}isProtected(t){return this._data[t*De+2]&536870912}loadCell(t,r){return _T=t*De,r.content=this._data[_T+0],r.fg=this._data[_T+1],r.bg=this._data[_T+2],r.content&2097152&&(r.combinedData=this._combined[t]),r.bg&268435456&&(r.extended=this._extendedAttrs[t]),r}setCell(t,r){r.content&2097152&&(this._combined[t]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*De+0]=r.content,this._data[t*De+1]=r.fg,this._data[t*De+2]=r.bg}setCellFromCodepoint(t,r,o,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*De+0]=r|o<<22,this._data[t*De+1]=i.fg,this._data[t*De+2]=i.bg}addCodepointToCell(t,r,o){let i=this._data[t*De+0];i&2097152?this._combined[t]+=Yc(r):i&2097151?(this._combined[t]=Yc(i&2097151)+Yc(r),i&=-2097152,i|=2097152):i=r|1<<22,o&&(i&=-12582913,i|=o<<22),this._data[t*De+0]=i}insertCells(t,r,o){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,o),r<this.length-t){let i=new Ns;for(let s=this.length-t-r-1;s>=0;--s)this.setCell(t+r+s,this.loadCell(t+s,i));for(let s=0;s<r;++s)this.setCell(t+s,o)}else for(let i=t;i<this.length;++i)this.setCell(i,o);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,o)}deleteCells(t,r,o){if(t%=this.length,r<this.length-t){let i=new Ns;for(let s=0;s<this.length-t-r;++s)this.setCell(t+s,this.loadCell(t+r+s,i));for(let s=this.length-r;s<this.length;++s)this.setCell(s,o)}else for(let i=t;i<this.length;++i)this.setCell(i,o);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,o),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,o)}replaceCells(t,r,o,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,o),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,o);t<r&&t<this.length;)this.isProtected(t)||this.setCell(t,o),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,o),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,o);t<r&&t<this.length;)this.setCell(t++,o)}resize(t,r){if(t===this.length)return this._data.length*4*gk<this._data.buffer.byteLength;let o=t*De;if(t>this.length){if(this._data.buffer.byteLength>=o*4)this._data=new Uint32Array(this._data.buffer,0,o);else{let i=new Uint32Array(o);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,r)}else{this._data=this._data.subarray(0,o);let i=Object.keys(this._combined);for(let n=0;n<i.length;n++){let a=parseInt(i[n],10);a>=t&&delete this._combined[a]}let s=Object.keys(this._extendedAttrs);for(let n=0;n<s.length;n++){let a=parseInt(s[n],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,o*4*gk<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*gk<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,r=!1){if(r){for(let o=0;o<this.length;++o)this.isProtected(o)||this.setCell(o,t);return}this._combined={},this._extendedAttrs={};for(let o=0;o<this.length;++o)this.setCell(o,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let r in t._combined)this._combined[r]=t._combined[r];this._extendedAttrs={};for(let r in t._extendedAttrs)this._extendedAttrs[r]=t._extendedAttrs[r];this.isWrapped=t.isWrapped}clone(){let t=new Lj(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let r in this._combined)t._combined[r]=this._combined[r];for(let r in this._extendedAttrs)t._extendedAttrs[r]=this._extendedAttrs[r];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303)return t+(this._data[t*De+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*De+0]&4194303||this._data[t*De+2]&50331648)return t+(this._data[t*De+0]>>22);return 0}copyCellsFrom(t,r,o,i,s){let n=t._data;if(s)for(let l=i-1;l>=0;l--){for(let c=0;c<De;c++)this._data[(o+l)*De+c]=n[(r+l)*De+c];n[(r+l)*De+2]&268435456&&(this._extendedAttrs[o+l]=t._extendedAttrs[r+l])}else for(let l=0;l<i;l++){for(let c=0;c<De;c++)this._data[(o+l)*De+c]=n[(r+l)*De+c];n[(r+l)*De+2]&268435456&&(this._extendedAttrs[o+l]=t._extendedAttrs[r+l])}let a=Object.keys(t._combined);for(let l=0;l<a.length;l++){let c=parseInt(a[l],10);c>=r&&(this._combined[c-r+o]=t._combined[c])}}translateToString(t,r,o,i){r=r??0,o=o??this.length,t&&(o=Math.min(o,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;r<o;){let n=this._data[r*De+0],a=n&2097151,l=n&2097152?this._combined[r]:a?Yc(a):Xc;if(s+=l,i)for(let c=0;c<l.length;++c)i.push(r);r+=n>>22||1}return i&&i.push(r),s}};function mme(e,t,r,o,i,s){let n=[];for(let a=0;a<e.length-1;a++){let l=a,c=e.get(++l);if(!c.isWrapped)continue;let u=[e.get(a)];for(;l<e.length&&c.isWrapped;)u.push(c),c=e.get(++l);if(!s&&o>=a&&o<l){a+=u.length-1;continue}let p=0,f=Mv(u,p,t),d=1,h=0;for(;d<u.length;){let S=Mv(u,d,t),y=S-h,v=r-f,b=Math.min(y,v);u[p].copyCellsFrom(u[d],h,f,b,!1),f+=b,f===r&&(p++,f=0),h+=b,h===S&&(d++,h=0),f===0&&p!==0&&u[p-1].getWidth(r-1)===2&&(u[p].copyCellsFrom(u[p-1],r-1,f++,1,!1),u[p-1].setCell(r-1,i))}u[p].replaceCells(f,r,i);let g=0;for(let S=u.length-1;S>0&&(S>p||u[S].getTrimmedLength()===0);S--)g++;g>0&&(n.push(a+u.length-g),n.push(g)),a+=u.length-1}return n}function gme(e,t){let r=[],o=0,i=t[o],s=0;for(let n=0;n<e.length;n++)if(i===n){let a=t[++o];e.onDeleteEmitter.fire({index:n-s,amount:a}),n+=a-1,s+=a,i=t[++o]}else r.push(n);return{layout:r,countRemoved:s}}function yme(e,t){let r=[];for(let o=0;o<t.length;o++)r.push(e.get(t[o]));for(let o=0;o<r.length;o++)e.set(o,r[o]);e.length=t.length}function vme(e,t,r){let o=[],i=e.map((l,c)=>Mv(e,c,t)).reduce((l,c)=>l+c),s=0,n=0,a=0;for(;a<i;){if(i-a<r){o.push(i-a);break}s+=r;let l=Mv(e,n,t);s>l&&(s-=l,n++);let c=e[n].getWidth(s-1)===2;c&&s--;let u=c?r-1:r;o.push(u),a+=u}return o}function Mv(e,t,r){if(t===e.length-1)return e[t].getTrimmedLength();let o=!e[t].hasContent(r-1)&&e[t].getWidth(r-1)===1,i=e[t+1].getWidth(0)===2;return o&&i?r-1:r}var Oj=class Dj{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Dj._nextId++,this._onDispose=this.register(new ne),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),jp(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Oj._nextId=1;var bme=Oj,Ur={},Up=Ur.B;Ur[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};Ur.A={"#":"\xA3"};Ur.B=void 0;Ur[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};Ur.C=Ur[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Ur.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};Ur.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};Ur.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};Ur.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};Ur.E=Ur[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};Ur.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};Ur.H=Ur[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Ur["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};var b9=4294967295,_9=class{constructor(e,t,r){this._hasScrollback=e,this._optionsService=t,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Er.clone(),this.savedCharset=Up,this.markers=[],this._nullCell=Ns.fromCharData([0,H9,1,0]),this._whitespaceCell=Ns.fromCharData([0,Xc,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new zT,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new v9(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new AT),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new AT),this._whitespaceCell}getBlankLine(e,t){return new xv(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>b9?b9:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Er);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new v9(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let r=this.getNullCell(Er),o=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)o+=+this.lines.get(n).resize(e,r);let s=0;if(this._rows<t)for(let n=this._rows;n<t;n++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new xv(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+s+1?(this.ybase--,s++,this.ydisp>0&&this.ydisp--):this.lines.push(new xv(e,r)));else for(let n=this._rows;n>t;n--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let n=this.lines.length-i;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),s&&(this.y+=s),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let s=0;s<this.lines.length;s++)o+=+this.lines.get(s).resize(e,r);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),o>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,o=mme(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Er),r);if(o.length>0){let i=gme(this.lines,o);yme(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,r){let o=this.getNullCell(Er),i=r;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new xv(e,o))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,t){let r=this._optionsService.rawOptions.reflowCursorLine,o=this.getNullCell(Er),i=[],s=0;for(let n=this.lines.length-1;n>=0;n--){let a=this.lines.get(n);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let l=[a];for(;a.isWrapped&&n>0;)a=this.lines.get(--n),l.unshift(a);if(!r){let b=this.ybase+this.y;if(b>=n&&b<n+l.length)continue}let c=l[l.length-1].getTrimmedLength(),u=vme(l,this._cols,e),p=u.length-l.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+p):f=Math.max(0,this.lines.length-this.lines.maxLength+p);let d=[];for(let b=0;b<p;b++){let _=this.getBlankLine(Er,!0);d.push(_)}d.length>0&&(i.push({start:n+l.length+s,newLines:d}),s+=d.length),l.push(...d);let h=u.length-1,g=u[h];g===0&&(h--,g=u[h]);let S=l.length-p-1,y=c;for(;S>=0;){let b=Math.min(y,g);if(l[h]===void 0)break;if(l[h].copyCellsFrom(l[S],y-b,g-b,b,!0),g-=b,g===0&&(h--,g=u[h]),y-=b,y===0){S--;let _=Math.max(S,0);y=Mv(l,_,this._cols)}}for(let b=0;b<l.length;b++)u[b]<e&&l[b].setCell(u[b],o);let v=p-f;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+s)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+t-1)}if(i.length>0){let n=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let l=this.lines.length,c=l-1,u=0,p=i[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+s);let f=0;for(let g=Math.min(this.lines.maxLength-1,l+s-1);g>=0;g--)if(p&&p.start>c+f){for(let S=p.newLines.length-1;S>=0;S--)this.lines.set(g--,p.newLines[S]);g++,n.push({index:c+1,amount:p.newLines.length}),f+=p.newLines.length,p=i[++u]}else this.lines.set(g,a[c--]);let d=0;for(let g=n.length-1;g>=0;g--)n[g].index+=d,this.lines.onInsertEmitter.fire(n[g]),d+=n[g].amount;let h=Math.max(0,l+s-this.lines.maxLength);h>0&&this.lines.onTrimEmitter.fire(h)}}translateBufferLineToString(e,t,r=0,o){let i=this.lines.get(e);return i?i.translateToString(t,r,o):""}getWrappedRangeForLine(e){let t=e,r=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:t,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new bme(e);return this.markers.push(t),t.register(this.lines.onTrim(r=>{t.line-=r,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(r=>{t.line>=r.index&&(t.line+=r.amount)})),t.register(this.lines.onDelete(r=>{t.line>=r.index&&t.line<r.index+r.amount&&t.dispose(),t.line>r.index&&(t.line-=r.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},_me=class extends ke{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ne),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 _9(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new _9(!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,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Bj=2,Ij=1,Jk=class extends ke{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ne),this.onResize=this._onResize.event,this._onScroll=this._register(new ne),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Bj),this.rows=Math.max(e.rawOptions.rows||0,Ij),this.buffers=this._register(new _me(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let r=this.cols!==e,o=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:r,rowsChanged:o})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let r=this.buffer,o;o=this._cachedBlankLine,(!o||o.length!==this.cols||o.getFg(0)!==e.fg||o.getBg(0)!==e.bg)&&(o=r.getBlankLine(e,t),this._cachedBlankLine=o),o.isWrapped=t;let i=r.ybase+r.scrollTop,s=r.ybase+r.scrollBottom;if(r.scrollTop===0){let n=r.lines.isFull;s===r.lines.length-1?n?r.lines.recycle().copyFrom(o):r.lines.push(o.clone()):r.lines.splice(s+1,0,o.clone()),n?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let n=s-i+1;r.lines.shiftElements(i+1,n-1,-1),r.lines.set(s,o.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,t){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let o=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),o!==r.ydisp&&(t||this._onScroll.fire(r.ydisp))}};Jk=ur([de(0,ti)],Jk);var $h={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:NT,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Sme=["normal","bold","100","200","300","400","500","600","700","800","900"],xme=class extends ke{constructor(e){super(),this._onOptionChange=this._register(new ne),this.onOptionChange=this._onOptionChange.event;let t={...$h};for(let r in e)if(r in t)try{let o=e[r];t[r]=this._sanitizeAndValidateOption(r,o)}catch(o){console.error(o)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register($t(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(r=>{r===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&t()})}_setupOptions(){let e=r=>{if(!(r in $h))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},t=(r,o)=>{if(!(r in $h))throw new Error(`No option with key "${r}"`);o=this._sanitizeAndValidateOption(r,o),this.rawOptions[r]!==o&&(this.rawOptions[r]=o,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let o={get:e.bind(this,r),set:t.bind(this,r)};Object.defineProperty(this.options,r,o)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=$h[e]),!Tme(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=$h[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Sme.includes(t)?t:$h[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Tme(e){return e==="block"||e==="underline"||e==="bar"}function Tv(e,t=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let o in e)r[o]=t<=1?e[o]:e[o]&&Tv(e[o],t-1);return r}var S9=Object.freeze({insertMode:!1}),x9=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),e5=class extends ke{constructor(e,t,r){super(),this._bufferService=e,this._logService=t,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ne),this.onData=this._onData.event,this._onUserInput=this._register(new ne),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ne),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ne),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Tv(S9),this.decPrivateModes=Tv(x9)}reset(){this.modes=Tv(S9),this.decPrivateModes=Tv(x9)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(o=>o.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};e5=ur([de(0,ei),de(1,G9),de(2,ti)],e5);var T9={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function yk(e,t){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!t&&(r|=3)),r}var vk=String.fromCharCode,w9={DEFAULT:e=>{let t=[yk(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${vk(t[0])}${vk(t[1])}${vk(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yk(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yk(e,!0)};${e.x};${e.y}${t}`}},t5=class extends ke{constructor(e,t,r){super(),this._bufferService=e,this._coreService=t,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ne),this.onProtocolChange=this._onProtocolChange.event;for(let o of Object.keys(T9))this.addProtocol(o,T9[o]);for(let o of Object.keys(w9))this.addEncoding(o,w9[o]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,r){if(e.deltaY===0||e.shiftKey||t===void 0||r===void 0)return 0;let o=t/r,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=o+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,r){if(r){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};t5=ur([de(0,ei),de(1,Vp),de(2,ti)],t5);var bk=[[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]],wme=[[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]],Fr;function Cme(e,t){let r=0,o=t.length-1,i;if(e<t[0][0]||e>t[o][1])return!1;for(;o>=r;)if(i=r+o>>1,e>t[i][1])r=i+1;else if(e<t[i][0])o=i-1;else return!0;return!1}var Pme=class{constructor(){if(this.version="6",!Fr){Fr=new Uint8Array(65536),Fr.fill(1),Fr[0]=0,Fr.fill(0,1,32),Fr.fill(0,127,160),Fr.fill(2,4352,4448),Fr[9001]=2,Fr[9002]=2,Fr.fill(2,11904,42192),Fr[12351]=1,Fr.fill(2,44032,55204),Fr.fill(2,63744,64256),Fr.fill(2,65040,65050),Fr.fill(2,65072,65136),Fr.fill(2,65280,65377),Fr.fill(2,65504,65511);for(let e=0;e<bk.length;++e)Fr.fill(0,bk[e][0],bk[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Fr[e]:Cme(e,wme)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let r=this.wcwidth(e),o=r===0&&t!==0;if(o){let i=$p.extractWidth(t);i===0?o=!1:i>r&&(r=i)}return $p.createPropertyValue(0,r,o)}},$p=class MT{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ne,this.onChange=this._onChange.event;let t=new Pme;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,r,o=!1){return(t&16777215)<<3|(r&3)<<1|(o?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let r=0,o=0,i=t.length;for(let s=0;s<i;++s){let n=t.charCodeAt(s);if(55296<=n&&n<=56319){if(++s>=i)return r+this.wcwidth(n);let c=t.charCodeAt(s);56320<=c&&c<=57343?n=(n-55296)*1024+c-56320+65536:r+=this.wcwidth(c)}let a=this.charProperties(n,o),l=MT.extractWidth(a);MT.extractShouldJoin(a)&&(l-=MT.extractWidth(o)),r+=l,o=a}return r}charProperties(t,r){return this._activeProvider.charProperties(t,r)}},Rme=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function C9(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&t&&(r.isWrapped=t[3]!==0&&t[3]!==32)}var gv=2147483647,Eme=256,Nj=class r5{constructor(t=32,r=32){if(this.maxLength=t,this.maxSubParamsLength=r,r>Eme)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let r=new r5;if(!t.length)return r;for(let o=Array.isArray(t[0])?1:0;o<t.length;++o){let i=t[o];if(Array.isArray(i))for(let s=0;s<i.length;++s)r.addSubParam(i[s]);else r.addParam(i)}return r}clone(){let t=new r5(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let r=0;r<this.length;++r){t.push(this.params[r]);let o=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-o>0&&t.push(Array.prototype.slice.call(this._subParams,o,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>gv?gv:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>gv?gv:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let r=this._subParamsIdx[t]>>8,o=this._subParamsIdx[t]&255;return o-r>0?this._subParams.subarray(r,o):null}getSubParamsAll(){let t={};for(let r=0;r<this.length;++r){let o=this._subParamsIdx[r]>>8,i=this._subParamsIdx[r]&255;i-o>0&&(t[r]=this._subParams.slice(o,i))}return t}addDigit(t){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let o=this._digitIsSub?this._subParams:this.params,i=o[r-1];o[r-1]=~i?Math.min(i*10+t,gv):t}},yv=[],kme=class{constructor(){this._state=0,this._active=yv,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=yv}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=yv,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||yv,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,r){if(!this._active.length)this._handlerFb(this._id,"PUT",UT(e,t,r));else for(let o=this._active.length-1;o>=0;o--)this._active[o].put(e,t,r)}start(){this.reset(),this._state=1}put(e,t,r){if(this._state!==3){if(this._state===1)for(;t<r;){let o=e[t++];if(o===59){this._state=2,this._start();break}if(o<48||57<o){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+o-48}this._state===2&&r-t>0&&this._put(e,t,r)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let r=!1,o=this._active.length-1,i=!1;if(this._stack.paused&&(o=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;o>=0&&(r=this._active[o].end(e),r!==!0);o--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!1,r;o--}for(;o>=0;o--)if(r=this._active[o].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!0,r}this._active=yv,this._id=-1,this._state=0}}},Qi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=UT(e,t,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,t}},vv=[],Mme=class{constructor(){this._handlers=Object.create(null),this._active=vv,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=vv}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,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=vv,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||vv,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(t)}put(e,t,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",UT(e,t,r));else for(let o=this._active.length-1;o>=0;o--)this._active[o].put(e,t,r)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,o=this._active.length-1,i=!1;if(this._stack.paused&&(o=this._stack.loopPosition-1,r=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&r===!1){for(;o>=0&&(r=this._active[o].unhook(e),r!==!0);o--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!1,r;o--}for(;o>=0;o--)if(r=this._active[o].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=o,this._stack.fallThrough=!0,r}this._active=vv,this._ident=0}},wv=new Nj;wv.addParam(0);var P9=class{constructor(e){this._handler=e,this._data="",this._params=wv,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():wv,this._data="",this._hitLimit=!1}put(e,t,r){this._hitLimit||(this._data+=UT(e,t,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(r=>(this._params=wv,this._data="",this._hitLimit=!1,r));return this._params=wv,this._data="",this._hitLimit=!1,t}},Ame=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,r,o){this.table[t<<8|e]=r<<4|o}addMany(e,t,r,o){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=r<<4|o}},Is=160,Lme=(function(){let e=new Ame(4095),t=Array.apply(null,Array(256)).map((a,l)=>l),r=(a,l)=>t.slice(a,l),o=r(32,127),i=r(0,24);i.push(25),i.push.apply(i,r(28,32));let s=r(0,14),n;e.setDefault(1,0),e.addMany(o,0,2,0);for(n in s)e.addMany([24,26,153,154],n,3,0),e.addMany(r(128,144),n,3,0),e.addMany(r(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(o,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(o,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(o,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Is,0,2,0),e.add(Is,8,5,8),e.add(Is,6,0,6),e.add(Is,11,0,11),e.add(Is,13,13,13),e})(),Ome=class extends ke{constructor(e=Lme){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Nj,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,r,o)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,r)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register($t(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kme),this._dcsParser=this._register(new Mme),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let s=e.intermediates.charCodeAt(i);if(32>s||s>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=s}}if(e.final.length!==1)throw new Error("final must be a single byte");let o=e.final.charCodeAt(0);if(t[0]>o||o>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return r<<=8,r|=o,r}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let o=this._escHandlers[r];return o.push(t),{dispose:()=>{let i=o.indexOf(t);i!==-1&&o.splice(i,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let o=this._csiHandlers[r];return o.push(t),{dispose:()=>{let i=o.indexOf(t);i!==-1&&o.splice(i,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,r,o,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=r,this._parseStack.transition=o,this._parseStack.chunkPos=i}parse(e,t,r){let o=0,i=0,s=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,s=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&l>-1){for(;l>=0&&(n=a[l](this._params),n!==!0);l--)if(n instanceof Promise)return this._parseStack.handlerPos=l,n}this._parseStack.handlers=[];break;case 4:if(r===!1&&l>-1){for(;l>=0&&(n=a[l](),n!==!0);l--)if(n instanceof Promise)return this._parseStack.handlerPos=l,n}this._parseStack.handlers=[];break;case 6:if(o=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(o!==24&&o!==26,r),n)return n;o===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(o=e[this._parseStack.chunkPos],n=this._oscParser.end(o!==24&&o!==26,r),n)return n;o===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,s=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=s;a<t;++a){switch(o=e[a],i=this._transitions.table[this.currentState<<8|(o<160?o:Is)],i>>4){case 2:for(let f=a+1;;++f){if(f>=t||(o=e[f])<32||o>126&&o<Is){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(o=e[f])<32||o>126&&o<Is){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(o=e[f])<32||o>126&&o<Is){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(o=e[f])<32||o>126&&o<Is){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[o]?this._executeHandlers[o]():this._executeHandlerFb(o),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:o,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|o],c=l?l.length-1:-1;for(;c>=0&&(n=l[c](this._params),n!==!0);c--)if(n instanceof Promise)return this._preserveStack(3,l,c,i,a),n;c<0&&this._csiHandlerFb(this._collect<<8|o,this._params),this.precedingJoinState=0;break;case 8:do switch(o){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(o-48)}while(++a<t&&(o=e[a])>47&&o<60);a--;break;case 9:this._collect<<=8,this._collect|=o;break;case 10:let u=this._escHandlers[this._collect<<8|o],p=u?u.length-1:-1;for(;p>=0&&(n=u[p](),n!==!0);p--)if(n instanceof Promise)return this._preserveStack(4,u,p,i,a),n;p<0&&this._escHandlerFb(this._collect<<8|o),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|o,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(o=e[f])===24||o===26||o===27||o>127&&o<Is){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(n=this._dcsParser.unhook(o!==24&&o!==26),n)return this._preserveStack(6,[],0,i,a),n;o===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(o=e[f])<32||o>127&&o<Is){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(n=this._oscParser.end(o!==24&&o!==26),n)return this._preserveStack(5,[],0,i,a),n;o===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},Dme=/^([\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})$/,Bme=/^[\da-f]+$/;function R9(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let r=Dme.exec(t);if(r){let o=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/o*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/o*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/o*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Bme.exec(t)&&[3,6,9,12].includes(t.length))){let r=t.length/3,o=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(r*i,r*i+r),16);o[i]=r===1?s<<4:r===2?s:r===3?s>>4:s>>8}return o}}function _k(e,t){let r=e.toString(16),o=r.length<2?"0"+r:r;switch(t){case 4:return r[0];case 8:return o;case 12:return(o+o).slice(0,3);default:return o+o}}function Ime(e,t=16){let[r,o,i]=e;return`rgb:${_k(r,t)}/${_k(o,t)}/${_k(i,t)}`}var Nme={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Kc=131072,E9=10;function k9(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var M9=5e3,A9=0,zme=class extends ke{constructor(e,t,r,o,i,s,n,a,l=new Ome){super(),this._bufferService=e,this._charsetService=t,this._coreService=r,this._logService=o,this._optionsService=i,this._oscLinkService=s,this._coreMouseService=n,this._unicodeService=a,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new kde,this._utf8Decoder=new Mde,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Er.clone(),this._eraseAttrDataInternal=Er.clone(),this._onRequestBell=this._register(new ne),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ne),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ne),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ne),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ne),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ne),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ne),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ne),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ne),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ne),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ne),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ne),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ne),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 o5(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:p})}),this._parser.setDcsHandlerFallback((c,u,p)=>{u==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:p})}),this._parser.setPrintHandler((c,u,p)=>this.print(c,u,p)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(Z.BEL,()=>this.bell()),this._parser.setExecuteHandler(Z.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Z.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Z.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Z.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Z.BS,()=>this.backspace()),this._parser.setExecuteHandler(Z.HT,()=>this.tab()),this._parser.setExecuteHandler(Z.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Z.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ET.IND,()=>this.index()),this._parser.setExecuteHandler(ET.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ET.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Qi(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Qi(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Qi(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Qi(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Qi(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Qi(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Qi(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Qi(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Qi(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Qi(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Qi(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Qi(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Ur)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new P9((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,r,o){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=r,this._parseStack.position=o}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),M9))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${M9} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let r,o=this._activeBuffer.x,i=this._activeBuffer.y,s=0,n=this._parseStack.paused;if(n){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(r),r;o=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Kc&&(s=this._parseStack.position+Kc)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Kc&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Kc))),n||this._dirtyRowTracker.clearRange(),e.length>Kc)for(let c=s;c<e.length;c+=Kc){let u=c+Kc<e.length?c+Kc:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,p))return this._preserveStack(o,i,p,c),this._logSlowResolvingAsync(r),r}else if(!n){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,c))return this._preserveStack(o,i,c,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==o||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,r){let o,i,s=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-t>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let d=t;d<r;++d){if(o=e[d],o<127&&s){let y=s[String.fromCharCode(o)];y&&(o=y.charCodeAt(0))}let h=this._unicodeService.charProperties(o,f);i=$p.extractWidth(h);let g=$p.extractShouldJoin(h),S=g?$p.extractWidth(f):0;if(f=h,n&&this._onA11yChar.fire(Yc(o)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-S>a){if(l){let y=p,v=this._activeBuffer.x-S;for(this._activeBuffer.x=S,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),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),S>0&&p instanceof xv&&p.copyCellsFrom(y,v,0,S,!1);v<a;)y.setCellFromCodepoint(v++,0,1,u)}else if(this._activeBuffer.x=a-1,i===2)continue}if(g&&this._activeBuffer.x){let y=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-y,o,i);for(let v=i-S;--v>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(p.insertCells(this._activeBuffer.x,i-S,this._activeBuffer.getNullCell(u)),p.getWidth(a-1)===2&&p.setCellFromCodepoint(a-1,0,1,u)),p.setCellFromCodepoint(this._activeBuffer.x++,o,i,u),i>0)for(;--i;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&r-t>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>k9(r.params[0],this._optionsService.rawOptions.windowOptions)?t(r):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new P9(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Qi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,r,o=!1,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.replaceCells(t,r,this._activeBuffer.getNullCell(this._eraseAttrData()),i),o&&(s.isWrapped=!1)}_resetBufferLine(e,t=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);r<this._bufferService.rows;r++)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,o=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-o+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,o;for(o=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-o;t--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(o,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(Er));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);o.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),o.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);o.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),o.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);o.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),o.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);o.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),o.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let r=e.params[0]||1,o=$p.extractWidth(t),i=this._activeBuffer.x-o,s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),n=new Uint32Array(s.length*r),a=0;for(let c=0;c<s.length;){let u=s.codePointAt(c)||0;n[a++]=u,c+=u>65535?2:1}let l=a;for(let c=1;c<r;++c)n.copyWithin(l,0,a),l+=a;return this.print(n,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Z.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Z.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Z.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Z.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Z.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Up),this._charsetService.setgCharset(1,Up),this._charsetService.setgCharset(2,Up),this._charsetService.setgCharset(3,Up);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let o=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:s}=this._coreMouseService,n=this._coreService,{buffers:a,cols:l}=this._bufferService,{active:c,alt:u}=a,p=this._optionsService.rawOptions,f=(g,S)=>(n.triggerDataEvent(`${Z.ESC}[${t?"":"?"}${g};${S}$y`),!0),d=g=>g?1:2,h=e.params[0];return t?h===2?f(h,4):h===4?f(h,d(n.modes.insertMode)):h===12?f(h,3):h===20?f(h,d(p.convertEol)):f(h,0):h===1?f(h,d(o.applicationCursorKeys)):h===3?f(h,p.windowOptions.setWinLines?l===80?2:l===132?1:0:0):h===6?f(h,d(o.origin)):h===7?f(h,d(o.wraparound)):h===8?f(h,3):h===9?f(h,d(i==="X10")):h===12?f(h,d(p.cursorBlink)):h===25?f(h,d(!n.isCursorHidden)):h===45?f(h,d(o.reverseWraparound)):h===66?f(h,d(o.applicationKeypad)):h===67?f(h,4):h===1e3?f(h,d(i==="VT200")):h===1002?f(h,d(i==="DRAG")):h===1003?f(h,d(i==="ANY")):h===1004?f(h,d(o.sendFocus)):h===1005?f(h,4):h===1006?f(h,d(s==="SGR")):h===1015?f(h,4):h===1016?f(h,d(s==="SGR_PIXELS")):h===1048?f(h,1):h===47||h===1047||h===1049?f(h,d(c===u)):h===2004?f(h,d(o.bracketedPasteMode)):h===2026?f(h,d(o.synchronizedOutput)):f(h,0)}_updateAttrColor(e,t,r,o,i){return t===2?(e|=50331648,e&=-16777216,e|=Av.fromColorRGB([r,o,i])):t===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,t,r){let o=[0,0,-1,0,0,0],i=0,s=0;do{if(o[s+i]=e.params[t+s],e.hasSubParams(t+s)){let n=e.getSubParams(t+s),a=0;do o[1]===5&&(i=1),o[s+a+1+i]=n[a];while(++a<n.length&&a+s+1+i<o.length);break}if(o[1]===5&&s+i>=2||o[1]===2&&s+i>=5)break;o[1]&&(i=1)}while(++s+t<e.length&&s+i<o.length);for(let n=2;n<o.length;++n)o[n]===-1&&(o[n]=0);switch(o[0]){case 38:r.fg=this._updateAttrColor(r.fg,o[1],o[3],o[4],o[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,o[1],o[3],o[4],o[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,o[1],o[3],o[4],o[5])}return s}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Er.fg,e.bg=Er.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,r,o=this._curAttrData;for(let i=0;i<t;i++)r=e.params[i],r>=30&&r<=37?(o.fg&=-50331904,o.fg|=16777216|r-30):r>=40&&r<=47?(o.bg&=-50331904,o.bg|=16777216|r-40):r>=90&&r<=97?(o.fg&=-50331904,o.fg|=16777216|r-90|8):r>=100&&r<=107?(o.bg&=-50331904,o.bg|=16777216|r-100|8):r===0?this._processSGR0(o):r===1?o.fg|=134217728:r===3?o.bg|=67108864:r===4?(o.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,o)):r===5?o.fg|=536870912:r===7?o.fg|=67108864:r===8?o.fg|=1073741824:r===9?o.fg|=2147483648:r===2?o.bg|=134217728:r===21?this._processUnderline(2,o):r===22?(o.fg&=-134217729,o.bg&=-134217729):r===23?o.bg&=-67108865:r===24?(o.fg&=-268435457,this._processUnderline(0,o)):r===25?o.fg&=-536870913:r===27?o.fg&=-67108865:r===28?o.fg&=-1073741825:r===29?o.fg&=2147483647:r===39?(o.fg&=-67108864,o.fg|=Er.fg&16777215):r===49?(o.bg&=-67108864,o.bg|=Er.bg&16777215):r===38||r===48||r===58?i+=this._extractColor(e,i,o):r===53?o.bg|=1073741824:r===55?o.bg&=-1073741825:r===59?(o.extended=o.extended.clone(),o.extended.underlineColor=-1,o.updateExtended()):r===100?(o.fg&=-67108864,o.fg|=Er.fg&16777215,o.bg&=-67108864,o.bg|=Er.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Z.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Z.ESC}[${t};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Z.ESC}[?${t};${r}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Er.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=t%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let t=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!k9(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Z.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>E9&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>E9&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],r=e.split(";");for(;r.length>1;){let o=r.shift(),i=r.shift();if(/^\d+$/.exec(o)){let s=parseInt(o);if(L9(s))if(i==="?")t.push({type:0,index:s});else{let n=R9(i);n&&t.push({type:1,index:s,color:n})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let r=e.slice(0,t).trim(),o=e.slice(t+1);return o?this._createHyperlink(r,o):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),o,i=r.findIndex(s=>s.startsWith("id="));return i!==-1&&(o=r[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:o,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let r=e.split(";");for(let o=0;o<r.length&&!(t>=this._specialColors.length);++o,++t)if(r[o]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=R9(r[o]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],r=e.split(";");for(let o=0;o<r.length;++o)if(/^\d+$/.exec(r[o])){let i=parseInt(r[o]);L9(i)&&t.push({type:2,index:i})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,Up),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Nme[e[0]],Ur[e[1]]||Up),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=Er.clone(),this._eraseAttrDataInternal=Er.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ns;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let r=this._activeBuffer.ybase+this._activeBuffer.y+t,o=this._activeBuffer.lines.get(r);o&&(o.fill(e),o.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let r=n=>(this._coreService.triggerDataEvent(`${Z.ESC}${n}${Z.ESC}\\`),!0),o=this._bufferService.buffer,i=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${o.scrollTop+1};${o.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},o5=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(A9=e,e=t,t=A9),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};o5=ur([de(0,ei)],o5);function L9(e){return 0<=e&&e<256}var Fme=5e7,O9=12,Ume=50,$me=class extends ke{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new ne),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let r;for(;r=this._writeBuffer.shift();){this._action(r);let o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Fme)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let o=this._writeBuffer[this._bufferOffset],i=this._action(o,t);if(i){let n=a=>performance.now()-r>=O9?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(r,a);i.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(n);return}let s=this._callbacks[this._bufferOffset];if(s&&s(),this._bufferOffset++,this._pendingData-=o.length,performance.now()-r>=O9)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ume&&(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()}},i5=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._dataByLinkId.set(l.id,l),l.id}let r=e,o=this._getEntryIdKey(r),i=this._entriesWithId.get(o);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let s=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(n,s)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(o=>o.line!==t)){let o=this._bufferService.buffer.addMarker(t);r.lines.push(o),o.onDispose(()=>this._removeMarkerFromLink(r,o))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let r=e.lines.indexOf(t);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};i5=ur([de(0,ei)],i5);var D9=!1,Hme=class extends ke{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new jh),this._onBinary=this._register(new ne),this.onBinary=this._onBinary.event,this._onData=this._register(new ne),this.onData=this._onData.event,this._onLineFeed=this._register(new ne),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ne),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ne),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ne),this._instantiationService=new pme,this.optionsService=this._register(new xme(e)),this._instantiationService.setService(ti,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Jk)),this._instantiationService.setService(ei,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qk)),this._instantiationService.setService(G9,this._logService),this.coreService=this._register(this._instantiationService.createInstance(e5)),this._instantiationService.setService(Vp,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(t5)),this._instantiationService.setService(q9,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance($p)),this._instantiationService.setService(Dde,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Rme),this._instantiationService.setService(Ode,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(i5),this._instantiationService.setService(K9,this._oscLinkService),this._inputHandler=this._register(new zme(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Po.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Po.forward(this._bufferService.onResize,this._onResize)),this._register(Po.forward(this.coreService.onData,this._onData)),this._register(Po.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new $me((t,r)=>this._inputHandler.parse(t,r))),this._register(Po.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ne),this._onScroll.event(e=>{this._onScrollApi?.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!D9&&(this._logService.warn("writeSync is unreliable and will be removed soon."),D9=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Bj),t=Math.max(t,Ij),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(C9.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(C9(this._bufferService),!1))),this._windowsWrappingHeuristics.value=$t(()=>{for(let t of e)t.dispose()})}}},jme={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:["'",'"']};function Wme(e,t,r,o){let i={type:0,cancel:!1,key:void 0},s=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=Z.ESC+"OA":i.key=Z.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=Z.ESC+"OD":i.key=Z.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=Z.ESC+"OC":i.key=Z.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=Z.ESC+"OB":i.key=Z.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":Z.DEL,e.altKey&&(i.key=Z.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Z.ESC+"[Z";break}i.key=Z.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Z.ESC+Z.CR:Z.CR,i.cancel=!0;break;case 27:i.key=Z.ESC,e.altKey&&(i.key=Z.ESC+Z.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;s?i.key=Z.ESC+"[1;"+(s+1)+"D":t?i.key=Z.ESC+"OD":i.key=Z.ESC+"[D";break;case 39:if(e.metaKey)break;s?i.key=Z.ESC+"[1;"+(s+1)+"C":t?i.key=Z.ESC+"OC":i.key=Z.ESC+"[C";break;case 38:if(e.metaKey)break;s?i.key=Z.ESC+"[1;"+(s+1)+"A":t?i.key=Z.ESC+"OA":i.key=Z.ESC+"[A";break;case 40:if(e.metaKey)break;s?i.key=Z.ESC+"[1;"+(s+1)+"B":t?i.key=Z.ESC+"OB":i.key=Z.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Z.ESC+"[2~");break;case 46:s?i.key=Z.ESC+"[3;"+(s+1)+"~":i.key=Z.ESC+"[3~";break;case 36:s?i.key=Z.ESC+"[1;"+(s+1)+"H":t?i.key=Z.ESC+"OH":i.key=Z.ESC+"[H";break;case 35:s?i.key=Z.ESC+"[1;"+(s+1)+"F":t?i.key=Z.ESC+"OF":i.key=Z.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=Z.ESC+"[5;"+(s+1)+"~":i.key=Z.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=Z.ESC+"[6;"+(s+1)+"~":i.key=Z.ESC+"[6~";break;case 112:s?i.key=Z.ESC+"[1;"+(s+1)+"P":i.key=Z.ESC+"OP";break;case 113:s?i.key=Z.ESC+"[1;"+(s+1)+"Q":i.key=Z.ESC+"OQ";break;case 114:s?i.key=Z.ESC+"[1;"+(s+1)+"R":i.key=Z.ESC+"OR";break;case 115:s?i.key=Z.ESC+"[1;"+(s+1)+"S":i.key=Z.ESC+"OS";break;case 116:s?i.key=Z.ESC+"[15;"+(s+1)+"~":i.key=Z.ESC+"[15~";break;case 117:s?i.key=Z.ESC+"[17;"+(s+1)+"~":i.key=Z.ESC+"[17~";break;case 118:s?i.key=Z.ESC+"[18;"+(s+1)+"~":i.key=Z.ESC+"[18~";break;case 119:s?i.key=Z.ESC+"[19;"+(s+1)+"~":i.key=Z.ESC+"[19~";break;case 120:s?i.key=Z.ESC+"[20;"+(s+1)+"~":i.key=Z.ESC+"[20~";break;case 121:s?i.key=Z.ESC+"[21;"+(s+1)+"~":i.key=Z.ESC+"[21~";break;case 122:s?i.key=Z.ESC+"[23;"+(s+1)+"~":i.key=Z.ESC+"[23~";break;case 123:s?i.key=Z.ESC+"[24;"+(s+1)+"~":i.key=Z.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Z.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Z.DEL:e.keyCode===219?i.key=Z.ESC:e.keyCode===220?i.key=Z.FS:e.keyCode===221&&(i.key=Z.GS);else if((!r||o)&&e.altKey&&!e.metaKey){let n=jme[e.keyCode]?.[e.shiftKey?1:0];if(n)i.key=Z.ESC+n;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(a);e.shiftKey&&(l=l.toUpperCase()),i.key=Z.ESC+l}else if(e.keyCode===32)i.key=Z.ESC+(e.ctrlKey?Z.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),i.key=Z.ESC+a,i.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=Z.US),e.key==="@"&&(i.key=Z.NUL));break}return i}var br=0,Vme=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new zT,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new zT,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((i,s)=>this._getKey(i)-this._getKey(s)),t=0,r=0,o=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<o.length;i++)r>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[r])?(o[i]=e[t],t++):o[i]=this._array[r++];this._array=o,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(br=this._search(t),br===-1)||this._getKey(this._array[br])!==t)return!1;do if(this._array[br]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(br),!0;while(++br<this._array.length&&this._getKey(this._array[br])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,s)=>i-s),t=0,r=new Array(this._array.length-e.length),o=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:r[o++]=this._array[i];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(br=this._search(e),!(br<0||br>=this._array.length)&&this._getKey(this._array[br])===e))do yield this._array[br];while(++br<this._array.length&&this._getKey(this._array[br])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(br=this._search(e),!(br<0||br>=this._array.length)&&this._getKey(this._array[br])===e))do t(this._array[br]);while(++br<this._array.length&&this._getKey(this._array[br])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,r=this._array.length-1;for(;r>=t;){let o=t+r>>1,i=this._getKey(this._array[o]);if(i>e)r=o-1;else if(i<e)t=o+1;else{for(;o>0&&this._getKey(this._array[o-1])===e;)o--;return o}}return t}},Sk=0,B9=0,qme=class extends ke{constructor(){super(),this._decorations=new Vme(e=>e?.marker.line),this._onDecorationRegistered=this._register(new ne),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ne),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register($t(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Gme(e);if(t){let r=t.marker.onDispose(()=>t.dispose()),o=t.onDispose(()=>{o.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),r.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,r){let o=0,i=0;for(let s of this._decorations.getKeyIterator(t))o=s.options.x??0,i=o+(s.options.width??1),e>=o&&e<i&&(!r||(s.options.layer??"bottom")===r)&&(yield s)}forEachDecorationAtCell(e,t,r,o){this._decorations.forEachByKey(t,i=>{Sk=i.options.x??0,B9=Sk+(i.options.width??1),e>=Sk&&e<B9&&(!r||(i.options.layer??"bottom")===r)&&o(i)})}},Gme=class extends Zc{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ne),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ne),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Jt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Jt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Kme=1e3,Yme=class{constructor(e,t=Kme){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,r){this._rowCount=r,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let o=performance.now();if(o-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=o,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=o-this._lastRefreshMs,s=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},s)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},I9=20,N9=!1,FT=class extends ke{constructor(e,t,r,o){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=o,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let s=0;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);if(this._topBoundaryFocusListener=s=>this._handleBoundaryFocus(s,0),this._bottomBoundaryFocusListener=s=>this._handleBoundaryFocus(s,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Yme(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");N9?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=i.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(i.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(i.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(s=>this._handleResize(s.rows))),this._register(this._terminal.onRender(s=>this._refreshRows(s.start,s.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(s=>this._handleChar(s))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
380
380
  `))),this._register(this._terminal.onA11yTab(s=>this._handleTab(s))),this._register(this._terminal.onKey(s=>this._handleKey(s.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(_e(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register($t(()=>{N9?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<I9+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
381
381
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===I9+1&&(this._liveRegion.textContent+=Tk.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let r=this._terminal.buffer,o=r.lines.length.toString();for(let i=e;i<=t;i++){let s=r.lines.get(r.ydisp+i),n=[],a=s?.translateToString(!0,void 0,void 0,n)||"",l=(r.ydisp+i+1).toString(),c=this._rowElements[i];c&&(a.length===0?(c.textContent="\xA0",this._rowColumns.set(c,[0,1])):(c.textContent=a,this._rowColumns.set(c,n)),c.setAttribute("aria-posinset",l),c.setAttribute("aria-setsize",o),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let r=e.target,o=this._rowElements[t===0?1:this._rowElements.length-2],i=r.getAttribute("aria-posinset"),s=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===s||e.relatedTarget!==o)return;let n,a;if(t===0?(n=r,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(n=this._rowElements.shift(),a=r,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===r.node&&t.offset>r.offset)&&([t,r]=[r,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let o=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(o)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:o,offset:o.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let i=({node:a,offset:l})=>{let c=a instanceof Text?a.parentNode:a,u=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let p=this._rowColumns.get(c);if(!p)return console.warn("columns is null. Race condition?"),null;let f=l<p.length?p[l]:p.slice(-1)[0]+1;return f>=this._terminal.cols&&(++u,f=0),{row:u,column:f}},s=i(t),n=i(r);if(!(!s||!n)){if(s.row>n.row||s.row===n.row&&s.column>=n.column)throw new Error("invalid range");this._terminal.select(s.column,s.row,(n.row-s.row)*this._terminal.cols-s.column+n.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;let o=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${o/t})`}};FT=ur([de(1,n5),de(2,bl),de(3,_l)],FT);var s5=class extends ke{constructor(e,t,r,o,i){super(),this._element=e,this._mouseService=t,this._renderService=r,this._bufferService=o,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ne),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ne),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register($t(()=>{jp(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(_e(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(_e(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(_e(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(_e(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let r=e.composedPath();for(let o=0;o<r.length;o++){let i=r[o];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(o=>{o?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[o,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(o)&&(r=this._checkLinkProviderResult(o,e,r)):i.provideLinks(e.y,s=>{if(this._isMouseOut)return;let n=s?.map(a=>({link:a}));this._activeProviderReplies?.set(o,n),r=this._checkLinkProviderResult(o,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let r=new Set;for(let o=0;o<t.size;o++){let i=t.get(o);if(i)for(let s=0;s<i.length;s++){let n=i[s],a=n.link.range.start.y<e?0:n.link.range.start.x,l=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let c=a;c<=l;c++){if(r.has(c)){i.splice(s--,1);break}r.add(c)}}}}_checkLinkProviderResult(e,t,r){if(!this._activeProviderReplies)return r;let o=this._activeProviderReplies.get(e),i=!1;for(let s=0;s<e;s++)(!this._activeProviderReplies.has(s)||this._activeProviderReplies.get(s))&&(i=!0);if(!i&&o){let s=o.find(n=>this._linkAtPosition(n.link,t));s&&(r=!0,this._handleNewLink(s))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let s=0;s<this._activeProviderReplies.size;s++){let n=this._activeProviderReplies.get(s)?.find(a=>this._linkAtPosition(a.link,t));if(n){r=!0,this._handleNewLink(n);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Xme(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,jp(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let o=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=o&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(o,i),this._lastMouseEvent)){let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._askForLink(s,!1)}})))}_linkHover(e,t,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(r,t.text)}_fireUnderlineEvent(e,t){let r=e.range,o=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-o-1,r.end.x,r.end.y-o-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(r,t.text)}_linkAtPosition(e,t){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,o=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return r<=i&&i<=o}_positionFromMouseEvent(e,t,r){let o=r.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(o)return{x:o[0],y:o[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,r,o,i){return{x1:e,y1:t,x2:r,y2:o,cols:this._bufferService.cols,fg:i}}};s5=ur([de(1,a5),de(2,_l),de(3,ei),de(4,X9)],s5);function Xme(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Zme=class extends Hme{constructor(e={}){super(e),this._linkifier=this._register(new jh),this.browser=wj,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new jh),this._onCursorMove=this._register(new ne),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ne),this.onKey=this._onKey.event,this._onRender=this._register(new ne),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ne),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ne),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ne),this.onBell=this._onBell.event,this._onFocus=this._register(new ne),this._onBlur=this._register(new ne),this._onA11yCharEmitter=this._register(new ne),this._onA11yTabEmitter=this._register(new ne),this._onWillOpen=this._register(new ne),this._setup(),this._decorationService=this._instantiationService.createInstance(qme),this._instantiationService.setService(Lv,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Fhe),this._instantiationService.setService(X9,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ck)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Po.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Po.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Po.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Po.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register($t(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let r,o="";switch(t.index){case 256:r="foreground",o="10";break;case 257:r="background",o="11";break;case 258:r="cursor",o="12";break;default:r="ansi",o="4;"+t.index}switch(t.type){case 0:let i=Ut.toColorRGB(r==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${Z.ESC}]${o};${Ime(i)}${xj.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(s=>s.ansi[t.index]=kr.toColor(...t.color));else{let s=r;this._themeService.modifyColors(n=>n[s]=kr.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(FT,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Z.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let r=Math.min(this.buffer.x,this.cols-1),o=this._renderService.dimensions.css.cell.height,i=t.getWidth(r),s=this._renderService.dimensions.css.cell.width*i,n=this.buffer.y*this._renderService.dimensions.css.cell.height,a=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=n+"px",this.textarea.style.width=s+"px",this.textarea.style.height=o+"px",this.textarea.style.lineHeight=o+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(_e(this.element,"copy",t=>{this.hasSelection()&&Rde(t,this._selectionService)}));let e=t=>Ede(t,this.textarea,this.coreService,this.optionsService);this._register(_e(this.textarea,"paste",e)),this._register(_e(this.element,"paste",e)),Cj?this._register(_e(this.element,"mousedown",t=>{t.button===2&&zH(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(_e(this.element,"contextmenu",t=>{zH(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),m5&&this._register(_e(this.element,"auxclick",t=>{t.button===1&&$9(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(_e(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(_e(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(_e(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(_e(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(_e(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(_e(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(_e(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(_e(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",xk.get()),Ej||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Nhe,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(bl,this._coreBrowserService),this._register(_e(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(_e(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gk,this._document,this._helperContainer),this._instantiationService.setService($T,this._charSizeService),this._themeService=this._instantiationService.createInstance(Zk),this._instantiationService.setService(Wh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(IT),this._instantiationService.setService(Y9,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yk,this.rows,this.screenElement)),this._instantiationService.setService(_l,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Wk,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Kk),this._instantiationService.setService(a5,this._mouseService);let o=this._linkifier.value=this._register(this._instantiationService.createInstance(s5,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Hk,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Xk,this.element,this.screenElement,o)),this._instantiationService.setService(Ide,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(Po.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(jk,this.screenElement)),this._register(_e(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(FT,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(BT,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(BT,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qk,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function r(s){let n=e._mouseService.getMouseReportCoords(s,e.screenElement);if(!n)return!1;let a,l;switch(s.overrideType||s.type){case"mousemove":l=32,s.buttons===void 0?(a=3,s.button!==void 0&&(a=s.button<3?s.button:3)):a=s.buttons&1?0:s.buttons&4?1:s.buttons&2?2:3;break;case"mouseup":l=0,a=s.button<3?s.button:3;break;case"mousedown":l=1,a=s.button<3?s.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(s)===!1)return!1;let c=s.deltaY;if(c===0||e.coreMouseService.consumeWheelEvent(s,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;l=c<0?0:1,a=4;break;default:return!1}return l===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:a,action:l,ctrl:s.ctrlKey,alt:s.altKey,shift:s.shiftKey})}let o={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:s=>(r(s),s.buttons||(this._document.removeEventListener("mouseup",o.mouseup),o.mousedrag&&this._document.removeEventListener("mousemove",o.mousedrag)),this.cancel(s)),wheel:s=>(r(s),this.cancel(s,!0)),mousedrag:s=>{s.buttons&&r(s)},mousemove:s=>{s.buttons||r(s)}};this._register(this.coreMouseService.onProtocolChange(s=>{s?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(s)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),s&8?o.mousemove||(t.addEventListener("mousemove",i.mousemove),o.mousemove=i.mousemove):(t.removeEventListener("mousemove",o.mousemove),o.mousemove=null),s&16?o.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),o.wheel=i.wheel):(t.removeEventListener("wheel",o.wheel),o.wheel=null),s&2?o.mouseup||(o.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",o.mouseup),o.mouseup=null),s&4?o.mousedrag||(o.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",o.mousedrag),o.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(_e(t,"mousedown",s=>{if(s.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(s)))return r(s),o.mouseup&&this._document.addEventListener("mouseup",o.mouseup),o.mousedrag&&this._document.addEventListener("mousemove",o.mousedrag),this.cancel(s)})),this._register(_e(t,"wheel",s=>{if(!o.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(s)===!1)return!1;if(!this.buffer.hasScrollback){if(s.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(s,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(s,!0);let n=Z.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(s.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(s,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){U9(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,r){this._selectionService.setSelection(e,t,r)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let r=Wme(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let o=this.rows-1;return this.scrollLines(r.type===2?-o:o),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((r.key===Z.ETX||r.key===Z.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let r=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?r:r&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Qme(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Er));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(Z.ESC+"[I"):this.coreService.triggerDataEvent(Z.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.ESC}[4;${r};${t}t`);break;case 1:let o=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Z.ESC}[6;${i};${o}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Qme(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Jme=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let r={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(r),t.dispose=()=>this._wrappedAddonDispose(r),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){t=r;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ege=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ns)}translateToString(e,t,r){return this._line.translateToString(e,t,r)}},z9=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new ege(t)}getNullCell(){return new Ns}},tge=class extends ke{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ne),this.onBufferChange=this._onBufferChange.event,this._normal=new z9(this._core.buffers.normal,"normal"),this._alternate=new z9(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)}},rge=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,r=>t(r.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(r,o)=>t(r,o.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},oge=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ige=["cols","rows"],Qn=0,zj=class extends ke{constructor(e){super(),this._core=this._register(new Zme(e)),this._addonManager=this._register(new Jme),this._publicOptions={...this._core.options};let t=o=>this._core.options[o],r=(o,i)=>{this._checkReadonlyOptions(o),this._core.options[o]=i};for(let o in this._core.options){let i={get:t.bind(this,o),set:r.bind(this,o)};Object.defineProperty(this._publicOptions,o,i)}}_checkReadonlyOptions(e){if(ige.includes(e))throw new Error(`Option "${e}" 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 rge(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new oge(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 tge(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,r){this._verifyIntegers(e,t,r),this._core.select(e,t,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
382
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return xk.get()},set promptLabel(e){xk.set(e)},get tooMuchOutput(){return Tk.get()},set tooMuchOutput(e){Tk.set(e)}}}_verifyIntegers(...e){for(Qn of e)if(Qn===1/0||isNaN(Qn)||Qn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Qn of e)if(Qn&&(Qn===1/0||isNaN(Qn)||Qn%1!==0||Qn<0))throw new Error("This API only accepts positive integers")}};var g5=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\^<>`]*[^\s"':,.!?{}|\\^~[\]`()<>]/;function sge(e){try{return!!new URL(e).host}catch{return!1}}function Uj(e,t){let r=e(t),o=e(t+1);return!!r&&!!o&&(o.isWrapped||r.isFull)}function nge(e,t){let r=[];for(let o=t;o-t<64;o++){let i=e(o);if(!i||(r.push(i.text),!Uj(e,o)))break}return r}function Fj(e,t,r){let o=t;for(let i of e){if(r<i.length)return{x:r+1,y:o+1};r-=i.length,o++}}function age(e,t,r){let o=r[0],i=Fj(e,t,r.index),s=Fj(e,t,r.index+o.length-1);if(!(!sge(o)||!i||!s))return{text:o,range:{start:i,end:s}}}function lge(e,t,r){let o=new RegExp(r.source,`${r.flags||""}g`);return[...e.join("").matchAll(o)].flatMap(s=>age(e,t,s)??[])}function $j(e,t,r=g5){if(!e(t-1))return[];let o=t-1;for(;o>0&&Uj(e,o-1);)o--;return lge(nge(e,o),o,r)}function Hj(e,t){let r=o=>{let i=e.buffer.active.getLine(o);if(!i)return;let s=e.cols,n=i.getCell(s-1);return{text:i.translateToString(!0,0,s),isWrapped:i.isWrapped,isFull:!!n&&n.getChars()!==""&&n.getChars()!==" "}};return{provideLinks(o,i){let s=$j(r,o,g5);i(s.map(n=>({range:n.range,text:n.text,activate:t})))}}}function jj(e){let t=new zj({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', Consolas, monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4"},linkHandler:{activate:(s,n)=>{window.open(n,"_blank")}}}),r=new g7;t.loadAddon(r);let o=t.registerLinkProvider(Hj(t,(s,n)=>{window.open(n,"_blank")}));t.open(e);let i;try{i=new BH,i.onContextLoss(()=>{i?.dispose(),i=void 0}),t.loadAddon(i)}catch{i=void 0}return r.fit(),{term:t,fitAddon:r,dispose:()=>{o.dispose(),i?.dispose(),t.dispose()}}}function Wj(e,t,r,o){if(e.type!=="keydown"||!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)return!0;let i=e.key.toLowerCase();return i==="c"&&t.hasSelection()?(e.preventDefault(),r.writeText(t.getSelection()),!1):i==="v"?(e.preventDefault(),r.readText().then(o),!1):!0}function Vj(e,t,r,o,i){let s=jj(e);s.term.onData(c=>r(t,c)),s.term.attachCustomKeyEventHandler(c=>Wj(c,s.term,navigator.clipboard,u=>s.term.paste(u)));let n=o(t,c=>s.term.write(c)),a=new ResizeObserver(()=>{s.fitAddon.fit(),i(t,s.term.cols,s.term.rows)});return a.observe(e),{handle:s,cleanup:()=>{a.disconnect(),n(),s.dispose()}}}function qj(e,t,r,o,i,s){let n=(0,Bv.useRef)(null);(0,Bv.useEffect)(()=>{let a=e.current;if(!a)return;let{handle:l,cleanup:c}=Vj(a,t,o,i,s);return n.current=l,()=>{c(),n.current=null}},[e,t,i,o,s]),(0,Bv.useEffect)(()=>{let a=n.current;if(!r||!a)return;let l=setTimeout(()=>{a.fitAddon.fit(),a.term.focus(),s(t,a.term.cols,a.term.rows)},50);return()=>clearTimeout(l)},[r,t,s])}var Yj=m(x(),1);function Kj({sessionId:e,visible:t,onOutput:r,sendInput:o,sendResize:i}){let s=(0,Gj.useRef)(null);return qj(s,e,t,o,r,i),(0,Yj.jsx)(q,{ref:s,sx:{position:"absolute",inset:"0 0 0 8px",visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none"}})}var qp=m(x(),1);function Xj({sessions:e,activeId:t,initialized:r,onOutput:o,sendInput:i,sendResize:s}){let n=e.find(l=>l.id===t),a=n!==void 0&&zx(n,r);return(0,qp.jsxs)(q,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:[e.map(l=>(0,qp.jsx)(Kj,{sessionId:l.id,visible:l.id===t,onOutput:o,sendInput:i,sendResize:s},l.id)),a&&(0,qp.jsx)(m7,{}),e.length===0&&(0,qp.jsx)(q,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,qp.jsx)(Y,{variant:"body2",color:"text.disabled",children:"Create a session to get started"})})]})}var Zj=m(x(),1),Qj=ue((0,Zj.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build");var zs=m(x(),1);function Jj({message:e}){return e.role==="tool"?(0,zs.jsx)(cge,{tool:e.tool,target:e.target}):(0,zs.jsx)(uge,{role:e.role,text:e.text})}function cge({tool:e,target:t}){return(0,zs.jsxs)(q,{sx:{display:"flex",alignItems:"center",gap:1,py:.5,pl:1},children:[(0,zs.jsx)(Qj,{sx:{fontSize:14,color:"text.disabled"}}),(0,zs.jsxs)(Y,{variant:"caption",sx:{color:"text.secondary",fontFamily:"monospace"},children:[(0,zs.jsx)(q,{component:"span",sx:{color:"warning.main"},children:e}),t&&(0,zs.jsxs)(q,{component:"span",children:[" ",t]})]})]})}function uge({role:e,text:t}){let r=e==="user",o=r?"info.main":"success.main";return(0,zs.jsxs)(q,{sx:{mb:1.5,pl:1.5,py:1,pr:1,borderLeft:2,borderColor:o,borderTopRightRadius:1,borderBottomRightRadius:1,bgcolor:r?"action.hover":"transparent"},children:[(0,zs.jsx)(Y,{variant:"caption",sx:{color:o,fontWeight:600,display:"block",mb:.5},children:r?"User":"Assistant"}),(0,zs.jsx)(Y,{variant:"body2",sx:{color:"text.primary",whiteSpace:"pre-wrap",overflowWrap:"anywhere",lineHeight:1.6},children:t})]})}var ra=m(x(),1);function pge(e){let t=new Map;return e.map(r=>{let o=r.role==="tool"?`tool:${r.tool}:${r.target}`:`${r.role}:${r.text.slice(0,40)}`,i=t.get(o)??0;return t.set(o,i+1),{...r,key:`${o}#${i}`}})}function tW({messages:e,loading:t}){return t?(0,ra.jsxs)(q,{sx:eW,children:[(0,ra.jsx)(nt,{size:20}),(0,ra.jsx)(Y,{variant:"caption",color:"text.disabled",children:"Loading transcript\u2026"})]}):e.length===0?(0,ra.jsx)(q,{sx:eW,children:(0,ra.jsx)(Y,{variant:"body2",color:"text.disabled",children:"No transcript available"})}):(0,ra.jsx)(q,{sx:{position:"absolute",inset:0,overflowY:"auto",p:2},children:(0,ra.jsx)(q,{sx:{maxWidth:820,mx:"auto"},children:pge(e).map(r=>(0,ra.jsx)(Jj,{message:r},r.key))})})}var eW={position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:1.5,alignItems:"center",justifyContent:"center"};var y5=m(x(),1);function rW({sessionId:e,transcript:t}){let r=t?.sessionId===e;return(0,y5.jsx)(q,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:(0,y5.jsx)(tW,{messages:r?t?.messages??[]:[],loading:!r})})}var v5=m(x(),1);function oW({viewingTranscriptSessionId:e,transcript:t,...r}){return e!==null?(0,v5.jsx)(rW,{sessionId:e,transcript:t}):(0,v5.jsx)(Xj,{...r})}var qh=m(N(),1);function iW(e,t){let r=Math.max(0,e-t),o=Math.floor(r/86400),i=Math.floor(r%86400/3600),s=Math.floor(r%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${s}m`:`${s}m`}function dge(e,t,r,o){if(t==null)return;let i=Math.max(0,t-o),s=Math.max(0,r-i)/r;if(!(s<.05))return e/s}function qT(e,t,r,o){let i=dge(e,t,r,o);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var fge={ok:"success.main",warn:"warning.main",over:"error.main"};function GT(e){return fge[e]}var Iv=m(x(),1),hge={ok:"success",warn:"warning",over:"error"};function sW({percentage:e,level:t}){return(0,Iv.jsxs)(q,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,Iv.jsx)(ig,{variant:"determinate",value:Math.min(100,e),color:hge[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,Iv.jsxs)(q,{sx:{minWidth:40,textAlign:"right",color:GT(t)},children:[Math.round(e),"%"]})]})}function nW(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var lW=m(x(),1);function aW(){return(0,lW.jsx)(Xe,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function cW(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${hh(e.tokensUp)} \u2193 ${hh(e.tokensDown)}`}var mge=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function b5(e){return mge.format(e)}var uW={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};var Fs=m(x(),1);function pW({peak:e,now:t}){let{label:r,seconds:o,tint:i}=uW[e.window],s=qT(e.usedPercentage,e.resetsAt,o,t);return(0,Fs.jsxs)(Pa,{sx:n=>({backgroundColor:i?n.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,Fs.jsxs)(Ct,{children:[r,e.resetDetected&&(0,Fs.jsx)(aW,{})]}),(0,Fs.jsx)(Ct,{sx:{minWidth:160},children:(0,Fs.jsx)(sW,{percentage:e.usedPercentage,level:s})}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:nW(e)}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:cW(e)}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,Fs.jsx)(at,{title:`Cycle started ${b5(new Date(e.createdAt))}`,children:(0,Fs.jsx)("span",{children:b5(new Date(e.resetsAt*1e3))})})})]})}var KT=m(N(),1);function YT(e){let[t,r]=(0,KT.useState)(()=>Math.floor(Date.now()/1e3));return(0,KT.useEffect)(()=>{let o=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(o)},[e]),t}var ri=m(x(),1);function dW({peaks:e}){let t=YT(3e4);return(0,ri.jsx)(kg,{component:pt,children:(0,ri.jsxs)(Pg,{size:"small",children:[(0,ri.jsx)(Mg,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,ri.jsxs)(Pa,{children:[(0,ri.jsx)(Ct,{children:"Window"}),(0,ri.jsx)(Ct,{children:"Peak usage"}),(0,ri.jsx)(Ct,{align:"right",children:(0,ri.jsx)(at,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,ri.jsx)("span",{children:"Avg context"})})}),(0,ri.jsx)(Ct,{align:"right",children:"Tokens spent"}),(0,ri.jsx)(Ct,{align:"right",children:"Cycle reset"})]})}),(0,ri.jsx)(Rg,{children:e.map(r=>(0,ri.jsx)(pW,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var oa=m(N(),1),x5=30;async function gge(e){let t=await fetch(`/api/usage/history?page=${e}&pageSize=${x5}`);if(!t.ok)throw new Error(`Failed to load usage history (HTTP ${t.status}).`);return t.json()}function fW(){let[e,t]=(0,oa.useState)(0),[r,o]=(0,oa.useState)([]),[i,s]=(0,oa.useState)(0),[n,a]=(0,oa.useState)(!1),[l,c]=(0,oa.useState)(!1),[u,p]=(0,oa.useState)(null);return(0,oa.useEffect)(()=>{let f=!1;return c(!0),gge(e).then(d=>{f||(o(d.rows),s(d.total),a(!0),c(!1))},d=>{f||(p(d instanceof Error?d:new Error(String(d))),c(!1))}),()=>{f=!0}},[e]),(0,oa.useEffect)(()=>{if(i===0)return;let f=Math.ceil(i/x5)-1;e>f&&t(f)},[e,i]),{page:e,setPage:t,rows:r,total:i,loaded:n,fetching:l,error:u,pageSize:x5}}var Qc=m(x(),1);function hW(){let{page:e,setPage:t,rows:r,total:o,loaded:i,fetching:s,error:n,pageSize:a}=fW(),l=(0,qh.useRef)(null),[c,u]=(0,qh.useState)();if((0,qh.useLayoutEffect)(()=>{r.length===a&&l.current&&u(l.current.offsetHeight)},[r,a]),n)throw n;return(0,Qc.jsxs)(Jx,{loading:!i,title:"Usage history",isEmpty:o===0,emptyMessage:"No usage peaks recorded yet.",children:[(0,Qc.jsx)(q,{sx:{height:4,mb:1},children:s&&(0,Qc.jsx)(ig,{})}),(0,Qc.jsx)(q,{ref:l,sx:{minHeight:c},children:(0,Qc.jsx)(dW,{peaks:r})}),(0,Qc.jsx)(HC,{component:"div",count:o,page:e,rowsPerPage:a,rowsPerPageOptions:[a],onPageChange:(p,f)=>t(f)})]})}var Mr=m(x(),1);function yge({socket:e}){return(0,Mr.jsx)(zl,{maxWidth:"md",sx:{py:3,px:2},children:(0,Mr.jsx)(SU,{socket:e})})}function vge({socket:e}){return(0,Mr.jsx)(oW,{sessions:e.sessions,activeId:e.activeId,initialized:e.initialized,onOutput:e.onOutput,sendInput:e.sendInput,sendResize:e.sendResize,viewingTranscriptSessionId:e.viewingTranscriptSessionId,transcript:e.transcript})}function mW({socket:e}){return(0,Mr.jsx)(bp,{children:(0,Mr.jsxs)(qo,{element:(0,Mr.jsx)(o7,{socket:e}),children:[(0,Mr.jsx)(qo,{path:"sessions",element:(0,Mr.jsx)(vge,{socket:e})}),(0,Mr.jsx)(qo,{path:"backlog/*",element:(0,Mr.jsx)(yge,{socket:e})}),(0,Mr.jsx)(qo,{path:"news",element:(0,Mr.jsx)(h7,{})}),(0,Mr.jsx)(qo,{path:"usage",element:(0,Mr.jsx)(hW,{})}),(0,Mr.jsx)(qo,{path:"backups",element:(0,Mr.jsx)(u7,{})}),(0,Mr.jsx)(qo,{path:"*",element:(0,Mr.jsx)($E,{to:"/sessions",replace:!0})})]})})}var XT=m(N(),1),bge=5e3;function gW(e){let[t,r]=(0,XT.useState)(null);return(0,XT.useEffect)(()=>{if(!e){r(null);return}let o=!1,i=async()=>{try{let a=await(await fetch(`/api/git-status?cwd=${encodeURIComponent(e)}`)).json();o||r(a??null)}catch{o||r(null)}};i();let s=setInterval(i,bge);return()=>{o=!0,clearInterval(s)}},[e]),t}var ia=m(x(),1),_ge={display:"flex",alignItems:"center",gap:1,ml:2,fontFamily:"monospace",fontSize:13,cursor:"default"},Sge={maxHeight:360,overflow:"auto",fontFamily:"monospace",fontSize:12},xge={tooltip:{sx:{maxWidth:"none"}}},yW=[{key:"new",label:"New",prefix:"+",color:"success.main"},{key:"modified",label:"Modified",prefix:"~",color:"warning.main"},{key:"deleted",label:"Deleted",prefix:"-",color:"error.main"}];function Tge({counts:e}){return(0,ia.jsx)(q,{sx:Sge,children:yW.filter(t=>e[t.key].length>0).map(t=>(0,ia.jsxs)(q,{sx:{mb:.5,"&:last-child":{mb:0}},children:[(0,ia.jsxs)(q,{sx:{color:t.color,fontWeight:700},children:[t.label," (",e[t.key].length,")"]}),e[t.key].map(r=>(0,ia.jsx)(q,{sx:{pl:1,whiteSpace:"nowrap"},children:r},r))]},t.key))})}function vW({cwd:e}){let t=gW(e),r=t?yW.map(o=>({...o,count:t[o.key].length})).filter(o=>o.count>0):[];return!t||r.length===0?null:(0,ia.jsx)(at,{title:(0,ia.jsx)(Tge,{counts:t}),slotProps:xge,children:(0,ia.jsx)(q,{sx:_ge,children:r.map(o=>(0,ia.jsxs)(q,{component:"span",sx:{color:o.color},children:[o.prefix,o.count]},o.key))})})}var Gh=m(x(),1),wge=["/sessions","/backlog","/news"];function bW(){let e=Pr(),t=sr(),r=wge.findIndex(i=>e.pathname.startsWith(i)),o=i=>{e.pathname!==i&&t(i)};return(0,Gh.jsxs)(Lg,{value:r===-1?0:r,textColor:"inherit",indicatorColor:"secondary",children:[(0,Gh.jsx)(Xl,{label:"Sessions",onClick:()=>o("/sessions")}),(0,Gh.jsx)(Xl,{label:"Backlog",onClick:()=>o("/backlog")}),(0,Gh.jsx)(Xl,{label:"News",onClick:()=>o("/news")})]})}var QT=m(N(),1),ZT=m(x(),1),Cge={color:"inherit"};function _W({cwd:e}){let[t,r]=(0,QT.useState)(null);return(0,QT.useEffect)(()=>{if(!e){r(null);return}let o=!1;return(async()=>{try{let s=await(await fetch(`/api/github-url?cwd=${encodeURIComponent(e)}`)).json();o||r(s?.url??null)}catch{o||r(null)}})(),()=>{o=!0}},[e]),t?(0,ZT.jsx)(at,{title:"Open in GitHub",children:(0,ZT.jsx)(Le,{sx:Cge,onClick:()=>window.open(t,"_blank"),children:(0,ZT.jsx)(Vx,{})})}):null}var xW=m(N(),1);var JT=m(x(),1);function SW({window:e,windowSeconds:t,fallbackLabel:r,now:o}){let i=e?.used_percentage;if(i==null)return null;let s=qT(i,e?.resets_at,t,o),n=e?.resets_at!=null?iW(e.resets_at,o):r;return(0,JT.jsxs)(q,{component:"span",children:[(0,JT.jsxs)(q,{component:"span",sx:{color:GT(s)},children:[Math.round(i),"%"]})," ",(0,JT.jsxs)(q,{component:"span",sx:{color:"text.secondary"},children:["(",n,")"]})]})}var Jc=m(x(),1);function TW({rateLimits:e}){let t=YT(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(o=>o.window?.used_percentage!=null);return(0,Jc.jsx)(Jc.Fragment,{children:r.map((o,i)=>(0,Jc.jsxs)(xW.Fragment,{children:[i>0?(0,Jc.jsx)(q,{component:"span",sx:{color:"text.secondary",mr:.5},children:","}):null,(0,Jc.jsx)(SW,{window:o.window,windowSeconds:o.windowSeconds,fallbackLabel:o.fallbackLabel,now:t})]},o.fallbackLabel))})}var e1=m(x(),1),Pge={display:"flex",alignItems:"center",ml:2,fontFamily:"monospace",fontSize:13};function Rge(e){return e?.five_hour?.used_percentage!=null||e?.seven_day?.used_percentage!=null}function wW({rateLimits:e}){return Rge(e)?(0,e1.jsx)(at,{title:"Claude account usage (5h / 7d windows) \u2014 view history",children:(0,e1.jsx)(hs,{component:Ga,to:"/usage",underline:"hover",color:"inherit",sx:Pge,children:(0,e1.jsx)(TW,{rateLimits:e})})}):null}var CW=m(x(),1),PW=ue((0,CW.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var Sl=m(N(),1);var t1=[{target:"daemon",label:"Restart daemon",message:"This restarts the sessions daemon. Running claude sessions will resume."},{target:"webserver",label:"Restart webserver",message:"This restarts the web server. The connection will drop briefly while it comes back."},{target:"both",label:"Restart both",message:"This restarts the sessions daemon and the web server. The connection will drop briefly while it comes back."}];function r1(e){return fetch(`/api/restart?target=${e}`,{method:"POST"})}var Ege=15e3;function RW(e){let[t,r]=(0,Sl.useState)(!1),[o,i]=(0,Sl.useState)(null),s=(0,Sl.useRef)(!1),n=(0,Sl.useRef)(void 0);(0,Sl.useEffect)(()=>{t&&(e?s.current=!0:s.current&&(clearTimeout(n.current),globalThis.location.reload()))},[t,e]),(0,Sl.useEffect)(()=>()=>clearTimeout(n.current),[]);async function a(){r(!0),s.current=!1,n.current=setTimeout(()=>{r(!1),i("Web server did not come back")},Ege);try{if(!(await r1("webserver")).ok)throw new Error("restart failed")}catch{clearTimeout(n.current),r(!1),i("Failed to restart web server")}}return{pending:t,error:o,clearError:()=>i(null),restart:a}}var fn=m(x(),1),kge={color:"inherit",mr:1.5};function EW({reconnecting:e}){let{pending:t,error:r,clearError:o,restart:i}=RW(e);return(0,fn.jsxs)(fn.Fragment,{children:[(0,fn.jsx)(at,{title:"Restart web server",children:(0,fn.jsx)("span",{children:(0,fn.jsx)(Le,{sx:kge,disabled:t,onClick:i,children:t?(0,fn.jsx)(nt,{size:24}):(0,fn.jsx)(PW,{})})})}),(0,fn.jsx)(zc,{error:r,onClose:o})]})}var Kh=m(x(),1);function Mge(e){return e?Ch(e)?(0,Kh.jsxs)("span",{style:{display:"flex",flexGrow:1,alignItems:"center",justifyContent:"space-between",gap:6,minWidth:0},children:[Ap(e),(0,Kh.jsx)(Bc,{})]}):Ap(e):"Select repo..."}function kW({repos:e,selected:t,onSelect:r}){return(0,Kh.jsx)(wh,{label:Mge(t),children:o=>(0,Kh.jsx)($U,{repos:e,selected:t,onSelect:r,close:o})})}var T5={"assist-draft":{label:"draft",args:["draft","--once"],prompt:!0,nav:!0},"assist-bug":{label:"bug",args:["bug","--once"],prompt:!0,nav:!0},"assist-refine":{label:"refine",args:["refine","--once"],prompt:!0,nav:!1}};function Age(e){return e in T5}function Lge(e,t){let r=[...T5[e].args],o=t?.trim();return o&&r.push(o),r}function MW(e,t,r,o,i){if(Age(e)&&t){r(Lge(e,i),t);return}o(e)}var w5=Object.entries(T5).map(([e,{label:t,prompt:r,nav:o}])=>({value:e,label:t,prompt:r,nav:o})),AW="Enter prompt...";var OW=m(N(),1);var Yh=m(x(),1);function Oge(e,t){e.key==="Enter"&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),t.trim()!==""&&e.currentTarget.closest("form")?.requestSubmit())}function LW({value:e,onChange:t,onSubmit:r}){return(0,Yh.jsx)(pt,{elevation:4,sx:{...Th,left:"auto",width:320},children:(0,Yh.jsxs)(Oe,{component:"form",direction:"row",spacing:1,sx:{p:1,alignItems:"flex-start"},onSubmit:o=>{o.preventDefault(),r()},children:[(0,Yh.jsx)(Ln,{value:e,onChange:o=>t(o.target.value),onKeyDown:o=>Oge(o,e),placeholder:AW,size:"small",autoFocus:!0,fullWidth:!0,multiline:!0,maxRows:7,slotProps:{input:{sx:{fontSize:13}}}}),(0,Yh.jsx)(Ke,{type:"submit",variant:"contained",size:"small",sx:{whiteSpace:"nowrap"},children:"Start"})]})})}var C5=m(x(),1);function Nv({disabled:e,onSubmit:t,label:r="prompt",allowEmpty:o=!1}){let[i,s]=(0,OW.useState)("");return(0,C5.jsx)(wh,{label:r,disabled:e,children:n=>(0,C5.jsx)(LW,{value:i,onChange:s,onSubmit:()=>{!o&&!i.trim()||(t(i),s(""),n())}})})}var Gp=m(x(),1),Dge={textTransform:"none",fontSize:11,fontWeight:600};function DW({onSelect:e,disabled:t=!1,children:r}){return(0,Gp.jsxs)(Gp.Fragment,{children:[w5.filter(o=>o.nav&&o.prompt).map(o=>(0,Gp.jsx)(Nv,{label:o.label,allowEmpty:!0,disabled:t,onSubmit:i=>e(o.value,i)},o.value)),r,w5.filter(o=>o.nav&&!o.prompt).map(o=>(0,Gp.jsx)(Ke,{size:"small",variant:"outlined",disabled:t,onClick:()=>e(o.value),sx:Dge,children:o.label},o.value))]})}var zv=m(N(),1);function o1(e){let[t,r]=(0,zv.useState)([]),[o,i]=(0,zv.useState)(!0);return(0,zv.useEffect)(()=>{if(!e){r([]),i(!1);return}let s=!1;return i(!0),fetch(`/api/pr-list?cwd=${encodeURIComponent(e)}`).then(n=>n.json()).then(n=>{s||(r(Array.isArray(n?.prs)?n.prs:[]),i(!1))}).catch(()=>{s||(r([]),i(!1))}),()=>{s=!0}},[e]),{prs:t,loading:o}}var NW=m(N(),1);var ts=m(x(),1);function IW({cwd:e,onPick:t,header:r}){let{prs:o,loading:i}=o1(e);return(0,ts.jsxs)(pt,{elevation:4,sx:{...Th,left:"auto",width:320},children:[r,i?(0,ts.jsx)(BW,{text:"Loading open PRs\u2026"}):o.length===0?(0,ts.jsx)(BW,{text:"No open PRs"}):(0,ts.jsx)(qu,{dense:!0,disablePadding:!0,children:o.map(s=>(0,ts.jsx)(Bge,{pr:s,onPick:t},s.number))})]})}function Bge({pr:e,onPick:t}){return(0,ts.jsx)(vo,{onMouseDown:r=>r.preventDefault(),onClick:()=>t(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,ts.jsxs)(Oe,{spacing:.25,sx:{minWidth:0},children:[(0,ts.jsx)(Y,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:e.title}),(0,ts.jsxs)(Y,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",Cc(e.createdAt)]})]})})}function BW({text:e}){return(0,ts.jsx)(q,{sx:{p:1.5},children:(0,ts.jsx)(Y,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var sa=m(x(),1);function zW({cwd:e,onSelect:t,close:r}){let[o,i]=(0,NW.useState)("review");return(0,sa.jsx)(IW,{cwd:e,header:(0,sa.jsxs)(BC,{row:!0,value:o,onChange:s=>i(s.target.value),sx:{px:1.5,py:.5},children:[(0,sa.jsx)(Rn,{value:"review",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Review",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}}),(0,sa.jsx)(Rn,{value:"review-comments",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Address Comments",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}}),(0,sa.jsx)(Rn,{value:"review-post",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Review & post",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}})]}),onPick:s=>{t(s,o),r()}})}var P5=m(x(),1);function FW({cwd:e,disabled:t,onSelect:r}){let{prs:o,loading:i}=o1(e);return i||o.length===0?null:(0,P5.jsx)(wh,{label:"review",disabled:t,children:s=>(0,P5.jsx)(zW,{cwd:e,onSelect:r,close:s})})}function UW(e){switch(e){case"review-comments":return["review-comments"];case"review-post":return["review","--no-prompt","--submit"];default:return["review"]}}var Kp=m(x(),1);function $W({onCreate:e,onCreateDesign:t,onCreateAssist:r}){let{selectedCwd:o}=Rs(),i=!o;return(0,Kp.jsx)(Oe,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:(0,Kp.jsxs)(DW,{disabled:i,onSelect:(s,n)=>MW(s,o,r,()=>{},n),children:[(0,Kp.jsx)(Nv,{allowEmpty:!0,disabled:i,onSubmit:s=>e(s,o)}),(0,Kp.jsx)(Nv,{label:"design",allowEmpty:!0,disabled:i,onSubmit:s=>t(s,o)}),(0,Kp.jsx)(FW,{cwd:o,disabled:i,onSelect:(s,n)=>r([...UW(n),String(s.number)],o,Gx(s))})]})})}var rs=m(x(),1),Ige={minHeight:48,pl:1,pr:14},Nge={width:240,ml:2};function HW({socket:e,selection:t}){return(0,rs.jsxs)(Ku,{variant:"dense",disableGutters:!0,sx:Ige,children:[(0,rs.jsx)(EW,{reconnecting:e.reconnecting}),(0,rs.jsx)(bW,{}),(0,rs.jsx)(q,{sx:Nge,children:(0,rs.jsx)(kW,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd})}),(0,rs.jsx)(vW,{cwd:t.selectedCwd}),(0,rs.jsxs)(q,{sx:{display:"flex",ml:1,mr:2},children:[(0,rs.jsx)(Wx,{cwd:t.selectedCwd}),(0,rs.jsx)(_W,{cwd:t.selectedCwd})]}),(0,rs.jsx)($W,{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateAssist:e.createAssistSession}),(0,rs.jsx)(wW,{rateLimits:e.rateLimits})]})}var s1=m(N(),1);var jW=m(x(),1),WW=ue((0,jW.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var VW=m(x(),1),qW=ue((0,VW.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var GW=m(x(),1),KW=ue((0,GW.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var R5=m(x(),1);function YW({mode:e}){return e==="dark"?(0,R5.jsx)(KW,{fontSize:"small"}):(0,R5.jsx)(qW,{fontSize:"small"})}var oi=m(x(),1);function XW({mode:e,onToggleColorMode:t,onRestart:r,onUpdate:o}){return[(0,oi.jsxs)(vo,{onClick:t,children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(YW,{mode:e})}),(0,oi.jsx)(lg,{children:"Toggle dark mode"})]},"color-mode"),(0,oi.jsx)(jl,{},"restart-divider"),...t1.map(i=>(0,oi.jsxs)(vo,{onClick:()=>r(i.target),children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(qx,{fontSize:"small"})}),(0,oi.jsx)(lg,{children:i.label})]},i.target)),(0,oi.jsxs)(vo,{onClick:o,children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(WW,{fontSize:"small"})}),(0,oi.jsx)(lg,{children:"Update assist"})]},"update")]}var ZW=m(x(),1),QW=ue((0,ZW.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var E5=m(x(),1),JW=ue([(0,E5.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,E5.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber");var Fv="0.388.4";var i1=m(N(),1),k5=(0,i1.createContext)(null);function eV(){return(0,i1.useContext)(k5)}var eu=m(x(),1);function tV(){let e=eV();return Fv?(0,eu.jsxs)(eu.Fragment,{children:[(0,eu.jsxs)(Y,{variant:"caption",sx:{opacity:.4,userSelect:"none",lineHeight:1},children:["v",Fv]}),e&&e!==Fv&&(0,eu.jsx)(at,{title:`Daemon is running v${e}, but this page was served by v${Fv}. Restart the daemon to match.`,children:(0,eu.jsx)(JW,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})]}):null}var Xh=m(x(),1);function rV({open:e,onOpen:t}){return(0,Xh.jsxs)(q,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:"inherit"},children:[(0,Xh.jsx)(tV,{}),(0,Xh.jsx)(Le,{onClick:r=>t(r.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,Xh.jsx)(QW,{fontSize:"small"})})]})}var iV=m(x(),1);function oV({target:e,onClose:t}){let r=t1.find(o=>o.target===e);return r?(0,iV.jsx)(xi,{title:r.label,message:r.message,confirmLabel:"Restart",onConfirm:()=>{r1(e),t()},onCancel:t}):null}var nV=m(x(),1);function sV({onConfirm:e,onClose:t}){return(0,nV.jsx)(xi,{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal.",confirmLabel:"Update",onConfirm:()=>{e(),t()},onCancel:t})}var xl=m(x(),1);function aV({mode:e,toggle:t}){let[r,o]=(0,s1.useState)(null),[i,s]=(0,s1.useState)(null),[n,a]=(0,s1.useState)(!1),{launchAssist:l}=kc(),c=!!r;return(0,xl.jsxs)(xl.Fragment,{children:[(0,xl.jsx)(rV,{open:c,onOpen:o}),(0,xl.jsx)(Gu,{anchorEl:r,open:c,onClose:()=>o(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:XW({mode:e,onToggleColorMode:()=>{t(),o(null)},onRestart:u=>{o(null),s(u)},onUpdate:()=>{o(null),a(!0)}})}),i&&(0,xl.jsx)(oV,{target:i,onClose:()=>s(null)}),n&&(0,xl.jsx)(sV,{onConfirm:()=>l(["update"]),onClose:()=>a(!1)})]})}var n1=m(x(),1);function lV({notice:e,onClose:t,onView:r}){let o=e?.sessionId??null;return(0,n1.jsx)(kn,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,n1.jsx)(fo,{severity:"success",variant:"filled",onClose:t,action:o!==null?(0,n1.jsx)(Ke,{color:"inherit",size:"small",onClick:()=>r(o),children:"View"}):void 0,children:e?.message})})}var a1=m(x(),1);function cV({reconnecting:e}){return(0,a1.jsx)(kn,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,a1.jsx)(fo,{severity:"info",variant:"filled",icon:(0,a1.jsx)(nt,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var Yp=m(N(),1);function uV(e,t){let r=new Set,o=[];for(let i of t)i.cwd&&!r.has(i.cwd)&&(r.add(i.cwd),o.push(i.cwd));return e&&!r.has(e)&&o.unshift(e),o}function pV(e,t){let[r,o]=(0,Yp.useState)(e);(0,Yp.useEffect)(()=>{e&&!r&&o(e)},[e,r]);let i=(0,Yp.useMemo)(()=>uV(e,t),[e,t]);return(0,Yp.useMemo)(()=>({repos:i,selectedCwd:r,setSelectedCwd:o}),[i,r])}var l1=m(N(),1);function dV(e){let t=(0,l1.useMemo)(()=>({launchAssist:e.createAssistSession}),[e.createAssistSession]),r=sr(),o=(0,l1.useCallback)(i=>{e.selectSession(i),r("/sessions"),e.clearSuccess()},[r,e.selectSession,e.clearSuccess]);return{launch:t,viewLaunchedSession:o}}var ZV=m(N(),1);var fV=m(N(),1);function c1(e,t,r){if(!e)return;let o=t.find(s=>s.id===e);return o?o.cwd:r.find(s=>s.sessionId===e)?.cwd}function hV(e,t,r,o){let i=c1(e,t,r);(0,fV.useEffect)(()=>{e&&i&&o({type:"set-active",cwd:i,sessionId:e})},[e,i,o])}var u1=m(N(),1);function mV(e,t){let r=(0,u1.useRef)(new Map);(0,u1.useEffect)(()=>{let o=new Set;for(let{id:i,status:s}of e)o.add(i),r.current.get(i)!==s&&(r.current.set(i,s),console.debug(`[sessions] render session ${i} status=${s}`),t({type:"ui-status",sessionId:i,status:s}));for(let i of r.current.keys())o.has(i)||r.current.delete(i)},[e,t])}var ii=m(N(),1);function gV(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r})}function yV(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,design:!0})}function vV(e){return(t,r,o)=>e({type:"create-assist",assistArgs:t,cwd:r,title:o?.title,subtitle:o?.subtitle})}function bV(e){return(t,r,o)=>e({type:"resume",sessionId:t,cwd:r,name:o})}function _V(e,t){return r=>{t.delete(r),e({type:"retry",sessionId:r})}}function SV(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function xV(e,t,r){return o=>{e({type:"dismiss",sessionId:o}),t.delete(o),r.delete(o)}}function TV(e){return(t,r)=>e({type:"set-autorun",sessionId:t,enabled:r})}function wV(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function CV(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function PV(e){return(t,r)=>e({type:"input",sessionId:t,data:r})}function RV(e){return(t,r,o)=>e({type:"resize",sessionId:t,cols:r,rows:o})}function EV(e,t){return(r,o)=>{let i=e.get(r);return i&&o(i),t.set(r,o),()=>t.delete(r)}}function kV(e,t,r){let o={createSession:(0,ii.useMemo)(()=>gV(e),[e]),createDesignSession:(0,ii.useMemo)(()=>yV(e),[e]),createAssistSession:(0,ii.useMemo)(()=>vV(e),[e]),resumeSession:(0,ii.useMemo)(()=>bV(e),[e]),sendInput:(0,ii.useMemo)(()=>PV(e),[e]),sendResize:(0,ii.useMemo)(()=>RV(e),[e]),setAutoRun:(0,ii.useMemo)(()=>TV(e),[e]),setAutoAdvance:(0,ii.useMemo)(()=>wV(e),[e]),setStarred:(0,ii.useMemo)(()=>CV(e),[e])},i=(0,ii.useMemo)(()=>EV(t.current,r.current),[t,r]),s=(0,ii.useCallback)(l=>{_V(e,t.current)(l)},[e,t]),n=(0,ii.useCallback)(l=>{SV(e,t.current)(l)},[e,t]),a=(0,ii.useCallback)(l=>{xV(e,t.current,r.current)(l)},[e,t,r]);return{...o,onOutput:i,retrySession:s,restartSession:n,dismissSession:a}}var p1=m(N(),1);function MV(e,t,r){let o=(0,p1.useCallback)(n=>{r(n),e({type:"fetch-transcript",sessionId:n})},[e,r]),i=(0,p1.useCallback)(()=>{r(null)},[r]),s=(0,p1.useCallback)(n=>{r(null),t(n)},[t,r]);return{viewTranscript:o,clearTranscript:i,selectSession:s}}var hn=m(N(),1);var LV=m(N(),1);function AV(e,t,r=null){return t!==null?e.some(o=>o.id===t)?t:e[0]?.id??null:r&&e.some(o=>o.id===r)?r:e[0]?.id??null}function OV(e,t,r){let o=Pr().pathname,i=o.startsWith("/backlog")||o.startsWith("/usage");(0,LV.useEffect)(()=>{if(i){t(null);return}t(s=>AV(e,s,r))},[e,t,r,i])}var M5=m(N(),1);function DV(){let[e,t]=(0,M5.useState)(null),[r,o]=(0,M5.useState)(null);return{daemonActiveId:e,setDaemonActiveId:t,daemonVersion:r,setDaemonVersion:o}}var Xp=m(N(),1);function BV(e,t){if(!t.some(o=>e.has(o)))return e;let r=new Set(e);for(let o of t)r.delete(o);return r}function IV(e,t){let r=[];for(let o of t){let i=e.get(o.id);i!==void 0&&i!==o.startedAt&&r.push(o.id)}return r}function NV(){let[e,t]=(0,Xp.useState)(new Set),r=(0,Xp.useRef)(new Map),o=(0,Xp.useCallback)(s=>{t(n=>n.has(s)?n:new Set(n).add(s))},[]),i=(0,Xp.useCallback)(s=>{let n=IV(r.current,s);r.current=new Map(s.map(a=>[a.id,a.startedAt])),n.length&&t(a=>BV(a,n))},[]);return{initialized:e,markInitialized:o,syncSessions:i}}var Zh=m(N(),1);function zV(){let[e,t]=(0,Zh.useState)(null),[r,o]=(0,Zh.useState)(null),i=(0,Zh.useCallback)(()=>t(null),[]),s=(0,Zh.useCallback)(()=>o(null),[]);return{error:e,setError:t,clearError:i,success:r,setSuccess:o,clearSuccess:s}}var FV=m(N(),1);function UV(e,t){return(0,FV.useCallback)(r=>{e(r),t(r)},[e,t])}var tu=m(N(),1);function $V(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function HV(e,t){let r=e.sessionId;t.setViewingTranscriptSessionId(null),t.setActiveId(r),e.isNew&&t.setSuccess({message:"New session started",sessionId:r})}function jV(e,t){let r=e.sessionId,o=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,o+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function WV(e,t){let r=new Set(t.map(i=>i.id)),o=null;for(let i of Object.values(e))r.has(i)&&(o=i);return o}function VV(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd);let o=e.active??{};t.setDaemonActiveId(WV(o,r))}function qV(e,t){switch(e.type){case"sessions":VV(e,t);break;case"created":HV(e,t);break;case"history":t.setHistory(e.sessions);break;case"transcript":t.setTranscript({sessionId:e.sessionId,messages:e.messages});break;case"hello":t.setDaemonVersion(e.version);break;case"error":t.setError(e.message);break;case"limits":t.setRateLimits(e.rateLimits);break;case"clear":$V(e,t);break;case"output":jV(e,t);break}}function GV(e,t={}){let r=location.protocol==="https:"?"wss:":"ws:",o=new WebSocket(`${r}//${location.host}/ws`);return o.onopen=()=>{t.onOpen?.(),o.send(JSON.stringify({type:"hello"})),o.send(JSON.stringify({type:"history"}))},o.onmessage=i=>{qV(JSON.parse(i.data),e)},o.onclose=()=>t.onClose?.(),o}function KV(e,t,r,o){let i=!1,s,n=0,a=!1,l=()=>{i||t(GV(e,{onOpen:()=>{a&&r(),a=!1,o(!1),n=0},onClose:()=>{if(i)return;a=!0,o(!0);let c=Math.min(300*2**n,2e3);n+=1,s=setTimeout(l,c)}}))};return l(),()=>{i=!0,s&&clearTimeout(s)}}function YV(e){let t=(0,tu.useRef)(null),[r,o]=(0,tu.useState)(!1),{handleSessions:i,markInitialized:s,buffers:n,handlers:a}=e;(0,tu.useEffect)(()=>{let c=()=>{n.current?.clear();let p=a.current;if(p)for(let f of p.values())f("\x1Bc")},u=KV({...e,setSessions:i},p=>{t.current=p},c,o);return()=>{u(),t.current?.close()}},[i,s,n,a]);let l=(0,tu.useCallback)(()=>{let c=t.current;c?.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function XV(){let[e,t]=(0,hn.useState)([]),[r,o]=(0,hn.useState)([]),[i,s]=(0,hn.useState)(null),n=DV(),[a,l]=(0,hn.useState)(null),[c,u]=(0,hn.useState)(null),[p,f]=(0,hn.useState)(""),d=zV(),[h,g]=(0,hn.useState)(null),{initialized:S,markInitialized:y,syncSessions:v}=NV(),b=(0,hn.useRef)(new Map),_=(0,hn.useRef)(new Map),C=UV(v,t),{wsRef:P,requestHistory:k,reconnecting:L}=YV({handleSessions:C,setHistory:o,setActiveId:s,...n,setTranscript:l,setViewingTranscriptSessionId:u,setCurrentCwd:f,...d,setRateLimits:g,markInitialized:y,buffers:b,handlers:_});return OV(e,s,n.daemonActiveId),{sessions:e,history:r,activeId:i,setActiveId:s,daemonVersion:n.daemonVersion,transcript:a,viewingTranscriptSessionId:c,setViewingTranscriptSessionId:u,currentCwd:p,...d,rateLimits:h,initialized:S,wsRef:P,buffers:b,handlers:_,requestHistory:k,reconnecting:L}}function QV(){let{sessions:e,history:t,activeId:r,setActiveId:o,daemonVersion:i,transcript:s,viewingTranscriptSessionId:n,setViewingTranscriptSessionId:a,currentCwd:l,error:c,clearError:u,success:p,clearSuccess:f,rateLimits:d,initialized:h,wsRef:g,buffers:S,handlers:y,requestHistory:v,reconnecting:b}=XV(),_=(0,ZV.useCallback)(B=>{let I=g.current;I?.readyState===WebSocket.OPEN&&I.send(JSON.stringify(B))},[g]),C=kV(_,S,y);hV(r,e,t,_),mV(e,_);let{viewTranscript:P,clearTranscript:k,selectSession:L}=MV(_,o,a);return{sessions:e,history:t,activeId:r,setActiveId:o,daemonVersion:i,selectSession:L,transcript:s,viewingTranscriptSessionId:n,viewTranscript:P,clearTranscript:k,currentCwd:l,error:c,clearError:u,success:p,clearSuccess:f,rateLimits:d,initialized:h,...C,requestHistory:v,reconnecting:b}}var JV=m(N(),1);function eq(e,t,r,o){let i=c1(e,t,r);(0,JV.useEffect)(()=>{i&&o(i)},[i,o])}var os=m(x(),1),zge={zIndex:e=>e.zIndex.drawer+1},Fge={minHeight:48};function tq({mode:e,toggle:t}){let r=QV(),o=pV(r.currentCwd,r.history);eq(r.activeId,r.sessions,r.history,o.setSelectedCwd);let{launch:i,viewLaunchedSession:s}=dV(r);return(0,os.jsx)(Iy.Provider,{value:o,children:(0,os.jsxs)(t2.Provider,{value:i,children:[(0,os.jsx)(k5.Provider,{value:r.daemonVersion,children:(0,os.jsx)(aV,{mode:e,toggle:t})}),(0,os.jsx)(Ow,{position:"fixed",elevation:1,sx:zge,children:(0,os.jsx)(HW,{socket:r,selection:o})}),(0,os.jsx)(Ku,{variant:"dense",sx:Fge}),(0,os.jsx)(mW,{socket:r}),(0,os.jsx)(cV,{reconnecting:r.reconnecting}),(0,os.jsx)(zc,{error:r.error,onClose:r.clearError}),(0,os.jsx)(lV,{notice:r.success,onClose:r.clearSuccess,onView:s})]})})}var rq=m(N(),1);function oq(){let[e,t]=(0,rq.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(o=>{let i=o==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",i)}catch{}return i})}}var Zp=m(x(),1),Uge={MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}}};function $ge(){let{mode:e,toggle:t}=oq(),r=(0,sq.useMemo)(()=>xn({palette:{mode:e,...e==="dark"&&{background:{default:"#1e1e1e",paper:"#252526"}}},components:Uge}),[e]);return(0,Zp.jsxs)(qb,{theme:r,children:[(0,Zp.jsx)(R_,{}),(0,Zp.jsx)(KE,{children:(0,Zp.jsx)(tq,{mode:e,toggle:t})})]})}var iq=document.getElementById("app");iq&&(0,nq.createRoot)(iq).render((0,Zp.jsx)($ge,{}));})();
382
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return xk.get()},set promptLabel(e){xk.set(e)},get tooMuchOutput(){return Tk.get()},set tooMuchOutput(e){Tk.set(e)}}}_verifyIntegers(...e){for(Qn of e)if(Qn===1/0||isNaN(Qn)||Qn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Qn of e)if(Qn&&(Qn===1/0||isNaN(Qn)||Qn%1!==0||Qn<0))throw new Error("This API only accepts positive integers")}};var g5=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\^<>`]*[^\s"':,.!?{}|\\^~[\]`()<>]/;function sge(e){try{return!!new URL(e).host}catch{return!1}}function Uj(e,t){let r=e(t),o=e(t+1);return!!r&&!!o&&(o.isWrapped||r.isFull)}function nge(e,t){let r=[];for(let o=t;o-t<64;o++){let i=e(o);if(!i||(r.push(i.text),!Uj(e,o)))break}return r}function Fj(e,t,r){let o=t;for(let i of e){if(r<i.length)return{x:r+1,y:o+1};r-=i.length,o++}}function age(e,t,r){let o=r[0],i=Fj(e,t,r.index),s=Fj(e,t,r.index+o.length-1);if(!(!sge(o)||!i||!s))return{text:o,range:{start:i,end:s}}}function lge(e,t,r){let o=new RegExp(r.source,`${r.flags||""}g`);return[...e.join("").matchAll(o)].flatMap(s=>age(e,t,s)??[])}function $j(e,t,r=g5){if(!e(t-1))return[];let o=t-1;for(;o>0&&Uj(e,o-1);)o--;return lge(nge(e,o),o,r)}function Hj(e,t){let r=o=>{let i=e.buffer.active.getLine(o);if(!i)return;let s=e.cols,n=i.getCell(s-1);return{text:i.translateToString(!0,0,s),isWrapped:i.isWrapped,isFull:!!n&&n.getChars()!==""&&n.getChars()!==" "}};return{provideLinks(o,i){let s=$j(r,o,g5);i(s.map(n=>({range:n.range,text:n.text,activate:t})))}}}function jj(e){let t=new zj({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', Consolas, monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4"},linkHandler:{activate:(s,n)=>{window.open(n,"_blank")}}}),r=new g7;t.loadAddon(r);let o=t.registerLinkProvider(Hj(t,(s,n)=>{window.open(n,"_blank")}));t.open(e);let i;try{i=new BH,i.onContextLoss(()=>{i?.dispose(),i=void 0}),t.loadAddon(i)}catch{i=void 0}return r.fit(),{term:t,fitAddon:r,dispose:()=>{o.dispose(),i?.dispose(),t.dispose()}}}function Wj(e,t,r,o){if(e.type!=="keydown"||!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)return!0;let i=e.key.toLowerCase();return i==="c"&&t.hasSelection()?(e.preventDefault(),r.writeText(t.getSelection()),!1):i==="v"?(e.preventDefault(),r.readText().then(o),!1):!0}function Vj(e,t,r,o,i){let s=jj(e);s.term.onData(c=>r(t,c)),s.term.attachCustomKeyEventHandler(c=>Wj(c,s.term,navigator.clipboard,u=>s.term.paste(u)));let n=o(t,c=>s.term.write(c)),a=new ResizeObserver(()=>{s.fitAddon.fit(),i(t,s.term.cols,s.term.rows)});return a.observe(e),{handle:s,cleanup:()=>{a.disconnect(),n(),s.dispose()}}}function qj(e,t,r,o,i,s){let n=(0,Bv.useRef)(null);(0,Bv.useEffect)(()=>{let a=e.current;if(!a)return;let{handle:l,cleanup:c}=Vj(a,t,o,i,s);return n.current=l,()=>{c(),n.current=null}},[e,t,i,o,s]),(0,Bv.useEffect)(()=>{let a=n.current;if(!r||!a)return;let l=setTimeout(()=>{a.fitAddon.fit(),a.term.focus(),s(t,a.term.cols,a.term.rows)},50);return()=>clearTimeout(l)},[r,t,s])}var Yj=m(x(),1);function Kj({sessionId:e,visible:t,onOutput:r,sendInput:o,sendResize:i}){let s=(0,Gj.useRef)(null);return qj(s,e,t,o,r,i),(0,Yj.jsx)(q,{ref:s,sx:{position:"absolute",inset:"0 0 0 8px",visibility:t?"visible":"hidden",pointerEvents:t?"auto":"none"}})}var qp=m(x(),1);function Xj({sessions:e,activeId:t,initialized:r,onOutput:o,sendInput:i,sendResize:s}){let n=e.find(l=>l.id===t),a=n!==void 0&&zx(n,r);return(0,qp.jsxs)(q,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:[e.map(l=>(0,qp.jsx)(Kj,{sessionId:l.id,visible:l.id===t,onOutput:o,sendInput:i,sendResize:s},l.id)),a&&(0,qp.jsx)(m7,{}),e.length===0&&(0,qp.jsx)(q,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,qp.jsx)(Y,{variant:"body2",color:"text.disabled",children:"Create a session to get started"})})]})}var Zj=m(x(),1),Qj=ue((0,Zj.jsx)("path",{d:"m22.7 19-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4"}),"Build");var zs=m(x(),1);function Jj({message:e}){return e.role==="tool"?(0,zs.jsx)(cge,{tool:e.tool,target:e.target}):(0,zs.jsx)(uge,{role:e.role,text:e.text})}function cge({tool:e,target:t}){return(0,zs.jsxs)(q,{sx:{display:"flex",alignItems:"center",gap:1,py:.5,pl:1},children:[(0,zs.jsx)(Qj,{sx:{fontSize:14,color:"text.disabled"}}),(0,zs.jsxs)(Y,{variant:"caption",sx:{color:"text.secondary",fontFamily:"monospace"},children:[(0,zs.jsx)(q,{component:"span",sx:{color:"warning.main"},children:e}),t&&(0,zs.jsxs)(q,{component:"span",children:[" ",t]})]})]})}function uge({role:e,text:t}){let r=e==="user",o=r?"info.main":"success.main";return(0,zs.jsxs)(q,{sx:{mb:1.5,pl:1.5,py:1,pr:1,borderLeft:2,borderColor:o,borderTopRightRadius:1,borderBottomRightRadius:1,bgcolor:r?"action.hover":"transparent"},children:[(0,zs.jsx)(Y,{variant:"caption",sx:{color:o,fontWeight:600,display:"block",mb:.5},children:r?"User":"Assistant"}),(0,zs.jsx)(Y,{variant:"body2",sx:{color:"text.primary",whiteSpace:"pre-wrap",overflowWrap:"anywhere",lineHeight:1.6},children:t})]})}var ra=m(x(),1);function pge(e){let t=new Map;return e.map(r=>{let o=r.role==="tool"?`tool:${r.tool}:${r.target}`:`${r.role}:${r.text.slice(0,40)}`,i=t.get(o)??0;return t.set(o,i+1),{...r,key:`${o}#${i}`}})}function tW({messages:e,loading:t}){return t?(0,ra.jsxs)(q,{sx:eW,children:[(0,ra.jsx)(nt,{size:20}),(0,ra.jsx)(Y,{variant:"caption",color:"text.disabled",children:"Loading transcript\u2026"})]}):e.length===0?(0,ra.jsx)(q,{sx:eW,children:(0,ra.jsx)(Y,{variant:"body2",color:"text.disabled",children:"No transcript available"})}):(0,ra.jsx)(q,{sx:{position:"absolute",inset:0,overflowY:"auto",p:2},children:(0,ra.jsx)(q,{sx:{maxWidth:820,mx:"auto"},children:pge(e).map(r=>(0,ra.jsx)(Jj,{message:r},r.key))})})}var eW={position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:1.5,alignItems:"center",justifyContent:"center"};var y5=m(x(),1);function rW({sessionId:e,transcript:t}){let r=t?.sessionId===e;return(0,y5.jsx)(q,{sx:{flex:1,position:"relative",bgcolor:"background.default"},children:(0,y5.jsx)(tW,{messages:r?t?.messages??[]:[],loading:!r})})}var v5=m(x(),1);function oW({viewingTranscriptSessionId:e,transcript:t,...r}){return e!==null?(0,v5.jsx)(rW,{sessionId:e,transcript:t}):(0,v5.jsx)(Xj,{...r})}var qh=m(N(),1);function iW(e,t){let r=Math.max(0,e-t),o=Math.floor(r/86400),i=Math.floor(r%86400/3600),s=Math.floor(r%3600/60);return o>0?`${o}d ${i}h`:i>0?`${i}h ${s}m`:`${s}m`}function dge(e,t,r,o){if(t==null)return;let i=Math.max(0,t-o),s=Math.max(0,r-i)/r;if(!(s<.05))return e/s}function qT(e,t,r,o){let i=dge(e,t,r,o);return i==null?"ok":i>100?"over":i>75?"warn":"ok"}var fge={ok:"success.main",warn:"warning.main",over:"error.main"};function GT(e){return fge[e]}var Iv=m(x(),1),hge={ok:"success",warn:"warning",over:"error"};function sW({percentage:e,level:t}){return(0,Iv.jsxs)(q,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,Iv.jsx)(ig,{variant:"determinate",value:Math.min(100,e),color:hge[t],sx:{flexGrow:1,height:8,borderRadius:1}}),(0,Iv.jsxs)(q,{sx:{minWidth:40,textAlign:"right",color:GT(t)},children:[Math.round(e),"%"]})]})}function nW(e){return e.avgContextPct==null?"\u2014":`${Math.round(e.avgContextPct)}%`}var lW=m(x(),1);function aW(){return(0,lW.jsx)(Xe,{label:"reset",size:"small",color:"warning",variant:"outlined",title:"Quota reset mid-cycle \u2014 this is the peak reached before the reset.",sx:{ml:1}})}function cW(e){return!e.tokensUp&&!e.tokensDown?"\u2014":`\u2191 ${hh(e.tokensUp)} \u2193 ${hh(e.tokensDown)}`}var mge=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function b5(e){return mge.format(e)}var uW={five_hour:{label:"5h",seconds:18e3},seven_day:{label:"7d",seconds:604800,tint:{light:"rgba(0, 0, 0, 0.1)",dark:"rgba(255, 255, 255, 0.1)"}}};var Fs=m(x(),1);function pW({peak:e,now:t}){let{label:r,seconds:o,tint:i}=uW[e.window],s=qT(e.usedPercentage,e.resetsAt,o,t);return(0,Fs.jsxs)(Pa,{sx:n=>({backgroundColor:i?n.palette.mode==="dark"?i.dark:i.light:void 0}),children:[(0,Fs.jsxs)(Ct,{children:[r,e.resetDetected&&(0,Fs.jsx)(aW,{})]}),(0,Fs.jsx)(Ct,{sx:{minWidth:160},children:(0,Fs.jsx)(sW,{percentage:e.usedPercentage,level:s})}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:nW(e)}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:cW(e)}),(0,Fs.jsx)(Ct,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,Fs.jsx)(at,{title:`Cycle started ${b5(new Date(e.createdAt))}`,children:(0,Fs.jsx)("span",{children:b5(new Date(e.resetsAt*1e3))})})})]})}var KT=m(N(),1);function YT(e){let[t,r]=(0,KT.useState)(()=>Math.floor(Date.now()/1e3));return(0,KT.useEffect)(()=>{let o=setInterval(()=>r(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(o)},[e]),t}var ri=m(x(),1);function dW({peaks:e}){let t=YT(3e4);return(0,ri.jsx)(kg,{component:pt,children:(0,ri.jsxs)(Pg,{size:"small",children:[(0,ri.jsx)(Mg,{sx:{"& th":{whiteSpace:"nowrap"}},children:(0,ri.jsxs)(Pa,{children:[(0,ri.jsx)(Ct,{children:"Window"}),(0,ri.jsx)(Ct,{children:"Peak usage"}),(0,ri.jsx)(Ct,{align:"right",children:(0,ri.jsx)(at,{title:"Mean context-window usage across all readings in this rate-limit cycle \u2014 distinct from the Peak usage quota above.",children:(0,ri.jsx)("span",{children:"Avg context"})})}),(0,ri.jsx)(Ct,{align:"right",children:"Tokens spent"}),(0,ri.jsx)(Ct,{align:"right",children:"Cycle reset"})]})}),(0,ri.jsx)(Rg,{children:e.map(r=>(0,ri.jsx)(pW,{peak:r,now:t},`${r.window}-${r.resetsAt}-${r.segment}`))})]})})}var oa=m(N(),1),x5=30;async function gge(e){let t=await fetch(`/api/usage/history?page=${e}&pageSize=${x5}`);if(!t.ok)throw new Error(`Failed to load usage history (HTTP ${t.status}).`);return t.json()}function fW(){let[e,t]=(0,oa.useState)(0),[r,o]=(0,oa.useState)([]),[i,s]=(0,oa.useState)(0),[n,a]=(0,oa.useState)(!1),[l,c]=(0,oa.useState)(!1),[u,p]=(0,oa.useState)(null);return(0,oa.useEffect)(()=>{let f=!1;return c(!0),gge(e).then(d=>{f||(o(d.rows),s(d.total),a(!0),c(!1))},d=>{f||(p(d instanceof Error?d:new Error(String(d))),c(!1))}),()=>{f=!0}},[e]),(0,oa.useEffect)(()=>{if(i===0)return;let f=Math.ceil(i/x5)-1;e>f&&t(f)},[e,i]),{page:e,setPage:t,rows:r,total:i,loaded:n,fetching:l,error:u,pageSize:x5}}var Qc=m(x(),1);function hW(){let{page:e,setPage:t,rows:r,total:o,loaded:i,fetching:s,error:n,pageSize:a}=fW(),l=(0,qh.useRef)(null),[c,u]=(0,qh.useState)();if((0,qh.useLayoutEffect)(()=>{r.length===a&&l.current&&u(l.current.offsetHeight)},[r,a]),n)throw n;return(0,Qc.jsxs)(Jx,{loading:!i,title:"Usage history",isEmpty:o===0,emptyMessage:"No usage peaks recorded yet.",children:[(0,Qc.jsx)(q,{sx:{height:4,mb:1},children:s&&(0,Qc.jsx)(ig,{})}),(0,Qc.jsx)(q,{ref:l,sx:{minHeight:c},children:(0,Qc.jsx)(dW,{peaks:r})}),(0,Qc.jsx)(HC,{component:"div",count:o,page:e,rowsPerPage:a,rowsPerPageOptions:[a],onPageChange:(p,f)=>t(f)})]})}var Mr=m(x(),1);function yge({socket:e}){return(0,Mr.jsx)(zl,{maxWidth:"md",sx:{py:3,px:2},children:(0,Mr.jsx)(SU,{socket:e})})}function vge({socket:e}){return(0,Mr.jsx)(oW,{sessions:e.sessions,activeId:e.activeId,initialized:e.initialized,onOutput:e.onOutput,sendInput:e.sendInput,sendResize:e.sendResize,viewingTranscriptSessionId:e.viewingTranscriptSessionId,transcript:e.transcript})}function mW({socket:e}){return(0,Mr.jsx)(bp,{children:(0,Mr.jsxs)(qo,{element:(0,Mr.jsx)(o7,{socket:e}),children:[(0,Mr.jsx)(qo,{path:"sessions",element:(0,Mr.jsx)(vge,{socket:e})}),(0,Mr.jsx)(qo,{path:"backlog/*",element:(0,Mr.jsx)(yge,{socket:e})}),(0,Mr.jsx)(qo,{path:"news",element:(0,Mr.jsx)(h7,{})}),(0,Mr.jsx)(qo,{path:"usage",element:(0,Mr.jsx)(hW,{})}),(0,Mr.jsx)(qo,{path:"backups",element:(0,Mr.jsx)(u7,{})}),(0,Mr.jsx)(qo,{path:"*",element:(0,Mr.jsx)($E,{to:"/sessions",replace:!0})})]})})}var XT=m(N(),1),bge=5e3;function gW(e){let[t,r]=(0,XT.useState)(null);return(0,XT.useEffect)(()=>{if(!e){r(null);return}let o=!1,i=async()=>{try{let a=await(await fetch(`/api/git-status?cwd=${encodeURIComponent(e)}`)).json();o||r(a??null)}catch{o||r(null)}};i();let s=setInterval(i,bge);return()=>{o=!0,clearInterval(s)}},[e]),t}var ia=m(x(),1),_ge={display:"flex",alignItems:"center",gap:1,ml:2,fontFamily:"monospace",fontSize:13,cursor:"default"},Sge={maxHeight:360,overflow:"auto",fontFamily:"monospace",fontSize:12},xge={tooltip:{sx:{maxWidth:"none"}}},yW=[{key:"new",label:"New",prefix:"+",color:"success.main"},{key:"modified",label:"Modified",prefix:"~",color:"warning.main"},{key:"deleted",label:"Deleted",prefix:"-",color:"error.main"}];function Tge({counts:e}){return(0,ia.jsx)(q,{sx:Sge,children:yW.filter(t=>e[t.key].length>0).map(t=>(0,ia.jsxs)(q,{sx:{mb:.5,"&:last-child":{mb:0}},children:[(0,ia.jsxs)(q,{sx:{color:t.color,fontWeight:700},children:[t.label," (",e[t.key].length,")"]}),e[t.key].map(r=>(0,ia.jsx)(q,{sx:{pl:1,whiteSpace:"nowrap"},children:r},r))]},t.key))})}function vW({cwd:e}){let t=gW(e),r=t?yW.map(o=>({...o,count:t[o.key].length})).filter(o=>o.count>0):[];return!t||r.length===0?null:(0,ia.jsx)(at,{title:(0,ia.jsx)(Tge,{counts:t}),slotProps:xge,children:(0,ia.jsx)(q,{sx:_ge,children:r.map(o=>(0,ia.jsxs)(q,{component:"span",sx:{color:o.color},children:[o.prefix,o.count]},o.key))})})}var Gh=m(x(),1),wge=["/sessions","/backlog","/news"];function bW(){let e=Pr(),t=sr(),r=wge.findIndex(i=>e.pathname.startsWith(i)),o=i=>{e.pathname!==i&&t(i)};return(0,Gh.jsxs)(Lg,{value:r===-1?0:r,textColor:"inherit",indicatorColor:"secondary",children:[(0,Gh.jsx)(Xl,{label:"Sessions",onClick:()=>o("/sessions")}),(0,Gh.jsx)(Xl,{label:"Backlog",onClick:()=>o("/backlog")}),(0,Gh.jsx)(Xl,{label:"News",onClick:()=>o("/news")})]})}var QT=m(N(),1),ZT=m(x(),1),Cge={color:"inherit"};function _W({cwd:e}){let[t,r]=(0,QT.useState)(null);return(0,QT.useEffect)(()=>{if(!e){r(null);return}let o=!1;return(async()=>{try{let s=await(await fetch(`/api/github-url?cwd=${encodeURIComponent(e)}`)).json();o||r(s?.url??null)}catch{o||r(null)}})(),()=>{o=!0}},[e]),t?(0,ZT.jsx)(at,{title:"Open in GitHub",children:(0,ZT.jsx)(Le,{sx:Cge,onClick:()=>window.open(t,"_blank"),children:(0,ZT.jsx)(Vx,{})})}):null}var xW=m(N(),1);var JT=m(x(),1);function SW({window:e,windowSeconds:t,fallbackLabel:r,now:o}){let i=e?.used_percentage;if(i==null)return null;let s=qT(i,e?.resets_at,t,o),n=e?.resets_at!=null?iW(e.resets_at,o):r;return(0,JT.jsxs)(q,{component:"span",children:[(0,JT.jsxs)(q,{component:"span",sx:{color:GT(s)},children:[Math.round(i),"%"]})," ",(0,JT.jsxs)(q,{component:"span",sx:{color:"text.secondary"},children:["(",n,")"]})]})}var Jc=m(x(),1);function TW({rateLimits:e}){let t=YT(3e4),r=[{window:e.five_hour,windowSeconds:18e3,fallbackLabel:"5h"},{window:e.seven_day,windowSeconds:604800,fallbackLabel:"7d"}].filter(o=>o.window?.used_percentage!=null);return(0,Jc.jsx)(Jc.Fragment,{children:r.map((o,i)=>(0,Jc.jsxs)(xW.Fragment,{children:[i>0?(0,Jc.jsx)(q,{component:"span",sx:{color:"text.secondary",mr:.5},children:","}):null,(0,Jc.jsx)(SW,{window:o.window,windowSeconds:o.windowSeconds,fallbackLabel:o.fallbackLabel,now:t})]},o.fallbackLabel))})}var e1=m(x(),1),Pge={display:"flex",alignItems:"center",ml:2,fontFamily:"monospace",fontSize:13};function Rge(e){return e?.five_hour?.used_percentage!=null||e?.seven_day?.used_percentage!=null}function wW({rateLimits:e}){return Rge(e)?(0,e1.jsx)(at,{title:"Claude account usage (5h / 7d windows) \u2014 view history",children:(0,e1.jsx)(hs,{component:Ga,to:"/usage",underline:"hover",color:"inherit",sx:Pge,children:(0,e1.jsx)(TW,{rateLimits:e})})}):null}var CW=m(x(),1),PW=ue((0,CW.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var Sl=m(N(),1);var t1=[{target:"daemon",label:"Restart daemon",message:"This restarts the sessions daemon. Running claude sessions will resume."},{target:"webserver",label:"Restart webserver",message:"This restarts the web server. The connection will drop briefly while it comes back."},{target:"both",label:"Restart both",message:"This restarts the sessions daemon and the web server. The connection will drop briefly while it comes back."}];function r1(e){return fetch(`/api/restart?target=${e}`,{method:"POST"})}var Ege=15e3;function RW(e){let[t,r]=(0,Sl.useState)(!1),[o,i]=(0,Sl.useState)(null),s=(0,Sl.useRef)(!1),n=(0,Sl.useRef)(void 0);(0,Sl.useEffect)(()=>{t&&(e?s.current=!0:s.current&&(clearTimeout(n.current),globalThis.location.reload()))},[t,e]),(0,Sl.useEffect)(()=>()=>clearTimeout(n.current),[]);async function a(){r(!0),s.current=!1,n.current=setTimeout(()=>{r(!1),i("Web server did not come back")},Ege);try{if(!(await r1("webserver")).ok)throw new Error("restart failed")}catch{clearTimeout(n.current),r(!1),i("Failed to restart web server")}}return{pending:t,error:o,clearError:()=>i(null),restart:a}}var fn=m(x(),1),kge={color:"inherit",mr:1.5};function EW({reconnecting:e}){let{pending:t,error:r,clearError:o,restart:i}=RW(e);return(0,fn.jsxs)(fn.Fragment,{children:[(0,fn.jsx)(at,{title:"Restart web server",children:(0,fn.jsx)("span",{children:(0,fn.jsx)(Le,{sx:kge,disabled:t,onClick:i,children:t?(0,fn.jsx)(nt,{size:24}):(0,fn.jsx)(PW,{})})})}),(0,fn.jsx)(zc,{error:r,onClose:o})]})}var Kh=m(x(),1);function Mge(e){return e?Ch(e)?(0,Kh.jsxs)("span",{style:{display:"flex",flexGrow:1,alignItems:"center",justifyContent:"space-between",gap:6,minWidth:0},children:[Ap(e),(0,Kh.jsx)(Bc,{})]}):Ap(e):"Select repo..."}function kW({repos:e,selected:t,onSelect:r}){return(0,Kh.jsx)(wh,{label:Mge(t),children:o=>(0,Kh.jsx)($U,{repos:e,selected:t,onSelect:r,close:o})})}var T5={"assist-draft":{label:"draft",args:["draft","--once"],prompt:!0,nav:!0},"assist-bug":{label:"bug",args:["bug","--once"],prompt:!0,nav:!0},"assist-refine":{label:"refine",args:["refine","--once"],prompt:!0,nav:!1}};function Age(e){return e in T5}function Lge(e,t){let r=[...T5[e].args],o=t?.trim();return o&&r.push(o),r}function MW(e,t,r,o,i){if(Age(e)&&t){r(Lge(e,i),t);return}o(e)}var w5=Object.entries(T5).map(([e,{label:t,prompt:r,nav:o}])=>({value:e,label:t,prompt:r,nav:o})),AW="Enter prompt...";var OW=m(N(),1);var Yh=m(x(),1);function Oge(e,t){e.key==="Enter"&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),t.trim()!==""&&e.currentTarget.closest("form")?.requestSubmit())}function LW({value:e,onChange:t,onSubmit:r}){return(0,Yh.jsx)(pt,{elevation:4,sx:{...Th,left:"auto",width:320},children:(0,Yh.jsxs)(Oe,{component:"form",direction:"row",spacing:1,sx:{p:1,alignItems:"flex-start"},onSubmit:o=>{o.preventDefault(),r()},children:[(0,Yh.jsx)(Ln,{value:e,onChange:o=>t(o.target.value),onKeyDown:o=>Oge(o,e),placeholder:AW,size:"small",autoFocus:!0,fullWidth:!0,multiline:!0,maxRows:7,slotProps:{input:{sx:{fontSize:13}}}}),(0,Yh.jsx)(Ke,{type:"submit",variant:"contained",size:"small",sx:{whiteSpace:"nowrap"},children:"Start"})]})})}var C5=m(x(),1);function Nv({disabled:e,onSubmit:t,label:r="prompt",allowEmpty:o=!1}){let[i,s]=(0,OW.useState)("");return(0,C5.jsx)(wh,{label:r,disabled:e,children:n=>(0,C5.jsx)(LW,{value:i,onChange:s,onSubmit:()=>{!o&&!i.trim()||(t(i),s(""),n())}})})}var Gp=m(x(),1),Dge={textTransform:"none",fontSize:11,fontWeight:600};function DW({onSelect:e,disabled:t=!1,children:r}){return(0,Gp.jsxs)(Gp.Fragment,{children:[w5.filter(o=>o.nav&&o.prompt).map(o=>(0,Gp.jsx)(Nv,{label:o.label,allowEmpty:!0,disabled:t,onSubmit:i=>e(o.value,i)},o.value)),r,w5.filter(o=>o.nav&&!o.prompt).map(o=>(0,Gp.jsx)(Ke,{size:"small",variant:"outlined",disabled:t,onClick:()=>e(o.value),sx:Dge,children:o.label},o.value))]})}var zv=m(N(),1);function o1(e){let[t,r]=(0,zv.useState)([]),[o,i]=(0,zv.useState)(!0);return(0,zv.useEffect)(()=>{if(!e){r([]),i(!1);return}let s=!1;return i(!0),fetch(`/api/pr-list?cwd=${encodeURIComponent(e)}`).then(n=>n.json()).then(n=>{s||(r(Array.isArray(n?.prs)?n.prs:[]),i(!1))}).catch(()=>{s||(r([]),i(!1))}),()=>{s=!0}},[e]),{prs:t,loading:o}}var NW=m(N(),1);var ts=m(x(),1);function IW({cwd:e,onPick:t,header:r}){let{prs:o,loading:i}=o1(e);return(0,ts.jsxs)(pt,{elevation:4,sx:{...Th,left:"auto",width:320},children:[r,i?(0,ts.jsx)(BW,{text:"Loading open PRs\u2026"}):o.length===0?(0,ts.jsx)(BW,{text:"No open PRs"}):(0,ts.jsx)(qu,{dense:!0,disablePadding:!0,children:o.map(s=>(0,ts.jsx)(Bge,{pr:s,onPick:t},s.number))})]})}function Bge({pr:e,onPick:t}){return(0,ts.jsx)(vo,{onMouseDown:r=>r.preventDefault(),onClick:()=>t(e),sx:{alignItems:"flex-start",py:.75,whiteSpace:"normal"},children:(0,ts.jsxs)(Oe,{spacing:.25,sx:{minWidth:0},children:[(0,ts.jsx)(Y,{sx:{fontSize:13,lineHeight:1.3,fontWeight:500},children:e.title}),(0,ts.jsxs)(Y,{sx:{fontSize:11,color:"text.secondary"},children:["#",e.number," \xB7 ",e.author," \xB7 ",Cc(e.createdAt)]})]})})}function BW({text:e}){return(0,ts.jsx)(q,{sx:{p:1.5},children:(0,ts.jsx)(Y,{sx:{fontSize:13,color:"text.secondary"},children:e})})}var sa=m(x(),1);function zW({cwd:e,onSelect:t,close:r}){let[o,i]=(0,NW.useState)("review");return(0,sa.jsx)(IW,{cwd:e,header:(0,sa.jsxs)(BC,{row:!0,value:o,onChange:s=>i(s.target.value),sx:{px:1.5,py:.5},children:[(0,sa.jsx)(Rn,{value:"review",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Review",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}}),(0,sa.jsx)(Rn,{value:"review-comments",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Address Comments",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}}),(0,sa.jsx)(Rn,{value:"review-post",control:(0,sa.jsx)(Sg,{size:"small"}),label:"Review & post",onMouseDown:s=>s.preventDefault(),slotProps:{typography:{sx:{fontSize:13}}}})]}),onPick:s=>{t(s,o),r()}})}var P5=m(x(),1);function FW({cwd:e,disabled:t,onSelect:r}){let{prs:o,loading:i}=o1(e);return i||o.length===0?null:(0,P5.jsx)(wh,{label:"review",disabled:t,children:s=>(0,P5.jsx)(zW,{cwd:e,onSelect:r,close:s})})}function UW(e){switch(e){case"review-comments":return["review-comments"];case"review-post":return["review","--no-prompt","--submit"];default:return["review"]}}var Kp=m(x(),1);function $W({onCreate:e,onCreateDesign:t,onCreateAssist:r}){let{selectedCwd:o}=Rs(),i=!o;return(0,Kp.jsx)(Oe,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:(0,Kp.jsxs)(DW,{disabled:i,onSelect:(s,n)=>MW(s,o,r,()=>{},n),children:[(0,Kp.jsx)(Nv,{allowEmpty:!0,disabled:i,onSubmit:s=>e(s,o)}),(0,Kp.jsx)(Nv,{label:"design",allowEmpty:!0,disabled:i,onSubmit:s=>t(s,o)}),(0,Kp.jsx)(FW,{cwd:o,disabled:i,onSelect:(s,n)=>r([...UW(n),String(s.number)],o,Gx(s))})]})})}var rs=m(x(),1),Ige={minHeight:48,pl:1,pr:14},Nge={width:240,ml:2};function HW({socket:e,selection:t}){return(0,rs.jsxs)(Ku,{variant:"dense",disableGutters:!0,sx:Ige,children:[(0,rs.jsx)(EW,{reconnecting:e.reconnecting}),(0,rs.jsx)(bW,{}),(0,rs.jsx)(q,{sx:Nge,children:(0,rs.jsx)(kW,{repos:t.repos,selected:t.selectedCwd,onSelect:t.setSelectedCwd})}),(0,rs.jsx)(vW,{cwd:t.selectedCwd}),(0,rs.jsxs)(q,{sx:{display:"flex",ml:1,mr:2},children:[(0,rs.jsx)(Wx,{cwd:t.selectedCwd}),(0,rs.jsx)(_W,{cwd:t.selectedCwd})]}),(0,rs.jsx)($W,{onCreate:e.createSession,onCreateDesign:e.createDesignSession,onCreateAssist:e.createAssistSession}),(0,rs.jsx)(wW,{rateLimits:e.rateLimits})]})}var s1=m(N(),1);var jW=m(x(),1),WW=ue((0,jW.jsx)("path",{d:"m12 16.5 4-4h-3v-9h-2v9H8zm9-13h-6v1.99h6v14.03H3V5.49h6V3.5H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2v-14c0-1.1-.9-2-2-2"}),"SystemUpdateAlt");var VW=m(x(),1),qW=ue((0,VW.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6c3.31 0 6 2.69 6 6s-2.69 6-6 6"}),"Brightness4");var GW=m(x(),1),KW=ue((0,GW.jsx)("path",{d:"M20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zM12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6m0-10c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4"}),"Brightness7");var R5=m(x(),1);function YW({mode:e}){return e==="dark"?(0,R5.jsx)(KW,{fontSize:"small"}):(0,R5.jsx)(qW,{fontSize:"small"})}var oi=m(x(),1);function XW({mode:e,onToggleColorMode:t,onRestart:r,onUpdate:o}){return[(0,oi.jsxs)(vo,{onClick:t,children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(YW,{mode:e})}),(0,oi.jsx)(lg,{children:"Toggle dark mode"})]},"color-mode"),(0,oi.jsx)(jl,{},"restart-divider"),...t1.map(i=>(0,oi.jsxs)(vo,{onClick:()=>r(i.target),children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(qx,{fontSize:"small"})}),(0,oi.jsx)(lg,{children:i.label})]},i.target)),(0,oi.jsxs)(vo,{onClick:o,children:[(0,oi.jsx)(ng,{children:(0,oi.jsx)(WW,{fontSize:"small"})}),(0,oi.jsx)(lg,{children:"Update assist"})]},"update")]}var ZW=m(x(),1),QW=ue((0,ZW.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var E5=m(x(),1),JW=ue([(0,E5.jsx)("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),(0,E5.jsx)("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber");var Fv="0.388.6";var i1=m(N(),1),k5=(0,i1.createContext)(null);function eV(){return(0,i1.useContext)(k5)}var eu=m(x(),1);function tV(){let e=eV();return Fv?(0,eu.jsxs)(eu.Fragment,{children:[(0,eu.jsxs)(Y,{variant:"caption",sx:{opacity:.4,userSelect:"none",lineHeight:1},children:["v",Fv]}),e&&e!==Fv&&(0,eu.jsx)(at,{title:`Daemon is running v${e}, but this page was served by v${Fv}. Restart the daemon to match.`,children:(0,eu.jsx)(JW,{fontSize:"small",color:"warning","aria-label":"Version mismatch"})})]}):null}var Xh=m(x(),1);function rV({open:e,onOpen:t}){return(0,Xh.jsxs)(q,{sx:{position:"fixed",top:8,right:16,zIndex:r=>r.zIndex.drawer+2,display:"flex",alignItems:"center",gap:.5,color:"inherit"},children:[(0,Xh.jsx)(tV,{}),(0,Xh.jsx)(Le,{onClick:r=>t(r.currentTarget),size:"small",sx:{color:"inherit"},"aria-label":"Open menu","aria-haspopup":"true","aria-expanded":e?"true":void 0,children:(0,Xh.jsx)(QW,{fontSize:"small"})})]})}var iV=m(x(),1);function oV({target:e,onClose:t}){let r=t1.find(o=>o.target===e);return r?(0,iV.jsx)(xi,{title:r.label,message:r.message,confirmLabel:"Restart",onConfirm:()=>{r1(e),t()},onCancel:t}):null}var nV=m(x(),1);function sV({onConfirm:e,onClose:t}){return(0,nV.jsx)(xi,{title:"Update assist",message:"This starts a new session running 'assist update'. Its output will appear in the terminal.",confirmLabel:"Update",onConfirm:()=>{e(),t()},onCancel:t})}var xl=m(x(),1);function aV({mode:e,toggle:t}){let[r,o]=(0,s1.useState)(null),[i,s]=(0,s1.useState)(null),[n,a]=(0,s1.useState)(!1),{launchAssist:l}=kc(),c=!!r;return(0,xl.jsxs)(xl.Fragment,{children:[(0,xl.jsx)(rV,{open:c,onOpen:o}),(0,xl.jsx)(Gu,{anchorEl:r,open:c,onClose:()=>o(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:XW({mode:e,onToggleColorMode:()=>{t(),o(null)},onRestart:u=>{o(null),s(u)},onUpdate:()=>{o(null),a(!0)}})}),i&&(0,xl.jsx)(oV,{target:i,onClose:()=>s(null)}),n&&(0,xl.jsx)(sV,{onConfirm:()=>l(["update"]),onClose:()=>a(!1)})]})}var n1=m(x(),1);function lV({notice:e,onClose:t,onView:r}){let o=e?.sessionId??null;return(0,n1.jsx)(kn,{open:e!==null,autoHideDuration:6e3,onClose:t,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,n1.jsx)(fo,{severity:"success",variant:"filled",onClose:t,action:o!==null?(0,n1.jsx)(Ke,{color:"inherit",size:"small",onClick:()=>r(o),children:"View"}):void 0,children:e?.message})})}var a1=m(x(),1);function cV({reconnecting:e}){return(0,a1.jsx)(kn,{open:e,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:(0,a1.jsx)(fo,{severity:"info",variant:"filled",icon:(0,a1.jsx)(nt,{size:16,color:"inherit"}),children:"Reconnecting\u2026"})})}var Yp=m(N(),1);function uV(e,t){let r=new Set,o=[];for(let i of t)i.cwd&&!r.has(i.cwd)&&(r.add(i.cwd),o.push(i.cwd));return e&&!r.has(e)&&o.unshift(e),o}function pV(e,t){let[r,o]=(0,Yp.useState)(e);(0,Yp.useEffect)(()=>{e&&!r&&o(e)},[e,r]);let i=(0,Yp.useMemo)(()=>uV(e,t),[e,t]);return(0,Yp.useMemo)(()=>({repos:i,selectedCwd:r,setSelectedCwd:o}),[i,r])}var l1=m(N(),1);function dV(e){let t=(0,l1.useMemo)(()=>({launchAssist:e.createAssistSession}),[e.createAssistSession]),r=sr(),o=(0,l1.useCallback)(i=>{e.selectSession(i),r("/sessions"),e.clearSuccess()},[r,e.selectSession,e.clearSuccess]);return{launch:t,viewLaunchedSession:o}}var ZV=m(N(),1);var fV=m(N(),1);function c1(e,t,r){if(!e)return;let o=t.find(s=>s.id===e);return o?o.cwd:r.find(s=>s.sessionId===e)?.cwd}function hV(e,t,r,o){let i=c1(e,t,r);(0,fV.useEffect)(()=>{e&&i&&o({type:"set-active",cwd:i,sessionId:e})},[e,i,o])}var u1=m(N(),1);function mV(e,t){let r=(0,u1.useRef)(new Map);(0,u1.useEffect)(()=>{let o=new Set;for(let{id:i,status:s}of e)o.add(i),r.current.get(i)!==s&&(r.current.set(i,s),console.debug(`[sessions] render session ${i} status=${s}`),t({type:"ui-status",sessionId:i,status:s}));for(let i of r.current.keys())o.has(i)||r.current.delete(i)},[e,t])}var ii=m(N(),1);function gV(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r})}function yV(e){return(t,r)=>e({type:"create",prompt:t||void 0,cwd:r,design:!0})}function vV(e){return(t,r,o)=>e({type:"create-assist",assistArgs:t,cwd:r,title:o?.title,subtitle:o?.subtitle})}function bV(e){return(t,r,o)=>e({type:"resume",sessionId:t,cwd:r,name:o})}function _V(e,t){return r=>{t.delete(r),e({type:"retry",sessionId:r})}}function SV(e,t){return r=>{t.delete(r),e({type:"restart",sessionId:r})}}function xV(e,t,r){return o=>{e({type:"dismiss",sessionId:o}),t.delete(o),r.delete(o)}}function TV(e){return(t,r)=>e({type:"set-autorun",sessionId:t,enabled:r})}function wV(e){return(t,r)=>e({type:"set-autoadvance",sessionId:t,enabled:r})}function CV(e){return(t,r)=>e({type:"set-starred",sessionId:t,starred:r})}function PV(e){return(t,r)=>e({type:"input",sessionId:t,data:r})}function RV(e){return(t,r,o)=>e({type:"resize",sessionId:t,cols:r,rows:o})}function EV(e,t){return(r,o)=>{let i=e.get(r);return i&&o(i),t.set(r,o),()=>t.delete(r)}}function kV(e,t,r){let o={createSession:(0,ii.useMemo)(()=>gV(e),[e]),createDesignSession:(0,ii.useMemo)(()=>yV(e),[e]),createAssistSession:(0,ii.useMemo)(()=>vV(e),[e]),resumeSession:(0,ii.useMemo)(()=>bV(e),[e]),sendInput:(0,ii.useMemo)(()=>PV(e),[e]),sendResize:(0,ii.useMemo)(()=>RV(e),[e]),setAutoRun:(0,ii.useMemo)(()=>TV(e),[e]),setAutoAdvance:(0,ii.useMemo)(()=>wV(e),[e]),setStarred:(0,ii.useMemo)(()=>CV(e),[e])},i=(0,ii.useMemo)(()=>EV(t.current,r.current),[t,r]),s=(0,ii.useCallback)(l=>{_V(e,t.current)(l)},[e,t]),n=(0,ii.useCallback)(l=>{SV(e,t.current)(l)},[e,t]),a=(0,ii.useCallback)(l=>{xV(e,t.current,r.current)(l)},[e,t,r]);return{...o,onOutput:i,retrySession:s,restartSession:n,dismissSession:a}}var p1=m(N(),1);function MV(e,t,r){let o=(0,p1.useCallback)(n=>{r(n),e({type:"fetch-transcript",sessionId:n})},[e,r]),i=(0,p1.useCallback)(()=>{r(null)},[r]),s=(0,p1.useCallback)(n=>{r(null),t(n)},[t,r]);return{viewTranscript:o,clearTranscript:i,selectSession:s}}var hn=m(N(),1);var LV=m(N(),1);function AV(e,t,r=null){return t!==null?e.some(o=>o.id===t)?t:e[0]?.id??null:r&&e.some(o=>o.id===r)?r:e[0]?.id??null}function OV(e,t,r){let o=Pr().pathname,i=o.startsWith("/backlog")||o.startsWith("/usage");(0,LV.useEffect)(()=>{if(i){t(null);return}t(s=>AV(e,s,r))},[e,t,r,i])}var M5=m(N(),1);function DV(){let[e,t]=(0,M5.useState)(null),[r,o]=(0,M5.useState)(null);return{daemonActiveId:e,setDaemonActiveId:t,daemonVersion:r,setDaemonVersion:o}}var Xp=m(N(),1);function BV(e,t){if(!t.some(o=>e.has(o)))return e;let r=new Set(e);for(let o of t)r.delete(o);return r}function IV(e,t){let r=[];for(let o of t){let i=e.get(o.id);i!==void 0&&i!==o.startedAt&&r.push(o.id)}return r}function NV(){let[e,t]=(0,Xp.useState)(new Set),r=(0,Xp.useRef)(new Map),o=(0,Xp.useCallback)(s=>{t(n=>n.has(s)?n:new Set(n).add(s))},[]),i=(0,Xp.useCallback)(s=>{let n=IV(r.current,s);r.current=new Map(s.map(a=>[a.id,a.startedAt])),n.length&&t(a=>BV(a,n))},[]);return{initialized:e,markInitialized:o,syncSessions:i}}var Zh=m(N(),1);function zV(){let[e,t]=(0,Zh.useState)(null),[r,o]=(0,Zh.useState)(null),i=(0,Zh.useCallback)(()=>t(null),[]),s=(0,Zh.useCallback)(()=>o(null),[]);return{error:e,setError:t,clearError:i,success:r,setSuccess:o,clearSuccess:s}}var FV=m(N(),1);function UV(e,t){return(0,FV.useCallback)(r=>{e(r),t(r)},[e,t])}var tu=m(N(),1);function $V(e,t){let r=e.sessionId;t.buffers.current?.delete(r),t.handlers.current?.get(r)?.("\x1Bc")}function HV(e,t){let r=e.sessionId;t.setViewingTranscriptSessionId(null),t.setActiveId(r),e.isNew&&t.setSuccess({message:"New session started",sessionId:r})}function jV(e,t){let r=e.sessionId,o=t.buffers.current?.get(r)??"";t.buffers.current?.set(r,o+e.data),t.handlers.current?.get(r)?.(e.data),t.markInitialized(r)}function WV(e,t){let r=new Set(t.map(i=>i.id)),o=null;for(let i of Object.values(e))r.has(i)&&(o=i);return o}function VV(e,t){let r=e.sessions;t.setSessions(r),e.cwd&&t.setCurrentCwd(e.cwd);let o=e.active??{};t.setDaemonActiveId(WV(o,r))}function qV(e,t){switch(e.type){case"sessions":VV(e,t);break;case"created":HV(e,t);break;case"history":t.setHistory(e.sessions);break;case"transcript":t.setTranscript({sessionId:e.sessionId,messages:e.messages});break;case"hello":t.setDaemonVersion(e.version);break;case"error":t.setError(e.message);break;case"limits":t.setRateLimits(e.rateLimits);break;case"clear":$V(e,t);break;case"output":jV(e,t);break}}function GV(e,t={}){let r=location.protocol==="https:"?"wss:":"ws:",o=new WebSocket(`${r}//${location.host}/ws`);return o.onopen=()=>{t.onOpen?.(),o.send(JSON.stringify({type:"hello"})),o.send(JSON.stringify({type:"history"}))},o.onmessage=i=>{qV(JSON.parse(i.data),e)},o.onclose=()=>t.onClose?.(),o}function KV(e,t,r,o){let i=!1,s,n=0,a=!1,l=()=>{i||t(GV(e,{onOpen:()=>{a&&r(),a=!1,o(!1),n=0},onClose:()=>{if(i)return;a=!0,o(!0);let c=Math.min(300*2**n,2e3);n+=1,s=setTimeout(l,c)}}))};return l(),()=>{i=!0,s&&clearTimeout(s)}}function YV(e){let t=(0,tu.useRef)(null),[r,o]=(0,tu.useState)(!1),{handleSessions:i,markInitialized:s,buffers:n,handlers:a}=e;(0,tu.useEffect)(()=>{let c=()=>{n.current?.clear();let p=a.current;if(p)for(let f of p.values())f("\x1Bc")},u=KV({...e,setSessions:i},p=>{t.current=p},c,o);return()=>{u(),t.current?.close()}},[i,s,n,a]);let l=(0,tu.useCallback)(()=>{let c=t.current;c?.readyState===WebSocket.OPEN&&c.send(JSON.stringify({type:"history"}))},[]);return{wsRef:t,requestHistory:l,reconnecting:r}}function XV(){let[e,t]=(0,hn.useState)([]),[r,o]=(0,hn.useState)([]),[i,s]=(0,hn.useState)(null),n=DV(),[a,l]=(0,hn.useState)(null),[c,u]=(0,hn.useState)(null),[p,f]=(0,hn.useState)(""),d=zV(),[h,g]=(0,hn.useState)(null),{initialized:S,markInitialized:y,syncSessions:v}=NV(),b=(0,hn.useRef)(new Map),_=(0,hn.useRef)(new Map),C=UV(v,t),{wsRef:P,requestHistory:k,reconnecting:L}=YV({handleSessions:C,setHistory:o,setActiveId:s,...n,setTranscript:l,setViewingTranscriptSessionId:u,setCurrentCwd:f,...d,setRateLimits:g,markInitialized:y,buffers:b,handlers:_});return OV(e,s,n.daemonActiveId),{sessions:e,history:r,activeId:i,setActiveId:s,daemonVersion:n.daemonVersion,transcript:a,viewingTranscriptSessionId:c,setViewingTranscriptSessionId:u,currentCwd:p,...d,rateLimits:h,initialized:S,wsRef:P,buffers:b,handlers:_,requestHistory:k,reconnecting:L}}function QV(){let{sessions:e,history:t,activeId:r,setActiveId:o,daemonVersion:i,transcript:s,viewingTranscriptSessionId:n,setViewingTranscriptSessionId:a,currentCwd:l,error:c,clearError:u,success:p,clearSuccess:f,rateLimits:d,initialized:h,wsRef:g,buffers:S,handlers:y,requestHistory:v,reconnecting:b}=XV(),_=(0,ZV.useCallback)(B=>{let I=g.current;I?.readyState===WebSocket.OPEN&&I.send(JSON.stringify(B))},[g]),C=kV(_,S,y);hV(r,e,t,_),mV(e,_);let{viewTranscript:P,clearTranscript:k,selectSession:L}=MV(_,o,a);return{sessions:e,history:t,activeId:r,setActiveId:o,daemonVersion:i,selectSession:L,transcript:s,viewingTranscriptSessionId:n,viewTranscript:P,clearTranscript:k,currentCwd:l,error:c,clearError:u,success:p,clearSuccess:f,rateLimits:d,initialized:h,...C,requestHistory:v,reconnecting:b}}var JV=m(N(),1);function eq(e,t,r,o){let i=c1(e,t,r);(0,JV.useEffect)(()=>{i&&o(i)},[i,o])}var os=m(x(),1),zge={zIndex:e=>e.zIndex.drawer+1},Fge={minHeight:48};function tq({mode:e,toggle:t}){let r=QV(),o=pV(r.currentCwd,r.history);eq(r.activeId,r.sessions,r.history,o.setSelectedCwd);let{launch:i,viewLaunchedSession:s}=dV(r);return(0,os.jsx)(Iy.Provider,{value:o,children:(0,os.jsxs)(t2.Provider,{value:i,children:[(0,os.jsx)(k5.Provider,{value:r.daemonVersion,children:(0,os.jsx)(aV,{mode:e,toggle:t})}),(0,os.jsx)(Ow,{position:"fixed",elevation:1,sx:zge,children:(0,os.jsx)(HW,{socket:r,selection:o})}),(0,os.jsx)(Ku,{variant:"dense",sx:Fge}),(0,os.jsx)(mW,{socket:r}),(0,os.jsx)(cV,{reconnecting:r.reconnecting}),(0,os.jsx)(zc,{error:r.error,onClose:r.clearError}),(0,os.jsx)(lV,{notice:r.success,onClose:r.clearSuccess,onView:s})]})})}var rq=m(N(),1);function oq(){let[e,t]=(0,rq.useState)(()=>{try{return localStorage.getItem("theme-mode")??"dark"}catch{return"dark"}});return{mode:e,toggle:()=>t(o=>{let i=o==="dark"?"light":"dark";try{localStorage.setItem("theme-mode",i)}catch{}return i})}}var Zp=m(x(),1),Uge={MuiButtonBase:{styleOverrides:{root:{cursor:"pointer","&.Mui-disabled":{cursor:"default"}}}},MuiLink:{styleOverrides:{root:{cursor:"pointer"}}}};function $ge(){let{mode:e,toggle:t}=oq(),r=(0,sq.useMemo)(()=>xn({palette:{mode:e,...e==="dark"&&{background:{default:"#1e1e1e",paper:"#252526"}}},components:Uge}),[e]);return(0,Zp.jsxs)(qb,{theme:r,children:[(0,Zp.jsx)(R_,{}),(0,Zp.jsx)(KE,{children:(0,Zp.jsx)(tq,{mode:e,toggle:t})})]})}var iq=document.getElementById("app");iq&&(0,nq.createRoot)(iq).render((0,Zp.jsx)($ge,{}));})();
383
383
  /*! Bundled license information:
384
384
 
385
385
  react/cjs/react.production.js:
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.388.4",
9
+ version: "0.388.6",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -16353,7 +16353,7 @@ function comment2(path61, line, body, startLine) {
16353
16353
  }
16354
16354
 
16355
16355
  // src/commands/prs/edit.ts
16356
- import { execSync as execSync39 } from "child_process";
16356
+ import { execFileSync as execFileSync6 } from "child_process";
16357
16357
 
16358
16358
  // src/commands/prs/buildPrBody.ts
16359
16359
  function jiraBrowseUrl(key) {
@@ -16522,21 +16522,21 @@ function edit(options2) {
16522
16522
  const { number, body } = getCurrentPr();
16523
16523
  const newBody = editPrBody(body, options2);
16524
16524
  validatePrContent(options2.title ?? "", newBody);
16525
- const args = [`gh pr edit ${number}`];
16526
- if (options2.title) args.push(`--title ${shellQuote(options2.title)}`);
16527
- args.push(`--body ${shellQuote(newBody)}`);
16525
+ const args = ["pr", "edit", String(number)];
16526
+ if (options2.title) args.push("--title", options2.title);
16527
+ args.push("--body", newBody);
16528
16528
  try {
16529
- execSync39(args.join(" "), { stdio: "inherit" });
16529
+ execFileSync6("gh", args, { stdio: "inherit" });
16530
16530
  } catch {
16531
16531
  process.exit(1);
16532
16532
  }
16533
16533
  }
16534
16534
 
16535
16535
  // src/commands/prs/fixed.ts
16536
- import { execSync as execSync42 } from "child_process";
16536
+ import { execSync as execSync41 } from "child_process";
16537
16537
 
16538
16538
  // src/commands/prs/resolveCommentWithReply.ts
16539
- import { execSync as execSync41 } from "child_process";
16539
+ import { execSync as execSync40 } from "child_process";
16540
16540
  import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync31 } from "fs";
16541
16541
  import { tmpdir as tmpdir5 } from "os";
16542
16542
  import { join as join48 } from "path";
@@ -16565,9 +16565,9 @@ function deleteCommentsCache(prNumber) {
16565
16565
  }
16566
16566
 
16567
16567
  // src/commands/prs/replyToComment.ts
16568
- import { execSync as execSync40 } from "child_process";
16568
+ import { execSync as execSync39 } from "child_process";
16569
16569
  function replyToComment(org, repo, prNumber, commentId, message) {
16570
- execSync40(
16570
+ execSync39(
16571
16571
  `gh api repos/${org}/${repo}/pulls/${prNumber}/comments -f body="${message.replace(/"/g, String.raw`\"`)}" -F in_reply_to=${commentId}`,
16572
16572
  { stdio: ["inherit", "pipe", "inherit"] }
16573
16573
  );
@@ -16579,7 +16579,7 @@ function resolveThread(threadId) {
16579
16579
  const queryFile = join48(tmpdir5(), `gh-mutation-${Date.now()}.graphql`);
16580
16580
  writeFileSync31(queryFile, mutation);
16581
16581
  try {
16582
- execSync41(
16582
+ execSync40(
16583
16583
  `gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
16584
16584
  { stdio: ["inherit", "pipe", "inherit"] }
16585
16585
  );
@@ -16631,7 +16631,7 @@ function resolveCommentWithReply(commentId, message) {
16631
16631
  // src/commands/prs/fixed.ts
16632
16632
  function verifySha(sha) {
16633
16633
  try {
16634
- return execSync42(`git rev-parse --verify ${sha}`, {
16634
+ return execSync41(`git rev-parse --verify ${sha}`, {
16635
16635
  encoding: "utf8"
16636
16636
  }).trim();
16637
16637
  } catch {
@@ -16645,7 +16645,7 @@ function fixed(commentId, sha) {
16645
16645
  const { org, repo } = getRepoInfo();
16646
16646
  const repoUrl = `https://github.com/${org}/${repo}`;
16647
16647
  const message = `Fixed in [${fullSha}](${repoUrl}/commit/${fullSha})`;
16648
- execSync42("git push", { stdio: "inherit" });
16648
+ execSync41("git push", { stdio: "inherit" });
16649
16649
  resolveCommentWithReply(commentId, message);
16650
16650
  } catch (error) {
16651
16651
  if (isGhNotInstalled(error)) {
@@ -16663,7 +16663,7 @@ import { join as join50 } from "path";
16663
16663
  import { stringify } from "yaml";
16664
16664
 
16665
16665
  // src/commands/prs/fetchThreadIds.ts
16666
- import { execSync as execSync43 } from "child_process";
16666
+ import { execSync as execSync42 } from "child_process";
16667
16667
  import { unlinkSync as unlinkSync13, writeFileSync as writeFileSync32 } from "fs";
16668
16668
  import { tmpdir as tmpdir6 } from "os";
16669
16669
  import { join as join49 } from "path";
@@ -16672,7 +16672,7 @@ function fetchThreadIds(org, repo, prNumber) {
16672
16672
  const queryFile = join49(tmpdir6(), `gh-query-${Date.now()}.graphql`);
16673
16673
  writeFileSync32(queryFile, THREAD_QUERY);
16674
16674
  try {
16675
- const result = execSync43(
16675
+ const result = execSync42(
16676
16676
  `gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
16677
16677
  { encoding: "utf8" }
16678
16678
  );
@@ -16694,9 +16694,9 @@ function fetchThreadIds(org, repo, prNumber) {
16694
16694
  }
16695
16695
 
16696
16696
  // src/commands/prs/listComments/fetchReviewComments.ts
16697
- import { execSync as execSync44 } from "child_process";
16697
+ import { execSync as execSync43 } from "child_process";
16698
16698
  function fetchJson(endpoint) {
16699
- const result = execSync44(`gh api --paginate ${endpoint}`, {
16699
+ const result = execSync43(`gh api --paginate ${endpoint}`, {
16700
16700
  encoding: "utf8"
16701
16701
  });
16702
16702
  if (!result.trim()) return [];
@@ -16835,7 +16835,7 @@ async function listComments() {
16835
16835
  }
16836
16836
 
16837
16837
  // src/commands/prs/prs/index.ts
16838
- import { execSync as execSync45 } from "child_process";
16838
+ import { execSync as execSync44 } from "child_process";
16839
16839
 
16840
16840
  // src/commands/prs/prs/displayPaginated/index.ts
16841
16841
  import enquirer9 from "enquirer";
@@ -16942,7 +16942,7 @@ async function prs(options2) {
16942
16942
  const state = options2.open ? "open" : options2.closed ? "closed" : "all";
16943
16943
  try {
16944
16944
  const { org, repo } = getRepoInfo();
16945
- const result = execSync45(
16945
+ const result = execSync44(
16946
16946
  `gh pr list --state ${state} --json number,title,url,author,createdAt,mergedAt,closedAt,state,changedFiles --limit 100 -R ${org}/${repo}`,
16947
16947
  { encoding: "utf8" }
16948
16948
  );
@@ -16965,22 +16965,21 @@ async function prs(options2) {
16965
16965
  }
16966
16966
 
16967
16967
  // src/commands/prs/raise.ts
16968
- import { execSync as execSync47 } from "child_process";
16968
+ import { execFileSync as execFileSync7 } from "child_process";
16969
16969
 
16970
16970
  // src/commands/prs/buildCreateArgs.ts
16971
+ function buildEditArgs(number, title, body) {
16972
+ return ["pr", "edit", String(number), "--title", title, "--body", body];
16973
+ }
16971
16974
  function buildCreateArgs(title, body, options2) {
16972
- const args = [
16973
- "gh pr create",
16974
- `--title ${shellQuote(title)}`,
16975
- `--body ${shellQuote(body)}`
16976
- ];
16975
+ const args = ["pr", "create", "--title", title, "--body", body];
16977
16976
  const valueFlags = [
16978
16977
  ["--base", options2.base],
16979
16978
  ["--head", options2.head],
16980
16979
  ["--milestone", options2.milestone]
16981
16980
  ];
16982
16981
  for (const [flag, value] of valueFlags) {
16983
- if (value) args.push(`${flag} ${shellQuote(value)}`);
16982
+ if (value) args.push(flag, value);
16984
16983
  }
16985
16984
  if (options2.draft) args.push("--draft");
16986
16985
  if (options2.web) args.push("--web");
@@ -16991,23 +16990,23 @@ function buildCreateArgs(title, body, options2) {
16991
16990
  ];
16992
16991
  for (const [flag, values] of repeatableFlags) {
16993
16992
  for (const value of values ?? []) {
16994
- args.push(`${flag} ${shellQuote(value)}`);
16993
+ args.push(flag, value);
16995
16994
  }
16996
16995
  }
16997
16996
  return args;
16998
16997
  }
16999
16998
 
17000
16999
  // src/commands/prs/readSessionPrRef.ts
17001
- import { execSync as execSync46 } from "child_process";
17000
+ import { execSync as execSync45 } from "child_process";
17002
17001
  function readSessionPrRef() {
17003
17002
  try {
17004
- const branch2 = execSync46("git rev-parse --abbrev-ref HEAD", {
17003
+ const branch2 = execSync45("git rev-parse --abbrev-ref HEAD", {
17005
17004
  encoding: "utf8",
17006
17005
  stdio: ["pipe", "pipe", "pipe"]
17007
17006
  }).trim();
17008
17007
  if (!branch2 || branch2 === "HEAD") return null;
17009
17008
  const pr = JSON.parse(
17010
- execSync46(`gh pr view ${branch2} --json number,title,url,state`, {
17009
+ execSync45(`gh pr view ${branch2} --json number,title,url,state`, {
17011
17010
  encoding: "utf8",
17012
17011
  stdio: ["pipe", "pipe", "pipe"]
17013
17012
  })
@@ -17045,13 +17044,9 @@ async function raise(options2) {
17045
17044
  );
17046
17045
  process.exit(1);
17047
17046
  }
17048
- const args = existing !== null ? [
17049
- `gh pr edit ${existing}`,
17050
- `--title ${shellQuote(options2.title)}`,
17051
- `--body ${shellQuote(body)}`
17052
- ] : buildCreateArgs(options2.title, body, options2);
17047
+ const args = existing !== null ? buildEditArgs(existing, options2.title, body) : buildCreateArgs(options2.title, body, options2);
17053
17048
  try {
17054
- execSync47(args.join(" "), { stdio: "inherit" });
17049
+ execFileSync7("gh", args, { stdio: "inherit" });
17055
17050
  } catch {
17056
17051
  process.exit(1);
17057
17052
  }
@@ -17089,7 +17084,7 @@ function reply(commentId, body) {
17089
17084
  }
17090
17085
 
17091
17086
  // src/commands/prs/wontfix.ts
17092
- import { execSync as execSync48 } from "child_process";
17087
+ import { execSync as execSync46 } from "child_process";
17093
17088
  function validateReason(reason) {
17094
17089
  const lowerReason = reason.toLowerCase();
17095
17090
  if (lowerReason.includes("claude") || lowerReason.includes("opus")) {
@@ -17106,7 +17101,7 @@ function validateShaReferences(reason) {
17106
17101
  const invalidShas = [];
17107
17102
  for (const sha of shas) {
17108
17103
  try {
17109
- execSync48(`git cat-file -t ${sha}`, { stdio: "pipe" });
17104
+ execSync46(`git cat-file -t ${sha}`, { stdio: "pipe" });
17110
17105
  } catch {
17111
17106
  invalidShas.push(sha);
17112
17107
  }
@@ -17283,10 +17278,10 @@ import chalk158 from "chalk";
17283
17278
  import Enquirer2 from "enquirer";
17284
17279
 
17285
17280
  // src/commands/ravendb/searchItems.ts
17286
- import { execSync as execSync49 } from "child_process";
17281
+ import { execSync as execSync47 } from "child_process";
17287
17282
  import chalk157 from "chalk";
17288
17283
  function opExec(args) {
17289
- return execSync49(`op ${args}`, {
17284
+ return execSync47(`op ${args}`, {
17290
17285
  encoding: "utf8",
17291
17286
  stdio: ["pipe", "pipe", "pipe"]
17292
17287
  }).trim();
@@ -17438,7 +17433,7 @@ ${errorText}`
17438
17433
  }
17439
17434
 
17440
17435
  // src/commands/ravendb/resolveOpSecret.ts
17441
- import { execSync as execSync50 } from "child_process";
17436
+ import { execSync as execSync48 } from "child_process";
17442
17437
  import chalk162 from "chalk";
17443
17438
  function resolveOpSecret(reference) {
17444
17439
  if (!reference.startsWith("op://")) {
@@ -17446,7 +17441,7 @@ function resolveOpSecret(reference) {
17446
17441
  process.exit(1);
17447
17442
  }
17448
17443
  try {
17449
- return execSync50(`op read "${reference}"`, {
17444
+ return execSync48(`op read "${reference}"`, {
17450
17445
  encoding: "utf8",
17451
17446
  stdio: ["pipe", "pipe", "pipe"]
17452
17447
  }).trim();
@@ -17710,7 +17705,7 @@ Refactor check failed:
17710
17705
  }
17711
17706
 
17712
17707
  // src/commands/refactor/check/getViolations/index.ts
17713
- import { execSync as execSync51 } from "child_process";
17708
+ import { execSync as execSync49 } from "child_process";
17714
17709
  import fs24 from "fs";
17715
17710
  import { minimatch as minimatch6 } from "minimatch";
17716
17711
 
@@ -17760,7 +17755,7 @@ function getGitFiles(options2) {
17760
17755
  }
17761
17756
  const files = /* @__PURE__ */ new Set();
17762
17757
  if (options2.staged || options2.modified) {
17763
- const staged = execSync51("git diff --cached --name-only", {
17758
+ const staged = execSync49("git diff --cached --name-only", {
17764
17759
  encoding: "utf8"
17765
17760
  });
17766
17761
  for (const file of staged.trim().split("\n").filter(Boolean)) {
@@ -17768,7 +17763,7 @@ function getGitFiles(options2) {
17768
17763
  }
17769
17764
  }
17770
17765
  if (options2.unstaged || options2.modified) {
17771
- const unstaged = execSync51("git diff --name-only", { encoding: "utf8" });
17766
+ const unstaged = execSync49("git diff --name-only", { encoding: "utf8" });
17772
17767
  for (const file of unstaged.trim().split("\n").filter(Boolean)) {
17773
17768
  files.add(file);
17774
17769
  }
@@ -19311,7 +19306,7 @@ function registerRefactor(program2) {
19311
19306
  }
19312
19307
 
19313
19308
  // src/commands/review/review.ts
19314
- import { execFileSync as execFileSync6 } from "child_process";
19309
+ import { execFileSync as execFileSync8 } from "child_process";
19315
19310
 
19316
19311
  // src/commands/review/annotateDiffWithLineNumbers.ts
19317
19312
  var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
@@ -19446,9 +19441,9 @@ function buildReviewPaths(repoRoot, key) {
19446
19441
  }
19447
19442
 
19448
19443
  // src/commands/review/fetchExistingComments.ts
19449
- import { execSync as execSync52 } from "child_process";
19444
+ import { execSync as execSync50 } from "child_process";
19450
19445
  function fetchRawComments(org, repo, prNumber) {
19451
- const out = execSync52(
19446
+ const out = execSync50(
19452
19447
  `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
19453
19448
  { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
19454
19449
  );
@@ -19479,14 +19474,14 @@ function fetchExistingComments() {
19479
19474
  }
19480
19475
 
19481
19476
  // src/commands/review/gatherContext.ts
19482
- import { execSync as execSync55 } from "child_process";
19477
+ import { execSync as execSync53 } from "child_process";
19483
19478
 
19484
19479
  // src/commands/review/fetchPrDiff.ts
19485
- import { execSync as execSync53 } from "child_process";
19480
+ import { execSync as execSync51 } from "child_process";
19486
19481
  function fetchPrDiff(prNumber, baseSha, headSha) {
19487
19482
  const { org, repo } = getRepoInfo();
19488
19483
  try {
19489
- return execSync53(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
19484
+ return execSync51(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
19490
19485
  encoding: "utf8",
19491
19486
  maxBuffer: 256 * 1024 * 1024,
19492
19487
  stdio: ["ignore", "pipe", "pipe"]
@@ -19501,19 +19496,19 @@ function isDiffTooLarge(error) {
19501
19496
  }
19502
19497
  function fetchDiffViaGit(baseSha, headSha) {
19503
19498
  try {
19504
- execSync53(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
19499
+ execSync51(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
19505
19500
  } catch {
19506
19501
  }
19507
- return execSync53(`git diff ${baseSha}...${headSha}`, {
19502
+ return execSync51(`git diff ${baseSha}...${headSha}`, {
19508
19503
  encoding: "utf8",
19509
19504
  maxBuffer: 256 * 1024 * 1024
19510
19505
  });
19511
19506
  }
19512
19507
 
19513
19508
  // src/commands/review/fetchPrDiffInfo.ts
19514
- import { execSync as execSync54 } from "child_process";
19509
+ import { execSync as execSync52 } from "child_process";
19515
19510
  function getCurrentBranch3() {
19516
- return execSync54("git rev-parse --abbrev-ref HEAD", {
19511
+ return execSync52("git rev-parse --abbrev-ref HEAD", {
19517
19512
  encoding: "utf8"
19518
19513
  }).trim();
19519
19514
  }
@@ -19521,7 +19516,7 @@ function fetchPrDiffInfo() {
19521
19516
  const { org, repo } = getRepoInfo();
19522
19517
  const branch2 = getCurrentBranch3();
19523
19518
  const fields = "number,baseRefName,baseRefOid,headRefName,headRefOid";
19524
- const raw = execSync54(
19519
+ const raw = execSync52(
19525
19520
  `gh pr list --state open --head ${branch2} --json ${fields} -R ${org}/${repo}`,
19526
19521
  {
19527
19522
  encoding: "utf8",
@@ -19546,7 +19541,7 @@ function fetchPrDiffInfo() {
19546
19541
  }
19547
19542
  function fetchPrChangedFiles(prNumber) {
19548
19543
  const { org, repo } = getRepoInfo();
19549
- const out = execSync54(
19544
+ const out = execSync52(
19550
19545
  `gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
19551
19546
  {
19552
19547
  encoding: "utf8",
@@ -19558,11 +19553,11 @@ function fetchPrChangedFiles(prNumber) {
19558
19553
 
19559
19554
  // src/commands/review/gatherContext.ts
19560
19555
  function gatherContext() {
19561
- const branch2 = execSync55("git rev-parse --abbrev-ref HEAD", {
19556
+ const branch2 = execSync53("git rev-parse --abbrev-ref HEAD", {
19562
19557
  encoding: "utf8"
19563
19558
  }).trim();
19564
- const sha = execSync55("git rev-parse HEAD", { encoding: "utf8" }).trim();
19565
- const shortSha = execSync55("git rev-parse --short=7 HEAD", {
19559
+ const sha = execSync53("git rev-parse HEAD", { encoding: "utf8" }).trim();
19560
+ const shortSha = execSync53("git rev-parse --short=7 HEAD", {
19566
19561
  encoding: "utf8"
19567
19562
  }).trim();
19568
19563
  const prInfo = fetchPrDiffInfo();
@@ -21009,7 +21004,7 @@ function validateOptions(options2) {
21009
21004
  }
21010
21005
  function checkoutPr(number) {
21011
21006
  try {
21012
- execFileSync6("gh", ["pr", "checkout", number], { stdio: "inherit" });
21007
+ execFileSync8("gh", ["pr", "checkout", number], { stdio: "inherit" });
21013
21008
  } catch {
21014
21009
  console.error(`gh pr checkout ${number} failed; aborting.`);
21015
21010
  process.exit(1);
@@ -22212,7 +22207,7 @@ import { mkdirSync as mkdirSync20 } from "fs";
22212
22207
  import { join as join57 } from "path";
22213
22208
 
22214
22209
  // src/commands/voice/checkLockFile.ts
22215
- import { execSync as execSync56 } from "child_process";
22210
+ import { execSync as execSync54 } from "child_process";
22216
22211
  import { existsSync as existsSync47, mkdirSync as mkdirSync19, readFileSync as readFileSync42, writeFileSync as writeFileSync37 } from "fs";
22217
22212
  import { join as join56 } from "path";
22218
22213
  function isProcessAlive2(pid) {
@@ -22241,7 +22236,7 @@ function bootstrapVenv() {
22241
22236
  if (existsSync47(getVenvPython())) return;
22242
22237
  console.log("Setting up Python environment...");
22243
22238
  const pythonDir = getPythonDir();
22244
- execSync56(
22239
+ execSync54(
22245
22240
  `uv sync --project "${pythonDir}" --extra runtime --no-install-project`,
22246
22241
  {
22247
22242
  stdio: "inherit",
@@ -22608,7 +22603,7 @@ async function auth() {
22608
22603
  }
22609
22604
 
22610
22605
  // src/commands/roam/postRoamActivity.ts
22611
- import { execFileSync as execFileSync7 } from "child_process";
22606
+ import { execFileSync as execFileSync9 } from "child_process";
22612
22607
  import { readdirSync as readdirSync11, readFileSync as readFileSync45, statSync as statSync8 } from "fs";
22613
22608
  import { join as join59 } from "path";
22614
22609
  function findPortFile(roamDir) {
@@ -22641,7 +22636,7 @@ function postRoamActivity(app, event) {
22641
22636
  }
22642
22637
  const url = `http://127.0.0.1:${port}/api/v1/activity/${app}/${event}?pid=${app === "codex" ? 99998 : 99999}`;
22643
22638
  try {
22644
- execFileSync7("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
22639
+ execFileSync9("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
22645
22640
  stdio: "ignore"
22646
22641
  });
22647
22642
  } catch {
@@ -22837,11 +22832,11 @@ function resolveParams(params, cliArgs) {
22837
22832
  }
22838
22833
 
22839
22834
  // src/commands/run/runPreCommands.ts
22840
- import { execSync as execSync57 } from "child_process";
22835
+ import { execSync as execSync55 } from "child_process";
22841
22836
  function runPreCommands(pre, cwd) {
22842
22837
  for (const cmd of pre) {
22843
22838
  try {
22844
- execSync57(cmd, { stdio: "inherit", cwd });
22839
+ execSync55(cmd, { stdio: "inherit", cwd });
22845
22840
  } catch (error) {
22846
22841
  const code = error && typeof error === "object" && "status" in error ? error.status : 1;
22847
22842
  process.exit(code);
@@ -22850,13 +22845,13 @@ function runPreCommands(pre, cwd) {
22850
22845
  }
22851
22846
 
22852
22847
  // src/commands/run/spawnRunCommand.ts
22853
- import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
22848
+ import { execFileSync as execFileSync10, spawn as spawn8 } from "child_process";
22854
22849
  import { existsSync as existsSync50 } from "fs";
22855
22850
  import { dirname as dirname27, join as join60, resolve as resolve13 } from "path";
22856
22851
  function resolveCommand2(command) {
22857
22852
  if (process.platform !== "win32" || command !== "bash") return command;
22858
22853
  try {
22859
- const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
22854
+ const gitPath = execFileSync10("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
22860
22855
  const gitRoot = resolve13(dirname27(gitPath), "..");
22861
22856
  const gitBash = join60(gitRoot, "bin", "bash.exe");
22862
22857
  if (existsSync50(gitBash)) return gitBash;
@@ -23142,7 +23137,7 @@ function registerRun(program2) {
23142
23137
  }
23143
23138
 
23144
23139
  // src/commands/screenshot/index.ts
23145
- import { execSync as execSync58 } from "child_process";
23140
+ import { execSync as execSync56 } from "child_process";
23146
23141
  import { existsSync as existsSync52, mkdirSync as mkdirSync23, unlinkSync as unlinkSync19, writeFileSync as writeFileSync40 } from "fs";
23147
23142
  import { tmpdir as tmpdir7 } from "os";
23148
23143
  import { join as join63, resolve as resolve15 } from "path";
@@ -23285,7 +23280,7 @@ function runPowerShellScript(processName, outputPath) {
23285
23280
  const scriptPath = join63(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
23286
23281
  writeFileSync40(scriptPath, captureWindowPs1, "utf8");
23287
23282
  try {
23288
- execSync58(
23283
+ execSync56(
23289
23284
  `powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
23290
23285
  { stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
23291
23286
  );
@@ -23309,11 +23304,11 @@ function screenshot(processName) {
23309
23304
  }
23310
23305
 
23311
23306
  // src/commands/sessions/daemon/listDaemonPids.ts
23312
- import { execFileSync as execFileSync9 } from "child_process";
23307
+ import { execFileSync as execFileSync11 } from "child_process";
23313
23308
  function listDaemonPids() {
23314
23309
  if (process.platform === "win32") return [];
23315
23310
  try {
23316
- const out = execFileSync9("ps", ["-eo", "pid=,args="], {
23311
+ const out = execFileSync11("ps", ["-eo", "pid=,args="], {
23317
23312
  encoding: "utf8"
23318
23313
  });
23319
23314
  return out.split("\n").filter((line) => line.includes("assist") && / daemon run\b/.test(line)).map((line) => Number.parseInt(line.trim(), 10)).filter((pid) => Number.isInteger(pid));
@@ -26016,7 +26011,7 @@ function summaryPathFor(jsonlPath2) {
26016
26011
  }
26017
26012
 
26018
26013
  // src/commands/sessions/summarise/summariseSession.ts
26019
- import { execFileSync as execFileSync10 } from "child_process";
26014
+ import { execFileSync as execFileSync12 } from "child_process";
26020
26015
 
26021
26016
  // src/commands/sessions/summarise/iterateUserMessages.ts
26022
26017
  import * as fs37 from "fs";
@@ -26120,7 +26115,7 @@ function summariseSession(jsonlPath2) {
26120
26115
  }
26121
26116
  const prompt = buildPrompt3(firstMessage, backlogIds);
26122
26117
  try {
26123
- const output = execFileSync10("claude", ["-p", "--model", "haiku", prompt], {
26118
+ const output = execFileSync12("claude", ["-p", "--model", "haiku", prompt], {
26124
26119
  encoding: "utf8",
26125
26120
  timeout: 3e4,
26126
26121
  stdio: ["ignore", "pipe", "ignore"]
@@ -26530,7 +26525,7 @@ function syncCommands(claudeDir, targetBase) {
26530
26525
  }
26531
26526
 
26532
26527
  // src/commands/update.ts
26533
- import { execSync as execSync59 } from "child_process";
26528
+ import { execSync as execSync57 } from "child_process";
26534
26529
  import * as path60 from "path";
26535
26530
 
26536
26531
  // src/commands/restartDaemonAfterUpdate.ts
@@ -26554,7 +26549,7 @@ function isGlobalNpmInstall(dir) {
26554
26549
  if (resolved.split(path60.sep).includes("node_modules")) {
26555
26550
  return true;
26556
26551
  }
26557
- const globalPrefix = execSync59("npm prefix -g", { stdio: "pipe" }).toString().trim();
26552
+ const globalPrefix = execSync57("npm prefix -g", { stdio: "pipe" }).toString().trim();
26558
26553
  return resolved.toLowerCase().startsWith(path60.resolve(globalPrefix).toLowerCase());
26559
26554
  } catch {
26560
26555
  return false;
@@ -26565,18 +26560,18 @@ async function update2() {
26565
26560
  console.log(`Assist is installed at: ${installDir}`);
26566
26561
  if (isGitRepo(installDir)) {
26567
26562
  console.log("Detected git repo installation, pulling latest...");
26568
- execSync59("git pull", { cwd: installDir, stdio: "inherit" });
26563
+ execSync57("git pull", { cwd: installDir, stdio: "inherit" });
26569
26564
  console.log("Installing dependencies...");
26570
- execSync59("npm i", { cwd: installDir, stdio: "inherit" });
26565
+ execSync57("npm i", { cwd: installDir, stdio: "inherit" });
26571
26566
  console.log("Building...");
26572
- execSync59("npm run build", { cwd: installDir, stdio: "inherit" });
26567
+ execSync57("npm run build", { cwd: installDir, stdio: "inherit" });
26573
26568
  console.log("Syncing commands...");
26574
- execSync59("assist sync", { stdio: "inherit" });
26569
+ execSync57("assist sync", { stdio: "inherit" });
26575
26570
  } else if (isGlobalNpmInstall(installDir)) {
26576
26571
  console.log("Detected global npm installation, updating...");
26577
- execSync59("npm i -g @staff0rd/assist@latest", { stdio: "inherit" });
26572
+ execSync57("npm i -g @staff0rd/assist@latest", { stdio: "inherit" });
26578
26573
  console.log("Syncing commands...");
26579
- execSync59("assist sync", { stdio: "inherit" });
26574
+ execSync57("assist sync", { stdio: "inherit" });
26580
26575
  } else {
26581
26576
  console.error(
26582
26577
  "Could not determine installation method. Expected a git repo or global npm install."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.388.4",
3
+ "version": "0.388.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {