speckit-assistant 0.1.4 → 0.1.5

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.
Files changed (65) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +17 -17
  3. package/.next/app-path-routes-manifest.json +4 -4
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/cache/webpack/client-production/1.pack +0 -0
  6. package/.next/cache/webpack/client-production/15.pack +0 -0
  7. package/.next/cache/webpack/client-production/20.pack +0 -0
  8. package/.next/cache/webpack/client-production/24.pack +0 -0
  9. package/.next/cache/webpack/client-production/25.pack +0 -0
  10. package/.next/cache/webpack/client-production/27.pack +0 -0
  11. package/.next/cache/webpack/client-production/28.pack +0 -0
  12. package/.next/cache/webpack/client-production/29.pack +0 -0
  13. package/.next/cache/webpack/client-production/31.pack +0 -0
  14. package/.next/cache/webpack/client-production/4.pack +0 -0
  15. package/.next/cache/webpack/client-production/6.pack +0 -0
  16. package/.next/cache/webpack/client-production/index.pack +0 -0
  17. package/.next/cache/webpack/client-production/index.pack.old +0 -0
  18. package/.next/cache/webpack/server-production/10.pack +0 -0
  19. package/.next/cache/webpack/server-production/11.pack +0 -0
  20. package/.next/cache/webpack/server-production/13.pack +0 -0
  21. package/.next/cache/webpack/server-production/18.pack +0 -0
  22. package/.next/cache/webpack/server-production/2.pack +0 -0
  23. package/.next/cache/webpack/server-production/21.pack +0 -0
  24. package/.next/cache/webpack/server-production/27.pack +0 -0
  25. package/.next/cache/webpack/server-production/29.pack +0 -0
  26. package/.next/cache/webpack/server-production/3.pack +0 -0
  27. package/.next/cache/webpack/server-production/31.pack +0 -0
  28. package/.next/cache/webpack/server-production/32.pack +0 -0
  29. package/.next/cache/webpack/server-production/33.pack +0 -0
  30. package/.next/cache/webpack/server-production/6.pack +0 -0
  31. package/.next/cache/webpack/server-production/9.pack +0 -0
  32. package/.next/cache/webpack/server-production/index.pack +0 -0
  33. package/.next/cache/webpack/server-production/index.pack.old +0 -0
  34. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  35. package/.next/server/app/_not-found.html +1 -1
  36. package/.next/server/app/_not-found.rsc +2 -2
  37. package/.next/server/app/api/feature/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/file/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/git/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/personas/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/phase/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/state/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/state/watch/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/task/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/terminal/input/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/terminal/resize/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/terminal/stream/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/index.html +1 -1
  49. package/.next/server/app/index.rsc +3 -3
  50. package/.next/server/app/page.js +1 -1
  51. package/.next/server/app/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app-paths-manifest.json +4 -4
  53. package/.next/server/pages/404.html +1 -1
  54. package/.next/server/pages/500.html +1 -1
  55. package/.next/static/chunks/app/page-b3dea12c644f2054.js +1 -0
  56. package/.next/static/css/0024e90648d29466.css +3 -0
  57. package/.next/trace +3 -3
  58. package/bin/adapters/primary/api/terminalManager.js +8 -8
  59. package/bin/adapters/secondary/agent/ProcessAgentRunner.js +64 -50
  60. package/bin/adapters/secondary/pty/ptyLoader.js +11 -11
  61. package/package.json +5 -1
  62. package/.next/static/chunks/app/page-63ac4ff563941667.js +0 -1
  63. package/.next/static/css/31544403e38a69f8.css +0 -3
  64. /package/.next/static/{ELGpn5csIINP2EpeEMCo6 → 8CUCTC2XnkR-leKsH4TwE}/_buildManifest.js +0 -0
  65. /package/.next/static/{ELGpn5csIINP2EpeEMCo6 → 8CUCTC2XnkR-leKsH4TwE}/_ssgManifest.js +0 -0
@@ -24,7 +24,7 @@ WARNING: This link could potentially be dangerous`)){let a=window.open();if(a){t
24
24
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(a){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),jn&&a&&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:3===this._activeSelectionMode})}_isClickInSelection(a){let b=this._getMouseBufferCoords(a),c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&!!b&&this._areCoordsInSelection(b,c,d)}isCellInSelection(a,b){let c=this._model.finalSelectionStart,d=this._model.finalSelectionEnd;return!!c&&!!d&&this._areCoordsInSelection([a,b],c,d)}_areCoordsInSelection(a,b,c){return a[1]>b[1]&&a[1]<c[1]||b[1]===c[1]&&a[1]===b[1]&&a[0]>=b[0]&&a[0]<c[0]||b[1]<c[1]&&a[1]===c[1]&&a[0]<c[0]||b[1]<c[1]&&a[1]===b[1]&&a[0]>=b[0]}_selectWordAtCursor(a,b){let c=this._linkifier.currentLink?.link?.range;if(c)return this._model.selectionStart=[c.start.x-1,c.start.y-1],this._model.selectionStartLength=jC(c,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let d=this._getMouseBufferCoords(a);return!!d&&(this._selectWordAt(d,b),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(a,b){this._model.clearSelection(),a=Math.max(a,0),b=Math.min(b,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,a],this._model.selectionEnd=[this._bufferService.cols,b],this.refresh(),this._onSelectionChange.fire()}_handleTrim(a){this._model.handleTrim(a)&&this.refresh()}_getMouseBufferCoords(a){let b=this._mouseService.getCoords(a,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(b)return b[0]--,b[1]--,b[1]+=this._bufferService.buffer.ydisp,b}_getMouseEventScrollAmount(a){let b=i8(this._coreBrowserService.window,a,this._screenElement)[1],c=this._renderService.dimensions.css.canvas.height;return b>=0&&b<=c?0:(b>c&&(b-=c),(b=Math.min(Math.max(b,-50),50)/50)/Math.abs(b)+Math.round(14*b))}shouldForceSelection(a){return jj?a.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:a.shiftKey}handleMouseDown(a){if(this._mouseDownTimeStamp=a.timeStamp,!(2===a.button&&this.hasSelection)&&0===a.button){if(!this._enabled){if(!this.shouldForceSelection(a))return;a.stopPropagation()}a.preventDefault(),this._dragScrollAmount=0,this._enabled&&a.shiftKey?this._handleIncrementalClick(a):1===a.detail?this._handleSingleClick(a):2===a.detail?this._handleDoubleClick(a):3===a.detail&&this._handleTripleClick(a),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(a){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(a))}_handleSingleClick(a){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(a),this._model.selectionStart=this._getMouseBufferCoords(a),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let b=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);b&&b.length!==this._model.selectionStart[0]&&0===b.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(a){this._selectWordAtCursor(a,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(a){let b=this._getMouseBufferCoords(a);b&&(this._activeSelectionMode=2,this._selectLineAt(b[1]))}shouldColumnSelect(a){return a.altKey&&!(jj&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(a){if(a.stopImmediatePropagation(),!this._model.selectionStart)return;let b=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(a),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(a),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let c=this._bufferService.buffer;if(this._model.selectionEnd[1]<c.lines.length){let a=c.lines.get(this._model.selectionEnd[1]);a&&0===a.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}b&&b[0]===this._model.selectionEnd[0]&&b[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 a=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(a.ydisp+this._bufferService.rows,a.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=a.ydisp),this.refresh()}}_handleMouseUp(a){let b=a.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&b<500&&a.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let b=this._mouseService.getCoords(a,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(b&&void 0!==b[0]&&void 0!==b[1]){let a=function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,v,w;let x,y=c.buffer.x,z=c.buffer.y;if(!c.buffer.hasScrollback){let v,w,x;return e=y,g=0,(0===jw(f=z,b,h=c,i=d).length?"":jA(jy(e,f,e,f-jx(f,h),!1,h).length,jz("D",i)))+jw(z,b,c,d)+(j=y,k=z,l=a,v=jw(k,m=b,n=c,o=d).length>0?m-jx(m,n):k,x=(p=j,q=k,w=jw(r=l,s=m,u=n,o).length>0?s-jx(s,u):q,p<r&&w<=s||p>=r&&w<s?"C":"D"),jA(jy(j,v,l,m,"C"===x,n).length,jz(x,o)))}if(z===b)return x=y>a?"D":"C",jA(Math.abs(y-a),jz(x,d));x=z>b?"D":"C";let A=Math.abs(z-b);return jA((v=z>b?a:y,c.cols-v+(A-1)*c.cols+1+(w=0,(z>b?y:a)-1)),jz(x,d))}(b[0]-1,b[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(a,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let a=this._model.finalSelectionStart,b=this._model.finalSelectionEnd,c=!!a&&!!b&&(a[0]!==b[0]||a[1]!==b[1]);if(!c){this._oldHasSelection&&this._fireOnSelectionChange(a,b,c);return}!a||!b||this._oldSelectionStart&&this._oldSelectionEnd&&a[0]===this._oldSelectionStart[0]&&a[1]===this._oldSelectionStart[1]&&b[0]===this._oldSelectionEnd[0]&&b[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(a,b,c)}_fireOnSelectionChange(a,b,c){this._oldSelectionStart=a,this._oldSelectionEnd=b,this._oldHasSelection=c,this._onSelectionChange.fire()}_handleBufferActivate(a){this.clearSelection(),this._trimListener.dispose(),this._trimListener=a.activeBuffer.lines.onTrim(a=>this._handleTrim(a))}_convertViewportColToCharacterIndex(a,b){let c=b;for(let d=0;b>=d;d++){let e=a.loadCell(d,this._workCell).getChars().length;0===this._workCell.getWidth()?c--:e>1&&b!==d&&(c+=e-1)}return c}setSelection(a,b,c){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[a,b],this._model.selectionStartLength=c,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(a){this._isClickInSelection(a)||(this._selectWordAtCursor(a,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(a,b,c=!0,d=!0){if(a[0]>=this._bufferService.cols)return;let e=this._bufferService.buffer,f=e.lines.get(a[1]);if(!f)return;let g=e.translateBufferLineToString(a[1],!1),h=this._convertViewportColToCharacterIndex(f,a[0]),i=h,j=a[0]-h,k=0,l=0,m=0,n=0;if(" "===g.charAt(h)){for(;h>0&&" "===g.charAt(h-1);)h--;for(;i<g.length&&" "===g.charAt(i+1);)i++}else{let b=a[0],c=a[0];0===f.getWidth(b)&&(k++,b--),2===f.getWidth(c)&&(l++,c++);let d=f.getString(c).length;for(d>1&&(n+=d-1,i+=d-1);b>0&&h>0&&!this._isCharWordSeparator(f.loadCell(b-1,this._workCell));){f.loadCell(b-1,this._workCell);let a=this._workCell.getChars().length;0===this._workCell.getWidth()?(k++,b--):a>1&&(m+=a-1,h-=a-1),h--,b--}for(;c<f.length&&i+1<g.length&&!this._isCharWordSeparator(f.loadCell(c+1,this._workCell));){f.loadCell(c+1,this._workCell);let a=this._workCell.getChars().length;2===this._workCell.getWidth()?(l++,c++):a>1&&(n+=a-1,i+=a-1),i++,c++}}i++;let o=h+j-k+m,p=Math.min(this._bufferService.cols,i-h+k+l-m-n);if(!(!b&&""===g.slice(h,i).trim())){if(c&&0===o&&32!==f.getCodePoint(0)){let b=e.lines.get(a[1]-1);if(b&&f.isWrapped&&32!==b.getCodePoint(this._bufferService.cols-1)){let b=this._getWordAt([this._bufferService.cols-1,a[1]-1],!1,!0,!1);if(b){let a=this._bufferService.cols-b.start;o-=a,p+=a}}}if(d&&o+p===this._bufferService.cols&&32!==f.getCodePoint(this._bufferService.cols-1)){let b=e.lines.get(a[1]+1);if(b?.isWrapped&&32!==b.getCodePoint(0)){let b=this._getWordAt([0,a[1]+1],!1,!1,!0);b&&(p+=b.length)}}return{start:o,length:p}}}_selectWordAt(a,b){let c=this._getWordAt(a,b);if(c){for(;c.start<0;)c.start+=this._bufferService.cols,a[1]--;this._model.selectionStart=[c.start,a[1]],this._model.selectionStartLength=c.length}}_selectToWordAt(a){let b=this._getWordAt(a,!0);if(b){let c=a[1];for(;b.start<0;)b.start+=this._bufferService.cols,c--;if(!this._model.areSelectionValuesReversed())for(;b.start+b.length>this._bufferService.cols;)b.length-=this._bufferService.cols,c++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?b.start:b.start+b.length,c]}}_isCharWordSeparator(a){return 0!==a.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(a.getChars())>=0}_selectLineAt(a){let b=this._bufferService.buffer.getWrappedRangeForLine(a),c={start:{x:0,y:b.first},end:{x:this._bufferService.cols-1,y:b.last}};this._model.selectionStart=[0,b.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=jC(c,this._bufferService.cols)}};jE=fH([fI(3,f_),fI(4,f1),fI(5,gc),fI(6,f5),fI(7,gd),fI(8,gb)],jE);var jF=class{constructor(){this._data={}}set(a,b,c){this._data[a]||(this._data[a]={}),this._data[a][b]=c}get(a,b){return this._data[a]?this._data[a][b]:void 0}clear(){this._data={}}},jG=class{constructor(){this._color=new jF,this._css=new jF}setCss(a,b,c){this._css.set(a,b,c)}getCss(a,b){return this._css.get(a,b)}setColor(a,b,c){this._color.set(a,b,c)}getColor(a,b){return this._color.get(a,b)}clear(){this._color.clear(),this._css.clear()}},jH=Object.freeze((()=>{let a=[ke.toColor("#2e3436"),ke.toColor("#cc0000"),ke.toColor("#4e9a06"),ke.toColor("#c4a000"),ke.toColor("#3465a4"),ke.toColor("#75507b"),ke.toColor("#06989a"),ke.toColor("#d3d7cf"),ke.toColor("#555753"),ke.toColor("#ef2929"),ke.toColor("#8ae234"),ke.toColor("#fce94f"),ke.toColor("#729fcf"),ke.toColor("#ad7fa8"),ke.toColor("#34e2e2"),ke.toColor("#eeeeec")],b=[0,95,135,175,215,255];for(let c=0;c<216;c++){let d=b[c/36%6|0],e=b[c/6%6|0],f=b[c%6];a.push({css:iG.toCss(d,e,f),rgba:iG.toRgba(d,e,f)})}for(let b=0;b<24;b++){let c=8+10*b;a.push({css:iG.toCss(c,c,c),rgba:iG.toRgba(c,c,c)})}return a})()),jI=ke.toColor("#ffffff"),jJ=ke.toColor("#000000"),jK=ke.toColor("#ffffff"),jL={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},jM=class extends gy{constructor(a){super(),this._optionsService=a,this._contrastCache=new jG,this._halfContrastCache=new jG,this._onChangeColors=this._register(new gZ),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:jI,background:jJ,cursor:jK,cursorAccent:jJ,selectionForeground:void 0,selectionBackgroundTransparent:jL,selectionBackgroundOpaque:kd.blend(jJ,jL),selectionInactiveBackgroundTransparent:jL,selectionInactiveBackgroundOpaque:kd.blend(jJ,jL),scrollbarSliderBackground:kd.opacity(jI,.2),scrollbarSliderHoverBackground:kd.opacity(jI,.4),scrollbarSliderActiveBackground:kd.opacity(jI,.5),overviewRulerBorder:jI,ansi:jH.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(a={}){let b=this._colors;if(b.foreground=jN(a.foreground,jI),b.background=jN(a.background,jJ),b.cursor=kd.blend(b.background,jN(a.cursor,jK)),b.cursorAccent=kd.blend(b.background,jN(a.cursorAccent,jJ)),b.selectionBackgroundTransparent=jN(a.selectionBackground,jL),b.selectionBackgroundOpaque=kd.blend(b.background,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundTransparent=jN(a.selectionInactiveBackground,b.selectionBackgroundTransparent),b.selectionInactiveBackgroundOpaque=kd.blend(b.background,b.selectionInactiveBackgroundTransparent),b.selectionForeground=a.selectionForeground?jN(a.selectionForeground,iL):void 0,b.selectionForeground===iL&&(b.selectionForeground=void 0),kd.isOpaque(b.selectionBackgroundTransparent)&&(b.selectionBackgroundTransparent=kd.opacity(b.selectionBackgroundTransparent,.3)),kd.isOpaque(b.selectionInactiveBackgroundTransparent)&&(b.selectionInactiveBackgroundTransparent=kd.opacity(b.selectionInactiveBackgroundTransparent,.3)),b.scrollbarSliderBackground=jN(a.scrollbarSliderBackground,kd.opacity(b.foreground,.2)),b.scrollbarSliderHoverBackground=jN(a.scrollbarSliderHoverBackground,kd.opacity(b.foreground,.4)),b.scrollbarSliderActiveBackground=jN(a.scrollbarSliderActiveBackground,kd.opacity(b.foreground,.5)),b.overviewRulerBorder=jN(a.overviewRulerBorder,jI),b.ansi=jH.slice(),b.ansi[0]=jN(a.black,jH[0]),b.ansi[1]=jN(a.red,jH[1]),b.ansi[2]=jN(a.green,jH[2]),b.ansi[3]=jN(a.yellow,jH[3]),b.ansi[4]=jN(a.blue,jH[4]),b.ansi[5]=jN(a.magenta,jH[5]),b.ansi[6]=jN(a.cyan,jH[6]),b.ansi[7]=jN(a.white,jH[7]),b.ansi[8]=jN(a.brightBlack,jH[8]),b.ansi[9]=jN(a.brightRed,jH[9]),b.ansi[10]=jN(a.brightGreen,jH[10]),b.ansi[11]=jN(a.brightYellow,jH[11]),b.ansi[12]=jN(a.brightBlue,jH[12]),b.ansi[13]=jN(a.brightMagenta,jH[13]),b.ansi[14]=jN(a.brightCyan,jH[14]),b.ansi[15]=jN(a.brightWhite,jH[15]),a.extendedAnsi){let c=Math.min(b.ansi.length-16,a.extendedAnsi.length);for(let d=0;d<c;d++)b.ansi[d+16]=jN(a.extendedAnsi[d],jH[d+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(a){this._restoreColor(a),this._onChangeColors.fire(this.colors)}_restoreColor(a){if(void 0===a){for(let a=0;a<this._restoreColors.ansi.length;++a)this._colors.ansi[a]=this._restoreColors.ansi[a];return}switch(a){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[a]=this._restoreColors.ansi[a]}}modifyColors(a){a(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function jN(a,b){if(void 0!==a)try{return ke.toColor(a)}catch{}return b}jM=fH([fI(0,f5)],jM);var jO=class{constructor(...a){for(let[b,c]of(this._entries=new Map,a))this.set(b,c)}set(a,b){let c=this._entries.get(a);return this._entries.set(a,b),c}forEach(a){for(let[b,c]of this._entries.entries())a(b,c)}has(a){return this._entries.has(a)}get(a){return this._entries.get(a)}},jP=class{constructor(){this._services=new jO,this._services.set(f3,this)}setService(a,b){this._services.set(a,b)}getService(a){return this._services.get(a)}createInstance(a,...b){let c=(a[fY]||[]).sort((a,b)=>a.index-b.index),d=[];for(let b of c){let c=this._services.get(b.id);if(!c)throw Error(`[createInstance] ${a.name} depends on UNKNOWN service ${b.id._id}.`);d.push(c)}let e=c.length>0?c[0].index:b.length;if(b.length!==e)throw Error(`[createInstance] First service dependency of ${a.name} at position ${e+1} conflicts with ${b.length} static arguments`);return new a(...b,...d)}},jQ={trace:0,debug:1,info:2,warn:3,error:4,off:5},jR=class extends gy{constructor(a){super(),this._optionsService=a,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=jQ[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(a){for(let b=0;b<a.length;b++)"function"==typeof a[b]&&(a[b]=a[b]())}_log(a,b,c){this._evalLazyOptionalParams(c),a.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+b,...c)}trace(a,...b){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,a,b)}debug(a,...b){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,a,b)}info(a,...b){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,a,b)}warn(a,...b){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,a,b)}error(a,...b){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,a,b)}};jR=fH([fI(0,f5)],jR);var jS=class extends gy{constructor(a){super(),this._maxLength=a,this.onDeleteEmitter=this._register(new gZ),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new gZ),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new gZ),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(a){if(this._maxLength===a)return;let b=Array(a);for(let c=0;c<Math.min(a,this.length);c++)b[c]=this._array[this._getCyclicIndex(c)];this._array=b,this._maxLength=a,this._startIndex=0}get length(){return this._length}set length(a){if(a>this._length)for(let b=this._length;b<a;b++)this._array[b]=void 0;this._length=a}get(a){return this._array[this._getCyclicIndex(a)]}set(a,b){this._array[this._getCyclicIndex(a)]=b}push(a){this._array[this._getCyclicIndex(this._length)]=a,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(a,b,...c){if(b){for(let c=a;c<this._length-b;c++)this._array[this._getCyclicIndex(c)]=this._array[this._getCyclicIndex(c+b)];this._length-=b,this.onDeleteEmitter.fire({index:a,amount:b})}for(let b=this._length-1;b>=a;b--)this._array[this._getCyclicIndex(b+c.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<c.length;b++)this._array[this._getCyclicIndex(a+b)]=c[b];if(c.length&&this.onInsertEmitter.fire({index:a,amount:c.length}),this._length+c.length>this._maxLength){let a=this._length+c.length-this._maxLength;this._startIndex+=a,this._length=this._maxLength,this.onTrimEmitter.fire(a)}else this._length+=c.length}trimStart(a){a>this._length&&(a=this._length),this._startIndex+=a,this._length-=a,this.onTrimEmitter.fire(a)}shiftElements(a,b,c){if(!(b<=0)){if(a<0||a>=this._length)throw Error("start argument out of range");if(a+c<0)throw Error("Cannot shift elements in list beyond index 0");if(c>0){for(let d=b-1;d>=0;d--)this.set(a+d+c,this.get(a+d));let d=a+b+c-this._length;if(d>0)for(this._length+=d;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let d=0;d<b;d++)this.set(a+d+c,this.get(a+d))}}_getCyclicIndex(a){return(this._startIndex+a)%this._maxLength}},jT=Object.freeze(new fU),jU=0,jV=class a{constructor(a,b,c=!1){this.isWrapped=c,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*a);let d=b||fW.fromCharData([0,"",1,0]);for(let b=0;b<a;++b)this.setCell(b,d);this.length=a}get(a){let b=this._data[3*a+0],c=2097151&b;return[this._data[3*a+1],2097152&b?this._combined[a]:c?fQ(c):"",b>>22,2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):c]}set(a,b){this._data[3*a+1]=b[0],b[1].length>1?(this._combined[a]=b[1],this._data[3*a+0]=2097152|a|b[2]<<22):this._data[3*a+0]=b[1].charCodeAt(0)|b[2]<<22}getWidth(a){return this._data[3*a+0]>>22}hasWidth(a){return 0xc00000&this._data[3*a+0]}getFg(a){return this._data[3*a+1]}getBg(a){return this._data[3*a+2]}hasContent(a){return 4194303&this._data[3*a+0]}getCodePoint(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a].charCodeAt(this._combined[a].length-1):2097151&b}isCombined(a){return 2097152&this._data[3*a+0]}getString(a){let b=this._data[3*a+0];return 2097152&b?this._combined[a]:2097151&b?fQ(2097151&b):""}isProtected(a){return 0x20000000&this._data[3*a+2]}loadCell(a,b){return jU=3*a,b.content=this._data[jU+0],b.fg=this._data[jU+1],b.bg=this._data[jU+2],2097152&b.content&&(b.combinedData=this._combined[a]),0x10000000&b.bg&&(b.extended=this._extendedAttrs[a]),b}setCell(a,b){2097152&b.content&&(this._combined[a]=b.combinedData),0x10000000&b.bg&&(this._extendedAttrs[a]=b.extended),this._data[3*a+0]=b.content,this._data[3*a+1]=b.fg,this._data[3*a+2]=b.bg}setCellFromCodepoint(a,b,c,d){0x10000000&d.bg&&(this._extendedAttrs[a]=d.extended),this._data[3*a+0]=b|c<<22,this._data[3*a+1]=d.fg,this._data[3*a+2]=d.bg}addCodepointToCell(a,b,c){let d=this._data[3*a+0];2097152&d?this._combined[a]+=fQ(b):2097151&d?(this._combined[a]=fQ(2097151&d)+fQ(b),d&=-2097152,d|=2097152):d=4194304|b,c&&(d&=-0xc00001,d|=c<<22),this._data[3*a+0]=d}insertCells(a,b,c){if((a%=this.length)&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length-a){let d=new fW;for(let c=this.length-a-b-1;c>=0;--c)this.setCell(a+b+c,this.loadCell(a+c,d));for(let d=0;d<b;++d)this.setCell(a+d,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,c)}deleteCells(a,b,c){if(a%=this.length,b<this.length-a){let d=new fW;for(let c=0;c<this.length-a-b;++c)this.setCell(a+c,this.loadCell(a+b+c,d));for(let a=this.length-b;a<this.length;++a)this.setCell(a,c)}else for(let b=a;b<this.length;++b)this.setCell(b,c);a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),0!==this.getWidth(a)||this.hasContent(a)||this.setCellFromCodepoint(a,0,1,c)}replaceCells(a,b,c,d=!1){if(d){for(a&&2===this.getWidth(a-1)&&!this.isProtected(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&!this.isProtected(b)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.isProtected(a)||this.setCell(a,c),a++;return}for(a&&2===this.getWidth(a-1)&&this.setCellFromCodepoint(a-1,0,1,c),b<this.length&&2===this.getWidth(b-1)&&this.setCellFromCodepoint(b,0,1,c);a<b&&a<this.length;)this.setCell(a++,c)}resize(a,b){if(a===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let c=3*a;if(a>this.length){if(this._data.buffer.byteLength>=4*c)this._data=new Uint32Array(this._data.buffer,0,c);else{let a=new Uint32Array(c);a.set(this._data),this._data=a}for(let c=this.length;c<a;++c)this.setCell(c,b)}else{this._data=this._data.subarray(0,c);let b=Object.keys(this._combined);for(let c=0;c<b.length;c++){let d=parseInt(b[c],10);d>=a&&delete this._combined[d]}let d=Object.keys(this._extendedAttrs);for(let b=0;b<d.length;b++){let c=parseInt(d[b],10);c>=a&&delete this._extendedAttrs[c]}}return this.length=a,4*c*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let a=new Uint32Array(this._data.length);return a.set(this._data),this._data=a,1}return 0}fill(a,b=!1){if(b){for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,a);return}this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,a)}copyFrom(a){for(let b in this.length!==a.length?this._data=new Uint32Array(a._data):this._data.set(a._data),this.length=a.length,this._combined={},a._combined)this._combined[b]=a._combined[b];for(let b in this._extendedAttrs={},a._extendedAttrs)this._extendedAttrs[b]=a._extendedAttrs[b];this.isWrapped=a.isWrapped}clone(){let b=new a(0);for(let a in b._data=new Uint32Array(this._data),b.length=this.length,this._combined)b._combined[a]=this._combined[a];for(let a in this._extendedAttrs)b._extendedAttrs[a]=this._extendedAttrs[a];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0])return a+(this._data[3*a+0]>>22);return 0}getNoBgTrimmedLength(){for(let a=this.length-1;a>=0;--a)if(4194303&this._data[3*a+0]||0x3000000&this._data[3*a+2])return a+(this._data[3*a+0]>>22);return 0}copyCellsFrom(a,b,c,d,e){let f=a._data;if(e)for(let e=d-1;e>=0;e--){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}else for(let e=0;e<d;e++){for(let a=0;a<3;a++)this._data[(c+e)*3+a]=f[(b+e)*3+a];0x10000000&f[(b+e)*3+2]&&(this._extendedAttrs[c+e]=a._extendedAttrs[b+e])}let g=Object.keys(a._combined);for(let d=0;d<g.length;d++){let e=parseInt(g[d],10);e>=b&&(this._combined[e-b+c]=a._combined[e])}}translateToString(a,b,c,d){b=b??0,c=c??this.length,a&&(c=Math.min(c,this.getTrimmedLength())),d&&(d.length=0);let e="";for(;b<c;){let a=this._data[3*b+0],c=2097151&a,f=2097152&a?this._combined[b]:c?fQ(c):" ";if(e+=f,d)for(let a=0;a<f.length;++a)d.push(b);b+=a>>22||1}return d&&d.push(b),e}};function jW(a,b,c){if(b===a.length-1)return a[b].getTrimmedLength();let d=!a[b].hasContent(c-1)&&1===a[b].getWidth(c-1),e=2===a[b+1].getWidth(0);return d&&e?c-1:c}var jX=class a{constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=a._nextId++,this._onDispose=this.register(new gZ),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),gu(this._disposables),this._disposables.length=0)}register(a){return this._disposables.push(a),a}};jX._nextId=1;var jY={},jZ=jY.B;jY[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"\xb0",g:"\xb1",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"\xa3","~":"\xb7"},jY.A={"#":"\xa3"},jY.B=void 0,jY[4]={"#":"\xa3","@":"\xbe","[":"ij","\\":"\xbd","]":"|","{":"\xa8","|":"f","}":"\xbc","~":"\xb4"},jY.C=jY[5]={"[":"\xc4","\\":"\xd6","]":"\xc5","^":"\xdc","`":"\xe9","{":"\xe4","|":"\xf6","}":"\xe5","~":"\xfc"},jY.R={"#":"\xa3","@":"\xe0","[":"\xb0","\\":"\xe7","]":"\xa7","{":"\xe9","|":"\xf9","}":"\xe8","~":"\xa8"},jY.Q={"@":"\xe0","[":"\xe2","\\":"\xe7","]":"\xea","^":"\xee","`":"\xf4","{":"\xe9","|":"\xf9","}":"\xe8","~":"\xfb"},jY.K={"@":"\xa7","[":"\xc4","\\":"\xd6","]":"\xdc","{":"\xe4","|":"\xf6","}":"\xfc","~":"\xdf"},jY.Y={"#":"\xa3","@":"\xa7","[":"\xb0","\\":"\xe7","]":"\xe9","`":"\xf9","{":"\xe0","|":"\xf2","}":"\xe8","~":"\xec"},jY.E=jY[6]={"@":"\xc4","[":"\xc6","\\":"\xd8","]":"\xc5","^":"\xdc","`":"\xe4","{":"\xe6","|":"\xf8","}":"\xe5","~":"\xfc"},jY.Z={"#":"\xa3","@":"\xa7","[":"\xa1","\\":"\xd1","]":"\xbf","{":"\xb0","|":"\xf1","}":"\xe7"},jY.H=jY[7]={"@":"\xc9","[":"\xc4","\\":"\xd6","]":"\xc5","^":"\xdc","`":"\xe9","{":"\xe4","|":"\xf6","}":"\xe5","~":"\xfc"},jY["="]={"#":"\xf9","@":"\xe0","[":"\xe9","\\":"\xe7","]":"\xea","^":"\xee",_:"\xe8","`":"\xf4","{":"\xe4","|":"\xf6","}":"\xfc","~":"\xfb"};var j$=class{constructor(a,b,c){this._hasScrollback=a,this._optionsService=b,this._bufferService=c,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=jT.clone(),this.savedCharset=jZ,this.markers=[],this._nullCell=fW.fromCharData([0,"",1,0]),this._whitespaceCell=fW.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new js,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new jS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(a){return a?(this._nullCell.fg=a.fg,this._nullCell.bg=a.bg,this._nullCell.extended=a.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new fV),this._nullCell}getWhitespaceCell(a){return a?(this._whitespaceCell.fg=a.fg,this._whitespaceCell.bg=a.bg,this._whitespaceCell.extended=a.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new fV),this._whitespaceCell}getBlankLine(a,b){return new jV(this._bufferService.cols,this.getNullCell(a),b)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let a=this.ybase+this.y-this.ydisp;return a>=0&&a<this._rows}_getCorrectBufferLength(a){if(!this._hasScrollback)return a;let b=a+this._optionsService.rawOptions.scrollback;return b>0xffffffff?0xffffffff:b}fillViewportRows(a){if(0===this.lines.length){void 0===a&&(a=jT);let b=this._rows;for(;b--;)this.lines.push(this.getBlankLine(a))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new jS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(a,b){let c=this.getNullCell(jT),d=0,e=this._getCorrectBufferLength(b);if(e>this.lines.maxLength&&(this.lines.maxLength=e),this.lines.length>0){if(this._cols<a)for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);let f=0;if(this._rows<b)for(let d=this._rows;d<b;d++)this.lines.length<b+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new jV(a,c)):this.ybase>0&&this.lines.length<=this.ybase+this.y+f+1?(this.ybase--,f++,this.ydisp>0&&this.ydisp--):this.lines.push(new jV(a,c)));else for(let a=this._rows;a>b;a--)this.lines.length>b+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(e<this.lines.maxLength){let a=this.lines.length-e;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=e}this.x=Math.min(this.x,a-1),this.y=Math.min(this.y,b-1),f&&(this.y+=f),this.savedX=Math.min(this.savedX,a-1),this.scrollTop=0}if(this.scrollBottom=b-1,this._isReflowEnabled&&(this._reflow(a,b),this._cols>a))for(let b=0;b<this.lines.length;b++)d+=+this.lines.get(b).resize(a,c);this._cols=a,this._rows=b,this._memoryCleanupQueue.clear(),d>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let a=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,a=!1);let b=0;for(;this._memoryCleanupPosition<this.lines.length;)if((b+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return a}get _isReflowEnabled(){let a=this._optionsService.rawOptions.windowsPty;return a&&a.buildNumber?this._hasScrollback&&"conpty"===a.backend&&a.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(a,b){this._cols!==a&&(a>this._cols?this._reflowLarger(a,b):this._reflowSmaller(a,b))}_reflowLarger(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=function(a,b,c,d,e,f){let g=[];for(let h=0;h<a.length-1;h++){let i=h,j=a.get(++i);if(!j.isWrapped)continue;let k=[a.get(h)];for(;i<a.length&&j.isWrapped;)k.push(j),j=a.get(++i);if(!f&&d>=h&&d<i){h+=k.length-1;continue}let l=0,m=jW(k,0,b),n=1,o=0;for(;n<k.length;){let a=jW(k,n,b),d=Math.min(a-o,c-m);k[l].copyCellsFrom(k[n],o,m,d,!1),(m+=d)===c&&(l++,m=0),(o+=d)===a&&(n++,o=0),0===m&&0!==l&&2===k[l-1].getWidth(c-1)&&(k[l].copyCellsFrom(k[l-1],c-1,m++,1,!1),k[l-1].setCell(c-1,e))}k[l].replaceCells(m,c,e);let p=0;for(let a=k.length-1;a>0&&(a>l||0===k[a].getTrimmedLength());a--)p++;p>0&&(g.push(h+k.length-p),g.push(p)),h+=k.length-1}return g}(this.lines,this._cols,a,this.ybase+this.y,this.getNullCell(jT),c);if(d.length>0){let c=function(a,b){let c=[],d=0,e=b[0],f=0;for(let g=0;g<a.length;g++)if(e===g){let c=b[++d];a.onDeleteEmitter.fire({index:g-f,amount:c}),g+=c-1,f+=c,e=b[++d]}else c.push(g);return{layout:c,countRemoved:f}}(this.lines,d);(function(a,b){let c=[];for(let d=0;d<b.length;d++)c.push(a.get(b[d]));for(let b=0;b<c.length;b++)a.set(b,c[b]);a.length=b.length})(this.lines,c.layout),this._reflowLargerAdjustViewport(a,b,c.countRemoved)}}_reflowLargerAdjustViewport(a,b,c){let d=this.getNullCell(jT),e=c;for(;e-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<b&&this.lines.push(new jV(a,d))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-c,0)}_reflowSmaller(a,b){let c=this._optionsService.rawOptions.reflowCursorLine,d=this.getNullCell(jT),e=[],f=0;for(let g=this.lines.length-1;g>=0;g--){let h=this.lines.get(g);if(!h||!h.isWrapped&&h.getTrimmedLength()<=a)continue;let i=[h];for(;h.isWrapped&&g>0;)h=this.lines.get(--g),i.unshift(h);if(!c){let a=this.ybase+this.y;if(a>=g&&a<g+i.length)continue}let j=i[i.length-1].getTrimmedLength(),k=function(a,b,c){let d=[],e=a.map((c,d)=>jW(a,d,b)).reduce((a,b)=>a+b),f=0,g=0,h=0;for(;h<e;){if(e-h<c){d.push(e-h);break}f+=c;let i=jW(a,g,b);f>i&&(f-=i,g++);let j=2===a[g].getWidth(f-1);j&&f--;let k=j?c-1:c;d.push(k),h+=k}return d}(i,this._cols,a),l=k.length-i.length,m;m=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+l):Math.max(0,this.lines.length-this.lines.maxLength+l);let n=[];for(let a=0;a<l;a++){let a=this.getBlankLine(jT,!0);n.push(a)}n.length>0&&(e.push({start:g+i.length+f,newLines:n}),f+=n.length),i.push(...n);let o=k.length-1,p=k[o];0===p&&(p=k[--o]);let q=i.length-l-1,r=j;for(;q>=0;){let a=Math.min(r,p);if(void 0===i[o])break;i[o].copyCellsFrom(i[q],r-a,p-a,a,!0),0==(p-=a)&&(p=k[--o]),0==(r-=a)&&(r=jW(i,Math.max(--q,0),this._cols))}for(let b=0;b<i.length;b++)k[b]<a&&i[b].setCell(k[b],d);let s=l-m;for(;s-- >0;)0===this.ybase?this.y<b-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+f)-b&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+l,this.ybase+b-1)}if(e.length>0){let a=[],b=[];for(let a=0;a<this.lines.length;a++)b.push(this.lines.get(a));let c=this.lines.length,d=c-1,g=0,h=e[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+f);let i=0;for(let j=Math.min(this.lines.maxLength-1,c+f-1);j>=0;j--)if(h&&h.start>d+i){for(let a=h.newLines.length-1;a>=0;a--)this.lines.set(j--,h.newLines[a]);j++,a.push({index:d+1,amount:h.newLines.length}),i+=h.newLines.length,h=e[++g]}else this.lines.set(j,b[d--]);let j=0;for(let b=a.length-1;b>=0;b--)a[b].index+=j,this.lines.onInsertEmitter.fire(a[b]),j+=a[b].amount;let k=Math.max(0,c+f-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(a,b,c=0,d){let e=this.lines.get(a);return e?e.translateToString(b,c,d):""}getWrappedRangeForLine(a){let b=a,c=a;for(;b>0&&this.lines.get(b).isWrapped;)b--;for(;c+1<this.lines.length&&this.lines.get(c+1).isWrapped;)c++;return{first:b,last:c}}setupTabStops(a){for(null!=a?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);a<this._cols;a+=this._optionsService.rawOptions.tabStopWidth)this.tabs[a]=!0}prevStop(a){for(null==a&&(a=this.x);!this.tabs[--a]&&a>0;);return a>=this._cols?this._cols-1:a<0?0:a}nextStop(a){for(null==a&&(a=this.x);!this.tabs[++a]&&a<this._cols;);return a>=this._cols?this._cols-1:a<0?0:a}clearMarkers(a){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].line===a&&(this.markers[b].dispose(),this.markers.splice(b--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let a=0;a<this.markers.length;a++)this.markers[a].dispose();this.markers.length=0,this._isClearing=!1}addMarker(a){let b=new jX(a);return this.markers.push(b),b.register(this.lines.onTrim(a=>{b.line-=a,b.line<0&&b.dispose()})),b.register(this.lines.onInsert(a=>{b.line>=a.index&&(b.line+=a.amount)})),b.register(this.lines.onDelete(a=>{b.line>=a.index&&b.line<a.index+a.amount&&b.dispose(),b.line>a.index&&(b.line-=a.amount)})),b.register(b.onDispose(()=>this._removeMarker(b))),b}_removeMarker(a){this._isClearing||this.markers.splice(this.markers.indexOf(a),1)}},j_=class extends gy{constructor(a,b){super(),this._optionsService=a,this._bufferService=b,this._onBufferActivate=this._register(new gZ),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 j$(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new j$(!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(a){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(a),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(a,b){this._normal.resize(a,b),this._alt.resize(a,b),this.setupTabStops(a)}setupTabStops(a){this._normal.setupTabStops(a),this._alt.setupTabStops(a)}},j0=class extends gy{constructor(a){super(),this.isUserScrolling=!1,this._onResize=this._register(new gZ),this.onResize=this._onResize.event,this._onScroll=this._register(new gZ),this.onScroll=this._onScroll.event,this.cols=Math.max(a.rawOptions.cols||0,2),this.rows=Math.max(a.rawOptions.rows||0,1),this.buffers=this._register(new j_(a,this)),this._register(this.buffers.onBufferActivate(a=>{this._onScroll.fire(a.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(a,b){let c=this.cols!==a,d=this.rows!==b;this.cols=a,this.rows=b,this.buffers.resize(a,b),this._onResize.fire({cols:a,rows:b,colsChanged:c,rowsChanged:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(a,b=!1){let c=this.buffer,d;(d=this._cachedBlankLine)&&d.length===this.cols&&d.getFg(0)===a.fg&&d.getBg(0)===a.bg||(d=c.getBlankLine(a,b),this._cachedBlankLine=d),d.isWrapped=b;let e=c.ybase+c.scrollTop,f=c.ybase+c.scrollBottom;if(0===c.scrollTop){let a=c.lines.isFull;f===c.lines.length-1?a?c.lines.recycle().copyFrom(d):c.lines.push(d.clone()):c.lines.splice(f+1,0,d.clone()),a?this.isUserScrolling&&(c.ydisp=Math.max(c.ydisp-1,0)):(c.ybase++,this.isUserScrolling||c.ydisp++)}else{let a=f-e+1;c.lines.shiftElements(e+1,a-1,-1),c.lines.set(f,d.clone())}this.isUserScrolling||(c.ydisp=c.ybase),this._onScroll.fire(c.ydisp)}scrollLines(a,b){let c=this.buffer;if(a<0){if(0===c.ydisp)return;this.isUserScrolling=!0}else a+c.ydisp>=c.ybase&&(this.isUserScrolling=!1);let d=c.ydisp;c.ydisp=Math.max(Math.min(c.ydisp+a,c.ybase),0),d!==c.ydisp&&(b||this._onScroll.fire(c.ydisp))}};j0=fH([fI(0,f5)],j0);var j1={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:jj,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},j2=["normal","bold","100","200","300","400","500","600","700","800","900"],j3=class extends gy{constructor(a){super(),this._onOptionChange=this._register(new gZ),this.onOptionChange=this._onOptionChange.event;let b={...j1};for(let c in a)if(c in b)try{let d=a[c];b[c]=this._sanitizeAndValidateOption(c,d)}catch(a){console.error(a)}this.rawOptions=b,this.options={...b},this._setupOptions(),this._register(gv(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(a,b){return this.onOptionChange(c=>{c===a&&b(this.rawOptions[a])})}onMultipleOptionChange(a,b){return this.onOptionChange(c=>{-1!==a.indexOf(c)&&b()})}_setupOptions(){let a=a=>{if(!(a in j1))throw Error(`No option with key "${a}"`);return this.rawOptions[a]},b=(a,b)=>{if(!(a in j1))throw Error(`No option with key "${a}"`);b=this._sanitizeAndValidateOption(a,b),this.rawOptions[a]!==b&&(this.rawOptions[a]=b,this._onOptionChange.fire(a))};for(let c in this.rawOptions){let d={get:a.bind(this,c),set:b.bind(this,c)};Object.defineProperty(this.options,c,d)}}_sanitizeAndValidateOption(a,b){switch(a){case"cursorStyle":var c;if(b||(b=j1[a]),"block"!==(c=b)&&"underline"!==c&&"bar"!==c)throw Error(`"${b}" is not a valid value for ${a}`);break;case"wordSeparator":b||(b=j1[a]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof b&&1<=b&&b<=1e3)break;b=j2.includes(b)?b:j1[a];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw Error(`${a} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,0xffffffff))<0)throw Error(`${a} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw Error(`${a} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&0!==b)throw Error(`${a} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}};function j4(a,b=5){if("object"!=typeof a)return a;let c=Array.isArray(a)?[]:{};for(let d in a)c[d]=b<=1?a[d]:a[d]&&j4(a[d],b-1);return c}var j5=Object.freeze({insertMode:!1}),j6=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),j7=class extends gy{constructor(a,b,c){super(),this._bufferService=a,this._logService=b,this._optionsService=c,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new gZ),this.onData=this._onData.event,this._onUserInput=this._register(new gZ),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new gZ),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new gZ),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=j4(j5),this.decPrivateModes=j4(j6)}reset(){this.modes=j4(j5),this.decPrivateModes=j4(j6)}triggerDataEvent(a,b=!1){if(this._optionsService.rawOptions.disableStdin)return;let c=this._bufferService.buffer;b&&this._optionsService.rawOptions.scrollOnUserInput&&c.ybase!==c.ydisp&&this._onRequestScrollToBottom.fire(),b&&this._onUserInput.fire(),this._logService.debug(`sending data "${a}"`),this._logService.trace("sending data (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onData.fire(a)}triggerBinaryEvent(a){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${a}"`),this._logService.trace("sending binary (codes)",()=>a.split("").map(a=>a.charCodeAt(0))),this._onBinary.fire(a))}};j7=fH([fI(0,f_),fI(1,f4),fI(2,f5)],j7);var j8={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:a=>4!==a.button&&1===a.action&&(a.ctrl=!1,a.alt=!1,a.shift=!1,!0)},VT200:{events:19,restrict:a=>32!==a.action},DRAG:{events:23,restrict:a=>32!==a.action||3!==a.button},ANY:{events:31,restrict:a=>!0}};function j9(a,b){let c=16*!!a.ctrl|4*!!a.shift|8*!!a.alt;return 4===a.button?(c|=64,c|=a.action):(c|=3&a.button,4&a.button&&(c|=64),8&a.button&&(c|=128),32===a.action?c|=32:0!==a.action||b||(c|=3)),c}var ka=String.fromCharCode,kb={DEFAULT:a=>{let b=[j9(a,!1)+32,a.col+32,a.row+32];return b[0]>255||b[1]>255||b[2]>255?"":`\x1b[M${ka(b[0])}${ka(b[1])}${ka(b[2])}`},SGR:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${j9(a,!0)};${a.col};${a.row}${b}`},SGR_PIXELS:a=>{let b=0===a.action&&4!==a.button?"m":"M";return`\x1b[<${j9(a,!0)};${a.x};${a.y}${b}`}},kc=class extends gy{constructor(a,b,c){for(let d of(super(),this._bufferService=a,this._coreService=b,this._optionsService=c,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new gZ),this.onProtocolChange=this._onProtocolChange.event,Object.keys(j8)))this.addProtocol(d,j8[d]);for(let a of Object.keys(kb))this.addEncoding(a,kb[a]);this.reset()}addProtocol(a,b){this._protocols[a]=b}addEncoding(a,b){this._encodings[a]=b}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(a){if(!this._protocols[a])throw Error(`unknown protocol "${a}"`);this._activeProtocol=a,this._onProtocolChange.fire(this._protocols[a].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(a){if(!this._encodings[a])throw Error(`unknown encoding "${a}"`);this._activeEncoding=a}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(a,b,c){if(0===a.deltaY||a.shiftKey||void 0===b||void 0===c)return 0;let d=this._applyScrollModifier(a.deltaY,a);return a.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=b/c+0,50>Math.abs(a.deltaY)&&(d*=.3),this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):a.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(a,b){return b.altKey||b.ctrlKey||b.shiftKey?a*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:a*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(a){if(a.col<0||a.col>=this._bufferService.cols||a.row<0||a.row>=this._bufferService.rows||4===a.button&&32===a.action||3===a.button&&32!==a.action||4!==a.button&&(2===a.action||3===a.action)||(a.col++,a.row++,32===a.action&&this._lastEvent&&this._equalEvents(this._lastEvent,a,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(a))return!1;let b=this._encodings[this._activeEncoding](a);return b&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(b):this._coreService.triggerDataEvent(b,!0)),this._lastEvent=a,!0}explainEvents(a){return{down:!!(1&a),up:!!(2&a),drag:!!(4&a),move:!!(8&a),wheel:!!(16&a)}}_equalEvents(a,b,c){if(c){if(a.x!==b.x||a.y!==b.y)return!1}else if(a.col!==b.col||a.row!==b.row)return!1;return a.button===b.button&&a.action===b.action&&a.ctrl===b.ctrl&&a.alt===b.alt&&a.shift===b.shift}};kc=fH([fI(0,f_),fI(1,f1),fI(2,f5)],kc);var kd,ke,kf,kg,kh,ki=[[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]],kj=[[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]],kk=class{constructor(){if(this.version="6",!kh){(kh=new Uint8Array(65536)).fill(1),kh[0]=0,kh.fill(0,1,32),kh.fill(0,127,160),kh.fill(2,4352,4448),kh[9001]=2,kh[9002]=2,kh.fill(2,11904,42192),kh[12351]=1,kh.fill(2,44032,55204),kh.fill(2,63744,64256),kh.fill(2,65040,65050),kh.fill(2,65072,65136),kh.fill(2,65280,65377),kh.fill(2,65504,65511);for(let a=0;a<ki.length;++a)kh.fill(0,ki[a][0],ki[a][1]+1)}}wcwidth(a){return a<32?0:a<127?1:a<65536?kh[a]:!function(a,b){let c=0,d=b.length-1,e;if(a<b[0][0]||a>b[d][1])return!1;for(;d>=c;)if(a>b[e=c+d>>1][1])c=e+1;else{if(!(a<b[e][0]))return!0;d=e-1}return!1}(a,kj)?a>=131072&&a<=196605||a>=196608&&a<=262141?2:1:0}charProperties(a,b){let c=this.wcwidth(a),d=0===c&&0!==b;if(d){let a=kl.extractWidth(b);0===a?d=!1:a>c&&(c=a)}return kl.createPropertyValue(0,c,d)}},kl=class a{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new gZ,this.onChange=this._onChange.event;let a=new kk;this.register(a),this._active=a.version,this._activeProvider=a}static extractShouldJoin(a){return(1&a)!=0}static extractWidth(a){return a>>1&3}static extractCharKind(a){return a>>3}static createPropertyValue(a,b,c=!1){return(0xffffff&a)<<3|(3&b)<<1|!!c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(a){if(!this._providers[a])throw Error(`unknown Unicode version "${a}"`);this._active=a,this._activeProvider=this._providers[a],this._onChange.fire(a)}register(a){this._providers[a.version]=a}wcwidth(a){return this._activeProvider.wcwidth(a)}getStringCellWidth(b){let c=0,d=0,e=b.length;for(let f=0;f<e;++f){let g=b.charCodeAt(f);if(55296<=g&&g<=56319){if(++f>=e)return c+this.wcwidth(g);let a=b.charCodeAt(f);56320<=a&&a<=57343?g=(g-55296)*1024+a-56320+65536:c+=this.wcwidth(a)}let h=this.charProperties(g,d),i=a.extractWidth(h);a.extractShouldJoin(h)&&(i-=a.extractWidth(d)),c+=i,d=h}return c}charProperties(a,b){return this._activeProvider.charProperties(a,b)}},km=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(a){this.glevel=a,this.charset=this._charsets[a]}setgCharset(a,b){this._charsets[a]=b,this.glevel===a&&(this.charset=b)}};function kn(a){let b=a.buffer.lines.get(a.buffer.ybase+a.buffer.y-1)?.get(a.cols-1),c=a.buffer.lines.get(a.buffer.ybase+a.buffer.y);c&&b&&(c.isWrapped=0!==b[3]&&32!==b[3])}var ko=class a{constructor(a=32,b=32){if(this.maxLength=a,this.maxSubParamsLength=b,b>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(a),this.length=0,this._subParams=new Int32Array(b),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(a),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(b){let c=new a;if(!b.length)return c;for(let a=+!!Array.isArray(b[0]);a<b.length;++a){let d=b[a];if(Array.isArray(d))for(let a=0;a<d.length;++a)c.addSubParam(d[a]);else c.addParam(d)}return c}clone(){let b=new a(this.maxLength,this.maxSubParamsLength);return b.params.set(this.params),b.length=this.length,b._subParams.set(this._subParams),b._subParamsLength=this._subParamsLength,b._subParamsIdx.set(this._subParamsIdx),b._rejectDigits=this._rejectDigits,b._rejectSubDigits=this._rejectSubDigits,b._digitIsSub=this._digitIsSub,b}toArray(){let a=[];for(let b=0;b<this.length;++b){a.push(this.params[b]);let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&a.push(Array.prototype.slice.call(this._subParams,c,d))}return a}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(a){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=a>0x7fffffff?0x7fffffff:a}addSubParam(a){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(a<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=a>0x7fffffff?0x7fffffff:a,this._subParamsIdx[this.length-1]++}}hasSubParams(a){return(255&this._subParamsIdx[a])-(this._subParamsIdx[a]>>8)>0}getSubParams(a){let b=this._subParamsIdx[a]>>8,c=255&this._subParamsIdx[a];return c-b>0?this._subParams.subarray(b,c):null}getSubParamsAll(){let a={};for(let b=0;b<this.length;++b){let c=this._subParamsIdx[b]>>8,d=255&this._subParamsIdx[b];d-c>0&&(a[b]=this._subParams.slice(c,d))}return a}addDigit(a){let b;if(this._rejectDigits||!(b=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let c=this._digitIsSub?this._subParams:this.params,d=c[b-1];c[b-1]=~d?Math.min(10*d+a,0x7fffffff):a}},kp=[],kq=class{constructor(){this._state=0,this._active=kp,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kp}reset(){if(2===this._state)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].end(!1);this._stack.paused=!1,this._active=kp,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||kp,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].start();else this._handlerFb(this._id,"START")}_put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._id,"PUT",fR(a,b,c))}start(){this.reset(),this._state=1}put(a,b,c){if(3!==this._state){if(1===this._state)for(;b<c;){let c=a[b++];if(59===c){this._state=2,this._start();break}if(c<48||57<c){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+c-48}2===this._state&&c-b>0&&this._put(a,b,c)}}end(a,b=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].end(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._id,"END",a);this._active=kp,this._id=-1,this._state=0}}},kr=class{constructor(a){this._handler=a,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=fR(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data))instanceof Promise)return b.then(a=>(this._data="",this._hitLimit=!1,a));return this._data="",this._hitLimit=!1,b}},ks=[],kt=class{constructor(){this._handlers=Object.create(null),this._active=ks,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ks}registerHandler(a,b){void 0===this._handlers[a]&&(this._handlers[a]=[]);let c=this._handlers[a];return c.push(b),{dispose:()=>{let a=c.indexOf(b);-1!==a&&c.splice(a,1)}}}clearHandler(a){this._handlers[a]&&delete this._handlers[a]}setHandlerFallback(a){this._handlerFb=a}reset(){if(this._active.length)for(let a=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;a>=0;--a)this._active[a].unhook(!1);this._stack.paused=!1,this._active=ks,this._ident=0}hook(a,b){if(this.reset(),this._ident=a,this._active=this._handlers[a]||ks,this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(a,b,c){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(a,b,c);else this._handlerFb(this._ident,"PUT",fR(a,b,c))}unhook(a,b=!0){if(this._active.length){let c=!1,d=this._active.length-1,e=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,c=b,e=this._stack.fallThrough,this._stack.paused=!1),!e&&!1===c){for(;d>=0&&!0!==(c=this._active[d].unhook(a));d--)if(c instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,c;d--}for(;d>=0;d--)if((c=this._active[d].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,c}else this._handlerFb(this._ident,"UNHOOK",a);this._active=ks,this._ident=0}},ku=new ko;ku.addParam(0);var kv=class{constructor(a){this._handler=a,this._data="",this._params=ku,this._hitLimit=!1}hook(a){this._params=a.length>1||a.params[0]?a.clone():ku,this._data="",this._hitLimit=!1}put(a,b,c){this._hitLimit||(this._data+=fR(a,b,c),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(a){let b=!1;if(this._hitLimit)b=!1;else if(a&&(b=this._handler(this._data,this._params))instanceof Promise)return b.then(a=>(this._params=ku,this._data="",this._hitLimit=!1,a));return this._params=ku,this._data="",this._hitLimit=!1,b}},kw=class{constructor(a){this.table=new Uint8Array(a)}setDefault(a,b){this.table.fill(a<<4|b)}add(a,b,c,d){this.table[b<<8|a]=c<<4|d}addMany(a,b,c,d){for(let e=0;e<a.length;e++)this.table[b<<8|a[e]]=c<<4|d}},kx=function(){let a=new kw(4095),b=Array.apply(null,Array(256)).map((a,b)=>b),c=(a,c)=>b.slice(a,c),d=c(32,127),e=c(0,24);e.push(25),e.push.apply(e,c(28,32));let f=c(0,14),g;for(g in a.setDefault(1,0),a.addMany(d,0,2,0),f)a.addMany([24,26,153,154],g,3,0),a.addMany(c(128,144),g,3,0),a.addMany(c(144,152),g,3,0),a.add(156,g,0,0),a.add(27,g,11,1),a.add(157,g,4,8),a.addMany([152,158,159],g,0,7),a.add(155,g,11,3),a.add(144,g,11,9);return a.addMany(e,0,3,0),a.addMany(e,1,3,1),a.add(127,1,0,1),a.addMany(e,8,0,8),a.addMany(e,3,3,3),a.add(127,3,0,3),a.addMany(e,4,3,4),a.add(127,4,0,4),a.addMany(e,6,3,6),a.addMany(e,5,3,5),a.add(127,5,0,5),a.addMany(e,2,3,2),a.add(127,2,0,2),a.add(93,1,4,8),a.addMany(d,8,5,8),a.add(127,8,5,8),a.addMany([156,27,24,26,7],8,6,0),a.addMany(c(28,32),8,0,8),a.addMany([88,94,95],1,0,7),a.addMany(d,7,0,7),a.addMany(e,7,0,7),a.add(156,7,0,0),a.add(127,7,0,7),a.add(91,1,11,3),a.addMany(c(64,127),3,7,0),a.addMany(c(48,60),3,8,4),a.addMany([60,61,62,63],3,9,4),a.addMany(c(48,60),4,8,4),a.addMany(c(64,127),4,7,0),a.addMany([60,61,62,63],4,0,6),a.addMany(c(32,64),6,0,6),a.add(127,6,0,6),a.addMany(c(64,127),6,0,0),a.addMany(c(32,48),3,9,5),a.addMany(c(32,48),5,9,5),a.addMany(c(48,64),5,0,6),a.addMany(c(64,127),5,7,0),a.addMany(c(32,48),4,9,5),a.addMany(c(32,48),1,9,2),a.addMany(c(32,48),2,9,2),a.addMany(c(48,127),2,10,0),a.addMany(c(48,80),1,10,0),a.addMany(c(81,88),1,10,0),a.addMany([89,90,92],1,10,0),a.addMany(c(96,127),1,10,0),a.add(80,1,11,9),a.addMany(e,9,0,9),a.add(127,9,0,9),a.addMany(c(28,32),9,0,9),a.addMany(c(32,48),9,9,12),a.addMany(c(48,60),9,8,10),a.addMany([60,61,62,63],9,9,10),a.addMany(e,11,0,11),a.addMany(c(32,128),11,0,11),a.addMany(c(28,32),11,0,11),a.addMany(e,10,0,10),a.add(127,10,0,10),a.addMany(c(28,32),10,0,10),a.addMany(c(48,60),10,8,10),a.addMany([60,61,62,63],10,0,11),a.addMany(c(32,48),10,9,12),a.addMany(e,12,0,12),a.add(127,12,0,12),a.addMany(c(28,32),12,0,12),a.addMany(c(32,48),12,9,12),a.addMany(c(48,64),12,0,11),a.addMany(c(64,127),12,12,13),a.addMany(c(64,127),10,12,13),a.addMany(c(64,127),9,12,13),a.addMany(e,13,13,13),a.addMany(d,13,13,13),a.add(127,13,0,13),a.addMany([27,156,24,26],13,14,0),a.add(160,0,2,0),a.add(160,8,5,8),a.add(160,6,0,6),a.add(160,11,0,11),a.add(160,13,13,13),a}(),ky=class extends gy{constructor(a=kx){super(),this._transitions=a,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new ko,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(a,b,c)=>{},this._executeHandlerFb=a=>{},this._csiHandlerFb=(a,b)=>{},this._escHandlerFb=a=>{},this._errorHandlerFb=a=>a,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(gv(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kq),this._dcsParser=this._register(new kt),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(a,b=[64,126]){let c=0;if(a.prefix){if(a.prefix.length>1)throw Error("only one byte as prefix supported");if((c=a.prefix.charCodeAt(0))&&60>c||c>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(a.intermediates){if(a.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let b=0;b<a.intermediates.length;++b){let d=a.intermediates.charCodeAt(b);if(32>d||d>47)throw Error("intermediate must be in range 0x20 .. 0x2f");c<<=8,c|=d}}if(1!==a.final.length)throw Error("final must be a single byte");let d=a.final.charCodeAt(0);if(b[0]>d||d>b[1])throw Error(`final must be in range ${b[0]} .. ${b[1]}`);return c<<=8,c|=d}identToString(a){let b=[];for(;a;)b.push(String.fromCharCode(255&a)),a>>=8;return b.reverse().join("")}setPrintHandler(a){this._printHandler=a}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(a,b){let c=this._identifier(a,[48,126]);void 0===this._escHandlers[c]&&(this._escHandlers[c]=[]);let d=this._escHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearEscHandler(a){this._escHandlers[this._identifier(a,[48,126])]&&delete this._escHandlers[this._identifier(a,[48,126])]}setEscHandlerFallback(a){this._escHandlerFb=a}setExecuteHandler(a,b){this._executeHandlers[a.charCodeAt(0)]=b}clearExecuteHandler(a){this._executeHandlers[a.charCodeAt(0)]&&delete this._executeHandlers[a.charCodeAt(0)]}setExecuteHandlerFallback(a){this._executeHandlerFb=a}registerCsiHandler(a,b){let c=this._identifier(a);void 0===this._csiHandlers[c]&&(this._csiHandlers[c]=[]);let d=this._csiHandlers[c];return d.push(b),{dispose:()=>{let a=d.indexOf(b);-1!==a&&d.splice(a,1)}}}clearCsiHandler(a){this._csiHandlers[this._identifier(a)]&&delete this._csiHandlers[this._identifier(a)]}setCsiHandlerFallback(a){this._csiHandlerFb=a}registerDcsHandler(a,b){return this._dcsParser.registerHandler(this._identifier(a),b)}clearDcsHandler(a){this._dcsParser.clearHandler(this._identifier(a))}setDcsHandlerFallback(a){this._dcsParser.setHandlerFallback(a)}registerOscHandler(a,b){return this._oscParser.registerHandler(a,b)}clearOscHandler(a){this._oscParser.clearHandler(a)}setOscHandlerFallback(a){this._oscParser.setHandlerFallback(a)}setErrorHandler(a){this._errorHandler=a}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,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(a,b,c,d,e){this._parseStack.state=a,this._parseStack.handlers=b,this._parseStack.handlerPos=c,this._parseStack.transition=d,this._parseStack.chunkPos=e}parse(a,b,c){let d=0,e=0,f=0,g;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,f=this._parseStack.chunkPos+1;else{if(void 0===c||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let b=this._parseStack.handlers,e=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e](this._params));e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 4:if(!1===c&&e>-1){for(;e>=0&&!0!==(g=b[e]());e--)if(g instanceof Promise)return this._parseStack.handlerPos=e,g}this._parseStack.handlers=[];break;case 6:if(d=a[this._parseStack.chunkPos],g=this._dcsParser.unhook(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(d=a[this._parseStack.chunkPos],g=this._oscParser.end(24!==d&&26!==d,c))return g;27===d&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,f=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let c=f;c<b;++c){switch(d=a[c],(e=this._transitions.table[this.currentState<<8|(d<160?d:160)])>>4){case 2:for(let e=c+1;;++e)if(e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160||++e>=b||(d=a[e])<32||d>126&&d<160){this._printHandler(a,c,e),c=e-1;break}break;case 3:this._executeHandlers[d]?this._executeHandlers[d]():this._executeHandlerFb(d),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:d,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|d],h=f?f.length-1:-1;for(;h>=0&&!0!==(g=f[h](this._params));h--)if(g instanceof Promise)return this._preserveStack(3,f,h,e,c),g;h<0&&this._csiHandlerFb(this._collect<<8|d,this._params),this.precedingJoinState=0;break;case 8:do switch(d){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(d-48)}while(++c<b&&(d=a[c])>47&&d<60);c--;break;case 9:this._collect<<=8,this._collect|=d;break;case 10:let i=this._escHandlers[this._collect<<8|d],j=i?i.length-1:-1;for(;j>=0&&!0!==(g=i[j]());j--)if(g instanceof Promise)return this._preserveStack(4,i,j,e,c),g;j<0&&this._escHandlerFb(this._collect<<8|d),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|d,this._params);break;case 13:for(let e=c+1;;++e)if(e>=b||24===(d=a[e])||26===d||27===d||d>127&&d<160){this._dcsParser.put(a,c,e),c=e-1;break}break;case 14:if(g=this._dcsParser.unhook(24!==d&&26!==d))return this._preserveStack(6,[],0,e,c),g;27===d&&(e|=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 e=c+1;;e++)if(e>=b||(d=a[e])<32||d>127&&d<160){this._oscParser.put(a,c,e),c=e-1;break}break;case 6:if(g=this._oscParser.end(24!==d&&26!==d))return this._preserveStack(5,[],0,e,c),g;27===d&&(e|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&e}}},kz=/^([\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})$/,kA=/^[\da-f]+$/;function kB(a){if(!a)return;let b=a.toLowerCase();if(0===b.indexOf("rgb:")){b=b.slice(4);let a=kz.exec(b);if(a){let b=a[1]?15:a[4]?255:a[7]?4095:65535;return[Math.round(parseInt(a[1]||a[4]||a[7]||a[10],16)/b*255),Math.round(parseInt(a[2]||a[5]||a[8]||a[11],16)/b*255),Math.round(parseInt(a[3]||a[6]||a[9]||a[12],16)/b*255)]}}else if(0===b.indexOf("#")&&(b=b.slice(1),kA.exec(b)&&[3,6,9,12].includes(b.length))){let a=b.length/3,c=[0,0,0];for(let d=0;d<3;++d){let e=parseInt(b.slice(a*d,a*d+a),16);c[d]=1===a?e<<4:2===a?e:3===a?e>>4:e>>8}return c}}function kC(a,b){let c=a.toString(16),d=c.length<2?"0"+c:c;switch(b){case 4:return c[0];case 8:return d;case 12:return(d+d).slice(0,3);default:return d+d}}var kD={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function kE(a,b){if(a>24)return b.setWinLines||!1;switch(a){case 1:return!!b.restoreWin;case 2:return!!b.minimizeWin;case 3:return!!b.setWinPosition;case 4:return!!b.setWinSizePixels;case 5:return!!b.raiseWin;case 6:return!!b.lowerWin;case 7:return!!b.refreshWin;case 8:return!!b.setWinSizeChars;case 9:return!!b.maximizeWin;case 10:return!!b.fullscreenWin;case 11:return!!b.getWinState;case 13:return!!b.getWinPosition;case 14:return!!b.getWinSizePixels;case 15:return!!b.getScreenSizePixels;case 16:return!!b.getCellSizePixels;case 18:return!!b.getWinSizeChars;case 19:return!!b.getScreenSizeChars;case 20:return!!b.getIconTitle;case 21:return!!b.getWinTitle;case 22:return!!b.pushTitle;case 23:return!!b.popTitle;case 24:return!!b.setWinLines}return!1}var kF=0,kG=class extends gy{constructor(a,b,c,d,e,f,g,h,i=new ky){for(let j in super(),this._bufferService=a,this._charsetService=b,this._coreService=c,this._logService=d,this._optionsService=e,this._oscLinkService=f,this._coreMouseService=g,this._unicodeService=h,this._parser=i,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new fS,this._utf8Decoder=new fT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=jT.clone(),this._eraseAttrDataInternal=jT.clone(),this._onRequestBell=this._register(new gZ),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new gZ),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new gZ),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new gZ),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new gZ),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new gZ),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new gZ),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new gZ),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new gZ),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new gZ),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new gZ),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new gZ),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new gZ),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 kH(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,b)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:b.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,b,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:b,data:c})}),this._parser.setDcsHandlerFallback((a,b,c)=>{"HOOK"===b&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:b,payload:c})}),this._parser.setPrintHandler((a,b,c)=>this.print(a,b,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(iD.BEL,()=>this.bell()),this._parser.setExecuteHandler(iD.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(iD.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(iD.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(iD.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(iD.BS,()=>this.backspace()),this._parser.setExecuteHandler(iD.HT,()=>this.tab()),this._parser.setExecuteHandler(iD.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(iD.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(iE.IND,()=>this.index()),this._parser.setExecuteHandler(iE.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(iE.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new kr(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new kr(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new kr(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new kr(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new kr(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new kr(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new kr(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new kr(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new kr(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new kr(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new kr(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new kr(a=>this.restoreCursorColor(a))),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()),jY)this._parser.registerEscHandler({intermediates:"(",final:j},()=>this.selectCharset("("+j)),this._parser.registerEscHandler({intermediates:")",final:j},()=>this.selectCharset(")"+j)),this._parser.registerEscHandler({intermediates:"*",final:j},()=>this.selectCharset("*"+j)),this._parser.registerEscHandler({intermediates:"+",final:j},()=>this.selectCharset("+"+j)),this._parser.registerEscHandler({intermediates:"-",final:j},()=>this.selectCharset("-"+j)),this._parser.registerEscHandler({intermediates:".",final:j},()=>this.selectCharset("."+j)),this._parser.registerEscHandler({intermediates:"/",final:j},()=>this.selectCharset("/"+j));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new kv((a,b)=>this.requestStatusString(a,b)))}getAttrData(){return this._curAttrData}_preserveStack(a,b,c,d){this._parseStack.paused=!0,this._parseStack.cursorStartX=a,this._parseStack.cursorStartY=b,this._parseStack.decodedLength=c,this._parseStack.position=d}_logSlowResolvingAsync(a){this._logService.logLevel<=3&&Promise.race([a,new Promise((a,b)=>setTimeout(()=>b("#SLOW_TIMEOUT"),5e3))]).catch(a=>{if("#SLOW_TIMEOUT"!==a)throw a;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(a,b){let c,d=this._activeBuffer.x,e=this._activeBuffer.y,f=0,g=this._parseStack.paused;if(g){if(c=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,b))return this._logSlowResolvingAsync(c),c;d=this._parseStack.cursorStartX,e=this._parseStack.cursorStartY,this._parseStack.paused=!1,a.length>131072&&(f=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof a?` "${a}"`:` "${Array.prototype.map.call(a,a=>String.fromCharCode(a)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof a?a.split("").map(a=>a.charCodeAt(0)):a),this._parseBuffer.length<a.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(a.length,131072))),g||this._dirtyRowTracker.clearRange(),a.length>131072)for(let b=f;b<a.length;b+=131072){let f=b+131072<a.length?b+131072:a.length,g="string"==typeof a?this._stringDecoder.decode(a.substring(b,f),this._parseBuffer):this._utf8Decoder.decode(a.subarray(b,f),this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,g))return this._preserveStack(d,e,g,b),this._logSlowResolvingAsync(c),c}else if(!g){let b="string"==typeof a?this._stringDecoder.decode(a,this._parseBuffer):this._utf8Decoder.decode(a,this._parseBuffer);if(c=this._parser.parse(this._parseBuffer,b))return this._preserveStack(d,e,b,0),this._logSlowResolvingAsync(c),c}(this._activeBuffer.x!==d||this._activeBuffer.y!==e)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),i=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);i<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(i,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(a,b,c){let d,e,f=this._charsetService.charset,g=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,i=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,k=this._curAttrData,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&c-b>0&&2===l.getWidth(this._activeBuffer.x-1)&&l.setCellFromCodepoint(this._activeBuffer.x-1,0,1,k);let m=this._parser.precedingJoinState;for(let n=b;n<c;++n){if((d=a[n])<127&&f){let a=f[String.fromCharCode(d)];a&&(d=a.charCodeAt(0))}let b=this._unicodeService.charProperties(d,m);e=kl.extractWidth(b);let c=kl.extractShouldJoin(b),o=c?kl.extractWidth(m):0;if(m=b,g&&this._onA11yChar.fire(fQ(d)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+e-o>h){if(i){let a=l,b=this._activeBuffer.x-o;for(this._activeBuffer.x=o,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),l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),o>0&&l instanceof jV&&l.copyCellsFrom(a,b,0,o,!1);b<h;)a.setCellFromCodepoint(b++,0,1,k)}else if(this._activeBuffer.x=h-1,2===e)continue}if(c&&this._activeBuffer.x){let a=l.getWidth(this._activeBuffer.x-1)?1:2;l.addCodepointToCell(this._activeBuffer.x-a,d,e);for(let a=e-o;--a>=0;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k);continue}if(j&&(l.insertCells(this._activeBuffer.x,e-o,this._activeBuffer.getNullCell(k)),2===l.getWidth(h-1)&&l.setCellFromCodepoint(h-1,0,1,k)),l.setCellFromCodepoint(this._activeBuffer.x++,d,e,k),e>0)for(;--e;)l.setCellFromCodepoint(this._activeBuffer.x++,0,0,k)}this._parser.precedingJoinState=m,this._activeBuffer.x<h&&c-b>0&&0===l.getWidth(this._activeBuffer.x)&&!l.hasContent(this._activeBuffer.x)&&l.setCellFromCodepoint(this._activeBuffer.x,0,1,k),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(a,b){return"t"!==a.final||a.prefix||a.intermediates?this._parser.registerCsiHandler(a,b):this._parser.registerCsiHandler(a,a=>!kE(a.params[0],this._optionsService.rawOptions.windowOptions)||b(a))}registerDcsHandler(a,b){return this._parser.registerDcsHandler(a,new kv(b))}registerEscHandler(a,b){return this._parser.registerEscHandler(a,b)}registerOscHandler(a,b){return this._parser.registerOscHandler(a,new kr(b))}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(0===this._activeBuffer.x&&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 a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);a.hasWidth(this._activeBuffer.x)&&!a.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let a=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-a),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(a=this._bufferService.cols-1){this._activeBuffer.x=Math.min(a,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(a,b){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=a,this._activeBuffer.y=this._activeBuffer.scrollTop+b):(this._activeBuffer.x=a,this._activeBuffer.y=b),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(a,b){this._restrictCursor(),this._setCursor(this._activeBuffer.x+a,this._activeBuffer.y+b)}cursorUp(a){let b=this._activeBuffer.y-this._activeBuffer.scrollTop;return b>=0?this._moveCursor(0,-Math.min(b,a.params[0]||1)):this._moveCursor(0,-(a.params[0]||1)),!0}cursorDown(a){let b=this._activeBuffer.scrollBottom-this._activeBuffer.y;return b>=0?this._moveCursor(0,Math.min(b,a.params[0]||1)):this._moveCursor(0,a.params[0]||1),!0}cursorForward(a){return this._moveCursor(a.params[0]||1,0),!0}cursorBackward(a){return this._moveCursor(-(a.params[0]||1),0),!0}cursorNextLine(a){return this.cursorDown(a),this._activeBuffer.x=0,!0}cursorPrecedingLine(a){return this.cursorUp(a),this._activeBuffer.x=0,!0}cursorCharAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(a){return this._setCursor(a.length>=2?(a.params[1]||1)-1:0,(a.params[0]||1)-1),!0}charPosAbsolute(a){return this._setCursor((a.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(a){return this._moveCursor(a.params[0]||1,0),!0}linePosAbsolute(a){return this._setCursor(this._activeBuffer.x,(a.params[0]||1)-1),!0}vPositionRelative(a){return this._moveCursor(0,a.params[0]||1),!0}hVPosition(a){return this.cursorPosition(a),!0}tabClear(a){let b=a.params[0];return 0===b?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===b&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(a){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let b=a.params[0]||1;for(;b--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(a){let b=a.params[0];return 1===b&&(this._curAttrData.bg|=0x20000000),(2===b||0===b)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(a,b,c,d=!1,e=!1){let f=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);f.replaceCells(b,c,this._activeBuffer.getNullCell(this._eraseAttrData()),e),d&&(f.isWrapped=!1)}_resetBufferLine(a,b=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c&&(c.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),b),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+a),c.isWrapped=!1)}eraseInDisplay(a,b=!1){let c;switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);c<this._bufferService.rows;c++)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(c);break;case 1:for(c=this._activeBuffer.y,this._dirtyRowTracker.markDirty(c),this._eraseInBufferLine(c,0,this._activeBuffer.x+1,!0,b),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(c+1).isWrapped=!1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(c=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,c-1);c--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+c)?.getTrimmedLength(););for(;c>=0;c--)this._bufferService.scroll(this._eraseAttrData())}else{for(c=this._bufferService.rows,this._dirtyRowTracker.markDirty(c-1);c--;)this._resetBufferLine(c,b);this._dirtyRowTracker.markDirty(0)}break;case 3:let d=this._activeBuffer.lines.length-this._bufferService.rows;d>0&&(this._activeBuffer.lines.trimStart(d),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-d,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-d,0),this._onScroll.fire(0))}return!0}eraseInLine(a,b=!1){switch(this._restrictCursor(this._bufferService.cols),a.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,b);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,b);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,b)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,e=this._bufferService.rows-1+this._activeBuffer.ybase-d+1;for(;b--;)this._activeBuffer.lines.splice(e-1,1),this._activeBuffer.lines.splice(c,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(a){this._restrictCursor();let b=a.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let c=this._activeBuffer.ybase+this._activeBuffer.y,d;for(d=this._bufferService.rows-1-this._activeBuffer.scrollBottom,d=this._bufferService.rows-1+this._activeBuffer.ybase-d;b--;)this._activeBuffer.lines.splice(c,1),this._activeBuffer.lines.splice(d,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.insertCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.deleteCells(this._activeBuffer.x,a.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(a){let b=a.params[0]||1;for(;b--;)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(a){let b=a.params[0]||1;for(;b--;)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(jT));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(0,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.insertCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(a){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let b=a.params[0]||1;for(let a=this._activeBuffer.scrollTop;a<=this._activeBuffer.scrollBottom;++a){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+a);c.deleteCells(this._activeBuffer.x,b,this._activeBuffer.getNullCell(this._eraseAttrData())),c.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(a){this._restrictCursor();let b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return b&&(b.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(a.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(a){let b=this._parser.precedingJoinState;if(!b)return!0;let c=a.params[0]||1,d=kl.extractWidth(b),e=this._activeBuffer.x-d,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(e),g=new Uint32Array(f.length*c),h=0;for(let a=0;a<f.length;){let b=f.codePointAt(a)||0;g[h++]=b,a+=b>65535?2:1}let i=h;for(let a=1;a<c;++a)g.copyWithin(i,0,h),i+=h;return this.print(g,0,i),!0}sendDeviceAttributesPrimary(a){return a.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(iD.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(iD.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(a){return a.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(iD.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(iD.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(a.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(iD.ESC+"[>83;40003;0c")),!0}_is(a){return 0===(this._optionsService.rawOptions.termName+"").indexOf(a)}setMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,jZ),this._charsetService.setgCharset(1,jZ),this._charsetService.setgCharset(2,jZ),this._charsetService.setgCharset(3,jZ);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}return!0}resetMode(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(a){for(let b=0;b<a.length;b++)switch(a.params[b]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===a.params[b]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(a,b){let c,d,e,f;(d=c||={})[d.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",d[d.SET=1]="SET",d[d.RESET=2]="RESET",d[d.PERMANENTLY_SET=3]="PERMANENTLY_SET",d[d.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let g=this._coreService.decPrivateModes,{activeProtocol:h,activeEncoding:i}=this._coreMouseService,j=this._coreService,{buffers:k,cols:l}=this._bufferService,{active:m,alt:n}=k,o=this._optionsService.rawOptions,p=a=>a?1:2,q=a.params[0];return e=q,f=b?2===q?4:4===q?p(j.modes.insertMode):12===q?3:20===q?p(o.convertEol):0:1===q?p(g.applicationCursorKeys):3===q?o.windowOptions.setWinLines?80===l?2:+(132===l):0:6===q?p(g.origin):7===q?p(g.wraparound):8===q?3:9===q?p("X10"===h):12===q?p(o.cursorBlink):25===q?p(!j.isCursorHidden):45===q?p(g.reverseWraparound):66===q?p(g.applicationKeypad):67===q?4:1e3===q?p("VT200"===h):1002===q?p("DRAG"===h):1003===q?p("ANY"===h):1004===q?p(g.sendFocus):1005===q?4:1006===q?p("SGR"===i):1015===q?4:1016===q?p("SGR_PIXELS"===i):1048===q?1:47===q||1047===q||1049===q?p(m===n):2004===q?p(g.bracketedPasteMode):2026===q?p(g.synchronizedOutput):0,j.triggerDataEvent(`${iD.ESC}[${b?"":"?"}${e};${f}$y`),!0}_updateAttrColor(a,b,c,d,e){return 2===b?(a|=0x3000000,a&=-0x1000000,a|=fU.fromColorRGB([c,d,e])):5===b&&(a&=-0x3000100,a|=0x2000000|255&c),a}_extractColor(a,b,c){let d=[0,0,-1,0,0,0],e=0,f=0;do{if(d[f+e]=a.params[b+f],a.hasSubParams(b+f)){let c=a.getSubParams(b+f),g=0;do 5===d[1]&&(e=1),d[f+g+1+e]=c[g];while(++g<c.length&&g+f+1+e<d.length);break}if(5===d[1]&&f+e>=2||2===d[1]&&f+e>=5)break;d[1]&&(e=1)}while(++f+b<a.length&&f+e<d.length);for(let a=2;a<d.length;++a)-1===d[a]&&(d[a]=0);switch(d[0]){case 38:c.fg=this._updateAttrColor(c.fg,d[1],d[3],d[4],d[5]);break;case 48:c.bg=this._updateAttrColor(c.bg,d[1],d[3],d[4],d[5]);break;case 58:c.extended=c.extended.clone(),c.extended.underlineColor=this._updateAttrColor(c.extended.underlineColor,d[1],d[3],d[4],d[5])}return f}_processUnderline(a,b){b.extended=b.extended.clone(),(!~a||a>5)&&(a=1),b.extended.underlineStyle=a,b.fg|=0x10000000,0===a&&(b.fg&=-0x10000001),b.updateExtended()}_processSGR0(a){a.fg=jT.fg,a.bg=jT.bg,a.extended=a.extended.clone(),a.extended.underlineStyle=0,a.extended.underlineColor&=-0x4000000,a.updateExtended()}charAttributes(a){if(1===a.length&&0===a.params[0])return this._processSGR0(this._curAttrData),!0;let b=a.length,c,d=this._curAttrData;for(let e=0;e<b;e++)(c=a.params[e])>=30&&c<=37?(d.fg&=-0x3000100,d.fg|=0x1000000|c-30):c>=40&&c<=47?(d.bg&=-0x3000100,d.bg|=0x1000000|c-40):c>=90&&c<=97?(d.fg&=-0x3000100,d.fg|=0x1000000|c-90|8):c>=100&&c<=107?(d.bg&=-0x3000100,d.bg|=0x1000000|c-100|8):0===c?this._processSGR0(d):1===c?d.fg|=0x8000000:3===c?d.bg|=0x4000000:4===c?(d.fg|=0x10000000,this._processUnderline(a.hasSubParams(e)?a.getSubParams(e)[0]:1,d)):5===c?d.fg|=0x20000000:7===c?d.fg|=0x4000000:8===c?d.fg|=0x40000000:9===c?d.fg|=0x80000000:2===c?d.bg|=0x8000000:21===c?this._processUnderline(2,d):22===c?(d.fg&=-0x8000001,d.bg&=-0x8000001):23===c?d.bg&=-0x4000001:24===c?(d.fg&=-0x10000001,this._processUnderline(0,d)):25===c?d.fg&=-0x20000001:27===c?d.fg&=-0x4000001:28===c?d.fg&=-0x40000001:29===c?d.fg&=0x7fffffff:39===c?(d.fg&=-0x4000000,d.fg|=0xffffff&jT.fg):49===c?(d.bg&=-0x4000000,d.bg|=0xffffff&jT.bg):38===c||48===c||58===c?e+=this._extractColor(a,e,d):53===c?d.bg|=0x40000000:55===c?d.bg&=-0x40000001:59===c?(d.extended=d.extended.clone(),d.extended.underlineColor=-1,d.updateExtended()):100===c?(d.fg&=-0x4000000,d.fg|=0xffffff&jT.fg,d.bg&=-0x4000000,d.bg|=0xffffff&jT.bg):this._logService.debug("Unknown SGR attribute: %d.",c);return!0}deviceStatus(a){switch(a.params[0]){case 5:this._coreService.triggerDataEvent(`${iD.ESC}[0n`);break;case 6:let b=this._activeBuffer.y+1,c=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${iD.ESC}[${b};${c}R`)}return!0}deviceStatusPrivate(a){if(6===a.params[0]){let a=this._activeBuffer.y+1,b=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${iD.ESC}[?${a};${b}R`)}return!0}softReset(a){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=jT.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(a){let b=0===a.length?1:a.params[0];if(0===b)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(b){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"}this._coreService.decPrivateModes.cursorBlink=b%2==1}return!0}setScrollRegion(a){let b=a.params[0]||1,c;return(a.length<2||(c=a.params[1])>this._bufferService.rows||0===c)&&(c=this._bufferService.rows),c>b&&(this._activeBuffer.scrollTop=b-1,this._activeBuffer.scrollBottom=c-1,this._setCursor(0,0)),!0}windowOptions(a){if(!kE(a.params[0],this._optionsService.rawOptions.windowOptions))return!0;let b=a.length>1?a.params[1]:0;switch(a.params[0]){case 14:2!==b&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${iD.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===b||2===b)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===b||1===b)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===b||2===b)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===b||1===b)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(a){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(a){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(a){return this._windowTitle=a,this._onTitleChange.fire(a),!0}setIconName(a){return this._iconName=a,!0}setOrReportIndexedColor(a){let b=[],c=a.split(";");for(;c.length>1;){let a=c.shift(),d=c.shift();if(/^\d+$/.exec(a)){let c=parseInt(a);if(kI(c))if("?"===d)b.push({type:0,index:c});else{let a=kB(d);a&&b.push({type:1,index:c,color:a})}}}return b.length&&this._onColor.fire(b),!0}setHyperlink(a){let b=a.indexOf(";");if(-1===b)return!0;let c=a.slice(0,b).trim(),d=a.slice(b+1);return d?this._createHyperlink(c,d):!c.trim()&&this._finishHyperlink()}_createHyperlink(a,b){this._getCurrentLinkId()&&this._finishHyperlink();let c=a.split(":"),d,e=c.findIndex(a=>a.startsWith("id="));return -1!==e&&(d=c[e].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:d,uri:b}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(a,b){let c=a.split(";");for(let a=0;a<c.length&&!(b>=this._specialColors.length);++a,++b)if("?"===c[a])this._onColor.fire([{type:0,index:this._specialColors[b]}]);else{let d=kB(c[a]);d&&this._onColor.fire([{type:1,index:this._specialColors[b],color:d}])}return!0}setOrReportFgColor(a){return this._setOrReportSpecialColor(a,0)}setOrReportBgColor(a){return this._setOrReportSpecialColor(a,1)}setOrReportCursorColor(a){return this._setOrReportSpecialColor(a,2)}restoreIndexedColor(a){if(!a)return this._onColor.fire([{type:2}]),!0;let b=[],c=a.split(";");for(let a=0;a<c.length;++a)if(/^\d+$/.exec(c[a])){let d=parseInt(c[a]);kI(d)&&b.push({type:2,index:d})}return b.length&&this._onColor.fire(b),!0}restoreFgColor(a){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(a){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(a){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,jZ),!0}selectCharset(a){return 2!==a.length?this.selectDefaultCharset():"/"===a[0]||this._charsetService.setgCharset(kD[a[0]],jY[a[1]]||jZ),!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 a=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,a,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=jT.clone(),this._eraseAttrDataInternal=jT.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(a){return this._charsetService.setgLevel(a),!0}screenAlignmentPattern(){let a=new fW;a.content=4194373,a.fg=this._curAttrData.fg,a.bg=this._curAttrData.bg,this._setCursor(0,0);for(let b=0;b<this._bufferService.rows;++b){let c=this._activeBuffer.ybase+this._activeBuffer.y+b,d=this._activeBuffer.lines.get(c);d&&(d.fill(a),d.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(a,b){let c=a=>(this._coreService.triggerDataEvent(`${iD.ESC}${a}${iD.ESC}\\`),!0),d=this._bufferService.buffer,e=this._optionsService.rawOptions;return c('"q'===a?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===a?'P1$r61;1"p':"r"===a?`P1$r${d.scrollTop+1};${d.scrollBottom+1}r`:"m"===a?"P1$r0m":" q"===a?`P1$r${({block:2,underline:4,bar:6})[e.cursorStyle]-!!e.cursorBlink} q`:"P0$r")}markRangeDirty(a,b){this._dirtyRowTracker.markRangeDirty(a,b)}},kH=class{constructor(a){this._bufferService=a,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(a){a<this.start?this.start=a:a>this.end&&(this.end=a)}markRangeDirty(a,b){a>b&&(kF=a,a=b,b=kF),a<this.start&&(this.start=a),b>this.end&&(this.end=b)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function kI(a){return 0<=a&&a<256}kH=fH([fI(0,f_)],kH);var kJ=class extends gy{constructor(a){super(),this._action=a,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new gZ),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(a,b){let c;if(void 0!==b&&this._syncCalls>b){this._syncCalls=0;return}if(this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;c=this._writeBuffer.shift();){this._action(c);let a=this._callbacks.shift();a&&a()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(a,b){if(this._pendingData>5e7)throw 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+=a.length,this._writeBuffer.push(a),this._callbacks.push(b),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=a.length,this._writeBuffer.push(a),this._callbacks.push(b)}_innerWrite(a=0,b=!0){let c=a||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let a=this._writeBuffer[this._bufferOffset],d=this._action(a,b);if(d){let a=a=>performance.now()-c>=12?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(c,a);d.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(a);return}let e=this._callbacks[this._bufferOffset];if(e&&e(),this._bufferOffset++,this._pendingData-=a.length,performance.now()-c>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},kK=class{constructor(a){this._bufferService=a,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(a){let b=this._bufferService.buffer;if(void 0===a.id){let c=b.addMarker(b.ybase+b.y),d={data:a,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._dataByLinkId.set(d.id,d),d.id}let c=this._getEntryIdKey(a),d=this._entriesWithId.get(c);if(d)return this.addLineToLink(d.id,b.ybase+b.y),d.id;let e=b.addMarker(b.ybase+b.y),f={id:this._nextId++,key:this._getEntryIdKey(a),data:a,lines:[e]};return e.onDispose(()=>this._removeMarkerFromLink(f,e)),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(a,b){let c=this._dataByLinkId.get(a);if(c&&c.lines.every(a=>a.line!==b)){let a=this._bufferService.buffer.addMarker(b);c.lines.push(a),a.onDispose(()=>this._removeMarkerFromLink(c,a))}}getLinkData(a){return this._dataByLinkId.get(a)?.data}_getEntryIdKey(a){return`${a.id};;${a.uri}`}_removeMarkerFromLink(a,b){let c=a.lines.indexOf(b);-1!==c&&(a.lines.splice(c,1),0===a.lines.length&&(void 0!==a.data.id&&this._entriesWithId.delete(a.key),this._dataByLinkId.delete(a.id)))}};kK=fH([fI(0,f_)],kK);var kL=!1,kM=class extends gy{constructor(a){super(),this._windowsWrappingHeuristics=this._register(new gz),this._onBinary=this._register(new gZ),this.onBinary=this._onBinary.event,this._onData=this._register(new gZ),this.onData=this._onData.event,this._onLineFeed=this._register(new gZ),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new gZ),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new gZ),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new gZ),this._instantiationService=new jP,this.optionsService=this._register(new j3(a)),this._instantiationService.setService(f5,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(j0)),this._instantiationService.setService(f_,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(jR)),this._instantiationService.setService(f4,this._logService),this.coreService=this._register(this._instantiationService.createInstance(j7)),this._instantiationService.setService(f1,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(kc)),this._instantiationService.setService(f0,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(kl)),this._instantiationService.setService(f7,this.unicodeService),this._charsetService=this._instantiationService.createInstance(km),this._instantiationService.setService(f2,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(kK),this._instantiationService.setService(f6,this._oscLinkService),this._inputHandler=this._register(new kG(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(gS.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(gS.forward(this._bufferService.onResize,this._onResize)),this._register(gS.forward(this.coreService.onData,this._onData)),this._register(gS.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 kJ((a,b)=>this._inputHandler.parse(a,b))),this._register(gS.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new gZ),this._onScroll.event(a=>{this._onScrollApi?.fire(a.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(a){for(let b in a)this.optionsService.options[b]=a[b]}write(a,b){this._writeBuffer.write(a,b)}writeSync(a,b){this._logService.logLevel<=3&&!kL&&(this._logService.warn("writeSync is unreliable and will be removed soon."),kL=!0),this._writeBuffer.writeSync(a,b)}input(a,b=!0){this.coreService.triggerDataEvent(a,b)}resize(a,b){isNaN(a)||isNaN(b)||(a=Math.max(a,2),b=Math.max(b,1),this._bufferService.resize(a,b))}scroll(a,b=!1){this._bufferService.scroll(a,b)}scrollLines(a,b){this._bufferService.scrollLines(a,b)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}registerEscHandler(a,b){return this._inputHandler.registerEscHandler(a,b)}registerDcsHandler(a,b){return this._inputHandler.registerDcsHandler(a,b)}registerCsiHandler(a,b){return this._inputHandler.registerCsiHandler(a,b)}registerOscHandler(a,b){return this._inputHandler.registerOscHandler(a,b)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let a=!1,b=this.optionsService.rawOptions.windowsPty;b&&void 0!==b.buildNumber&&void 0!==b.buildNumber?a="conpty"===b.backend&&b.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(a=!0),a?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let a=[];a.push(this.onLineFeed(kn.bind(null,this._bufferService))),a.push(this.registerCsiHandler({final:"H"},()=>(kn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=gv(()=>{for(let b of a)b.dispose()})}}},kN={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:["'",'"']},kO=0,kP=class{constructor(a){this._getKey=a,this._array=[],this._insertedValues=[],this._flushInsertedTask=new js,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new js,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(a){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(a)}_flushInserted(){let a=this._insertedValues.sort((a,b)=>this._getKey(a)-this._getKey(b)),b=0,c=0,d=Array(this._array.length+this._insertedValues.length);for(let e=0;e<d.length;e++)c>=this._array.length||this._getKey(a[b])<=this._getKey(this._array[c])?(d[e]=a[b],b++):d[e]=this._array[c++];this._array=d,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(a){if(this._flushCleanupInserted(),0===this._array.length)return!1;let b=this._getKey(a);if(void 0===b||-1===(kO=this._search(b))||this._getKey(this._array[kO])!==b)return!1;do if(this._array[kO]===a)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(kO),!0;while(++kO<this._array.length&&this._getKey(this._array[kO])===b);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let a=this._deletedIndices.sort((a,b)=>a-b),b=0,c=Array(this._array.length-a.length),d=0;for(let e=0;e<this._array.length;e++)a[b]===e?b++:c[d++]=this._array[e];this._array=c,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(a){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((kO=this._search(a))<0||kO>=this._array.length)&&this._getKey(this._array[kO])===a)do yield this._array[kO];while(++kO<this._array.length&&this._getKey(this._array[kO])===a)}forEachByKey(a,b){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((kO=this._search(a))<0||kO>=this._array.length)&&this._getKey(this._array[kO])===a)do b(this._array[kO]);while(++kO<this._array.length&&this._getKey(this._array[kO])===a)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(a){let b=0,c=this._array.length-1;for(;c>=b;){let d=b+c>>1,e=this._getKey(this._array[d]);if(e>a)c=d-1;else if(e<a)b=d+1;else{for(;d>0&&this._getKey(this._array[d-1])===a;)d--;return d}}return b}},kQ=0,kR=0,kS=class extends gy{constructor(){super(),this._decorations=new kP(a=>a?.marker.line),this._onDecorationRegistered=this._register(new gZ),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new gZ),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(gv(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(a){if(a.marker.isDisposed)return;let b=new kT(a);if(b){let a=b.marker.onDispose(()=>b.dispose()),c=b.onDispose(()=>{c.dispose(),b&&(this._decorations.delete(b)&&this._onDecorationRemoved.fire(b),a.dispose())});this._decorations.insert(b),this._onDecorationRegistered.fire(b)}return b}reset(){for(let a of this._decorations.values())a.dispose();this._decorations.clear()}*getDecorationsAtCell(a,b,c){let d=0,e=0;for(let f of this._decorations.getKeyIterator(b))e=(d=f.options.x??0)+(f.options.width??1),a>=d&&a<e&&(!c||(f.options.layer??"bottom")===c)&&(yield f)}forEachDecorationAtCell(a,b,c,d){this._decorations.forEachByKey(b,b=>{kR=(kQ=b.options.x??0)+(b.options.width??1),a>=kQ&&a<kR&&(!c||(b.options.layer??"bottom")===c)&&d(b)})}},kT=class extends gx{constructor(a){super(),this.options=a,this.onRenderEmitter=this.add(new gZ),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new gZ),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=a.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=ke.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=ke.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},kU=class{constructor(a,b=1e3){this._renderCallback=a,this._debounceThresholdMS=b,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(a,b,c){this._rowCount=c,a=void 0!==a?a:0,b=void 0!==b?b:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,a):a,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,b):b;let d=performance.now();if(d-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=d,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=d-this._lastRefreshMs,b=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},b)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let a=Math.max(this._rowStart,0),b=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(a,b)}},kV=class extends gy{constructor(a,b,c,d){super(),this._terminal=a,this._coreBrowserService=c,this._renderService=d,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let e=this._coreBrowserService.mainDocument;this._accessibilityContainer=e.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=e.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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=e.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new kU(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
25
25
  `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(h$(e,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(gv(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(a){for(let b=0;b<a;b++)this._handleChar(" ")}_handleChar(a){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==a&&(this._charsToAnnounce+=a):this._charsToAnnounce+=a,a===`
26
26
  `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=fM.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(a){this._clearLiveRegion(),/\p{Control}/u.test(a)||this._charsToConsume.push(a)}_refreshRows(a,b){this._liveRegionDebouncer.refresh(a,b,this._terminal.rows)}_renderRows(a,b){let c=this._terminal.buffer,d=c.lines.length.toString();for(let e=a;e<=b;e++){let a=c.lines.get(c.ydisp+e),b=[],f=a?.translateToString(!0,void 0,void 0,b)||"",g=(c.ydisp+e+1).toString(),h=this._rowElements[e];h&&(0===f.length?(h.textContent="\xa0",this._rowColumns.set(h,[0,1])):(h.textContent=f,this._rowColumns.set(h,b)),h.setAttribute("aria-posinset",g),h.setAttribute("aria-setsize",d),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(a,b){let c,d,e=a.target,f=this._rowElements[0===b?1:this._rowElements.length-2];if(e.getAttribute("aria-posinset")!==(0===b?"1":`${this._terminal.buffer.lines.length}`)&&a.relatedTarget===f){if(0===b?(c=e,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=e,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),0===b){let a=this._createAccessibilityTreeNode();this._rowElements.unshift(a),this._rowContainer.insertAdjacentElement("afterbegin",a)}else{let a=this._createAccessibilityTreeNode();this._rowElements.push(a),this._rowContainer.appendChild(a)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===b?-1:1),this._rowElements[0===b?1:this._rowElements.length-2].focus(),a.preventDefault(),a.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let a=this._coreBrowserService.mainDocument.getSelection();if(!a)return;if(a.isCollapsed){this._rowContainer.contains(a.anchorNode)&&this._terminal.clearSelection();return}if(!a.anchorNode||!a.focusNode)return void console.error("anchorNode and/or focusNode are null");let b={node:a.anchorNode,offset:a.anchorOffset},c={node:a.focusNode,offset:a.focusOffset};if((b.node.compareDocumentPosition(c.node)&Node.DOCUMENT_POSITION_PRECEDING||b.node===c.node&&b.offset>c.offset)&&([b,c]=[c,b]),b.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(b={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(b.node))return;let d=this._rowElements.slice(-1)[0];if(c.node.compareDocumentPosition(d)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(c={node:d,offset:d.textContent?.length??0}),!this._rowContainer.contains(c.node))return;let e=({node:a,offset:b})=>{let c=a instanceof Text?a.parentNode:a,d=parseInt(c?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let e=this._rowColumns.get(c);if(!e)return console.warn("columns is null. Race condition?"),null;let f=b<e.length?e[b]:e.slice(-1)[0]+1;return f>=this._terminal.cols&&(++d,f=0),{row:d,column:f}},f=e(b),g=e(c);if(!(!f||!g)){if(f.row>g.row||f.row===g.row&&f.column>=g.column)throw Error("invalid range");this._terminal.select(f.column,f.row,(g.row-f.row)*this._terminal.cols-f.column+g.column)}}_handleResize(a){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let a=this._rowContainer.children.length;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);for(;this._rowElements.length>a;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let a=this._coreBrowserService.mainDocument.createElement("div");return a.setAttribute("role","listitem"),a.tabIndex=-1,this._refreshRowDimensions(a),a}_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 a=0;a<this._terminal.rows;a++)this._refreshRowDimensions(this._rowElements[a]),this._alignRowWidth(this._rowElements[a])}}_refreshRowDimensions(a){a.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(a){a.style.transform="";let b=a.getBoundingClientRect().width,c=this._rowColumns.get(a)?.slice(-1)?.[0];if(!c)return;let d=c*this._renderService.dimensions.css.cell.width;a.style.transform=`scaleX(${d/b})`}};kV=fH([fI(1,f3),fI(2,gb),fI(3,gd)],kV);var kW=class extends gy{constructor(a,b,c,d,e){super(),this._element=a,this._mouseService=b,this._renderService=c,this._bufferService=d,this._linkProviderService=e,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new gZ),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new gZ),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(gv(()=>{gu(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(h$(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(h$(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(h$(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(h$(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(a){this._lastMouseEvent=a;let b=this._positionFromMouseEvent(a,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;let c=a.composedPath();for(let a=0;a<c.length;a++){let b=c[a];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(a){if(this._activeLine!==a.y||this._wasResized){this._clearCurrentLink(),this._askForLink(a,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,a)||(this._clearCurrentLink(),this._askForLink(a,!0))}_askForLink(a,b){this._activeProviderReplies&&b||(this._activeProviderReplies?.forEach(a=>{a?.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=a.y);let c=!1;for(let[d,e]of this._linkProviderService.linkProviders.entries())b?this._activeProviderReplies?.get(d)&&(c=this._checkLinkProviderResult(d,a,c)):e.provideLinks(a.y,b=>{if(this._isMouseOut)return;let e=b?.map(a=>({link:a}));this._activeProviderReplies?.set(d,e),c=this._checkLinkProviderResult(d,a,c),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(a.y,this._activeProviderReplies)})}_removeIntersectingLinks(a,b){let c=new Set;for(let d=0;d<b.size;d++){let e=b.get(d);if(e)for(let b=0;b<e.length;b++){let d=e[b],f=d.link.range.start.y<a?0:d.link.range.start.x,g=d.link.range.end.y>a?this._bufferService.cols:d.link.range.end.x;for(let a=f;a<=g;a++){if(c.has(a)){e.splice(b--,1);break}c.add(a)}}}}_checkLinkProviderResult(a,b,c){if(!this._activeProviderReplies)return c;let d=this._activeProviderReplies.get(a),e=!1;for(let b=0;b<a;b++)(!this._activeProviderReplies.has(b)||this._activeProviderReplies.get(b))&&(e=!0);if(!e&&d){let a=d.find(a=>this._linkAtPosition(a.link,b));a&&(c=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!c)for(let a=0;a<this._activeProviderReplies.size;a++){let d=this._activeProviderReplies.get(a)?.find(a=>this._linkAtPosition(a.link,b));if(d){c=!0,this._handleNewLink(d);break}}return c}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(a){var b,c;if(!this._currentLink)return;let d=this._positionFromMouseEvent(a,this._element,this._mouseService);d&&this._mouseDownLink&&(b=this._mouseDownLink.link,c=this._currentLink.link,b.text===c.text&&b.range.start.x===c.range.start.x&&b.range.start.y===c.range.start.y&&b.range.end.x===c.range.end.x&&b.range.end.y===c.range.end.y)&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(a,this._currentLink.link.text)}_clearCurrentLink(a,b){this._currentLink&&this._lastMouseEvent&&(!a||!b||this._currentLink.link.range.start.y>=a&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,gu(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(a){if(!this._lastMouseEvent)return;let b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(a.link,b)&&(this._currentLink=a,this._currentLink.state={decorations:{underline:void 0===a.link.decorations||a.link.decorations.underline,pointerCursor:void 0===a.link.decorations||a.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,a.link,this._lastMouseEvent),a.link.decorations={},Object.defineProperties(a.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:a=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==a&&(this._currentLink.state.decorations.pointerCursor=a,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",a))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:b=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==b&&(this._currentLink.state.decorations.underline=b,this._currentLink.state.isHovered&&this._fireUnderlineEvent(a.link,b))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(a=>{if(!this._currentLink)return;let b=0===a.start?0:a.start+1+this._bufferService.buffer.ydisp,c=this._bufferService.buffer.ydisp+1+a.end;if(this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=c&&(this._clearCurrentLink(b,c),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&a.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(c,b.text)}_fireUnderlineEvent(a,b){let c=a.range,d=this._bufferService.buffer.ydisp,e=this._createLinkUnderlineEvent(c.start.x-1,c.start.y-d-1,c.end.x,c.end.y-d-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(e)}_linkLeave(a,b,c){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&a.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(c,b.text)}_linkAtPosition(a,b){let c=a.range.start.y*this._bufferService.cols+a.range.start.x,d=a.range.end.y*this._bufferService.cols+a.range.end.x,e=b.y*this._bufferService.cols+b.x;return c<=e&&e<=d}_positionFromMouseEvent(a,b,c){let d=c.getCoords(a,b,this._bufferService.cols,this._bufferService.rows);if(d)return{x:d[0],y:d[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(a,b,c,d,e){return{x1:a,y1:b,x2:c,y2:d,cols:this._bufferService.cols,fg:e}}};kW=fH([fI(1,gc),fI(2,gd),fI(3,f_),fI(4,gh)],kW);var kX=class extends kM{constructor(a={}){super(a),this._linkifier=this._register(new gz),this.browser=jb,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new gz),this._onCursorMove=this._register(new gZ),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new gZ),this.onKey=this._onKey.event,this._onRender=this._register(new gZ),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new gZ),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new gZ),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new gZ),this.onBell=this._onBell.event,this._onFocus=this._register(new gZ),this._onBlur=this._register(new gZ),this._onA11yCharEmitter=this._register(new gZ),this._onA11yTabEmitter=this._register(new gZ),this._onWillOpen=this._register(new gZ),this._setup(),this._decorationService=this._instantiationService.createInstance(kS),this._instantiationService.setService(f8,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(i7),this._instantiationService.setService(gh,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(f9)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(a=>this.refresh(a?.start??0,a?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(a=>this._reportWindowsOptions(a))),this._register(this._inputHandler.onColor(a=>this._handleColorEvent(a))),this._register(gS.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(gS.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(gS.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(gS.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(a=>this._afterResize(a.cols,a.rows))),this._register(gv(()=>{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(a){if(this._themeService)for(let b of a){let a,c="";switch(b.index){case 256:a="foreground",c="10";break;case 257:a="background",c="11";break;case 258:a="cursor",c="12";break;default:a="ansi",c="4;"+b.index}switch(b.type){case 0:let d=kd.toColorRGB("ansi"===a?this._themeService.colors.ansi[b.index]:this._themeService.colors[a]);this.coreService.triggerDataEvent(`${iD.ESC}]${c};${function(a,b=16){let[c,d,e]=a;return`rgb:${kC(c,b)}/${kC(d,b)}/${kC(e,b)}`}(d)}${iF.ST}`);break;case 1:if("ansi"===a)this._themeService.modifyColors(a=>a.ansi[b.index]=iG.toColor(...b.color));else{let c=a;this._themeService.modifyColors(a=>a[c]=iG.toColor(...b.color))}break;case 2:this._themeService.restoreColor(b.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(a){a?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(kV,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(a){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(iD.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(iD.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let a=this.buffer.ybase+this.buffer.y,b=this.buffer.lines.get(a);if(!b)return;let c=Math.min(this.buffer.x,this.cols-1),d=this._renderService.dimensions.css.cell.height,e=b.getWidth(c),f=this._renderService.dimensions.css.cell.width*e,g=this.buffer.y*this._renderService.dimensions.css.cell.height,h=c*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=g+"px",this.textarea.style.width=f+"px",this.textarea.style.height=d+"px",this.textarea.style.lineHeight=d+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(h$(this.element,"copy",a=>{var b;this.hasSelection()&&(b=this._selectionService,a.clipboardData&&a.clipboardData.setData("text/plain",b.selectionText),a.preventDefault())}));let a=a=>{var b,c,d;return b=this.textarea,c=this.coreService,d=this.optionsService,void(a.stopPropagation(),a.clipboardData&&fN(a.clipboardData.getData("text/plain"),b,c,d))};this._register(h$(this.textarea,"paste",a)),this._register(h$(this.element,"paste",a)),jf?this._register(h$(this.element,"mousedown",a=>{2===a.button&&fP(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(h$(this.element,"contextmenu",a=>{fP(a,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jn&&this._register(h$(this.element,"auxclick",a=>{1===a.button&&fO(a,this.textarea,this.screenElement)}))}_bindKeys(){this._register(h$(this.textarea,"keyup",a=>this._keyUp(a),!0)),this._register(h$(this.textarea,"keydown",a=>this._keyDown(a),!0)),this._register(h$(this.textarea,"keypress",a=>this._keyPress(a),!0)),this._register(h$(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(h$(this.textarea,"compositionupdate",a=>this._compositionHelper.compositionupdate(a))),this._register(h$(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(h$(this.textarea,"input",a=>this._inputEvent(a),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(a){if(!a)throw Error("Terminal requires a parent element.");if(a.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=a.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"),a.appendChild(this.element);let b=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),b.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(h$(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),b.appendChild(this.screenElement);let c=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",fK.get()),jo||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",()=>c.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(i5,this.textarea,a.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(gb,this._coreBrowserService),this._register(h$(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(h$(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(i1,this._document,this._helperContainer),this._instantiationService.setService(ga,this._charSizeService),this._themeService=this._instantiationService.createInstance(jM),this._instantiationService.setService(gg,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(iP),this._instantiationService.setService(gf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ju,this.rows,this.screenElement)),this._instantiationService.setService(gd,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(iy,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(i9),this._instantiationService.setService(gc,this._mouseService);let d=this._linkifier.value=this._register(this._instantiationService.createInstance(kW,this.screenElement));this.element.appendChild(b);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(ir,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jE,this.element,this.screenElement,d)),this._instantiationService.setService(ge,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(gS.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(is,this.screenElement)),this._register(h$(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(kV,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ix,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ix,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(i0,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let a=this,b=this.element;function c(b){let c,d,e=a._mouseService.getMouseReportCoords(b,a.screenElement);if(!e)return!1;switch(b.overrideType||b.type){case"mousemove":d=32,void 0===b.buttons?(c=3,void 0!==b.button&&(c=b.button<3?b.button:3)):c=1&b.buttons?0:4&b.buttons?1:2&b.buttons?2:3;break;case"mouseup":d=0,c=b.button<3?b.button:3;break;case"mousedown":d=1,c=b.button<3?b.button:3;break;case"wheel":if(a._customWheelEventHandler&&!1===a._customWheelEventHandler(b))return!1;let f=b.deltaY;if(0===f||0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return!1;d=f<0?0:1,c=4;break;default:return!1}return void 0!==d&&void 0!==c&&!(c>4)&&a.coreMouseService.triggerMouseEvent({col:e.col,row:e.row,x:e.x,y:e.y,button:c,action:d,ctrl:b.ctrlKey,alt:b.altKey,shift:b.shiftKey})}let d={mouseup:null,wheel:null,mousedrag:null,mousemove:null},e=a=>(c(a),a.buttons||(this._document.removeEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.removeEventListener("mousemove",d.mousedrag)),this.cancel(a)),f=a=>(c(a),this.cancel(a,!0)),g=a=>{a.buttons&&c(a)},h=a=>{a.buttons||c(a)};this._register(this.coreMouseService.onProtocolChange(a=>{a?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&a?d.mousemove||(b.addEventListener("mousemove",h),d.mousemove=h):(b.removeEventListener("mousemove",d.mousemove),d.mousemove=null),16&a?d.wheel||(b.addEventListener("wheel",f,{passive:!1}),d.wheel=f):(b.removeEventListener("wheel",d.wheel),d.wheel=null),2&a?d.mouseup||(d.mouseup=e):(this._document.removeEventListener("mouseup",d.mouseup),d.mouseup=null),4&a?d.mousedrag||(d.mousedrag=g):(this._document.removeEventListener("mousemove",d.mousedrag),d.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(h$(b,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return c(a),d.mouseup&&this._document.addEventListener("mouseup",d.mouseup),d.mousedrag&&this._document.addEventListener("mousemove",d.mousedrag),this.cancel(a)})),this._register(h$(b,"wheel",b=>{if(!d.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(b))return!1;if(!this.buffer.hasScrollback){if(0===b.deltaY)return!1;if(0===a.coreMouseService.consumeWheelEvent(b,a._renderService?.dimensions?.device?.cell?.height,a._coreBrowserService?.dpr))return this.cancel(b,!0);let c=iD.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(b.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(b,!0)}}},{passive:!1}))}refresh(a,b){this._renderService?.refreshRows(a,b)}updateCursorStyle(a){this._selectionService?.shouldColumnSelect(a)?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(a,b){this._viewport?this._viewport.scrollLines(a):super.scrollLines(a,b),this.refresh(0,this.rows-1)}scrollPages(a){this.scrollLines(a*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(a){a&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(a){let b=a-this._bufferService.buffer.ydisp;0!==b&&this.scrollLines(b)}paste(a){fN(a,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(a){this._customKeyEventHandler=a}attachCustomWheelEventHandler(a){this._customWheelEventHandler=a}registerLinkProvider(a){return this._linkProviderService.registerLinkProvider(a)}registerCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let b=this._characterJoinerService.register(a);return this.refresh(0,this.rows-1),b}deregisterCharacterJoiner(a){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(a)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(a){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+a)}registerDecoration(a){return this._decorationService.registerDecoration(a)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(a,b,c){this._selectionService.setSelection(a,b,c)}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(a,b){this._selectionService?.selectLines(a,b)}_keyDown(a){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;let b=this.browser.isMac&&this.options.macOptionIsMeta&&a.altKey;if(!b&&!this._compositionHelper.keydown(a))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;b||"Dead"!==a.key&&"AltGraph"!==a.key||(this._unprocessedDeadKey=!0);let c=function(a,b,c,d){let e={type:0,cancel:!1,key:void 0},f=!!a.shiftKey|2*!!a.altKey|4*!!a.ctrlKey|8*!!a.metaKey;switch(a.keyCode){case 0:"UIKeyInputUpArrow"===a.key?b?e.key=iD.ESC+"OA":e.key=iD.ESC+"[A":"UIKeyInputLeftArrow"===a.key?b?e.key=iD.ESC+"OD":e.key=iD.ESC+"[D":"UIKeyInputRightArrow"===a.key?b?e.key=iD.ESC+"OC":e.key=iD.ESC+"[C":"UIKeyInputDownArrow"===a.key&&(b?e.key=iD.ESC+"OB":e.key=iD.ESC+"[B");break;case 8:e.key=a.ctrlKey?"\b":iD.DEL,a.altKey&&(e.key=iD.ESC+e.key);break;case 9:if(a.shiftKey){e.key=iD.ESC+"[Z";break}e.key=iD.HT,e.cancel=!0;break;case 13:e.key=a.altKey?iD.ESC+iD.CR:iD.CR,e.cancel=!0;break;case 27:e.key=iD.ESC,a.altKey&&(e.key=iD.ESC+iD.ESC),e.cancel=!0;break;case 37:if(a.metaKey)break;f?e.key=iD.ESC+"[1;"+(f+1)+"D":b?e.key=iD.ESC+"OD":e.key=iD.ESC+"[D";break;case 39:if(a.metaKey)break;f?e.key=iD.ESC+"[1;"+(f+1)+"C":b?e.key=iD.ESC+"OC":e.key=iD.ESC+"[C";break;case 38:if(a.metaKey)break;f?e.key=iD.ESC+"[1;"+(f+1)+"A":b?e.key=iD.ESC+"OA":e.key=iD.ESC+"[A";break;case 40:if(a.metaKey)break;f?e.key=iD.ESC+"[1;"+(f+1)+"B":b?e.key=iD.ESC+"OB":e.key=iD.ESC+"[B";break;case 45:a.shiftKey||a.ctrlKey||(e.key=iD.ESC+"[2~");break;case 46:f?e.key=iD.ESC+"[3;"+(f+1)+"~":e.key=iD.ESC+"[3~";break;case 36:f?e.key=iD.ESC+"[1;"+(f+1)+"H":b?e.key=iD.ESC+"OH":e.key=iD.ESC+"[H";break;case 35:f?e.key=iD.ESC+"[1;"+(f+1)+"F":b?e.key=iD.ESC+"OF":e.key=iD.ESC+"[F";break;case 33:a.shiftKey?e.type=2:a.ctrlKey?e.key=iD.ESC+"[5;"+(f+1)+"~":e.key=iD.ESC+"[5~";break;case 34:a.shiftKey?e.type=3:a.ctrlKey?e.key=iD.ESC+"[6;"+(f+1)+"~":e.key=iD.ESC+"[6~";break;case 112:f?e.key=iD.ESC+"[1;"+(f+1)+"P":e.key=iD.ESC+"OP";break;case 113:f?e.key=iD.ESC+"[1;"+(f+1)+"Q":e.key=iD.ESC+"OQ";break;case 114:f?e.key=iD.ESC+"[1;"+(f+1)+"R":e.key=iD.ESC+"OR";break;case 115:f?e.key=iD.ESC+"[1;"+(f+1)+"S":e.key=iD.ESC+"OS";break;case 116:f?e.key=iD.ESC+"[15;"+(f+1)+"~":e.key=iD.ESC+"[15~";break;case 117:f?e.key=iD.ESC+"[17;"+(f+1)+"~":e.key=iD.ESC+"[17~";break;case 118:f?e.key=iD.ESC+"[18;"+(f+1)+"~":e.key=iD.ESC+"[18~";break;case 119:f?e.key=iD.ESC+"[19;"+(f+1)+"~":e.key=iD.ESC+"[19~";break;case 120:f?e.key=iD.ESC+"[20;"+(f+1)+"~":e.key=iD.ESC+"[20~";break;case 121:f?e.key=iD.ESC+"[21;"+(f+1)+"~":e.key=iD.ESC+"[21~";break;case 122:f?e.key=iD.ESC+"[23;"+(f+1)+"~":e.key=iD.ESC+"[23~";break;case 123:f?e.key=iD.ESC+"[24;"+(f+1)+"~":e.key=iD.ESC+"[24~";break;default:if(!a.ctrlKey||a.shiftKey||a.altKey||a.metaKey)if((!c||d)&&a.altKey&&!a.metaKey){let b=kN[a.keyCode]?.[+!!a.shiftKey];if(b)e.key=iD.ESC+b;else if(a.keyCode>=65&&a.keyCode<=90){let b=String.fromCharCode(a.ctrlKey?a.keyCode-64:a.keyCode+32);a.shiftKey&&(b=b.toUpperCase()),e.key=iD.ESC+b}else if(32===a.keyCode)e.key=iD.ESC+(a.ctrlKey?iD.NUL:" ");else if("Dead"===a.key&&a.code.startsWith("Key")){let b=a.code.slice(3,4);a.shiftKey||(b=b.toLowerCase()),e.key=iD.ESC+b,e.cancel=!0}}else!c||a.altKey||a.ctrlKey||a.shiftKey||!a.metaKey?!a.key||a.ctrlKey||a.altKey||a.metaKey||!(a.keyCode>=48)||1!==a.key.length?a.key&&a.ctrlKey&&("_"===a.key&&(e.key=iD.US),"@"===a.key&&(e.key=iD.NUL)):e.key=a.key:65===a.keyCode&&(e.type=1);else a.keyCode>=65&&a.keyCode<=90?e.key=String.fromCharCode(a.keyCode-64):32===a.keyCode?e.key=iD.NUL:a.keyCode>=51&&a.keyCode<=55?e.key=String.fromCharCode(a.keyCode-51+27):56===a.keyCode?e.key=iD.DEL:219===a.keyCode?e.key=iD.ESC:220===a.keyCode?e.key=iD.FS:221===a.keyCode&&(e.key=iD.GS)}return e}(a,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(a),3===c.type||2===c.type){let b=this.rows-1;return this.scrollLines(2===c.type?-b:b),this.cancel(a,!0)}return 1===c.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,a)||(c.cancel&&this.cancel(a,!0),!c.key)||a.key&&!a.ctrlKey&&!a.altKey&&!a.metaKey&&1===a.key.length&&a.key.charCodeAt(0)>=65&&90>=a.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((c.key===iD.ETX||c.key===iD.CR)&&(this.textarea.value=""),this._onKey.fire({key:c.key,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(c.key,!0),!this.optionsService.rawOptions.screenReaderMode||a.altKey||a.ctrlKey)?this.cancel(a,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(a,b){let c=a.isMac&&!this.options.macOptionIsMeta&&b.altKey&&!b.ctrlKey&&!b.metaKey||a.isWindows&&b.altKey&&b.ctrlKey&&!b.metaKey||a.isWindows&&b.getModifierState("AltGraph");return"keypress"===b.type?c:c&&(!b.keyCode||b.keyCode>47)}_keyUp(a){var b;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(a)||(16===(b=a).keyCode||17===b.keyCode||18===b.keyCode||this.focus(),this.updateCursorStyle(a),this._keyPressHandled=!1)}_keyPress(a){let b;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(a))return!1;if(this.cancel(a),a.charCode)b=a.charCode;else if(null===a.which||void 0===a.which)b=a.keyCode;else{if(0===a.which||0===a.charCode)return!1;b=a.which}return!!b&&(!a.altKey&&!a.ctrlKey&&!a.metaKey||!!this._isThirdLevelShift(this.browser,a))&&(b=String.fromCharCode(b),this._onKey.fire({key:b,domEvent:a}),this._showCursor(),this.coreService.triggerDataEvent(b,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(a){if(a.data&&"insertText"===a.inputType&&(!a.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let b=a.data;return this.coreService.triggerDataEvent(b,!0),this.cancel(a),!0}return!1}resize(a,b){if(a===this.cols&&b===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(a,b)}_afterResize(a,b){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){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 a=1;a<this.rows;a++)this.buffer.lines.push(this.buffer.getBlankLine(jT));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 a=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=a,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(iD.ESC+"[I"):this.coreService.triggerDataEvent(iD.ESC+"[O")}_reportWindowsOptions(a){if(this._renderService)switch(a){case 0:let b=this._renderService.dimensions.css.canvas.width.toFixed(0),c=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${iD.ESC}[4;${c};${b}t`);break;case 1:let d=this._renderService.dimensions.css.cell.width.toFixed(0),e=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${iD.ESC}[6;${e};${d}t`)}}cancel(a,b){if(!(!this.options.cancelEvents&&!b))return a.preventDefault(),a.stopPropagation(),!1}},kY=class{constructor(){this._addons=[]}dispose(){for(let a=this._addons.length-1;a>=0;a--)this._addons[a].instance.dispose()}loadAddon(a,b){let c={instance:b,dispose:b.dispose,isDisposed:!1};this._addons.push(c),b.dispose=()=>this._wrappedAddonDispose(c),b.activate(a)}_wrappedAddonDispose(a){if(a.isDisposed)return;let b=-1;for(let c=0;c<this._addons.length;c++)if(this._addons[c]===a){b=c;break}if(-1===b)throw Error("Could not dispose an addon that has not been loaded");a.isDisposed=!0,a.dispose.apply(a.instance),this._addons.splice(b,1)}},kZ=class{constructor(a){this._line=a}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(a,b){if(!(a<0||a>=this._line.length))return b?(this._line.loadCell(a,b),b):this._line.loadCell(a,new fW)}translateToString(a,b,c){return this._line.translateToString(a,b,c)}},k$=class{constructor(a,b){this._buffer=a,this.type=b}init(a){return this._buffer=a,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(a){let b=this._buffer.lines.get(a);if(b)return new kZ(b)}getNullCell(){return new fW}},k_=class extends gy{constructor(a){super(),this._core=a,this._onBufferChange=this._register(new gZ),this.onBufferChange=this._onBufferChange.event,this._normal=new k$(this._core.buffers.normal,"normal"),this._alternate=new k$(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},k0=class{constructor(a){this._core=a}registerCsiHandler(a,b){return this._core.registerCsiHandler(a,a=>b(a.toArray()))}addCsiHandler(a,b){return this.registerCsiHandler(a,b)}registerDcsHandler(a,b){return this._core.registerDcsHandler(a,(a,c)=>b(a,c.toArray()))}addDcsHandler(a,b){return this.registerDcsHandler(a,b)}registerEscHandler(a,b){return this._core.registerEscHandler(a,b)}addEscHandler(a,b){return this.registerEscHandler(a,b)}registerOscHandler(a,b){return this._core.registerOscHandler(a,b)}addOscHandler(a,b){return this.registerOscHandler(a,b)}},k1=class{constructor(a){this._core=a}register(a){this._core.unicodeService.register(a)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(a){this._core.unicodeService.activeVersion=a}},k2=["cols","rows"],k3=0,k4=class extends gy{constructor(a){super(),this._core=this._register(new kX(a)),this._addonManager=this._register(new kY),this._publicOptions={...this._core.options};let b=a=>this._core.options[a],c=(a,b)=>{this._checkReadonlyOptions(a),this._core.options[a]=b};for(let a in this._core.options){let d={get:b.bind(this,a),set:c.bind(this,a)};Object.defineProperty(this._publicOptions,a,d)}}_checkReadonlyOptions(a){if(k2.includes(a))throw Error(`Option "${a}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get 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 k0(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new k1(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 k_(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let a=this._core.coreService.decPrivateModes,b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:a.applicationCursorKeys,applicationKeypadMode:a.applicationKeypad,bracketedPasteMode:a.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:a.origin,reverseWraparoundMode:a.reverseWraparound,sendFocusMode:a.sendFocus,synchronizedOutputMode:a.synchronizedOutput,wraparoundMode:a.wraparound}}get options(){return this._publicOptions}set options(a){for(let b in a)this._publicOptions[b]=a[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(a,b=!0){this._core.input(a,b)}resize(a,b){this._verifyIntegers(a,b),this._core.resize(a,b)}open(a){this._core.open(a)}attachCustomKeyEventHandler(a){this._core.attachCustomKeyEventHandler(a)}attachCustomWheelEventHandler(a){this._core.attachCustomWheelEventHandler(a)}registerLinkProvider(a){return this._core.registerLinkProvider(a)}registerCharacterJoiner(a){return this._checkProposedApi(),this._core.registerCharacterJoiner(a)}deregisterCharacterJoiner(a){this._checkProposedApi(),this._core.deregisterCharacterJoiner(a)}registerMarker(a=0){return this._verifyIntegers(a),this._core.registerMarker(a)}registerDecoration(a){return this._checkProposedApi(),this._verifyPositiveIntegers(a.x??0,a.width??0,a.height??0),this._core.registerDecoration(a)}hasSelection(){return this._core.hasSelection()}select(a,b,c){this._verifyIntegers(a,b,c),this._core.select(a,b,c)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(a,b){this._verifyIntegers(a,b),this._core.selectLines(a,b)}dispose(){super.dispose()}scrollLines(a){this._verifyIntegers(a),this._core.scrollLines(a)}scrollPages(a){this._verifyIntegers(a),this._core.scrollPages(a)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(a){this._verifyIntegers(a),this._core.scrollToLine(a)}clear(){this._core.clear()}write(a,b){this._core.write(a,b)}writeln(a,b){this._core.write(a),this._core.write(`\r
27
- `,b)}paste(a){this._core.paste(a)}refresh(a,b){this._verifyIntegers(a,b),this._core.refresh(a,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(a){this._addonManager.loadAddon(this,a)}static get strings(){return{get promptLabel(){return fK.get()},set promptLabel(t){fK.set(t)},get tooMuchOutput(){return fM.get()},set tooMuchOutput(t){fM.set(t)}}}_verifyIntegers(...a){for(k3 of a)if(k3===1/0||isNaN(k3)||k3%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...a){for(k3 of a)if(k3&&(k3===1/0||isNaN(k3)||k3%1!=0||k3<0))throw Error("This API only accepts positive integers")}},k5=class{activate(a){this._terminal=a}dispose(){}fit(){let a=this.proposeDimensions();if(!a||!this._terminal||isNaN(a.cols)||isNaN(a.rows))return;let b=this._terminal._core;(this._terminal.rows!==a.rows||this._terminal.cols!==a.cols)&&(b._renderService.clear(),this._terminal.resize(a.cols,a.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let a=this._terminal._core._renderService.dimensions;if(0===a.css.cell.width||0===a.css.cell.height)return;let b=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,c=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(c.getPropertyValue("height")),e=Math.max(0,parseInt(c.getPropertyValue("width"))),f=window.getComputedStyle(this._terminal.element),g={top:parseInt(f.getPropertyValue("padding-top")),bottom:parseInt(f.getPropertyValue("padding-bottom")),right:parseInt(f.getPropertyValue("padding-right")),left:parseInt(f.getPropertyValue("padding-left"))},h=g.top+g.bottom;return{cols:Math.max(2,Math.floor((e-(g.right+g.left)-b)/a.css.cell.width)),rows:Math.max(1,Math.floor((d-h)/a.css.cell.height))}}};c(7833);let k6=m("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),k7=(0,e.forwardRef)(({active:a,running:b=!1,onInput:c,onResize:f},g)=>{let h=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,e.useRef)(null),k=(0,e.useRef)(c),l=(0,e.useRef)(f);return k.current=c,l.current=f,(0,e.useImperativeHandle)(g,()=>({write:a=>i.current?.write(a),clear:()=>i.current?.clear(),focus:()=>i.current?.focus()}),[]),(0,e.useEffect)(()=>{if(!h.current)return;let a=new k4({cursorBlink:!0,theme:{background:"#000000",foreground:"#a1a1aa",cursor:"#f4f4f5",selectionBackground:"#27272a"},fontFamily:'Menlo, Monaco, Consolas, "Courier New", monospace',fontSize:11}),b=new k5;a.loadAddon(b),a.open(h.current);try{b.fit()}catch{}i.current=a,j.current=b;let c=a.onData(a=>k.current?.(a)),d=a.onResize(({cols:a,rows:b})=>l.current?.(a,b));l.current?.(a.cols,a.rows);let e=new ResizeObserver(()=>{try{b.fit()}catch{}});return e.observe(h.current),()=>{e.disconnect(),c.dispose(),d.dispose(),a.dispose(),i.current=null,j.current=null}},[]),(0,e.useEffect)(()=>{if(!a)return;let b=requestAnimationFrame(()=>{try{j.current?.fit()}catch{}i.current?.focus()});return()=>cancelAnimationFrame(b)},[a]),(0,d.jsxs)("div",{className:"flex flex-col h-full bg-black border-t border-zinc-800",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center px-4 py-2 border-b border-zinc-900 bg-zinc-950 shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(k6,{size:14,className:"text-zinc-500"}),(0,d.jsx)("span",{className:"font-mono text-xs font-semibold tracking-wider text-zinc-400",children:"CONSOLE OUTPUT"}),b&&(0,d.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-blue-500 animate-pulse"})]}),(0,d.jsx)("button",{onClick:()=>i.current?.clear(),title:"Clear console",className:"p-1 hover:bg-zinc-800 rounded transition text-zinc-500 hover:text-zinc-300",children:(0,d.jsx)(r,{size:14})})]}),(0,d.jsx)("div",{ref:h,onClick:()=>i.current?.focus(),className:"flex-1 w-full min-h-0 p-2 overflow-hidden"})]})});k7.displayName="AgentConsole";let k8=m("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),k9=({isOpen:a,onClose:b,persona:c,onSave:f})=>{let[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(!0),[m,n]=(0,e.useState)("gemini-2.5-flash"),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,u]=(0,e.useState)(""),[v,w]=(0,e.useState)("");return((0,e.useEffect)(()=>{c&&(h(c.label||""),j(c.command||""),l(!1!==c.enabled),n(c.model||"gemini-2.5-flash"),p(c.description||""),r(c.systemPrompt||""),u(Array.isArray(c.capabilities)?c.capabilities.join("\n"):""),w(Array.isArray(c.tools)?c.tools.join("\n"):""))},[c,a]),a&&c)?(0,d.jsx)("div",{className:"fixed inset-0 bg-black/85 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-zinc-950 border border-zinc-850 w-full max-w-2xl h-[85vh] rounded-xl flex flex-col overflow-hidden shadow-2xl animate-in fade-in zoom-in duration-200",children:[(0,d.jsxs)("header",{className:"px-6 py-4 border-b border-zinc-850 flex justify-between items-center bg-zinc-900/50",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 bg-blue-500/10 text-blue-400 rounded-lg",children:(0,d.jsx)(k8,{size:18})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-base font-bold text-white tracking-tight",children:["Configure Persona Agent: ",c.id.toUpperCase()]}),(0,d.jsx)("p",{className:"text-xs text-zinc-400 mt-0.5",children:"Customize capabilities, core instructions, models, and slash command integration."})]})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 hover:bg-zinc-800 rounded-lg text-zinc-400 hover:text-zinc-200 transition",children:(0,d.jsx)(x,{size:18})})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"Persona Name"}),(0,d.jsx)("input",{type:"text",value:g,onChange:a=>h(a.target.value),className:"w-full px-3 py-2 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. QA Agent"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"LLM Model"}),(0,d.jsxs)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full px-3 py-2 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",children:[(0,d.jsx)("option",{value:"gemini-2.5-flash",children:"Gemini 2.5 Flash (Fast, Google)"}),(0,d.jsx)("option",{value:"gemini-2.5-pro",children:"Gemini 2.5 Pro (Analytical, Google)"}),(0,d.jsx)("option",{value:"claude-3-5-sonnet",children:"Claude 3.5 Sonnet (Coding, Anthropic)"}),(0,d.jsx)("option",{value:"gpt-4o",children:"GPT-4o (Reasoning, OpenAI)"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-center",children:[(0,d.jsxs)("div",{className:"md:col-span-2",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"Slash Command / Execution Path"}),(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),className:"w-full px-3 py-2 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. /speckit.review.qa"})]}),(0,d.jsx)("div",{className:"flex items-center h-full pt-4",children:(0,d.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:k,onChange:a=>l(a.target.checked),className:"w-4 h-4 rounded border-zinc-800 bg-zinc-900 text-blue-500 focus:ring-0 focus:ring-offset-0"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-white",children:"Enable Agent Persona"}),(0,d.jsx)("span",{className:"text-[10px] text-zinc-500",children:"Run persona in review gate"})]})]})})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Agent Description"}),(0,d.jsx)("textarea",{rows:2,value:o,onChange:a=>p(a.target.value),className:"w-full p-3 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700 resize-none",placeholder:"Provide a general summary of this agent's responsibilities..."})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"System Prompt & Core Instructions"}),(0,d.jsx)("textarea",{rows:5,value:q,onChange:a=>r(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"System prompt instructions..."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Capabilities (one per line)"}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 flex items-center gap-0.5",children:[(0,d.jsx)(y,{size:10})," Environment injection"]})]}),(0,d.jsx)("textarea",{rows:4,value:s,onChange:a=>u(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. Runs Vitest suite"})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Authorized Tools (one per line)"}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 flex items-center gap-0.5",children:[(0,d.jsx)(y,{size:10})," CLI commands"]})]}),(0,d.jsx)("textarea",{rows:4,value:v,onChange:a=>w(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. npm test"})]})]})]}),(0,d.jsxs)("footer",{className:"px-6 py-4 border-t border-zinc-850 flex justify-end gap-3 bg-zinc-900/30",children:[(0,d.jsx)("button",{onClick:b,className:"px-4 py-2 bg-zinc-900 hover:bg-zinc-850 border border-zinc-850 hover:border-zinc-800 text-zinc-300 font-semibold text-xs rounded-lg transition",children:"Cancel"}),(0,d.jsxs)("button",{onClick:()=>{let a=s.split("\n").map(a=>a.trim()).filter(a=>a.length>0),b=v.split("\n").map(a=>a.trim()).filter(a=>a.length>0);f({...c,label:g,command:i,enabled:k,model:m,description:o,systemPrompt:q,capabilities:a,tools:b})},className:"px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white font-semibold text-xs rounded-lg transition flex items-center gap-1.5",children:[(0,d.jsx)(ft,{size:14}),(0,d.jsx)("span",{children:"Save Configuration"})]})]})]})}):null},la=m("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),lb=m("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),lc=m("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),ld=m("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),le=m("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),lf={developer:"Developer",qa:"QA Agent","code-review":"Code Reviewer",security:"Security Auditor","tech-lead":"Tech Lead"},lg={developer:"Implements features and writes source code.",qa:"Runs unit and integration test suites.","code-review":"Reviews code styles and architectural patterns.",security:"Checks for security vulnerabilities and secrets.","tech-lead":"Performs final technical audit and validation."},lh=({isOpen:a,onClose:b,featureName:c,activePhaseState:f,onApprove:g})=>{let[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[q,r]=(0,e.useState)("main"),[u,v]=(0,e.useState)(!1),[w,y]=(0,e.useState)(""),[A,B]=(0,e.useState)("files"),[C,D]=(0,e.useState)("");if((0,e.useEffect)(()=>{if(!a)return;let b=!0;return v(!0),y(""),fetch("/api/git?action=status").then(a=>{if(!a.ok)throw Error(`HTTP error! status: ${a.status}`);return a.json()}).then(a=>{b&&(a.error?y(a.error):(i(a.files||[]),k(a.log||[]),r(a.branch||"main"),a.files&&a.files.length>0?m(a.files[0].path):m("")))}).catch(a=>{b&&y(a.message||"Failed to fetch git status.")}).finally(()=>{b&&v(!1)}),()=>{b=!1}},[a]),(0,e.useEffect)(()=>{if(!a||!l)return void o("");let b=!0;return o("Loading diff..."),fetch(`/api/git?action=diff&file=${encodeURIComponent(l)}`).then(a=>{if(!a.ok)throw Error(`HTTP error! status: ${a.status}`);return a.json()}).then(a=>{b&&(a.error?o(`Error: ${a.error}`):o(a.diff||"No modifications found."))}).catch(a=>{b&&o(`Failed to load diff: ${a.message}`)}),()=>{b=!1}},[a,l]),!a)return null;let E=h.reduce((a,b)=>a+b.additions,0),F=h.reduce((a,b)=>a+b.deletions,0),G=f&&"idle"!==f.status?"running"===f.status?f.personas?.some(a=>"idle"!==a.status)?"passed":"running":"passed":"idle",H=f?.personas?.find(a=>"qa"===a.id),I=H?H.status:"idle",J=f?.personas?.find(a=>"security"===a.id),K=J?J.status:"idle",L=f?.personas?.length||0,M=f?.personas?.filter(a=>"passed"===a.status).length||0,N=L>0?Math.round(M/L*100):100*("passed"===G),O=[{id:"developer",label:lf.developer,desc:lg.developer,status:G},...(f?.personas||[]).map(a=>({id:a.id,label:lf[a.id]||a.id,desc:lg[a.id]||"",status:a.status}))];return(0,d.jsx)("div",{className:"fixed inset-0 bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-zinc-950 border border-zinc-850 w-full h-[95vh] rounded-xl flex flex-col overflow-hidden shadow-2xl animate-in fade-in zoom-in duration-200",children:[(0,d.jsxs)("header",{className:"px-6 py-4 border-b border-zinc-850 flex justify-between items-center bg-zinc-900/50",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"text-2xl",children:"⚡"}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("h2",{className:"text-base font-bold text-white tracking-tight",children:["Human Audit Portal: ",c]}),(0,d.jsx)("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded bg-blue-500/10 text-blue-400 border border-blue-500/20 uppercase animate-pulse",children:"Awaiting Sign-off"})]}),(0,d.jsx)("p",{className:"text-xs text-zinc-400 mt-0.5",children:"Inspect code changes, check agent validation reports, and sign off the gate to approve implementation."})]})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 hover:bg-zinc-800 rounded-lg text-zinc-400 hover:text-zinc-200 transition",children:(0,d.jsx)(x,{size:18})})]}),w&&(0,d.jsxs)("div",{className:"mx-6 mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-xs text-red-400",children:[(0,d.jsx)(la,{size:14,className:"shrink-0"}),(0,d.jsx)("span",{children:w})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 px-6 py-4 border-b border-zinc-850 bg-zinc-950",children:[(0,d.jsxs)("div",{className:"p-3 bg-zinc-900/40 border border-zinc-850/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-green-500/10 text-green-400",children:(0,d.jsx)(fC,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Tests Coverage"}),(0,d.jsx)("div",{className:"text-sm font-bold text-white mt-0.5",children:"passed"===I?"100% Passed":"running"===I?"Running...":"Awaiting QA"})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-900/40 border border-zinc-850/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-blue-500/10 text-blue-400",children:(0,d.jsx)(fA,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Lines Added"}),(0,d.jsx)("div",{className:"text-sm font-bold text-white mt-0.5",children:u?"Loading...":`+${E} / -${F} lines`})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-900/40 border border-zinc-850/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-purple-500/10 text-purple-400",children:(0,d.jsx)(s,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Security Scan"}),(0,d.jsx)("div",{className:"text-sm font-bold text-white mt-0.5",children:"passed"===K?"Grade A (Clean)":"failed"===K?"Failed":"running"===K?"Scanning...":"Awaiting Scan"})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-900/40 border border-zinc-850/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-amber-500/10 text-amber-400",children:(0,d.jsx)(lb,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Validation Duration"}),(0,d.jsx)("div",{className:"text-sm font-bold text-white mt-0.5",children:f?.personas?.some(a=>"passed"===a.status)?"1m 20s total":"0s"})]})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,d.jsxs)("div",{className:"w-80 border-r border-zinc-850 flex flex-col bg-zinc-950 shrink-0",children:[(0,d.jsxs)("div",{className:"flex border-b border-zinc-850 bg-zinc-900/20",children:[(0,d.jsx)("button",{onClick:()=>B("files"),className:`flex-1 py-2.5 text-center text-xs font-semibold border-b-2 transition ${"files"===A?"text-white border-white":"text-zinc-500 border-transparent hover:text-zinc-350"}`,children:"Modified Files"}),(0,d.jsx)("button",{onClick:()=>B("git"),className:`flex-1 py-2.5 text-center text-xs font-semibold border-b-2 transition ${"git"===A?"text-white border-white":"text-zinc-500 border-transparent hover:text-zinc-350"}`,children:"Git Commit History"})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4 space-y-1",children:"files"===A?u?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"Loading files..."}):0===h.length?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"No modified files found."}):h.map(a=>(0,d.jsxs)("div",{onClick:()=>m(a.path),className:`p-2.5 rounded-lg border text-xs cursor-pointer transition flex justify-between items-center ${l===a.path?"bg-zinc-900 border-zinc-700 text-white":"bg-transparent border-transparent text-zinc-400 hover:bg-zinc-900/50 hover:text-zinc-200"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)(fk,{size:13,className:"code"===a.type?"text-blue-400":"text-zinc-500"}),(0,d.jsx)("span",{className:"truncate font-mono text-[11px]",children:a.path.split("/").pop()})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 font-mono text-[10px] font-bold",children:[(0,d.jsxs)("span",{className:"text-green-500",children:["+",a.additions]}),(0,d.jsxs)("span",{className:"text-red-500",children:["-",a.deletions]})]})]},a.path)):(0,d.jsxs)("div",{className:"space-y-4 py-2",children:[(0,d.jsxs)("div",{className:"p-3 bg-zinc-900/30 border border-zinc-850 rounded-lg flex items-center gap-2 mb-2",children:[(0,d.jsx)(lc,{size:14,className:"text-blue-500 animate-pulse"}),(0,d.jsx)("span",{className:"text-xs text-zinc-300 font-bold",children:q}),(0,d.jsx)(ld,{size:10,className:"text-zinc-500"}),(0,d.jsxs)("span",{className:"text-[10px] text-zinc-500 font-mono",children:["origin/",q]})]}),u?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"Loading commit history..."}):0===j.length?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"No commit history found."}):j.map((a,b)=>(0,d.jsxs)("div",{className:"flex gap-3 relative pl-1",children:[b<j.length-1&&(0,d.jsx)("div",{className:"absolute left-2.5 top-5 bottom-0 w-px bg-zinc-800"}),(0,d.jsx)("div",{className:"relative z-10 mt-1",children:(0,d.jsx)(le,{size:12,className:"text-blue-500 bg-zinc-950 rounded-full"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center gap-2",children:[(0,d.jsx)("span",{className:"font-mono text-[10px] text-zinc-500",children:a.hash}),(0,d.jsx)("span",{className:"text-[9px] text-zinc-500",children:a.date})]}),(0,d.jsx)("p",{className:"text-[11px] font-semibold text-zinc-200 truncate mt-0.5 font-sans font-medium",children:a.message}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 mt-1 block",children:["by ",a.author]})]})]},a.hash))]})})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col bg-zinc-900/20 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-4 py-2.5 bg-zinc-950 border-b border-zinc-850 flex justify-between items-center",children:[(0,d.jsx)("span",{className:"text-xs font-mono text-zinc-300 font-bold",children:l||"No file selected"}),(0,d.jsx)("span",{className:"text-[10px] font-bold text-zinc-500 uppercase tracking-wide bg-zinc-900 border border-zinc-850 px-2 py-0.5 rounded",children:"Unified Diff"})]}),(0,d.jsx)("div",{className:"flex-1 p-4 overflow-auto font-mono text-[11px] leading-relaxed text-zinc-300 bg-black/60 select-text",children:n?n.split("\n").map((a,b)=>{let c="text-zinc-400";return a.startsWith("+")?c="text-green-500 bg-green-500/5 font-semibold":a.startsWith("-")&&(c="text-red-500 bg-red-500/5 font-semibold"),(0,d.jsx)("div",{className:`px-2 py-0.5 rounded ${c}`,children:a},b)}):(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-zinc-500 text-xs",children:[(0,d.jsx)(fk,{size:32,className:"mb-2 text-zinc-650"}),(0,d.jsx)("span",{children:"Select a code file from the left panel to inspect the git diff."})]})})]}),(0,d.jsxs)("div",{className:"w-96 border-l border-zinc-850 flex flex-col bg-zinc-950 shrink-0 overflow-y-auto",children:[(0,d.jsxs)("div",{className:"p-5 border-b border-zinc-850 space-y-4",children:[(0,d.jsx)("h3",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider",children:"Gate Analytics"}),(0,d.jsxs)("div",{className:"flex justify-between items-center gap-4 bg-zinc-900/30 border border-zinc-850 p-3 rounded-lg",children:[(0,d.jsxs)("div",{className:"relative w-16 h-16 shrink-0 flex items-center justify-center",children:[(0,d.jsxs)("svg",{className:"w-full h-full transform -rotate-90",children:[(0,d.jsx)("circle",{cx:"32",cy:"32",r:"28",className:"stroke-zinc-800",strokeWidth:"4",fill:"transparent"}),(0,d.jsx)("circle",{cx:"32",cy:"32",r:"28",className:"stroke-green-500",strokeWidth:"4",fill:"transparent",strokeDasharray:175,strokeDashoffset:175*(1-N/100)})]}),(0,d.jsxs)("span",{className:"absolute text-[11px] font-bold text-white",children:[N,"%"]})]}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("span",{className:"text-[10px] text-zinc-500 uppercase font-bold",children:"QA Gate Grade"}),(0,d.jsxs)("p",{className:"text-xs text-zinc-200 mt-0.5 font-semibold",children:[M," of ",L," automated verification reviews passed."]})]})]}),(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-zinc-500 uppercase font-bold",children:"Execution Time per Persona"}),(0,d.jsx)("div",{className:"space-y-2 bg-zinc-900/30 border border-zinc-850 p-3.5 rounded-lg",children:[{label:"Developer",time:"idle"===G?"0s":"45s",pct:100*("idle"!==G),color:"bg-zinc-500"},...(f?.personas||[]).map(a=>{let b="idle"!==a.status,c="0s",d=0;return b&&("qa"===a.id?(c="12s",d=26):"code-review"===a.id?(c="15s",d=33):"security"===a.id?(c="8s",d=18):"tech-lead"===a.id&&(c="10s",d=22)),{label:lf[a.id]||a.id,time:c,pct:d,color:({qa:"bg-green-500","code-review":"bg-blue-500",security:"bg-purple-500","tech-lead":"bg-amber-500"})[a.id]||"bg-zinc-500"}})].map(a=>(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"flex justify-between text-[10px] font-medium text-zinc-300 font-sans",children:[(0,d.jsx)("span",{children:a.label}),(0,d.jsx)("span",{className:"font-mono",children:a.time})]}),(0,d.jsx)("div",{className:"h-1.5 w-full bg-zinc-800 rounded-full overflow-hidden",children:(0,d.jsx)("div",{className:`h-full rounded-full ${a.color}`,style:{width:`${a.pct}%`}})})]},a.label))})]})]}),(0,d.jsxs)("div",{className:"p-5 border-b border-zinc-850 space-y-3",children:[(0,d.jsx)("h3",{className:"text-xs font-bold text-zinc-400 uppercase tracking-wider",children:"Persona Audits Summary"}),(0,d.jsx)("div",{className:"space-y-3",children:O.map(a=>{let b=(0,d.jsx)(lb,{size:13,className:"text-zinc-500 mt-0.5 shrink-0"});return"passed"===a.status?b=(0,d.jsx)(z,{size:13,className:"text-green-500 mt-0.5 shrink-0"}):"failed"===a.status?b=(0,d.jsx)(la,{size:13,className:"text-red-500 mt-0.5 shrink-0"}):"running"===a.status&&(b=(0,d.jsx)(lb,{size:13,className:"text-blue-400 animate-pulse mt-0.5 shrink-0"})),(0,d.jsxs)("div",{className:"flex gap-2.5 items-start",children:[b,(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] font-bold text-zinc-300",children:a.label}),(0,d.jsx)("span",{className:`text-[8px] font-bold px-1 rounded uppercase tracking-wider ${"passed"===a.status?"bg-green-500/10 text-green-400 border border-green-500/20":"failed"===a.status?"bg-red-500/10 text-red-400 border border-red-500/20":"running"===a.status?"bg-blue-500/10 text-blue-400 border border-blue-500/20 animate-pulse":"bg-zinc-800 text-zinc-400 border border-zinc-700"}`,children:a.status})]}),(0,d.jsx)("p",{className:"text-[9px] text-zinc-500",children:a.desc})]})]},a.id)})})]}),(0,d.jsxs)("div",{className:"p-5 flex-1 flex flex-col justify-end gap-3 min-h-[200px]",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-500 uppercase",children:"Reviewer Comments"}),(0,d.jsx)("textarea",{placeholder:"Insert audit notes or observations...",value:C,onChange:a=>D(a.target.value),className:"w-full h-16 p-2 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none resize-none text-white focus:border-zinc-700"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:b,className:"flex-1 py-2 bg-zinc-900 hover:bg-zinc-850 border border-zinc-850 hover:border-zinc-800 text-zinc-300 font-semibold text-xs rounded transition",children:"Cancel Audit"}),(0,d.jsxs)("button",{onClick:g,className:"flex-1 py-2 bg-green-500 hover:bg-green-600 text-white font-semibold text-xs rounded transition flex items-center justify-center gap-1.5",children:[(0,d.jsx)(p,{size:14}),(0,d.jsx)("span",{children:"Approve & Merge"})]})]})]})]})]})]})})},li=m("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),lj=m("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]),lk=m("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),ll=m("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),lm=m("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),ln=m("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),lo=m("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),lp=m("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),lq=m("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),lr=h()(async()=>{},{loadableGenerated:{modules:["app/page.tsx -> @/components/TerminalPanel"]},ssr:!1}),ls={constitution:"Constitution",specification:"Specification",clarification:"Clarification",planning:"Planning",checklist:"Checklist",analyze:"Analysis",tasks:"Tasks",taskstoissues:"Tasks to Issues",implementation:"Implementation"};function lt(){let[a,b]=(0,e.useState)(null),c=f().useRef(null),[g,h]=(0,e.useState)(null),[j,k]=(0,e.useState)("kanban"),[l,m]=(0,e.useState)("dark"),[n,p]=(0,e.useState)({agentType:"claude",customCommand:"",agentPath:""}),[q,r]=(0,e.useState)(""),[v,w]=(0,e.useState)(i),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(""),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)("editor"),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(!1),[P,Q]=(0,e.useState)(!1),R=()=>{Q(a=>!a)};f().useRef(g);let S=async()=>{try{let a=await fetch("/api/state"),c=await a.json();b(c)}catch(a){console.error("Failed to fetch state:",a)}},T=async a=>{let b=v.map(b=>b.id===a.id?a:b);w(b),z(null);try{await fetch("/api/personas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch(a){console.error("Failed to save persona config:",a)}},U=async a=>{try{let c=await fetch("/api/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activeFeatureName:a})}),d=await c.json();b(d);let e=d.features.find(b=>b.name===a),f=e?.phases.find(a=>"specification"===a.phase);f?.filePath?X(f.filePath):h(null)}catch(a){console.error(a)}},V=async a=>{if(a.preventDefault(),C.trim())try{let a=await fetch("/api/feature",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:C.trim()})}),c=await a.json();b(c),D("");let d=`specs/${C.trim()}/spec.md`;h({path:d,content:""})}catch(a){console.error(a)}},W=async c=>{if(confirm(`Are you sure you want to delete feature "${c}"?`))try{let d=await fetch("/api/feature",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c})}),e=await d.json();b(e),a?.activeFeatureName===c&&h(null)}catch(a){console.error(a)}},X=async a=>{try{let b=await fetch(`/api/file?path=${encodeURIComponent(a)}`),c=await b.json();h(c)}catch(a){console.error(a)}},Y=async a=>{if(g)try{let c=await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:g.path,content:a})}),d=await c.json();h({path:g.path,content:a}),d.state&&b(d.state)}catch(a){console.error(a)}},Z=async(c,d)=>{if(a?.activeFeatureName)try{let e=await fetch("/api/task",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({featureName:a.activeFeatureName,lineIndex:c,checked:d})}),f=await e.json();b(f);let h=f.features.find(a=>a.name===f.activeFeatureName),i=h?.phases.find(a=>"tasks"===a.phase);i?.filePath&&g?.path===i.filePath&&X(i.filePath)}catch(a){console.error(a)}},$=async(a,d,e)=>{let f=a.body?.getReader();if(!f){G(!1),M(null);return}let g=new TextDecoder,h="";for(;;){let{value:a,done:i}=await f.read();if(i)break;let j=(h+=g.decode(a)).split("\n\n");for(let a of(h=j.pop()||"",j))if(a.startsWith("event: log")){let b=a.split("\n").find(a=>a.startsWith("data: "));if(b){let a=JSON.parse(b.substring(6));c.current?.write(a.text)}}else if(a.startsWith("event: done")){let c=a.split("\n").find(a=>a.startsWith("data: "));if(c){let a=JSON.parse(c.substring(6));b(a.state);let f=e||a.state.activeFeatureName,g=a.state.features.find(a=>a.name===f),h=g?.phases.find(a=>a.phase===d);h?.filePath&&X(h.filePath)}G(!1),M(null),r("")}else if(a.startsWith("event: error")){let b=a.split("\n").find(a=>a.startsWith("data: "));if(b){let a=JSON.parse(b.substring(6));c.current?.write(`\r
27
+ `,b)}paste(a){this._core.paste(a)}refresh(a,b){this._verifyIntegers(a,b),this._core.refresh(a,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(a){this._addonManager.loadAddon(this,a)}static get strings(){return{get promptLabel(){return fK.get()},set promptLabel(t){fK.set(t)},get tooMuchOutput(){return fM.get()},set tooMuchOutput(t){fM.set(t)}}}_verifyIntegers(...a){for(k3 of a)if(k3===1/0||isNaN(k3)||k3%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...a){for(k3 of a)if(k3&&(k3===1/0||isNaN(k3)||k3%1!=0||k3<0))throw Error("This API only accepts positive integers")}},k5=class{activate(a){this._terminal=a}dispose(){}fit(){let a=this.proposeDimensions();if(!a||!this._terminal||isNaN(a.cols)||isNaN(a.rows))return;let b=this._terminal._core;(this._terminal.rows!==a.rows||this._terminal.cols!==a.cols)&&(b._renderService.clear(),this._terminal.resize(a.cols,a.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let a=this._terminal._core._renderService.dimensions;if(0===a.css.cell.width||0===a.css.cell.height)return;let b=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,c=window.getComputedStyle(this._terminal.element.parentElement),d=parseInt(c.getPropertyValue("height")),e=Math.max(0,parseInt(c.getPropertyValue("width"))),f=window.getComputedStyle(this._terminal.element),g={top:parseInt(f.getPropertyValue("padding-top")),bottom:parseInt(f.getPropertyValue("padding-bottom")),right:parseInt(f.getPropertyValue("padding-right")),left:parseInt(f.getPropertyValue("padding-left"))},h=g.top+g.bottom;return{cols:Math.max(2,Math.floor((e-(g.right+g.left)-b)/a.css.cell.width)),rows:Math.max(1,Math.floor((d-h)/a.css.cell.height))}}};c(7833);let k6=m("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),k7=(0,e.forwardRef)(({active:a,running:b=!1,onInput:c,onResize:f},g)=>{let h=(0,e.useRef)(null),i=(0,e.useRef)(null),j=(0,e.useRef)(null),k=(0,e.useRef)(c),l=(0,e.useRef)(f);return k.current=c,l.current=f,(0,e.useImperativeHandle)(g,()=>({write:a=>i.current?.write(a),clear:()=>i.current?.clear(),focus:()=>i.current?.focus()}),[]),(0,e.useEffect)(()=>{if(!h.current)return;let a=new k4({cursorBlink:!0,theme:{background:"#000000",foreground:"#a1a1aa",cursor:"#f4f4f5",selectionBackground:"#27272a"},fontFamily:'Menlo, Monaco, Consolas, "Courier New", monospace',fontSize:11}),b=new k5;a.loadAddon(b),a.open(h.current);try{b.fit()}catch{}i.current=a,j.current=b;let c=a.onData(a=>k.current?.(a)),d=a.onResize(({cols:a,rows:b})=>l.current?.(a,b));l.current?.(a.cols,a.rows);let e=new ResizeObserver(()=>{try{b.fit()}catch{}});return e.observe(h.current),()=>{e.disconnect(),c.dispose(),d.dispose(),a.dispose(),i.current=null,j.current=null}},[]),(0,e.useEffect)(()=>{if(!a)return;let b=requestAnimationFrame(()=>{try{j.current?.fit()}catch{}i.current?.focus()});return()=>cancelAnimationFrame(b)},[a]),(0,d.jsxs)("div",{className:"flex flex-col h-full bg-black border-t border-zinc-800",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center px-4 py-2 border-b border-zinc-900 bg-zinc-950 shrink-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(k6,{size:14,className:"text-zinc-500"}),(0,d.jsx)("span",{className:"font-mono text-xs font-semibold tracking-wider text-zinc-400",children:"CONSOLE OUTPUT"}),b&&(0,d.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-blue-500 animate-pulse"})]}),(0,d.jsx)("button",{onClick:()=>i.current?.clear(),title:"Clear console",className:"p-1 hover:bg-zinc-800 rounded transition text-zinc-500 hover:text-zinc-300",children:(0,d.jsx)(r,{size:14})})]}),(0,d.jsx)("div",{ref:h,onClick:()=>i.current?.focus(),className:"flex-1 w-full min-h-0 p-2 overflow-hidden"})]})});k7.displayName="AgentConsole";let k8=m("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),k9=({isOpen:a,onClose:b,persona:c,onSave:f})=>{let[g,h]=(0,e.useState)(""),[i,j]=(0,e.useState)(""),[k,l]=(0,e.useState)(!0),[m,n]=(0,e.useState)("gemini-2.5-flash"),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,u]=(0,e.useState)(""),[v,w]=(0,e.useState)("");return((0,e.useEffect)(()=>{c&&(h(c.label||""),j(c.command||""),l(!1!==c.enabled),n(c.model||"gemini-2.5-flash"),p(c.description||""),r(c.systemPrompt||""),u(Array.isArray(c.capabilities)?c.capabilities.join("\n"):""),w(Array.isArray(c.tools)?c.tools.join("\n"):""))},[c,a]),a&&c)?(0,d.jsx)("div",{className:"fixed inset-0 bg-black/85 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-zinc-950 border border-zinc-850 w-full max-w-2xl h-[85vh] rounded-xl flex flex-col overflow-hidden shadow-2xl animate-in fade-in zoom-in duration-200",children:[(0,d.jsxs)("header",{className:"px-6 py-4 border-b border-zinc-850 flex justify-between items-center bg-zinc-900/50",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 bg-blue-500/10 text-blue-400 rounded-lg",children:(0,d.jsx)(k8,{size:18})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-base font-bold text-white tracking-tight",children:["Configure Persona Agent: ",c.id.toUpperCase()]}),(0,d.jsx)("p",{className:"text-xs text-zinc-400 mt-0.5",children:"Customize capabilities, core instructions, models, and slash command integration."})]})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 hover:bg-zinc-800 rounded-lg text-zinc-400 hover:text-zinc-200 transition",children:(0,d.jsx)(x,{size:18})})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-5",children:[(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"Persona Name"}),(0,d.jsx)("input",{type:"text",value:g,onChange:a=>h(a.target.value),className:"w-full px-3 py-2 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. QA Agent"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"LLM Model"}),(0,d.jsxs)("select",{value:m,onChange:a=>n(a.target.value),className:"w-full px-3 py-2 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",children:[(0,d.jsx)("option",{value:"gemini-2.5-flash",children:"Gemini 2.5 Flash (Fast, Google)"}),(0,d.jsx)("option",{value:"gemini-2.5-pro",children:"Gemini 2.5 Pro (Analytical, Google)"}),(0,d.jsx)("option",{value:"claude-3-5-sonnet",children:"Claude 3.5 Sonnet (Coding, Anthropic)"}),(0,d.jsx)("option",{value:"gpt-4o",children:"GPT-4o (Reasoning, OpenAI)"})]})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-center",children:[(0,d.jsxs)("div",{className:"md:col-span-2",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider mb-1.5",children:"Slash Command / Execution Path"}),(0,d.jsx)("input",{type:"text",value:i,onChange:a=>j(a.target.value),className:"w-full px-3 py-2 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. /speckit.review.qa"})]}),(0,d.jsx)("div",{className:"flex items-center h-full pt-4",children:(0,d.jsxs)("label",{className:"flex items-center gap-2.5 cursor-pointer select-none",children:[(0,d.jsx)("input",{type:"checkbox",checked:k,onChange:a=>l(a.target.checked),className:"w-4 h-4 rounded border-zinc-800 bg-zinc-900 text-blue-500 focus:ring-0 focus:ring-offset-0"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{className:"text-xs font-semibold text-white",children:"Enable Agent Persona"}),(0,d.jsx)("span",{className:"text-[10px] text-zinc-500",children:"Run persona in review gate"})]})]})})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Agent Description"}),(0,d.jsx)("textarea",{rows:2,value:o,onChange:a=>p(a.target.value),className:"w-full p-3 text-xs bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700 resize-none",placeholder:"Provide a general summary of this agent's responsibilities..."})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"System Prompt & Core Instructions"}),(0,d.jsx)("textarea",{rows:5,value:q,onChange:a=>r(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"System prompt instructions..."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Capabilities (one per line)"}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 flex items-center gap-0.5",children:[(0,d.jsx)(y,{size:10})," Environment injection"]})]}),(0,d.jsx)("textarea",{rows:4,value:s,onChange:a=>u(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. Runs Vitest suite"})]}),(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-400 uppercase tracking-wider",children:"Authorized Tools (one per line)"}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 flex items-center gap-0.5",children:[(0,d.jsx)(y,{size:10})," CLI commands"]})]}),(0,d.jsx)("textarea",{rows:4,value:v,onChange:a=>w(a.target.value),className:"w-full p-3 text-xs font-mono bg-zinc-900 border border-zinc-800 rounded outline-none text-white focus:border-zinc-700",placeholder:"e.g. npm test"})]})]})]}),(0,d.jsxs)("footer",{className:"px-6 py-4 border-t border-zinc-850 flex justify-end gap-3 bg-zinc-900/30",children:[(0,d.jsx)("button",{onClick:b,className:"px-4 py-2 bg-zinc-900 hover:bg-zinc-850 border border-zinc-850 hover:border-zinc-800 text-zinc-300 font-semibold text-xs rounded-lg transition",children:"Cancel"}),(0,d.jsxs)("button",{onClick:()=>{let a=s.split("\n").map(a=>a.trim()).filter(a=>a.length>0),b=v.split("\n").map(a=>a.trim()).filter(a=>a.length>0);f({...c,label:g,command:i,enabled:k,model:m,description:o,systemPrompt:q,capabilities:a,tools:b})},className:"px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white font-semibold text-xs rounded-lg transition flex items-center gap-1.5",children:[(0,d.jsx)(ft,{size:14}),(0,d.jsx)("span",{children:"Save Configuration"})]})]})]})}):null},la=m("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),lb=m("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),lc=m("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),ld=m("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),le=m("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),lf={developer:"Developer",qa:"QA Agent","code-review":"Code Reviewer",security:"Security Auditor","tech-lead":"Tech Lead"},lg={developer:"Implements features and writes source code.",qa:"Runs unit and integration test suites.","code-review":"Reviews code styles and architectural patterns.",security:"Checks for security vulnerabilities and secrets.","tech-lead":"Performs final technical audit and validation."},lh=({isOpen:a,onClose:b,featureName:c,activePhaseState:f,onApprove:g})=>{let[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)([]),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(""),[q,r]=(0,e.useState)("main"),[u,v]=(0,e.useState)(!1),[w,y]=(0,e.useState)(""),[A,B]=(0,e.useState)("files"),[C,D]=(0,e.useState)("");if((0,e.useEffect)(()=>{if(!a)return;let b=!0;return v(!0),y(""),fetch("/api/git?action=status").then(a=>{if(!a.ok)throw Error(`HTTP error! status: ${a.status}`);return a.json()}).then(a=>{b&&(a.error?y(a.error):(i(a.files||[]),k(a.log||[]),r(a.branch||"main"),a.files&&a.files.length>0?m(a.files[0].path):m("")))}).catch(a=>{b&&y(a.message||"Failed to fetch git status.")}).finally(()=>{b&&v(!1)}),()=>{b=!1}},[a]),(0,e.useEffect)(()=>{if(!a||!l)return void o("");let b=!0;return o("Loading diff..."),fetch(`/api/git?action=diff&file=${encodeURIComponent(l)}`).then(a=>{if(!a.ok)throw Error(`HTTP error! status: ${a.status}`);return a.json()}).then(a=>{b&&(a.error?o(`Error: ${a.error}`):o(a.diff||"No modifications found."))}).catch(a=>{b&&o(`Failed to load diff: ${a.message}`)}),()=>{b=!1}},[a,l]),!a)return null;let E=h.reduce((a,b)=>a+b.additions,0),F=h.reduce((a,b)=>a+b.deletions,0),G=f&&"idle"!==f.status?"running"===f.status?f.personas?.some(a=>"idle"!==a.status)?"passed":"running":"passed":"idle",H=f?.personas?.find(a=>"qa"===a.id),I=H?H.status:"idle",J=f?.personas?.find(a=>"security"===a.id),K=J?J.status:"idle",L=f?.personas?.length||0,M=f?.personas?.filter(a=>"passed"===a.status).length||0,N=L>0?Math.round(M/L*100):100*("passed"===G),O=[{id:"developer",label:lf.developer,desc:lg.developer,status:G},...(f?.personas||[]).map(a=>({id:a.id,label:lf[a.id]||a.id,desc:lg[a.id]||"",status:a.status}))];return(0,d.jsx)("div",{className:"fixed inset-0 bg-black/50 dark:bg-black/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:(0,d.jsxs)("div",{className:"bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 w-full h-[95vh] rounded-xl flex flex-col overflow-hidden shadow-2xl animate-in fade-in zoom-in duration-200",children:[(0,d.jsxs)("header",{className:"px-6 py-4 border-b border-zinc-200 dark:border-zinc-800 flex justify-between items-center bg-zinc-50 dark:bg-zinc-900/50",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)("span",{className:"text-2xl",children:"⚡"}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsxs)("h2",{className:"text-base font-bold text-zinc-900 dark:text-white tracking-tight",children:["Human Audit Portal: ",c]}),(0,d.jsx)("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20 uppercase animate-pulse",children:"Awaiting Sign-off"})]}),(0,d.jsx)("p",{className:"text-xs text-zinc-600 dark:text-zinc-400 mt-0.5",children:"Inspect code changes, check agent validation reports, and sign off the gate to approve implementation."})]})]}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded-lg text-zinc-600 dark:text-zinc-400 hover:text-zinc-900 dark:hover:text-zinc-200 transition",children:(0,d.jsx)(x,{size:18})})]}),w&&(0,d.jsxs)("div",{className:"mx-6 mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center gap-2 text-xs text-red-600 dark:text-red-400",children:[(0,d.jsx)(la,{size:14,className:"shrink-0"}),(0,d.jsx)("span",{children:w})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 px-6 py-4 border-b border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950",children:[(0,d.jsxs)("div",{className:"p-3 bg-zinc-50 dark:bg-zinc-900/40 border border-zinc-200 dark:border-zinc-800/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-green-500/10 text-green-600 dark:text-green-400",children:(0,d.jsx)(fC,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Tests Coverage"}),(0,d.jsx)("div",{className:"text-sm font-bold text-zinc-900 dark:text-white mt-0.5",children:"passed"===I?"100% Passed":"running"===I?"Running...":"Awaiting QA"})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-50 dark:bg-zinc-900/40 border border-zinc-200 dark:border-zinc-800/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400",children:(0,d.jsx)(fA,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Lines Added"}),(0,d.jsx)("div",{className:"text-sm font-bold text-zinc-900 dark:text-white mt-0.5",children:u?"Loading...":`+${E} / -${F} lines`})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-50 dark:bg-zinc-900/40 border border-zinc-200 dark:border-zinc-800/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-purple-500/10 text-purple-600 dark:text-purple-400",children:(0,d.jsx)(s,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Security Scan"}),(0,d.jsx)("div",{className:"text-sm font-bold text-zinc-900 dark:text-white mt-0.5",children:"passed"===K?"Grade A (Clean)":"failed"===K?"Failed":"running"===K?"Scanning...":"Awaiting Scan"})]})]}),(0,d.jsxs)("div",{className:"p-3 bg-zinc-50 dark:bg-zinc-900/40 border border-zinc-200 dark:border-zinc-800/50 rounded-lg flex items-center gap-3",children:[(0,d.jsx)("div",{className:"p-2 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400",children:(0,d.jsx)(lb,{size:16})}),(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-[10px] font-bold text-zinc-500 uppercase",children:"Validation Duration"}),(0,d.jsx)("div",{className:"text-sm font-bold text-zinc-900 dark:text-white mt-0.5",children:f?.personas?.some(a=>"passed"===a.status)?"1m 20s total":"0s"})]})]})]}),(0,d.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,d.jsxs)("div",{className:"w-80 border-r border-zinc-200 dark:border-zinc-800 flex flex-col bg-white dark:bg-zinc-950 shrink-0",children:[(0,d.jsxs)("div",{className:"flex border-b border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/20",children:[(0,d.jsx)("button",{onClick:()=>B("files"),className:`flex-1 py-2.5 text-center text-xs font-semibold border-b-2 transition ${"files"===A?"text-zinc-900 border-zinc-900 dark:text-white dark:border-white":"text-zinc-500 border-transparent hover:text-zinc-700 dark:hover:text-zinc-400"}`,children:"Modified Files"}),(0,d.jsx)("button",{onClick:()=>B("git"),className:`flex-1 py-2.5 text-center text-xs font-semibold border-b-2 transition ${"git"===A?"text-zinc-900 border-zinc-900 dark:text-white dark:border-white":"text-zinc-500 border-transparent hover:text-zinc-700 dark:hover:text-zinc-400"}`,children:"Git Commit History"})]}),(0,d.jsx)("div",{className:"flex-1 overflow-y-auto p-4 space-y-1",children:"files"===A?u?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"Loading files..."}):0===h.length?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"No modified files found."}):h.map(a=>(0,d.jsxs)("div",{onClick:()=>m(a.path),className:`p-2.5 rounded-lg border text-xs cursor-pointer transition flex justify-between items-center ${l===a.path?"bg-zinc-100 dark:bg-zinc-900 border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white":"bg-transparent border-transparent text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-900/50 hover:text-zinc-900 dark:hover:text-zinc-200"}`,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)(fk,{size:13,className:"code"===a.type?"text-blue-600 dark:text-blue-400":"text-zinc-500"}),(0,d.jsx)("span",{className:"truncate font-mono text-[11px]",children:a.path.split("/").pop()})]}),(0,d.jsxs)("div",{className:"flex items-center gap-1 font-mono text-[10px] font-bold",children:[(0,d.jsxs)("span",{className:"text-green-500",children:["+",a.additions]}),(0,d.jsxs)("span",{className:"text-red-500",children:["-",a.deletions]})]})]},a.path)):(0,d.jsxs)("div",{className:"space-y-4 py-2",children:[(0,d.jsxs)("div",{className:"p-3 bg-zinc-50 dark:bg-zinc-900/30 border border-zinc-200 dark:border-zinc-800 rounded-lg flex items-center gap-2 mb-2",children:[(0,d.jsx)(lc,{size:14,className:"text-blue-500 animate-pulse"}),(0,d.jsx)("span",{className:"text-xs text-zinc-700 dark:text-zinc-300 font-bold",children:q}),(0,d.jsx)(ld,{size:10,className:"text-zinc-500"}),(0,d.jsxs)("span",{className:"text-[10px] text-zinc-500 font-mono",children:["origin/",q]})]}),u?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"Loading commit history..."}):0===j.length?(0,d.jsx)("div",{className:"text-zinc-500 text-xs text-center py-8",children:"No commit history found."}):j.map((a,b)=>(0,d.jsxs)("div",{className:"flex gap-3 relative pl-1",children:[b<j.length-1&&(0,d.jsx)("div",{className:"absolute left-2.5 top-5 bottom-0 w-px bg-zinc-200 dark:bg-zinc-800"}),(0,d.jsx)("div",{className:"relative z-10 mt-1",children:(0,d.jsx)(le,{size:12,className:"text-blue-500 bg-white dark:bg-zinc-950 rounded-full"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex justify-between items-center gap-2",children:[(0,d.jsx)("span",{className:"font-mono text-[10px] text-zinc-500",children:a.hash}),(0,d.jsx)("span",{className:"text-[9px] text-zinc-500",children:a.date})]}),(0,d.jsx)("p",{className:"text-[11px] font-semibold text-zinc-700 dark:text-zinc-200 truncate mt-0.5 font-sans font-medium",children:a.message}),(0,d.jsxs)("span",{className:"text-[9px] text-zinc-500 mt-1 block",children:["by ",a.author]})]})]},a.hash))]})})]}),(0,d.jsxs)("div",{className:"flex-1 flex flex-col bg-zinc-50 dark:bg-zinc-900/20 overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-4 py-2.5 bg-white dark:bg-zinc-950 border-b border-zinc-200 dark:border-zinc-800 flex justify-between items-center",children:[(0,d.jsx)("span",{className:"text-xs font-mono text-zinc-700 dark:text-zinc-300 font-bold",children:l||"No file selected"}),(0,d.jsx)("span",{className:"text-[10px] font-bold text-zinc-500 uppercase tracking-wide bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 px-2 py-0.5 rounded",children:"Unified Diff"})]}),(0,d.jsx)("div",{className:"flex-1 p-4 overflow-auto font-mono text-[11px] leading-relaxed text-zinc-700 dark:text-zinc-300 bg-zinc-50 dark:bg-black/60 select-text",children:n?n.split("\n").map((a,b)=>{let c="text-zinc-600 dark:text-zinc-400";return a.startsWith("+")?c="text-green-600 dark:text-green-500 bg-green-500/5 font-semibold":a.startsWith("-")&&(c="text-red-600 dark:text-red-500 bg-red-500/5 font-semibold"),(0,d.jsx)("div",{className:`px-2 py-0.5 rounded ${c}`,children:a},b)}):(0,d.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-zinc-500 text-xs",children:[(0,d.jsx)(fk,{size:32,className:"mb-2 text-zinc-400 dark:text-zinc-600"}),(0,d.jsx)("span",{children:"Select a code file from the left panel to inspect the git diff."})]})})]}),(0,d.jsxs)("div",{className:"w-96 border-l border-zinc-200 dark:border-zinc-800 flex flex-col bg-white dark:bg-zinc-950 shrink-0 overflow-y-auto",children:[(0,d.jsxs)("div",{className:"p-5 border-b border-zinc-200 dark:border-zinc-800 space-y-4",children:[(0,d.jsx)("h3",{className:"text-xs font-bold text-zinc-600 dark:text-zinc-400 uppercase tracking-wider",children:"Gate Analytics"}),(0,d.jsxs)("div",{className:"flex justify-between items-center gap-4 bg-zinc-50 dark:bg-zinc-900/30 border border-zinc-200 dark:border-zinc-800 p-3 rounded-lg",children:[(0,d.jsxs)("div",{className:"relative w-16 h-16 shrink-0 flex items-center justify-center",children:[(0,d.jsxs)("svg",{className:"w-full h-full transform -rotate-90",children:[(0,d.jsx)("circle",{cx:"32",cy:"32",r:"28",className:"stroke-zinc-200 dark:stroke-zinc-800",strokeWidth:"4",fill:"transparent"}),(0,d.jsx)("circle",{cx:"32",cy:"32",r:"28",className:"stroke-green-500",strokeWidth:"4",fill:"transparent",strokeDasharray:175,strokeDashoffset:175*(1-N/100)})]}),(0,d.jsxs)("span",{className:"absolute text-[11px] font-bold text-zinc-900 dark:text-white",children:[N,"%"]})]}),(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("span",{className:"text-[10px] text-zinc-500 uppercase font-bold",children:"QA Gate Grade"}),(0,d.jsxs)("p",{className:"text-xs text-zinc-700 dark:text-zinc-200 mt-0.5 font-semibold",children:[M," of ",L," automated verification reviews passed."]})]})]}),(0,d.jsxs)("div",{className:"space-y-2.5",children:[(0,d.jsx)("span",{className:"text-[10px] text-zinc-500 uppercase font-bold",children:"Execution Time per Persona"}),(0,d.jsx)("div",{className:"space-y-2 bg-zinc-50 dark:bg-zinc-900/30 border border-zinc-200 dark:border-zinc-800 p-3.5 rounded-lg",children:[{label:"Developer",time:"idle"===G?"0s":"45s",pct:100*("idle"!==G),color:"bg-zinc-500"},...(f?.personas||[]).map(a=>{let b="idle"!==a.status,c="0s",d=0;return b&&("qa"===a.id?(c="12s",d=26):"code-review"===a.id?(c="15s",d=33):"security"===a.id?(c="8s",d=18):"tech-lead"===a.id&&(c="10s",d=22)),{label:lf[a.id]||a.id,time:c,pct:d,color:({qa:"bg-green-500","code-review":"bg-blue-500",security:"bg-purple-500","tech-lead":"bg-amber-500"})[a.id]||"bg-zinc-500"}})].map(a=>(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"flex justify-between text-[10px] font-medium text-zinc-700 dark:text-zinc-300 font-sans",children:[(0,d.jsx)("span",{children:a.label}),(0,d.jsx)("span",{className:"font-mono",children:a.time})]}),(0,d.jsx)("div",{className:"h-1.5 w-full bg-zinc-200 dark:bg-zinc-800 rounded-full overflow-hidden",children:(0,d.jsx)("div",{className:`h-full rounded-full ${a.color}`,style:{width:`${a.pct}%`}})})]},a.label))})]})]}),(0,d.jsxs)("div",{className:"p-5 border-b border-zinc-200 dark:border-zinc-800 space-y-3",children:[(0,d.jsx)("h3",{className:"text-xs font-bold text-zinc-600 dark:text-zinc-400 uppercase tracking-wider",children:"Persona Audits Summary"}),(0,d.jsx)("div",{className:"space-y-3",children:O.map(a=>{let b=(0,d.jsx)(lb,{size:13,className:"text-zinc-500 mt-0.5 shrink-0"});return"passed"===a.status?b=(0,d.jsx)(z,{size:13,className:"text-green-500 mt-0.5 shrink-0"}):"failed"===a.status?b=(0,d.jsx)(la,{size:13,className:"text-red-500 mt-0.5 shrink-0"}):"running"===a.status&&(b=(0,d.jsx)(lb,{size:13,className:"text-blue-400 animate-pulse mt-0.5 shrink-0"})),(0,d.jsxs)("div",{className:"flex gap-2.5 items-start",children:[b,(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("span",{className:"text-[10px] font-bold text-zinc-700 dark:text-zinc-300",children:a.label}),(0,d.jsx)("span",{className:`text-[8px] font-bold px-1 rounded uppercase tracking-wider ${"passed"===a.status?"bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20":"failed"===a.status?"bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20":"running"===a.status?"bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20 animate-pulse":"bg-zinc-100 dark:bg-zinc-800 text-zinc-500 dark:text-zinc-400 border border-zinc-200 dark:border-zinc-700"}`,children:a.status})]}),(0,d.jsx)("p",{className:"text-[9px] text-zinc-500",children:a.desc})]})]},a.id)})})]}),(0,d.jsxs)("div",{className:"p-5 flex-1 flex flex-col justify-end gap-3 min-h-[200px]",children:[(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("label",{className:"block text-[10px] font-bold text-zinc-500 uppercase",children:"Reviewer Comments"}),(0,d.jsx)("textarea",{placeholder:"Insert audit notes or observations...",value:C,onChange:a=>D(a.target.value),className:"w-full h-16 p-2 text-xs bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 rounded outline-none resize-none text-zinc-900 dark:text-white focus:border-zinc-400 dark:focus:border-zinc-700"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{onClick:b,className:"flex-1 py-2 bg-zinc-100 dark:bg-zinc-900 hover:bg-zinc-200 dark:hover:bg-zinc-800 border border-zinc-200 dark:border-zinc-800 hover:border-zinc-300 dark:hover:border-zinc-800 text-zinc-700 dark:text-zinc-300 font-semibold text-xs rounded transition",children:"Cancel Audit"}),(0,d.jsxs)("button",{onClick:g,className:"flex-1 py-2 bg-green-500 hover:bg-green-600 text-white font-semibold text-xs rounded transition flex items-center justify-center gap-1.5",children:[(0,d.jsx)(p,{size:14}),(0,d.jsx)("span",{children:"Approve & Merge"})]})]})]})]})]})]})})},li=m("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),lj=m("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]),lk=m("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),ll=m("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),lm=m("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),ln=m("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),lo=m("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),lp=m("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),lq=m("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),lr=h()(async()=>{},{loadableGenerated:{modules:["app/page.tsx -> @/components/TerminalPanel"]},ssr:!1}),ls={constitution:"Constitution",specification:"Specification",clarification:"Clarification",planning:"Planning",checklist:"Checklist",analyze:"Analysis",tasks:"Tasks",taskstoissues:"Tasks to Issues",implementation:"Implementation"};function lt(){let[a,b]=(0,e.useState)(null),c=f().useRef(null),[g,h]=(0,e.useState)(null),[j,k]=(0,e.useState)("kanban"),[l,m]=(0,e.useState)("dark"),[n,p]=(0,e.useState)({agentType:"claude",customCommand:"",agentPath:""}),[q,r]=(0,e.useState)(""),[v,w]=(0,e.useState)(i),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(null),[C,D]=(0,e.useState)(""),[F,G]=(0,e.useState)(!1),[H,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)("editor"),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(!1),[P,Q]=(0,e.useState)(!1),R=()=>{Q(a=>!a)};f().useRef(g);let S=async()=>{try{let a=await fetch("/api/state"),c=await a.json();b(c)}catch(a){console.error("Failed to fetch state:",a)}},T=async a=>{let b=v.map(b=>b.id===a.id?a:b);w(b),z(null);try{await fetch("/api/personas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)})}catch(a){console.error("Failed to save persona config:",a)}},U=async a=>{try{let c=await fetch("/api/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({activeFeatureName:a})}),d=await c.json();b(d);let e=d.features.find(b=>b.name===a),f=e?.phases.find(a=>"specification"===a.phase);f?.filePath?X(f.filePath):h(null)}catch(a){console.error(a)}},V=async a=>{if(a.preventDefault(),C.trim())try{let a=await fetch("/api/feature",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:C.trim()})}),c=await a.json();b(c),D("");let d=`specs/${C.trim()}/spec.md`;h({path:d,content:""})}catch(a){console.error(a)}},W=async c=>{if(confirm(`Are you sure you want to delete feature "${c}"?`))try{let d=await fetch("/api/feature",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c})}),e=await d.json();b(e),a?.activeFeatureName===c&&h(null)}catch(a){console.error(a)}},X=async a=>{try{let b=await fetch(`/api/file?path=${encodeURIComponent(a)}`),c=await b.json();h(c)}catch(a){console.error(a)}},Y=async a=>{if(g)try{let c=await fetch("/api/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:g.path,content:a})}),d=await c.json();h({path:g.path,content:a}),d.state&&b(d.state)}catch(a){console.error(a)}},Z=async(c,d)=>{if(a?.activeFeatureName)try{let e=await fetch("/api/task",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({featureName:a.activeFeatureName,lineIndex:c,checked:d})}),f=await e.json();b(f);let h=f.features.find(a=>a.name===f.activeFeatureName),i=h?.phases.find(a=>"tasks"===a.phase);i?.filePath&&g?.path===i.filePath&&X(i.filePath)}catch(a){console.error(a)}},$=async(a,d,e)=>{let f=a.body?.getReader();if(!f){G(!1),M(null);return}let g=new TextDecoder,h="";for(;;){let{value:a,done:i}=await f.read();if(i)break;let j=(h+=g.decode(a)).split("\n\n");for(let a of(h=j.pop()||"",j))if(a.startsWith("event: log")){let b=a.split("\n").find(a=>a.startsWith("data: "));if(b){let a=JSON.parse(b.substring(6));c.current?.write(a.text)}}else if(a.startsWith("event: done")){let c=a.split("\n").find(a=>a.startsWith("data: "));if(c){let a=JSON.parse(c.substring(6));b(a.state);let f=e||a.state.activeFeatureName,g=a.state.features.find(a=>a.name===f),h=g?.phases.find(a=>a.phase===d);h?.filePath&&X(h.filePath)}G(!1),M(null),r("")}else if(a.startsWith("event: error")){let b=a.split("\n").find(a=>a.startsWith("data: "));if(b){let a=JSON.parse(b.substring(6));c.current?.write(`\r
28
28
  \x1b[31mError: ${a.message}\x1b[0m\r
29
29
  `)}G(!1),M(null)}}S()},_=async(b,d)=>{c.current?.clear(),G(!0),K("console"),M({phase:b,featureName:d||a?.activeFeatureName||null});try{let c=await fetch("/api/phase",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"run",phase:b,featureName:d||a?.activeFeatureName,agentConfig:n,prompt:q,..."implementation"===b?{personas:v}:{}})});await $(c,b,d)}catch(a){c.current?.write(`\r
30
30
  \x1b[31mExecution failed: ${a.message}\x1b[0m\r