@worca/ui 0.2.0-rc.4 → 0.2.0-rc.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.
@@ -1,6 +1,6 @@
1
1
  var Dg=Object.defineProperty;var Ta=(e,t)=>()=>(e&&(t=e(e=0)),t);var Aa=(e,t)=>{for(var s in t)Dg(e,s,{get:t[s],enumerable:!0})};var cc={};Aa(cc,{Terminal:()=>X0});function g_(e){return e.replace(/\r?\n/g,"\r")}function __(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function v_(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function b_(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");gu(r,t,s,i)}}function gu(e,t,s,i){e=g_(e),e=__(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function _u(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function fd(e,t,s,i,r){_u(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Ws(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Pn(e,t=0,s=e.length){let i="";for(let r=t;r<s;++r){let o=e[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}function S_(e){return e[_l]||[]}function He(e){if(Qa.has(e))return Qa.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");C_(t,s,r)};return t._id=e,Qa.set(e,t),t}function C_(e,t,s){t[md]===t?t[_l].push({id:e,index:s}):(t[_l]=[{id:e,index:s}],t[md]=t)}function $_(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
- WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}function fn(e){R_(e)||A_.onUnexpectedError(e)}function R_(e){return e instanceof L_?!0:e instanceof Error&&e.name===bl&&e.message===bl}function D_(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")}function P_(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function St(e,t=0){return e[e.length-(1+t)]}function B_(e,t){return(s,i)=>t(e(s),e(i))}function I_(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function N_(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function W_(e){bi=e}function Bn(e){return bi?.trackDisposable(e),e}function On(e){bi?.markAsDisposed(e)}function io(e,t){bi?.setParent(e,t)}function j_(e,t){if(bi)for(let s of e)bi.setParent(s,t)}function yd(e){return bi?.markAsSingleton(e),e}function yi(e){if(Ru.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function V_(...e){let t=_e(()=>yi(e));return j_(e,t),t}function _e(e){let t=Bn({dispose:N_(()=>{On(t),e()})});return t}function iv(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}function rv(e){return tc.INSTANCE.getZoomFactor(e)}function ov(){return vn}function Sv(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return ju.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Al)switch(t){case 59:return 85;case 60:if(pv)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(is)return 57;break}else if(_n&&(is&&t===93||!is&&t===92))return 57;return bv[t]||0}function Ev(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}function Mv(e){return 55296<=e&&e<=56319}function Rd(e){return 56320<=e&&e<=57343}function Bv(e,t){return(e-55296<<10)+(t-56320)+65536}function Ov(e){return oc(e,0)}function oc(e,t){switch(typeof e){case"object":return e===null?Ss(349,t):Array.isArray(e)?zv(e,t):Nv(e,t);case"string":return qu(e,t);case"boolean":return Iv(e,t);case"number":return Ss(e,t);case"undefined":return Ss(937,t);default:return Ss(617,t)}}function Ss(e,t){return(t<<5)-t+e|0}function Iv(e,t){return Ss(e?433:863,t)}function qu(e,t){t=Ss(149417,t);for(let s=0,i=e.length;s<i;s++)t=Ss(e.charCodeAt(s),t);return t}function zv(e,t){return t=Ss(104579,t),e.reduce((s,i)=>oc(i,s),t)}function Nv(e,t){return t=Ss(181387,t),Object.keys(e).sort().reduce((s,i)=>(s=qu(i,s),oc(e[i],s)),t)}function rl(e,t,s=32){let i=s-t,r=~((1<<i)-1);return(e<<t|(r&e)>>>i)>>>0}function Ld(e,t=0,s=e.byteLength,i=0){for(let r=0;r<s;r++)e[t+r]=i}function Fv(e,t,s="0"){for(;e.length<t;)e=s+e;return e}function Wr(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join(""):Fv((e>>>0).toString(16),t/4)}function q(e,t,s,i){return new jv(e,t,s,i)}function Vv(e,t){return function(s){return t(new Yr(e,s))}}function Uv(e){return function(t){return e(new Rl(t))}}function Gv(e){let t=e.getBoundingClientRect(),s=qt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}function Gu(e,t,s,...i){let r=Yv.exec(t);if(!r)throw new Error("Bad use of emmet");let o=r[1]||"div",n;return e!=="http://www.w3.org/1999/xhtml"?n=document.createElementNS(e,o):n=document.createElement(o),r[3]&&(n.id=r[3]),r[4]&&(n.className=r[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([a,c])=>{typeof c>"u"||(/^on\w+$/.test(a)?n[a]=c:a==="selected"?c&&n.setAttribute(a,"true"):n.setAttribute(a,c))}),n.append(...i),n}function Xv(e,t,...s){return Gu("http://www.w3.org/1999/xhtml",e,t,...s)}function mt(e){return typeof e=="number"?`${e}px`:e}function so(e){return new Jv(e)}function Zv(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...n){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,n)}),this[o]}}function nl(e,t){let s=t-e;return function(i){return e+s*ob(i)}}function ib(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}function rb(e){return Math.pow(e,3)}function ob(e){return 1-rb(1-e)}function mb(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,is&&(t.className+=" mac"),t}function mi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ys(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function vb(e){return 57508<=e&&e<=57558}function bb(e){return 9472<=e&&e<=9631}function yb(e){return vb(e)||bb(e)}function wb(){return{css:{canvas:hn(),cell:hn()},device:{canvas:hn(),cell:hn(),char:{width:0,height:0,left:0,top:0}}}}function hn(){return{width:0,height:0}}function Hd(e,t,s){for(;e.length<s;)e=t+e;return e}function xb(){return new Cb}function ac(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),n=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-n]}function Lb(e,t,s,i,r,o,n,a,c){if(!o)return;let l=ac(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(c?n/2:0))/n),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}function Mb(){if(!sp)return 0;let e=co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}function Hb(e,t,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Vb(r,o,e,t,s,i)+zn(o,t,s,i)+Ub(r,o,e,t,s,i);let n;if(o===t)return n=r>e?"D":"C",oo(Math.abs(r-e),ro(n,i));n=o>t?"D":"C";let a=Math.abs(o-t),c=jb(o>t?e:r,s)+(a-1)*s.cols+1+Wb(o>t?r:e,s);return oo(c,ro(n,i))}function Wb(e,t){return e-1}function jb(e,t){return t.cols-e}function Vb(e,t,s,i,r,o){return zn(t,i,r,o).length===0?"":oo(ap(e,t,e,t-wi(t,r),!1,r).length,ro("D",o))}function zn(e,t,s,i){let r=e-wi(e,s),o=t-wi(t,s),n=Math.abs(r-o)-qb(e,t,s);return oo(n,ro(np(e,t),i))}function Ub(e,t,s,i,r,o){let n;zn(t,i,r,o).length>0?n=i-wi(i,r):n=t;let a=i,c=Kb(e,t,s,i,r,o);return oo(ap(e,n,s,a,c==="C",r).length,ro(c,o))}function qb(e,t,s){let i=0,r=e-wi(e,s),o=t-wi(t,s);for(let n=0;n<Math.abs(r-o);n++){let a=np(e,t)==="A"?-1:1;s.buffer.lines.get(r+a*n)?.isWrapped&&i++}return i}function wi(e,t){let s=0,i=t.buffer.lines.get(e),r=i?.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i?.isWrapped;return s}function Kb(e,t,s,i,r,o){let n;return zn(s,i,r,o).length>0?n=i-wi(i,r):n=t,e<s&&n<=i||e>=s&&n<i?"C":"D"}function np(e,t){return e>t?"A":"B"}function ap(e,t,s,i,r,o){let n=e,a=t,c="";for(;(n!==s||a!==i)&&a>=0&&a<o.buffer.lines.length;)n+=r?1:-1,r&&n>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,n),n=0,e=0,a++):!r&&n<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),n=o.cols-1,e=n,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,n)}function ro(e,t){let s=t?"O":"[";return M.ESC+s+e}function oo(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}function jd(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}function fe(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}function n0(e,t,s,i,r,o){let n=[];for(let a=0;a<e.length-1;a++){let c=a,l=e.get(++c);if(!l.isWrapped)continue;let h=[e.get(a)];for(;c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(!o&&i>=a&&i<c){a+=h.length-1;continue}let d=0,f=no(h,d,t),p=1,m=0;for(;p<h.length;){let b=no(h,p,t),C=b-m,T=s-f,w=Math.min(C,T);h[d].copyCellsFrom(h[p],m,f,w,!1),f+=w,f===s&&(d++,f=0),m+=w,m===b&&(p++,m=0),f===0&&d!==0&&h[d-1].getWidth(s-1)===2&&(h[d].copyCellsFrom(h[d-1],s-1,f++,1,!1),h[d-1].setCell(s-1,r))}h[d].replaceCells(f,s,r);let _=0;for(let b=h.length-1;b>0&&(b>d||h[b].getTrimmedLength()===0);b--)_++;_>0&&(n.push(a+h.length-_),n.push(_)),a+=h.length-1}return n}function a0(e,t){let s=[],i=0,r=t[i],o=0;for(let n=0;n<e.length;n++)if(r===n){let a=t[++i];e.onDeleteEmitter.fire({index:n-o,amount:a}),n+=a-1,o+=a,r=t[++i]}else s.push(n);return{layout:s,countRemoved:o}}function l0(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function c0(e,t,s){let i=[],r=e.map((c,l)=>no(e,l,t)).reduce((c,l)=>c+l),o=0,n=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}o+=s;let c=no(e,n,t);o>c&&(o-=c,n++);let l=e[n].getWidth(o-1)===2;l&&o--;let h=l?s-1:s;i.push(h),a+=h}return i}function no(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}function f0(e){return e==="block"||e==="underline"||e==="bar"}function Qr(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&Qr(e[i],t-1);return s}function hl(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}function g0(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}function tu(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}function iu(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=k0.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),$0.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function pl(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function E0(e,t=16){let[s,i,r]=e;return`rgb:${pl(s,t)}/${pl(i,t)}/${pl(r,t)}`}function ou(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}function lu(e){return 0<=e&&e<256}function B0(e,t,s,i){let r={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=M.ESC+"OA":r.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=M.ESC+"OD":r.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=M.ESC+"OC":r.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=M.ESC+"OB":r.key=M.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(r.key=M.ESC+r.key);break;case 9:if(e.shiftKey){r.key=M.ESC+"[Z";break}r.key=M.HT,r.cancel=!0;break;case 13:r.key=e.altKey?M.ESC+M.CR:M.CR,r.cancel=!0;break;case 27:r.key=M.ESC,e.altKey&&(r.key=M.ESC+M.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"D":t?r.key=M.ESC+"OD":r.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"C":t?r.key=M.ESC+"OC":r.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"A":t?r.key=M.ESC+"OA":r.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"B":t?r.key=M.ESC+"OB":r.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=M.ESC+"[2~");break;case 46:o?r.key=M.ESC+"[3;"+(o+1)+"~":r.key=M.ESC+"[3~";break;case 36:o?r.key=M.ESC+"[1;"+(o+1)+"H":t?r.key=M.ESC+"OH":r.key=M.ESC+"[H";break;case 35:o?r.key=M.ESC+"[1;"+(o+1)+"F":t?r.key=M.ESC+"OF":r.key=M.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=M.ESC+"[5;"+(o+1)+"~":r.key=M.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=M.ESC+"[6;"+(o+1)+"~":r.key=M.ESC+"[6~";break;case 112:o?r.key=M.ESC+"[1;"+(o+1)+"P":r.key=M.ESC+"OP";break;case 113:o?r.key=M.ESC+"[1;"+(o+1)+"Q":r.key=M.ESC+"OQ";break;case 114:o?r.key=M.ESC+"[1;"+(o+1)+"R":r.key=M.ESC+"OR";break;case 115:o?r.key=M.ESC+"[1;"+(o+1)+"S":r.key=M.ESC+"OS";break;case 116:o?r.key=M.ESC+"[15;"+(o+1)+"~":r.key=M.ESC+"[15~";break;case 117:o?r.key=M.ESC+"[17;"+(o+1)+"~":r.key=M.ESC+"[17~";break;case 118:o?r.key=M.ESC+"[18;"+(o+1)+"~":r.key=M.ESC+"[18~";break;case 119:o?r.key=M.ESC+"[19;"+(o+1)+"~":r.key=M.ESC+"[19~";break;case 120:o?r.key=M.ESC+"[20;"+(o+1)+"~":r.key=M.ESC+"[20~";break;case 121:o?r.key=M.ESC+"[21;"+(o+1)+"~":r.key=M.ESC+"[21~";break;case 122:o?r.key=M.ESC+"[23;"+(o+1)+"~":r.key=M.ESC+"[23~";break;case 123:o?r.key=M.ESC+"[24;"+(o+1)+"~":r.key=M.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=M.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=M.DEL:e.keyCode===219?r.key=M.ESC:e.keyCode===220?r.key=M.FS:e.keyCode===221&&(r.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let n=M0[e.keyCode]?.[e.shiftKey?1:0];if(n)r.key=M.ESC+n;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),r.key=M.ESC+c}else if(e.keyCode===32)r.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),r.key=M.ESC+a,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=M.US),e.key==="@"&&(r.key=M.NUL));break}return r}function H0(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}function j0(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var mu,f_,m_,xe,H,ud,ml,pd,gl,y_,w_,vu,js,ao,xn,Pt,md,_l,Qa,lt,Su,Si,x_,Ql,Cu,ct,xu,k_,lo,vl,Mn,xs,ec,ks,E_,ku,Qi,$u,T_,A_,bl,L_,gd,wl,M_,Au,O_,_d,vd,bd,Fk,z_,Ru,F_,bi,H_,Du,Vs,se,Zi,kt,Cl,we,wd,U_,q_,K_,Sd,G_,Xe,kl,Y_,Cd,Bu,X_,El,J_,Z_,Q_,mn,ev,tv,gn,z,sv,Tl,tc,Wk,jk,er,Al,_n,sc,zu,Vk,Uk,vn,Ji,kn,$n,to,nv,Nu,Fu,av,lv,cv,hv,cn,bn,xd,dv,ws,Cs,xt,Hu,uv,el,Wu,is,pv,tl,fv,qk,rs,zs,mv,gv,_v,vv,Kk,Gk,Yk,Xk,Ns,Jk,ic,sl,kd,$d,bv,ju,yv,wv,Cv,xv,kv,$v,Rl,Ed,Tv,Yr,Td,Uu,Av,Rv,rc,Lv,Dv,il,Pv,Ad,Hv,Zk,qt,Qk,e2,t2,Dd,s2,i2,Wv,r2,o2,jv,Pd,qv,En,Kv,ol,Md,n2,Ie,Yv,Jv,Yu,ss,Xr,Qv,nc,Bd,eb,tb,sb,Od,Id,nb,ab,Xu,Ju,lb,cb,hb,zd,Nd,db,Ml,ub,pb,fb,Bl,Ol,gb,es,Fs,jr,Tn,M,wn,Zu,Il,ze,Ne,Fe,Ce,Fd,Le,ge,Se,at,Sn,_b,An,zl,Sb,Cb,al,Rt,dn,Wd,Vr,un,kb,Nl,Fl,Qu,$b,Eb,Tb,Ab,Rb,Hl,Db,ep,In,co,ho,tp,Pb,sp,Rn,Bb,Ob,ip,lc,rp,op,Ib,zb,Ln,Nb,Wl,Fb,Gb,ll,Yb,Xb,Jb,Zb,Qb,jl,Vd,Ud,Me,gi,Jr,qd,Kd,Ur,e0,Vl,t0,s0,i0,r0,Ul,o0,Gd,ne,Re,pn,cl,Zr,cp,h0,Oe,_i,Yd,Xd,d0,dp,up,ql,Xi,u0,p0,Jd,Zd,Kl,Qd,dl,eu,Gl,ul,m0,Be,_0,vi,v0,qr,b0,pp,Kr,y0,Ct,Gr,w0,eo,su,S0,Dt,C0,x0,k0,$0,T0,Hs,ru,nu,au,A0,Xl,R0,cu,L0,D0,Jl,hu,P0,M0,$e,O0,fl,du,I0,z0,N0,F0,uu,pu,Dn,Zl,W0,V0,U0,fu,q0,K0,G0,Y0,ts,X0,hc=Ta(()=>{mu=Object.defineProperty,f_=Object.getOwnPropertyDescriptor,m_=(e,t)=>{for(var s in t)mu(e,s,{get:t[s],enumerable:!0})},xe=(e,t,s,i)=>{for(var r=i>1?void 0:i?f_(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&mu(t,s,r),r},H=(e,t)=>(s,i)=>t(s,i,e),ud="Terminal input",ml={get:()=>ud,set:e=>ud=e},pd="Too much output to announce, navigate to rows manually to read",gl={get:()=>pd,set:e=>pd=e};y_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=r;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?t[i++]=(n-55296)*1024+a-56320+65536:(t[i++]=n,t[i++]=a);continue}n!==65279&&(t[i++]=n)}return i}},w_=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,o,n,a,c=0,l=0;if(this.interim[0]){let f=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let m=0,_;for(;(_=this.interim[++m]&63)&&m<4;)p<<=6,p|=_;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=b-m;for(;l<C;){if(l>=s)return 0;if(_=e[l++],(_&192)!==128){l--,f=!0;break}else this.interim[m++]=_,p<<=6,p|=_&63}f||(b===2?p<128?l--:t[i++]=p:b===3?p<2048||p>=55296&&p<=57343||p===65279||(t[i++]=p):p<65536||p>1114111||(t[i++]=p)),this.interim.fill(0)}let h=s-4,d=l;for(;d<s;){for(;d<h&&!((r=e[d])&128)&&!((o=e[d+1])&128)&&!((n=e[d+2])&128)&&!((a=e[d+3])&128);)t[i++]=r,t[i++]=o,t[i++]=n,t[i++]=a,d+=4;if(r=e[d++],r<128)t[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(c=(r&31)<<6|o&63,c<128){d--;continue}t[i++]=c}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(c=(r&15)<<12|(o&63)<<6|n&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[i++]=c}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,i;if(a=e[d++],(a&192)!==128){d--;continue}if(c=(r&7)<<18|(o&63)<<12|(n&63)<<6|a&63,c<65536||c>1114111)continue;t[i++]=c}}return i}},vu="",js=" ",ao=class bu{constructor(){this.fg=0,this.bg=0,this.extended=new xn}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new bu;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xn=class yu{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new yu(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pt=class wu extends ao{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xn,this.combinedData=""}static fromCharData(t){let s=new wu;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ws(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},md="di$target",_l="di$dependencies",Qa=new Map;lt=He("BufferService"),Su=He("CoreMouseService"),Si=He("CoreService"),x_=He("CharsetService"),Ql=He("InstantiationService"),Cu=He("LogService"),ct=He("OptionsService"),xu=He("OscLinkService"),k_=He("UnicodeService"),lo=He("DecorationService"),vl=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new Pt,n=s.getTrimmedLength(),a=-1,c=-1,l=!1;for(let h=0;h<n;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,a=o.extended.urlId;continue}else l=o.extended.urlId!==a;else c!==-1&&(l=!0);if(l||c!==-1&&h===n-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let f={start:{x:c+1,y:e},end:{x:h+(!l&&h===n-1?1:0),y:e}},p=!1;if(!r?.allowNonHttpProtocols)try{let m=new URL(d);["http:","https:"].includes(m.protocol)||(p=!0)}catch{p=!0}p||i.push({text:d,range:f,activate:(m,_)=>r?r.activate(m,_,f):$_(m,_),hover:(m,_)=>r?.hover?.(m,_,f),leave:(m,_)=>r?.leave?.(m,_,f)})}l=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,a=o.extended.urlId):(c=-1,a=-1)}}t(i)}};vl=xe([H(0,lt),H(1,ct),H(2,xu)],vl);Mn=He("CharSizeService"),xs=He("CoreBrowserService"),ec=He("MouseService"),ks=He("RenderService"),E_=He("SelectionService"),ku=He("CharacterJoinerService"),Qi=He("ThemeService"),$u=He("LinkProviderService"),T_=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gd.isErrorNoTelemetry(e)?new gd(e.message+`
3
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}function fn(e){R_(e)||A_.onUnexpectedError(e)}function R_(e){return e instanceof L_?!0:e instanceof Error&&e.name===bl&&e.message===bl}function D_(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")}function P_(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function St(e,t=0){return e[e.length-(1+t)]}function B_(e,t){return(s,i)=>t(e(s),e(i))}function I_(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function N_(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function W_(e){bi=e}function Bn(e){return bi?.trackDisposable(e),e}function On(e){bi?.markAsDisposed(e)}function io(e,t){bi?.setParent(e,t)}function j_(e,t){if(bi)for(let s of e)bi.setParent(s,t)}function yd(e){return bi?.markAsSingleton(e),e}function yi(e){if(Ru.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function V_(...e){let t=_e(()=>yi(e));return j_(e,t),t}function _e(e){let t=Bn({dispose:N_(()=>{On(t),e()})});return t}function iv(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}function rv(e){return tc.INSTANCE.getZoomFactor(e)}function ov(){return vn}function Sv(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return ju.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Al)switch(t){case 59:return 85;case 60:if(pv)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(is)return 57;break}else if(_n&&(is&&t===93||!is&&t===92))return 57;return bv[t]||0}function Ev(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}function Mv(e){return 55296<=e&&e<=56319}function Rd(e){return 56320<=e&&e<=57343}function Bv(e,t){return(e-55296<<10)+(t-56320)+65536}function Ov(e){return oc(e,0)}function oc(e,t){switch(typeof e){case"object":return e===null?Ss(349,t):Array.isArray(e)?zv(e,t):Nv(e,t);case"string":return qu(e,t);case"boolean":return Iv(e,t);case"number":return Ss(e,t);case"undefined":return Ss(937,t);default:return Ss(617,t)}}function Ss(e,t){return(t<<5)-t+e|0}function Iv(e,t){return Ss(e?433:863,t)}function qu(e,t){t=Ss(149417,t);for(let s=0,i=e.length;s<i;s++)t=Ss(e.charCodeAt(s),t);return t}function zv(e,t){return t=Ss(104579,t),e.reduce((s,i)=>oc(i,s),t)}function Nv(e,t){return t=Ss(181387,t),Object.keys(e).sort().reduce((s,i)=>(s=qu(i,s),oc(e[i],s)),t)}function rl(e,t,s=32){let i=s-t,r=~((1<<i)-1);return(e<<t|(r&e)>>>i)>>>0}function Ld(e,t=0,s=e.byteLength,i=0){for(let r=0;r<s;r++)e[t+r]=i}function Fv(e,t,s="0"){for(;e.length<t;)e=s+e;return e}function Wr(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join(""):Fv((e>>>0).toString(16),t/4)}function q(e,t,s,i){return new jv(e,t,s,i)}function Vv(e,t){return function(s){return t(new Yr(e,s))}}function Uv(e){return function(t){return e(new Rl(t))}}function Gv(e){let t=e.getBoundingClientRect(),s=qt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}function Gu(e,t,s,...i){let r=Yv.exec(t);if(!r)throw new Error("Bad use of emmet");let o=r[1]||"div",n;return e!=="http://www.w3.org/1999/xhtml"?n=document.createElementNS(e,o):n=document.createElement(o),r[3]&&(n.id=r[3]),r[4]&&(n.className=r[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([a,c])=>{typeof c>"u"||(/^on\w+$/.test(a)?n[a]=c:a==="selected"?c&&n.setAttribute(a,"true"):n.setAttribute(a,c))}),n.append(...i),n}function Xv(e,t,...s){return Gu("http://www.w3.org/1999/xhtml",e,t,...s)}function mt(e){return typeof e=="number"?`${e}px`:e}function so(e){return new Jv(e)}function Zv(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...n){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,n)}),this[o]}}function nl(e,t){let s=t-e;return function(i){return e+s*ob(i)}}function ib(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}function rb(e){return Math.pow(e,3)}function ob(e){return 1-rb(1-e)}function mb(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,is&&(t.className+=" mac"),t}function mi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ys(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function vb(e){return 57508<=e&&e<=57558}function bb(e){return 9472<=e&&e<=9631}function yb(e){return vb(e)||bb(e)}function wb(){return{css:{canvas:hn(),cell:hn()},device:{canvas:hn(),cell:hn(),char:{width:0,height:0,left:0,top:0}}}}function hn(){return{width:0,height:0}}function Hd(e,t,s){for(;e.length<s;)e=t+e;return e}function xb(){return new Cb}function ac(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),n=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-n]}function Lb(e,t,s,i,r,o,n,a,c){if(!o)return;let l=ac(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(c?n/2:0))/n),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}function Mb(){if(!sp)return 0;let e=co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}function Hb(e,t,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Vb(r,o,e,t,s,i)+zn(o,t,s,i)+Ub(r,o,e,t,s,i);let n;if(o===t)return n=r>e?"D":"C",oo(Math.abs(r-e),ro(n,i));n=o>t?"D":"C";let a=Math.abs(o-t),c=jb(o>t?e:r,s)+(a-1)*s.cols+1+Wb(o>t?r:e,s);return oo(c,ro(n,i))}function Wb(e,t){return e-1}function jb(e,t){return t.cols-e}function Vb(e,t,s,i,r,o){return zn(t,i,r,o).length===0?"":oo(ap(e,t,e,t-wi(t,r),!1,r).length,ro("D",o))}function zn(e,t,s,i){let r=e-wi(e,s),o=t-wi(t,s),n=Math.abs(r-o)-qb(e,t,s);return oo(n,ro(np(e,t),i))}function Ub(e,t,s,i,r,o){let n;zn(t,i,r,o).length>0?n=i-wi(i,r):n=t;let a=i,c=Kb(e,t,s,i,r,o);return oo(ap(e,n,s,a,c==="C",r).length,ro(c,o))}function qb(e,t,s){let i=0,r=e-wi(e,s),o=t-wi(t,s);for(let n=0;n<Math.abs(r-o);n++){let a=np(e,t)==="A"?-1:1;s.buffer.lines.get(r+a*n)?.isWrapped&&i++}return i}function wi(e,t){let s=0,i=t.buffer.lines.get(e),r=i?.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i?.isWrapped;return s}function Kb(e,t,s,i,r,o){let n;return zn(s,i,r,o).length>0?n=i-wi(i,r):n=t,e<s&&n<=i||e>=s&&n<i?"C":"D"}function np(e,t){return e>t?"A":"B"}function ap(e,t,s,i,r,o){let n=e,a=t,c="";for(;(n!==s||a!==i)&&a>=0&&a<o.buffer.lines.length;)n+=r?1:-1,r&&n>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,n),n=0,e=0,a++):!r&&n<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),n=o.cols-1,e=n,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,n)}function ro(e,t){let s=t?"O":"[";return M.ESC+s+e}function oo(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}function jd(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}function fe(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}function n0(e,t,s,i,r,o){let n=[];for(let a=0;a<e.length-1;a++){let c=a,l=e.get(++c);if(!l.isWrapped)continue;let h=[e.get(a)];for(;c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(!o&&i>=a&&i<c){a+=h.length-1;continue}let d=0,f=no(h,d,t),p=1,m=0;for(;p<h.length;){let b=no(h,p,t),C=b-m,T=s-f,w=Math.min(C,T);h[d].copyCellsFrom(h[p],m,f,w,!1),f+=w,f===s&&(d++,f=0),m+=w,m===b&&(p++,m=0),f===0&&d!==0&&h[d-1].getWidth(s-1)===2&&(h[d].copyCellsFrom(h[d-1],s-1,f++,1,!1),h[d-1].setCell(s-1,r))}h[d].replaceCells(f,s,r);let _=0;for(let b=h.length-1;b>0&&(b>d||h[b].getTrimmedLength()===0);b--)_++;_>0&&(n.push(a+h.length-_),n.push(_)),a+=h.length-1}return n}function a0(e,t){let s=[],i=0,r=t[i],o=0;for(let n=0;n<e.length;n++)if(r===n){let a=t[++i];e.onDeleteEmitter.fire({index:n-o,amount:a}),n+=a-1,o+=a,r=t[++i]}else s.push(n);return{layout:s,countRemoved:o}}function l0(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function c0(e,t,s){let i=[],r=e.map((c,l)=>no(e,l,t)).reduce((c,l)=>c+l),o=0,n=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}o+=s;let c=no(e,n,t);o>c&&(o-=c,n++);let l=e[n].getWidth(o-1)===2;l&&o--;let h=l?s-1:s;i.push(h),a+=h}return i}function no(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}function f0(e){return e==="block"||e==="underline"||e==="bar"}function Qr(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&Qr(e[i],t-1);return s}function hl(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}function g0(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}function tu(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}function iu(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=k0.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),$0.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function pl(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function E0(e,t=16){let[s,i,r]=e;return`rgb:${pl(s,t)}/${pl(i,t)}/${pl(r,t)}`}function ou(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}function lu(e){return 0<=e&&e<256}function B0(e,t,s,i){let r={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=M.ESC+"OA":r.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=M.ESC+"OD":r.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=M.ESC+"OC":r.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=M.ESC+"OB":r.key=M.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(r.key=M.ESC+r.key);break;case 9:if(e.shiftKey){r.key=M.ESC+"[Z";break}r.key=M.HT,r.cancel=!0;break;case 13:r.key=e.altKey?M.ESC+M.CR:M.CR,r.cancel=!0;break;case 27:r.key=M.ESC,e.altKey&&(r.key=M.ESC+M.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"D":t?r.key=M.ESC+"OD":r.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"C":t?r.key=M.ESC+"OC":r.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"A":t?r.key=M.ESC+"OA":r.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"B":t?r.key=M.ESC+"OB":r.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=M.ESC+"[2~");break;case 46:o?r.key=M.ESC+"[3;"+(o+1)+"~":r.key=M.ESC+"[3~";break;case 36:o?r.key=M.ESC+"[1;"+(o+1)+"H":t?r.key=M.ESC+"OH":r.key=M.ESC+"[H";break;case 35:o?r.key=M.ESC+"[1;"+(o+1)+"F":t?r.key=M.ESC+"OF":r.key=M.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=M.ESC+"[5;"+(o+1)+"~":r.key=M.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=M.ESC+"[6;"+(o+1)+"~":r.key=M.ESC+"[6~";break;case 112:o?r.key=M.ESC+"[1;"+(o+1)+"P":r.key=M.ESC+"OP";break;case 113:o?r.key=M.ESC+"[1;"+(o+1)+"Q":r.key=M.ESC+"OQ";break;case 114:o?r.key=M.ESC+"[1;"+(o+1)+"R":r.key=M.ESC+"OR";break;case 115:o?r.key=M.ESC+"[1;"+(o+1)+"S":r.key=M.ESC+"OS";break;case 116:o?r.key=M.ESC+"[15;"+(o+1)+"~":r.key=M.ESC+"[15~";break;case 117:o?r.key=M.ESC+"[17;"+(o+1)+"~":r.key=M.ESC+"[17~";break;case 118:o?r.key=M.ESC+"[18;"+(o+1)+"~":r.key=M.ESC+"[18~";break;case 119:o?r.key=M.ESC+"[19;"+(o+1)+"~":r.key=M.ESC+"[19~";break;case 120:o?r.key=M.ESC+"[20;"+(o+1)+"~":r.key=M.ESC+"[20~";break;case 121:o?r.key=M.ESC+"[21;"+(o+1)+"~":r.key=M.ESC+"[21~";break;case 122:o?r.key=M.ESC+"[23;"+(o+1)+"~":r.key=M.ESC+"[23~";break;case 123:o?r.key=M.ESC+"[24;"+(o+1)+"~":r.key=M.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=M.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=M.DEL:e.keyCode===219?r.key=M.ESC:e.keyCode===220?r.key=M.FS:e.keyCode===221&&(r.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let n=M0[e.keyCode]?.[e.shiftKey?1:0];if(n)r.key=M.ESC+n;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),r.key=M.ESC+c}else if(e.keyCode===32)r.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),r.key=M.ESC+a,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=M.US),e.key==="@"&&(r.key=M.NUL));break}return r}function H0(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}function j0(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var mu,f_,m_,xe,H,ud,ml,pd,gl,y_,w_,vu,js,ao,xn,Pt,md,_l,Qa,lt,Su,Si,x_,Ql,Cu,ct,xu,k_,lo,vl,Mn,xs,ec,ks,E_,ku,Qi,$u,T_,A_,bl,L_,gd,wl,M_,Au,O_,_d,vd,bd,Fk,z_,Ru,F_,bi,H_,Du,Vs,se,Zi,kt,Cl,we,wd,U_,q_,K_,Sd,G_,Xe,kl,Y_,Cd,Bu,X_,El,J_,Z_,Q_,mn,ev,tv,gn,z,sv,Tl,tc,Wk,jk,er,Al,_n,sc,zu,Vk,Uk,vn,Ji,kn,$n,to,nv,Nu,Fu,av,lv,cv,hv,cn,bn,xd,dv,ws,Cs,xt,Hu,uv,el,Wu,is,pv,tl,fv,qk,rs,zs,mv,gv,_v,vv,Kk,Gk,Yk,Xk,Ns,Jk,ic,sl,kd,$d,bv,ju,yv,wv,Cv,xv,kv,$v,Rl,Ed,Tv,Yr,Td,Uu,Av,Rv,rc,Lv,Dv,il,Pv,Ad,Hv,Zk,qt,Qk,e2,t2,Dd,s2,i2,Wv,r2,o2,jv,Pd,qv,En,Kv,ol,Md,n2,Ie,Yv,Jv,Yu,ss,Xr,Qv,nc,Bd,eb,tb,sb,Od,Id,nb,ab,Xu,Ju,lb,cb,hb,zd,Nd,db,Ml,ub,pb,fb,Bl,Ol,gb,es,Fs,jr,Tn,M,wn,Zu,Il,ze,Ne,Fe,Ce,Fd,Re,ge,Se,at,Sn,_b,An,zl,Sb,Cb,al,Rt,dn,Wd,Vr,un,kb,Nl,Fl,Qu,$b,Eb,Tb,Ab,Rb,Hl,Db,ep,In,co,ho,tp,Pb,sp,Rn,Bb,Ob,ip,lc,rp,op,Ib,zb,Ln,Nb,Wl,Fb,Gb,ll,Yb,Xb,Jb,Zb,Qb,jl,Vd,Ud,Pe,gi,Jr,qd,Kd,Ur,e0,Vl,t0,s0,i0,r0,Ul,o0,Gd,ne,Ae,pn,cl,Zr,cp,h0,Be,_i,Yd,Xd,d0,dp,up,ql,Xi,u0,p0,Jd,Zd,Kl,Qd,dl,eu,Gl,ul,m0,Me,_0,vi,v0,qr,b0,pp,Kr,y0,Ct,Gr,w0,eo,su,S0,Dt,C0,x0,k0,$0,T0,Hs,ru,nu,au,A0,Xl,R0,cu,L0,D0,Jl,hu,P0,M0,$e,O0,fl,du,I0,z0,N0,F0,uu,pu,Dn,Zl,W0,V0,U0,fu,q0,K0,G0,Y0,ts,X0,hc=Ta(()=>{mu=Object.defineProperty,f_=Object.getOwnPropertyDescriptor,m_=(e,t)=>{for(var s in t)mu(e,s,{get:t[s],enumerable:!0})},xe=(e,t,s,i)=>{for(var r=i>1?void 0:i?f_(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&mu(t,s,r),r},H=(e,t)=>(s,i)=>t(s,i,e),ud="Terminal input",ml={get:()=>ud,set:e=>ud=e},pd="Too much output to announce, navigate to rows manually to read",gl={get:()=>pd,set:e=>pd=e};y_=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=r;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?t[i++]=(n-55296)*1024+a-56320+65536:(t[i++]=n,t[i++]=a);continue}n!==65279&&(t[i++]=n)}return i}},w_=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,o,n,a,c=0,l=0;if(this.interim[0]){let f=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let m=0,_;for(;(_=this.interim[++m]&63)&&m<4;)p<<=6,p|=_;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=b-m;for(;l<C;){if(l>=s)return 0;if(_=e[l++],(_&192)!==128){l--,f=!0;break}else this.interim[m++]=_,p<<=6,p|=_&63}f||(b===2?p<128?l--:t[i++]=p:b===3?p<2048||p>=55296&&p<=57343||p===65279||(t[i++]=p):p<65536||p>1114111||(t[i++]=p)),this.interim.fill(0)}let h=s-4,d=l;for(;d<s;){for(;d<h&&!((r=e[d])&128)&&!((o=e[d+1])&128)&&!((n=e[d+2])&128)&&!((a=e[d+3])&128);)t[i++]=r,t[i++]=o,t[i++]=n,t[i++]=a,d+=4;if(r=e[d++],r<128)t[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(c=(r&31)<<6|o&63,c<128){d--;continue}t[i++]=c}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(c=(r&15)<<12|(o&63)<<6|n&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[i++]=c}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,i;if(a=e[d++],(a&192)!==128){d--;continue}if(c=(r&7)<<18|(o&63)<<12|(n&63)<<6|a&63,c<65536||c>1114111)continue;t[i++]=c}}return i}},vu="",js=" ",ao=class bu{constructor(){this.fg=0,this.bg=0,this.extended=new xn}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new bu;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},xn=class yu{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new yu(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Pt=class wu extends ao{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new xn,this.combinedData=""}static fromCharData(t){let s=new wu;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ws(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},md="di$target",_l="di$dependencies",Qa=new Map;lt=He("BufferService"),Su=He("CoreMouseService"),Si=He("CoreService"),x_=He("CharsetService"),Ql=He("InstantiationService"),Cu=He("LogService"),ct=He("OptionsService"),xu=He("OscLinkService"),k_=He("UnicodeService"),lo=He("DecorationService"),vl=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new Pt,n=s.getTrimmedLength(),a=-1,c=-1,l=!1;for(let h=0;h<n;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,a=o.extended.urlId;continue}else l=o.extended.urlId!==a;else c!==-1&&(l=!0);if(l||c!==-1&&h===n-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let f={start:{x:c+1,y:e},end:{x:h+(!l&&h===n-1?1:0),y:e}},p=!1;if(!r?.allowNonHttpProtocols)try{let m=new URL(d);["http:","https:"].includes(m.protocol)||(p=!0)}catch{p=!0}p||i.push({text:d,range:f,activate:(m,_)=>r?r.activate(m,_,f):$_(m,_),hover:(m,_)=>r?.hover?.(m,_,f),leave:(m,_)=>r?.leave?.(m,_,f)})}l=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,a=o.extended.urlId):(c=-1,a=-1)}}t(i)}};vl=xe([H(0,lt),H(1,ct),H(2,xu)],vl);Mn=He("CharSizeService"),xs=He("CoreBrowserService"),ec=He("MouseService"),ks=He("RenderService"),E_=He("SelectionService"),ku=He("CharacterJoinerService"),Qi=He("ThemeService"),$u=He("LinkProviderService"),T_=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gd.isErrorNoTelemetry(e)?new gd(e.message+`
4
4
 
5
5
  `+e.stack):new Error(e.message+`
6
6
 
@@ -28,11 +28,11 @@ ${h.join(`
28
28
  `).slice(2,3).join(`
29
29
  `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);gn.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*ev<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||fn;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof mn)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},sv=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Tl=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Tl.INSTANCE=new Tl;tc=Tl;Wk=tc.INSTANCE.onDidChangeZoomLevel;jk=tc.INSTANCE.onDidChangeFullscreen,er=typeof navigator=="object"?navigator.userAgent:"",Al=er.indexOf("Firefox")>=0,_n=er.indexOf("AppleWebKit")>=0,sc=er.indexOf("Chrome")>=0,zu=!sc&&er.indexOf("Safari")>=0,Vk=er.indexOf("Electron/")>=0,Uk=er.indexOf("Android")>=0,vn=!1;if(typeof kt.matchMedia=="function"){let e=kt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=kt.matchMedia("(display-mode: fullscreen)");vn=e.matches,iv(kt,e,({matches:s})=>{vn&&t.matches||(vn=s)})}Ji="en",kn=!1,$n=!1,to=!1,nv=!1,Nu=!1,Fu=!1,av=!1,lv=!1,cv=!1,hv=!1,bn=Ji,xd=Ji,Cs=globalThis;typeof Cs.vscode<"u"&&typeof Cs.vscode.process<"u"?xt=Cs.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(xt=process);Hu=typeof xt?.versions?.electron=="string",uv=Hu&&xt?.type==="renderer";if(typeof xt=="object"){kn=xt.platform==="win32",$n=xt.platform==="darwin",to=xt.platform==="linux",nv=to&&!!xt.env.SNAP&&!!xt.env.SNAP_REVISION,av=Hu,cv=!!xt.env.CI||!!xt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,cn=Ji,bn=Ji;let e=xt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);cn=t.userLocale,xd=t.osLocale,bn=t.resolvedLanguage||Ji,dv=t.languagePack?.translationsConfigFile}catch{}Nu=!0}else typeof navigator=="object"&&!uv?(ws=navigator.userAgent,kn=ws.indexOf("Windows")>=0,$n=ws.indexOf("Macintosh")>=0,lv=(ws.indexOf("Macintosh")>=0||ws.indexOf("iPad")>=0||ws.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,to=ws.indexOf("Linux")>=0,hv=ws?.indexOf("Mobi")>=0,Fu=!0,bn=globalThis._VSCODE_NLS_LANGUAGE||Ji,cn=navigator.language.toLowerCase(),xd=cn):console.error("Unable to resolve platform.");el=0;$n?el=1:kn?el=3:to&&(el=2);Wu=kn,is=$n,pv=to,tl=Nu,fv=Fu&&typeof Cs.importScripts=="function",qk=fv?Cs.origin:void 0,rs=ws,zs=bn;(e=>{function t(){return zs}e.value=t;function s(){return zs.length===2?zs==="en":zs.length>=3?zs[0]==="e"&&zs[1]==="n"&&zs[2]==="-":!1}e.isDefaultVariant=s;function i(){return zs==="en"}e.isDefault=i})(mv||(mv={}));gv=typeof Cs.postMessage=="function"&&!Cs.importScripts,_v=(()=>{if(gv){let e=[];Cs.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Cs.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),vv=!!(rs&&rs.indexOf("Chrome")>=0),Kk=!!(rs&&rs.indexOf("Firefox")>=0),Gk=!!(!vv&&rs&&rs.indexOf("Safari")>=0),Yk=!!(rs&&rs.indexOf("Edg/")>=0),Xk=!!(rs&&rs.indexOf("Android")>=0),Ns=typeof navigator=="object"?navigator:{},Jk={clipboard:{writeText:tl||document.queryCommandSupported&&document.queryCommandSupported("copy")||!!(Ns&&Ns.clipboard&&Ns.clipboard.writeText),readText:tl||!!(Ns&&Ns.clipboard&&Ns.clipboard.readText)},keyboard:tl||ov()?0:Ns.keyboard||zu?1:2,touch:"ontouchstart"in kt||Ns.maxTouchPoints>0,pointerEvents:kt.PointerEvent&&("ontouchstart"in kt||navigator.maxTouchPoints>0)},ic=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},sl=new ic,kd=new ic,$d=new ic,bv=new Array(230);(e=>{function t(a){return sl.keyCodeToStr(a)}e.toString=t;function s(a){return sl.strToKeyCode(a)}e.fromString=s;function i(a){return kd.keyCodeToStr(a)}e.toUserSettingsUS=i;function r(a){return $d.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function o(a){return kd.strToKeyCode(a)||$d.strToKeyCode(a)}e.fromUserSettings=o;function n(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return sl.keyCodeToStr(a)}e.toElectronAccelerator=n})(ju||(ju={}));yv=class Vu{constructor(t,s,i,r,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(t){return t instanceof Vu&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new wv([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},wv=class{constructor(e){if(e.length===0)throw D_("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};Cv=is?256:2048,xv=512,kv=1024,$v=is?2048:256,Rl=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=Sv(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Cv),this.altKey&&(t|=xv),this.shiftKey&&(t|=kv),this.metaKey&&(t|=$v),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new yv(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ed=new WeakMap;Tv=class{static getSameOriginWindowChain(e){let t=Ed.get(e);if(!t){t=[],Ed.set(e,t);let s=e,i;do i=Ev(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(e);for(let o of r){let n=o.window.deref();if(s+=n?.scrollY??0,i+=n?.scrollX??0,n===t||!o.iframeElement)break;let a=o.iframeElement.getBoundingClientRect();s+=a.top,i+=a.left}return{top:s,left:i}}},Yr=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Tv.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Td=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(sc){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(e){let r=e,o=e,n=e.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*n):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Al&&!is?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof r.wheelDeltaX<"u")zu&&Wu?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*n):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let a=e;a.deltaMode===a.DOM_DELTA_LINE?Al&&!is?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*n):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Uu=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Rv?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Xe.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Uu})})(Av||(Av={}));Rv=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Uu:(this._emitter||(this._emitter=new z),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},rc=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new wl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new wl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Lv=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new wl("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=_e(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?il=(e,t)=>{_v(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:il=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},Dv=e=>il(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(Pv||(Pv={}));Ad=class Lt{static fromArray(t){return new Lt(s=>{s.emitMany(t)})}static fromPromise(t){return new Lt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Lt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Lt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new z,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Xe.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Lt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Lt.map(this,t)}static filter(t,s){return new Lt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Lt.filter(this,t)}static coalesce(t){return Lt.filter(t,s=>!!s)}coalesce(){return Lt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Lt.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Ad.EMPTY=Ad.fromArray([]);Hv=class Ku{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(t){let s=t.length;if(s===0)return;let i=this._buff,r=this._buffLen,o=this._leftoverHighSurrogate,n,a;for(o!==0?(n=o,a=-1,o=0):(n=t.charCodeAt(0),a=0);;){let c=n;if(Mv(n))if(a+1<s){let l=t.charCodeAt(a+1);Rd(l)?(a++,c=Bv(n,l)):c=65533}else{o=n;break}else Rd(n)&&(c=65533);if(r=this._push(i,r,c),a++,a<s)n=t.charCodeAt(a);else break}this._buffLen=r,this._leftoverHighSurrogate=o}_push(t,s,i){return i<128?t[s++]=i:i<2048?(t[s++]=192|(i&1984)>>>6,t[s++]=128|(i&63)>>>0):i<65536?(t[s++]=224|(i&61440)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0):(t[s++]=240|(i&1835008)>>>18,t[s++]=128|(i&258048)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0),s>=64&&(this._step(),s-=64,this._totalLen+=64,t[0]=t[64],t[1]=t[65],t[2]=t[66]),s}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),Wr(this._h0)+Wr(this._h1)+Wr(this._h2)+Wr(this._h3)+Wr(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Ld(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Ld(this._buff));let t=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(t/4294967296),!1),this._buffDV.setUint32(60,t%4294967296,!1),this._step()}_step(){let t=Ku._bigBlock32,s=this._buffDV;for(let d=0;d<64;d+=4)t.setUint32(d,s.getUint32(d,!1),!1);for(let d=64;d<320;d+=4)t.setUint32(d,rl(t.getUint32(d-12,!1)^t.getUint32(d-32,!1)^t.getUint32(d-56,!1)^t.getUint32(d-64,!1),1),!1);let i=this._h0,r=this._h1,o=this._h2,n=this._h3,a=this._h4,c,l,h;for(let d=0;d<80;d++)d<20?(c=r&o|~r&n,l=1518500249):d<40?(c=r^o^n,l=1859775393):d<60?(c=r&o|r&n|o&n,l=2400959708):(c=r^o^n,l=3395469782),h=rl(i,5)+c+a+l+t.getUint32(d*4,!1)&4294967295,a=n,n=o,o=rl(r,30),r=i,i=h;this._h0=this._h0+i&4294967295,this._h1=this._h1+r&4294967295,this._h2=this._h2+o&4294967295,this._h3=this._h3+n&4294967295,this._h4=this._h4+a&4294967295}};Hv._bigBlock32=new DataView(new ArrayBuffer(320));({registerWindow:Zk,getWindow:qt,getDocument:Qk,getWindows:e2,getWindowsCount:t2,getWindowId:Dd,getWindowById:s2,hasWindow:i2,onDidRegisterWindow:Wv,onWillUnregisterWindow:r2,onDidUnregisterWindow:o2}=(function(){let e=new Map,t={window:kt,disposables:new Vs};e.set(kt.vscodeWindowId,t);let s=new z,i=new z,r=new z;function o(n,a){return(typeof n=="number"?e.get(n):void 0)??(a?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(n){if(e.has(n.vscodeWindowId))return se.None;let a=new Vs,c={window:n,disposables:a.add(new Vs)};return e.set(n.vscodeWindowId,c),a.add(_e(()=>{e.delete(n.vscodeWindowId),i.fire(n)})),a.add(q(n,Ie.BEFORE_UNLOAD,()=>{r.fire(n)})),s.fire(c),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(n){return n.vscodeWindowId},hasWindow(n){return e.has(n)},getWindowById:o,getWindow(n){let a=n;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let c=n;return c?.view?c.view.window:kt},getDocument(n){return qt(n).document}}})()),jv=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};Pd=function(e,t,s,i){let r=s;return t==="click"||t==="mousedown"||t==="contextmenu"?r=Vv(qt(e),s):(t==="keydown"||t==="keypress"||t==="keyup")&&(r=Uv(s)),q(e,t,r,i)},Kv=class extends Lv{constructor(e){super(),this.defaultTarget=e&&qt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},ol=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){fn(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let n=e.get(o)??[];for(t.set(o,n),e.set(o,[]),i.set(o,!0);n.length>0;)n.sort(ol.sort),n.shift().execute();i.set(o,!1)};En=(o,n,a=0)=>{let c=Dd(o),l=new ol(n,a),h=e.get(c);return h||(h=[],e.set(c,h)),h.push(l),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),l},qv=(o,n,a)=>{let c=Dd(o);if(i.get(c)){let l=new ol(n,a),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(l),l}else return En(o,n,a)}})();Md=class yn{constructor(t,s){this.width=t,this.height=s}with(t=this.width,s=this.height){return t!==this.width||s!==this.height?new yn(t,s):this}static is(t){return typeof t=="object"&&typeof t.height=="number"&&typeof t.width=="number"}static lift(t){return t instanceof yn?t:new yn(t.width,t.height)}static equals(t,s){return t===s?!0:!t||!s?!1:t.width===s.width&&t.height===s.height}};Md.None=new Md(0,0);n2=new class{constructor(){this.mutationObservers=new Map}observe(e,t,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let r=Ov(s),o=i.get(r);if(o)o.users+=1;else{let n=new z,a=new MutationObserver(l=>n.fire(l));a.observe(e,s);let c=o={users:1,observer:a,onDidMutate:n.event};t.add(_e(()=>{c.users-=1,c.users===0&&(n.dispose(),a.disconnect(),i?.delete(r),i?.size===0&&this.mutationObservers.delete(e))})),i.set(r,o)}return o.onDidMutate}},Ie={CLICK:"click",AUXCLICK:"auxclick",DBLCLICK:"dblclick",MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_MOVE:"mousemove",MOUSE_OUT:"mouseout",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",POINTER_LEAVE:"pointerleave",CONTEXT_MENU:"contextmenu",WHEEL:"wheel",KEY_DOWN:"keydown",KEY_PRESS:"keypress",KEY_UP:"keyup",LOAD:"load",BEFORE_UNLOAD:"beforeunload",UNLOAD:"unload",PAGE_SHOW:"pageshow",PAGE_HIDE:"pagehide",PASTE:"paste",ABORT:"abort",ERROR:"error",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_CHANGE:"fullscreenchange",WK_FULLSCREEN_CHANGE:"webkitfullscreenchange",SELECT:"select",CHANGE:"change",SUBMIT:"submit",RESET:"reset",FOCUS:"focus",FOCUS_IN:"focusin",FOCUS_OUT:"focusout",BLUR:"blur",INPUT:"input",STORAGE:"storage",DRAG_START:"dragstart",DRAG:"drag",DRAG_ENTER:"dragenter",DRAG_LEAVE:"dragleave",DRAG_OVER:"dragover",DROP:"drop",DRAG_END:"dragend",ANIMATION_START:_n?"webkitAnimationStart":"animationstart",ANIMATION_END:_n?"webkitAnimationEnd":"animationend",ANIMATION_ITERATION:_n?"webkitAnimationIteration":"animationiteration"},Yv=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;Xv.SVG=function(e,t,...s){return Gu("http://www.w3.org/2000/svg",e,t,...s)};Jv=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=mt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=mt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=mt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=mt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=mt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=mt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=mt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=mt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=mt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=mt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=mt(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=mt(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=mt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=mt(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};Yu=class{constructor(){this._hooks=new Vs,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=e;try{e.setPointerCapture(t),this._hooks.add(_e(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=qt(e)}this._hooks.add(q(o,Ie.POINTER_MOVE,n=>{if(n.buttons!==s){this.stopMonitoring(!0);return}n.preventDefault(),this._pointerMoveCallback(n)})),this._hooks.add(q(o,Ie.POINTER_UP,n=>this.stopMonitoring(!0)))}};(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ss||(ss={}));Xr=class rt extends se{constructor(){super(),this.dispatched=!1,this.targets=new wd,this.ignoreTargets=new wd,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Xe.runAndSubscribe(Wv,({window:t,disposables:s})=>{s.add(q(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(q(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(q(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:kt,disposables:this._store}))}static addTarget(t){if(!rt.isTouchDevice())return se.None;rt.INSTANCE||(rt.INSTANCE=yd(new rt));let s=rt.INSTANCE.targets.push(t);return _e(s)}static ignoreTarget(t){if(!rt.isTouchDevice())return se.None;rt.INSTANCE||(rt.INSTANCE=yd(new rt));let s=rt.INSTANCE.ignoreTargets.push(t);return _e(s)}static isTouchDevice(){return"ontouchstart"in kt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i<r;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let n=this.newGestureEvent(ss.Start,o.target);n.pageX=o.pageX,n.pageY=o.pageY,this.dispatchEvent(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,n=s.changedTouches.length;o<n;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],l=Date.now()-c.initialTimeStamp;if(l<rt.HOLD_DELAY&&Math.abs(c.initialPageX-St(c.rollingPageX))<30&&Math.abs(c.initialPageY-St(c.rollingPageY))<30){let h=this.newGestureEvent(ss.Tap,c.initialTarget);h.pageX=St(c.rollingPageX),h.pageY=St(c.rollingPageY),this.dispatchEvent(h)}else if(l>=rt.HOLD_DELAY&&Math.abs(c.initialPageX-St(c.rollingPageX))<30&&Math.abs(c.initialPageY-St(c.rollingPageY))<30){let h=this.newGestureEvent(ss.Contextmenu,c.initialTarget);h.pageX=St(c.rollingPageX),h.pageY=St(c.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=St(c.rollingPageX),d=St(c.rollingPageY),f=St(c.rollingTimestamps)-c.rollingTimestamps[0],p=h-c.rollingPageX[0],m=d-c.rollingPageY[0],_=[...this.targets].filter(b=>c.initialTarget instanceof Node&&b.contains(c.initialTarget));this.inertia(t,_,i,Math.abs(p)/f,p>0?1:-1,h,Math.abs(m)/f,m>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(ss.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===ss.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>rt.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===ss.Change||t.type===ss.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,o=t.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,o,n,a,c,l){this.handle=En(t,()=>{let h=Date.now(),d=h-i,f=0,p=0,m=!0;r+=rt.SCROLL_FRICTION*d,a+=rt.SCROLL_FRICTION*d,r>0&&(m=!1,f=o*r*d),a>0&&(m=!1,p=c*a*d);let _=this.newGestureEvent(ss.Change);_.translationX=f,_.translationY=p,s.forEach(b=>b.dispatchEvent(_)),m||this.inertia(t,s,h,r,o,n+f,a,c,l+p)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i<r;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let n=this.activeTouches[o.identifier],a=this.newGestureEvent(ss.Change,n.initialTarget);a.translationX=o.pageX-St(n.rollingPageX),a.translationY=o.pageY-St(n.rollingPageY),a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(o.pageX),n.rollingPageY.push(o.pageY),n.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Xr.SCROLL_FRICTION=-.005,Xr.HOLD_DELAY=700,Xr.CLEAR_TAP_COUNT_TIME=400,xe([Zv],Xr,"isTouchDevice",1);Qv=Xr,nc=class extends se{onclick(e,t){this._register(q(e,Ie.CLICK,s=>t(new Yr(qt(e),s))))}onmousedown(e,t){this._register(q(e,Ie.MOUSE_DOWN,s=>t(new Yr(qt(e),s))))}onmouseover(e,t){this._register(q(e,Ie.MOUSE_OVER,s=>t(new Yr(qt(e),s))))}onmouseleave(e,t){this._register(q(e,Ie.MOUSE_LEAVE,s=>t(new Yr(qt(e),s))))}onkeydown(e,t){this._register(q(e,Ie.KEY_DOWN,s=>t(new Rl(s))))}onkeyup(e,t){this._register(q(e,Ie.KEY_UP,s=>t(new Rl(s))))}oninput(e,t){this._register(q(e,Ie.INPUT,t))}onblur(e,t){this._register(q(e,Ie.BLUR,t))}onfocus(e,t){this._register(q(e,Ie.FOCUS,t))}onchange(e,t){this._register(q(e,Ie.CHANGE,t))}ignoreGesture(e){return Qv.ignoreTarget(e)}},Bd=11,eb=class extends nc{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Bd+"px",this.domNode.style.height=Bd+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Yu),this._register(Pd(this.bgDomNode,Ie.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Pd(this.domNode,Ie.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Kv),this._pointerdownScheduleRepeatTimer=this._register(new rc)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,qt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},tb=class Ll{constructor(t,s,i,r,o,n,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,n=n|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),a+o>n&&(a=n-o),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=n,this.scrollTop=a}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Ll(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ll(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,n=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:n,scrollHeightChanged:a,scrollTopChanged:c}}},sb=class extends se{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new tb(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Id(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Id.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Od=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};Id=class Dl{constructor(t,s,i,r){this.from=t,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let r,o;return t<s?(r=t+.75*i,o=s-.75*i):(r=t-.75*i,o=s+.75*i),ib(nl(t,r),nl(o,s),.33)}return nl(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Od(i,r,!1)}return new Od(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Dl.start(t,s,i)}static start(t,s,i){i=i+10;let r=Date.now()-10;return new Dl(t,s,r,i)}};nb=class extends se{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new rc)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},ab=140,Xu=class extends nc{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new nb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Yu),this._shouldRender=!0,this.domNode=so(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(q(this.domNode.domNode,Ie.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new eb(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=so(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(q(this.slider.domNode,Ie.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=Gv(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),n=Math.abs(o-s);if(Wu&&n>ab){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(a))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Ju=class Pl{constructor(t,s,i,r,o,n){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pl(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,o){let n=Math.max(0,i-t),a=Math.max(0,n-2*s),c=r>0&&r>i;if(!c)return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*a/r))),h=(a-l)/(r-i),d=o*h;return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:h,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=Pl._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},lb=class extends Xu{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Ju(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},cb=class extends Xu{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Ju(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},hb=500,zd=50,Nd=!0,db=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Ml=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,r=this._rear;do{let o=r===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(sc){let s=qt(t.browserEvent),i=rv(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let r=null,o=new db(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),n=Math.abs(s.deltaX),a=Math.abs(s.deltaY),c=Math.max(Math.min(r,n),1),l=Math.max(Math.min(o,a),1),h=Math.max(r,n),d=Math.max(o,a);h%c===0&&d%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ml.INSTANCE=new Ml;ub=Ml,pb=class extends nc{constructor(e,t,s){super(),this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new z),this.onWillScroll=this._onWillScroll.event,this._options=mb(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new cb(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new lb(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=so(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=so(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=so(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new rc),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=yi(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,is&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Td(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=yi(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Td(s))};this._mouseWheelToDispose.push(q(this._listenOnDomNode,Ie.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=ub.INSTANCE;Nd&&t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let n=!is&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!o&&(o=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),c={};if(r){let l=zd*r,h=a.scrollTop-(l<0?Math.floor(l):Math.ceil(l));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let l=zd*o,h=a.scrollLeft-(l<0?Math.floor(l):Math.ceil(l));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(a.scrollLeft!==c.scrollLeft||a.scrollTop!==c.scrollTop)&&(Nd&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),hb)}},fb=class extends pb{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};Bl=class extends se{constructor(e,t,s,i,r,o,n,a){super(),this._bufferService=s,this._optionsService=n,this._renderService=a,this._onRequestScrollLines=this._register(new z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new sb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>En(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new fb(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Xe.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_e(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(_e(()=>this._styleElement.remove())),this._register(Xe.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
30
30
  `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Bl=xe([H(2,lt),H(3,xs),H(4,Su),H(5,Qi),H(6,ct),H(7,ks)],Bl);Ol=class extends se{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(_e(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Ol=xe([H(1,lt),H(2,xs),H(3,lo),H(4,ks)],Ol);gb=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},es={full:0,left:0,center:0,right:0},Fs={full:0,left:0,center:0,right:0},jr={full:0,left:0,center:0,right:0},Tn=class extends se{constructor(e,t,s,i,r,o,n,a){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=n,this._coreBrowserService=a,this._colorZoneStore=new gb,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(_e(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Fs.full=this._canvas.width,Fs.left=e,Fs.center=t,Fs.right=e,this._refreshDrawHeightConstants(),jr.full=1,jr.left=1,jr.center=1+Fs.left,jr.right=1+Fs.left+Fs.center}_refreshDrawHeightConstants(){es.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);es.left=t,es.center=t,es.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*es.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*es.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*es.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*es.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(jr[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-es[e.position||"full"]/2),Fs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+es[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Tn=xe([H(2,lt),H(3,lo),H(4,ks),H(5,ct),H(6,Qi),H(7,xs)],Tn);(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
31
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL="\x7F"))(M||(M={}));(e=>(e.PAD="\x80",e.HOP="\x81",e.BPH="\x82",e.NBH="\x83",e.IND="\x84",e.NEL="\x85",e.SSA="\x86",e.ESA="\x87",e.HTS="\x88",e.HTJ="\x89",e.VTS="\x8A",e.PLD="\x8B",e.PLU="\x8C",e.RI="\x8D",e.SS2="\x8E",e.SS3="\x8F",e.DCS="\x90",e.PU1="\x91",e.PU2="\x92",e.STS="\x93",e.CCH="\x94",e.MW="\x95",e.SPA="\x96",e.EPA="\x97",e.SOS="\x98",e.SGCI="\x99",e.SCI="\x9A",e.CSI="\x9B",e.ST="\x9C",e.OSC="\x9D",e.PM="\x9E",e.APC="\x9F"))(wn||(wn={}));(e=>e.ST=`${M.ESC}\\`)(Zu||(Zu={}));Il=class{constructor(e,t,s,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Il=xe([H(2,lt),H(3,ct),H(4,Si),H(5,ks)],Il);ze=0,Ne=0,Fe=0,Ce=0,Fd={css:"#00000000",rgba:0};(e=>{function t(r,o,n,a){return a!==void 0?`#${mi(r)}${mi(o)}${mi(n)}${mi(a)}`:`#${mi(r)}${mi(o)}${mi(n)}`}e.toCss=t;function s(r,o,n,a=255){return(r<<24|o<<16|n<<8|a)>>>0}e.toRgba=s;function i(r,o,n,a){return{css:e.toCss(r,o,n,a),rgba:e.toRgba(r,o,n,a)}}e.toColor=i})(Le||(Le={}));(e=>{function t(c,l){if(Ce=(l.rgba&255)/255,Ce===1)return{css:l.css,rgba:l.rgba};let h=l.rgba>>24&255,d=l.rgba>>16&255,f=l.rgba>>8&255,p=c.rgba>>24&255,m=c.rgba>>16&255,_=c.rgba>>8&255;ze=p+Math.round((h-p)*Ce),Ne=m+Math.round((d-m)*Ce),Fe=_+Math.round((f-_)*Ce);let b=Le.toCss(ze,Ne,Fe),C=Le.toRgba(ze,Ne,Fe);return{css:b,rgba:C}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function i(c,l,h){let d=Sn.ensureContrastRatio(c.rgba,l.rgba,h);if(d)return Le.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(c){let l=(c.rgba|255)>>>0;return[ze,Ne,Fe]=Sn.toChannels(l),{css:Le.toCss(ze,Ne,Fe),rgba:l}}e.opaque=r;function o(c,l){return Ce=Math.round(l*255),[ze,Ne,Fe]=Sn.toChannels(c.rgba),{css:Le.toCss(ze,Ne,Fe,Ce),rgba:Le.toRgba(ze,Ne,Fe,Ce)}}e.opacity=o;function n(c,l){return Ce=c.rgba&255,o(c,Ce*l/255)}e.multiplyOpacity=n;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(ge||(ge={}));(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return ze=parseInt(r.slice(1,2).repeat(2),16),Ne=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Le.toColor(ze,Ne,Fe);case 5:return ze=parseInt(r.slice(1,2).repeat(2),16),Ne=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Ce=parseInt(r.slice(4,5).repeat(2),16),Le.toColor(ze,Ne,Fe,Ce);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return ze=parseInt(o[1]),Ne=parseInt(o[2]),Fe=parseInt(o[3]),Ce=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Le.toColor(ze,Ne,Fe,Ce);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ne,Fe,Ce]=t.getImageData(0,0,1,1).data,Ce!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Le.toRgba(ze,Ne,Fe,Ce),css:r}}e.toColor=i})(Se||(Se={}));(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,o){let n=i/255,a=r/255,c=o/255,l=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return l*.2126+h*.7152+d*.0722}e.relativeLuminance2=s})(at||(at={}));(e=>{function t(n,a){if(Ce=(a&255)/255,Ce===1)return a;let c=a>>24&255,l=a>>16&255,h=a>>8&255,d=n>>24&255,f=n>>16&255,p=n>>8&255;return ze=d+Math.round((c-d)*Ce),Ne=f+Math.round((l-f)*Ce),Fe=p+Math.round((h-p)*Ce),Le.toRgba(ze,Ne,Fe)}e.blend=t;function s(n,a,c){let l=at.relativeLuminance(n>>8),h=at.relativeLuminance(a>>8);if(ys(l,h)<c){if(h<l){let p=i(n,a,c),m=ys(l,at.relativeLuminance(p>>8));if(m<c){let _=r(n,a,c),b=ys(l,at.relativeLuminance(_>>8));return m>b?p:_}return p}let d=r(n,a,c),f=ys(l,at.relativeLuminance(d>>8));if(f<c){let p=i(n,a,c),m=ys(l,at.relativeLuminance(p>>8));return f>m?d:p}return d}}e.ensureContrastRatio=s;function i(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));for(;_<c&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=i;function r(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));for(;_<c&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=r;function o(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o})(Sn||(Sn={}));_b=class extends ao{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},An=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Pt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),r=0,o=0,n=0,a=t.getFg(0),c=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==c){if(l-r>1){let h=this._getJoinedRanges(i,n,o,t,r);for(let d=0;d<h.length;d++)s.push(h[d])}r=l,n=o,a=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||js.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(i,n,o,t,r);for(let h=0;h<l.length;h++)s.push(l[h])}return s}_getJoinedRanges(e,t,s,i,r){let o=e.substring(t,s),n=[];try{n=this._characterJoiners[0].handler(o)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(o);for(let l=0;l<c.length;l++)An._mergeRanges(n,c[l])}catch(c){console.error(c)}return this._stringRangesToCellRanges(n,i,r),n}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,o=0,n=e[i];if(n){for(let a=s;a<this._bufferService.cols;a++){let c=t.getWidth(a),l=t.getString(a).length||js.length;if(c!==0){if(!r&&n[0]<=o&&(n[0]=a,r=!0),n[1]<=o){if(n[1]=a,n=e[++i],!n)break;n[0]<=o?(n[0]=a,r=!0):r=!1}o+=l}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};An=xe([H(0,lt)],An);zl=class{constructor(e,t,s,i,r,o,n){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=n,this._workCell=new Pt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,o,n,a,c,l,h){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let _,b=0,C="",T=0,w=0,v=0,B=0,P=!1,F=0,U=!1,te=0,re=0,oe=[],ye=l!==-1&&h!==-1;for(let $=0;$<m;$++){e.loadCell($,this._workCell);let S=this._workCell.getWidth();if(S===0)continue;let R=!1,k=$>=re,D=$,L=this._workCell;if(f.length>0&&$===f[0][0]&&k){let ue=f.shift(),Ea=this._isCellInSelection(ue[0],t);for(T=ue[0]+1;T<ue[1];T++)k&&(k=Ea===this._isCellInSelection(T,t));k&&(k=!s||o<ue[0]||o>=ue[1]),k?(R=!0,L=new _b(this._workCell,e.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),D=ue[1]-1,S=L.getWidth()):re=ue[1]}let N=this._isCellInSelection($,t),J=s&&$===o,ce=ye&&$>=l&&$<=h,Ge=!1;this._decorationService.forEachDecorationAtCell($,t,void 0,ue=>{Ge=!0});let ut=L.getChars()||js;if(ut===" "&&(L.isUnderline()||L.isOverline())&&(ut="\xA0"),te=S*a-c.get(ut,L.isBold(),L.isItalic()),!_)_=this._document.createElement("span");else if(b&&(N&&U||!N&&!U&&L.bg===w)&&(N&&U&&p.selectionForeground||L.fg===v)&&L.extended.ext===B&&ce===P&&te===F&&!J&&!R&&!Ge&&k){L.isInvisible()?C+=js:C+=ut,b++;continue}else b&&(_.textContent=C),_=this._document.createElement("span"),b=0,C="";if(w=L.bg,v=L.fg,B=L.extended.ext,P=ce,F=te,U=N,R&&o>=$&&o<=D&&(o=$),!this._coreService.isCursorHidden&&J&&this._coreService.isCursorInitialized){if(oe.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&oe.push("xterm-cursor-blink"),oe.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":oe.push("xterm-cursor-outline");break;case"block":oe.push("xterm-cursor-block");break;case"bar":oe.push("xterm-cursor-bar");break;case"underline":oe.push("xterm-cursor-underline");break;default:break}}if(L.isBold()&&oe.push("xterm-bold"),L.isItalic()&&oe.push("xterm-italic"),L.isDim()&&oe.push("xterm-dim"),L.isInvisible()?C=js:C=L.getChars()||js,L.isUnderline()&&(oe.push(`xterm-underline-${L.extended.underlineStyle}`),C===" "&&(C="\xA0"),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${ao.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let ue=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&ue<8&&(ue+=8),_.style.textDecorationColor=p.ansi[ue].css}L.isOverline()&&(oe.push("xterm-overline"),C===" "&&(C="\xA0")),L.isStrikethrough()&&oe.push("xterm-strikethrough"),ce&&(_.style.textDecoration="underline");let ve=L.getFgColor(),Nt=L.getFgColorMode(),Te=L.getBgColor(),ps=L.getBgColorMode(),oi=!!L.isInverse();if(oi){let ue=ve;ve=Te,Te=ue;let Ea=Nt;Nt=ps,ps=Ea}let Ms,qo,kr=!1;this._decorationService.forEachDecorationAtCell($,t,void 0,ue=>{ue.options.layer!=="top"&&kr||(ue.backgroundColorRGB&&(ps=50331648,Te=ue.backgroundColorRGB.rgba>>8&16777215,Ms=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Nt=50331648,ve=ue.foregroundColorRGB.rgba>>8&16777215,qo=ue.foregroundColorRGB),kr=ue.options.layer==="top")}),!kr&&N&&(Ms=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,Te=Ms.rgba>>8&16777215,ps=50331648,kr=!0,p.selectionForeground&&(Nt=50331648,ve=p.selectionForeground.rgba>>8&16777215,qo=p.selectionForeground)),kr&&oe.push("xterm-decoration-top");let Bs;switch(ps){case 16777216:case 33554432:Bs=p.ansi[Te],oe.push(`xterm-bg-${Te}`);break;case 50331648:Bs=Le.toColor(Te>>16,Te>>8&255,Te&255),this._addStyle(_,`background-color:#${Hd((Te>>>0).toString(16),"0",6)}`);break;default:oi?(Bs=p.foreground,oe.push("xterm-bg-257")):Bs=p.background}switch(Ms||L.isDim()&&(Ms=ge.multiplyOpacity(Bs,.5)),Nt){case 16777216:case 33554432:L.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(_,Bs,p.ansi[ve],L,Ms,void 0)||oe.push(`xterm-fg-${ve}`);break;case 50331648:let ue=Le.toColor(ve>>16&255,ve>>8&255,ve&255);this._applyMinimumContrast(_,Bs,ue,L,Ms,qo)||this._addStyle(_,`color:#${Hd(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(_,Bs,p.foreground,L,Ms,qo)||oi&&oe.push("xterm-fg-257")}oe.length&&(_.className=oe.join(" "),oe.length=0),!J&&!R&&!Ge&&k?b++:_.textContent=C,te!==this.defaultSpacing&&(_.style.letterSpacing=`${te}px`),d.push(_),$=D}return _&&b&&(_.textContent=C),d}_applyMinimumContrast(e,t,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||yb(i.getCode()))return!1;let n=this._getContrastCache(i),a;if(!r&&!o&&(a=n.getColor(t.rgba,s.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ge.ensureContrastRatio(r||t,o||s,c),n.setColor((r||t).rgba,(o||s).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};zl=xe([H(1,ku),H(2,ct),H(3,xs),H(4,Si),H(5,lo),H(6,Qi)],zl);Sb=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let n=this._measure(e,0);return n>0&&(this._flat[i]=n),n}let r=e;t&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let n=0;t&&(n|=1),s&&(n|=2),o=this._measure(e,n),o>0&&this._holey.set(r,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},Cb=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,n=s[1]-r,a=Math.max(o,0),c=Math.min(n,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};al="xterm-dom-renderer-owner-",Rt="xterm-rows",dn="xterm-fg-",Wd="xterm-bg-",Vr="xterm-focus",un="xterm-selection",kb=1,Nl=class extends se{constructor(e,t,s,i,r,o,n,a,c,l,h,d,f,p){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=n,this._charSizeService=c,this._optionsService=l,this._bufferService=h,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=kb++,this._rowElements=[],this._selectionRenderModel=xb(),this.onRequestRedraw=this._register(new z).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Rt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(un),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=wb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(zl,document),this._element.classList.add(al+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(_e(()=>{this._element.classList.remove(al+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Sb(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Rt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Rt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Rt} .xterm-dim { color: ${ge.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${un} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${un} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${un} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,n]of e.ansi.entries())t+=`${this._terminalSelector} .${dn}${o} { color: ${n.css}; }${this._terminalSelector} .${dn}${o}.xterm-dim { color: ${ge.multiplyOpacity(n,.5).css}; }${this._terminalSelector} .${Wd}${o} { background-color: ${n.css}; }`;t+=`${this._terminalSelector} .${dn}257 { color: ${ge.opaque(e.background).css}; }${this._terminalSelector} .${dn}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(e.background),.5).css}; }${this._terminalSelector} .${Wd}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Vr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(o,c?t[0]:e[0],c?e[0]:t[0],n-o+1))}else{let c=i===o?e[0]:0,l=o===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));let h=n-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==n){let d=r===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-t);return o+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${n}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let l=c+s.ydisp,h=this._rowElements[c],d=s.lines.get(l);if(!h||!d)break;h.replaceChildren(...this._rowFactory.createRow(d,l,l===i,n,a,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${al}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,o){s<0&&(e=0),i<0&&(t=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),i=Math.max(Math.min(i,n),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,l=Math.min(a.x,r-1),h=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=s;p<=i;++p){let m=p+a.ydisp,_=this._rowElements[p],b=a.lines.get(m);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,m,m===c,d,f,l,h,this.dimensions.css.cell.width,this._widthCache,o?p===s?e:0:-1,o?(p===i?t:r)-1:-1))}}};Nl=xe([H(7,Ql),H(8,Mn),H(9,ct),H(10,lt),H(11,Si),H(12,xs),H(13,Qi)],Nl);Fl=class extends se{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new z),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Eb(this._optionsService))}catch{this._measureStrategy=this._register(new $b(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Fl=xe([H(2,ct)],Fl);Qu=class extends se{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},$b=class extends Qu{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Eb=class extends Qu{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Tb=class extends se{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Ab(this._window)),this._onDprChange=this._register(new z),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new z),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Xe.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,"focus",()=>this._isFocused=!0)),this._register(q(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Ab=class extends se{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zi),this._onDprChange=this._register(new z),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_e(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Rb=class extends se{constructor(){super(),this.linkProviders=[],this._register(_e(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};Hl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return Lb(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=ac(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Hl=xe([H(0,ks),H(1,Mn)],Hl);Db=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ep={};m_(ep,{getSafariVersion:()=>Mb,isChromeOS:()=>rp,isFirefox:()=>tp,isIpad:()=>Bb,isIphone:()=>Ob,isLegacyEdge:()=>Pb,isLinux:()=>lc,isMac:()=>Rn,isNode:()=>In,isSafari:()=>sp,isWindows:()=>ip});In=typeof process<"u"&&"title"in process,co=In?"node":navigator.userAgent,ho=In?"node":navigator.platform,tp=co.includes("Firefox"),Pb=co.includes("Edge"),sp=/^((?!chrome|android).)*safari/i.test(co);Rn=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ho),Bb=ho==="iPad",Ob=ho==="iPhone",ip=["Windows","Win16","Win32","WinCE"].includes(ho),lc=ho.indexOf("Linux")>=0,rp=/\bCrOS\b/.test(co),op=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},Ib=class extends op{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zb=class extends op{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ln=!In&&"requestIdleCallback"in window?zb:Ib,Nb=class{constructor(){this._queue=new Ln}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Wl=class extends se{constructor(e,t,s,i,r,o,n,a,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Zi),this._pausedResizeTask=new Nb,this._observerDisposable=this._register(new Zi),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new z),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new z),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new z),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new z),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Db((l,h)=>this._renderRows(l,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Fb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_e(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(n.onResize(()=>this._fullRefresh())),this._register(n.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(n.buffer.y,n.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=_e(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Wl=xe([H(2,ct),H(3,Mn),H(4,Si),H(5,lo),H(6,lt),H(7,xs),H(8,Qi)],Wl);Fb=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};Gb=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};ll=50,Yb=15,Xb=50,Jb=500,Zb="\xA0",Qb=new RegExp(Zb,"g"),jl=class extends se{constructor(e,t,s,i,r,o,n,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=n,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Pt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new z),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new z),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new z),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Gb(this._bufferService),this._activeSelectionMode=0,this._register(_e(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let n=e[1];n<=t[1];n++){let a=s.translateBufferLineToString(n,!0,r,o);i.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let n=s.lines.get(o),a=s.translateBufferLineToString(o,!0);n?.isWrapped?i[i.length-1]+=a:i.push(a)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),n=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(r=>r.replace(Qb," ")).join(ip?`\r
31
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL="\x7F"))(M||(M={}));(e=>(e.PAD="\x80",e.HOP="\x81",e.BPH="\x82",e.NBH="\x83",e.IND="\x84",e.NEL="\x85",e.SSA="\x86",e.ESA="\x87",e.HTS="\x88",e.HTJ="\x89",e.VTS="\x8A",e.PLD="\x8B",e.PLU="\x8C",e.RI="\x8D",e.SS2="\x8E",e.SS3="\x8F",e.DCS="\x90",e.PU1="\x91",e.PU2="\x92",e.STS="\x93",e.CCH="\x94",e.MW="\x95",e.SPA="\x96",e.EPA="\x97",e.SOS="\x98",e.SGCI="\x99",e.SCI="\x9A",e.CSI="\x9B",e.ST="\x9C",e.OSC="\x9D",e.PM="\x9E",e.APC="\x9F"))(wn||(wn={}));(e=>e.ST=`${M.ESC}\\`)(Zu||(Zu={}));Il=class{constructor(e,t,s,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Il=xe([H(2,lt),H(3,ct),H(4,Si),H(5,ks)],Il);ze=0,Ne=0,Fe=0,Ce=0,Fd={css:"#00000000",rgba:0};(e=>{function t(r,o,n,a){return a!==void 0?`#${mi(r)}${mi(o)}${mi(n)}${mi(a)}`:`#${mi(r)}${mi(o)}${mi(n)}`}e.toCss=t;function s(r,o,n,a=255){return(r<<24|o<<16|n<<8|a)>>>0}e.toRgba=s;function i(r,o,n,a){return{css:e.toCss(r,o,n,a),rgba:e.toRgba(r,o,n,a)}}e.toColor=i})(Re||(Re={}));(e=>{function t(c,l){if(Ce=(l.rgba&255)/255,Ce===1)return{css:l.css,rgba:l.rgba};let h=l.rgba>>24&255,d=l.rgba>>16&255,f=l.rgba>>8&255,p=c.rgba>>24&255,m=c.rgba>>16&255,_=c.rgba>>8&255;ze=p+Math.round((h-p)*Ce),Ne=m+Math.round((d-m)*Ce),Fe=_+Math.round((f-_)*Ce);let b=Re.toCss(ze,Ne,Fe),C=Re.toRgba(ze,Ne,Fe);return{css:b,rgba:C}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function i(c,l,h){let d=Sn.ensureContrastRatio(c.rgba,l.rgba,h);if(d)return Re.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(c){let l=(c.rgba|255)>>>0;return[ze,Ne,Fe]=Sn.toChannels(l),{css:Re.toCss(ze,Ne,Fe),rgba:l}}e.opaque=r;function o(c,l){return Ce=Math.round(l*255),[ze,Ne,Fe]=Sn.toChannels(c.rgba),{css:Re.toCss(ze,Ne,Fe,Ce),rgba:Re.toRgba(ze,Ne,Fe,Ce)}}e.opacity=o;function n(c,l){return Ce=c.rgba&255,o(c,Ce*l/255)}e.multiplyOpacity=n;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(ge||(ge={}));(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return ze=parseInt(r.slice(1,2).repeat(2),16),Ne=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Re.toColor(ze,Ne,Fe);case 5:return ze=parseInt(r.slice(1,2).repeat(2),16),Ne=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Ce=parseInt(r.slice(4,5).repeat(2),16),Re.toColor(ze,Ne,Fe,Ce);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return ze=parseInt(o[1]),Ne=parseInt(o[2]),Fe=parseInt(o[3]),Ce=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Re.toColor(ze,Ne,Fe,Ce);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ze,Ne,Fe,Ce]=t.getImageData(0,0,1,1).data,Ce!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Re.toRgba(ze,Ne,Fe,Ce),css:r}}e.toColor=i})(Se||(Se={}));(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,o){let n=i/255,a=r/255,c=o/255,l=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return l*.2126+h*.7152+d*.0722}e.relativeLuminance2=s})(at||(at={}));(e=>{function t(n,a){if(Ce=(a&255)/255,Ce===1)return a;let c=a>>24&255,l=a>>16&255,h=a>>8&255,d=n>>24&255,f=n>>16&255,p=n>>8&255;return ze=d+Math.round((c-d)*Ce),Ne=f+Math.round((l-f)*Ce),Fe=p+Math.round((h-p)*Ce),Re.toRgba(ze,Ne,Fe)}e.blend=t;function s(n,a,c){let l=at.relativeLuminance(n>>8),h=at.relativeLuminance(a>>8);if(ys(l,h)<c){if(h<l){let p=i(n,a,c),m=ys(l,at.relativeLuminance(p>>8));if(m<c){let _=r(n,a,c),b=ys(l,at.relativeLuminance(_>>8));return m>b?p:_}return p}let d=r(n,a,c),f=ys(l,at.relativeLuminance(d>>8));if(f<c){let p=i(n,a,c),m=ys(l,at.relativeLuminance(p>>8));return f>m?d:p}return d}}e.ensureContrastRatio=s;function i(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));for(;_<c&&(f>0||p>0||m>0);)f-=Math.max(0,Math.ceil(f*.1)),p-=Math.max(0,Math.ceil(p*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));return(f<<24|p<<16|m<<8|255)>>>0}e.reduceLuminance=i;function r(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,f=a>>24&255,p=a>>16&255,m=a>>8&255,_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));for(;_<c&&(f<255||p<255||m<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=ys(at.relativeLuminance2(f,p,m),at.relativeLuminance2(l,h,d));return(f<<24|p<<16|m<<8|255)>>>0}e.increaseLuminance=r;function o(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o})(Sn||(Sn={}));_b=class extends ao{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},An=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Pt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),r=0,o=0,n=0,a=t.getFg(0),c=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==c){if(l-r>1){let h=this._getJoinedRanges(i,n,o,t,r);for(let d=0;d<h.length;d++)s.push(h[d])}r=l,n=o,a=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||js.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(i,n,o,t,r);for(let h=0;h<l.length;h++)s.push(l[h])}return s}_getJoinedRanges(e,t,s,i,r){let o=e.substring(t,s),n=[];try{n=this._characterJoiners[0].handler(o)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(o);for(let l=0;l<c.length;l++)An._mergeRanges(n,c[l])}catch(c){console.error(c)}return this._stringRangesToCellRanges(n,i,r),n}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,o=0,n=e[i];if(n){for(let a=s;a<this._bufferService.cols;a++){let c=t.getWidth(a),l=t.getString(a).length||js.length;if(c!==0){if(!r&&n[0]<=o&&(n[0]=a,r=!0),n[1]<=o){if(n[1]=a,n=e[++i],!n)break;n[0]<=o?(n[0]=a,r=!0):r=!1}o+=l}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};An=xe([H(0,lt)],An);zl=class{constructor(e,t,s,i,r,o,n){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=n,this._workCell=new Pt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,o,n,a,c,l,h){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let _,b=0,C="",T=0,w=0,v=0,B=0,P=!1,F=0,U=!1,te=0,re=0,oe=[],ye=l!==-1&&h!==-1;for(let $=0;$<m;$++){e.loadCell($,this._workCell);let S=this._workCell.getWidth();if(S===0)continue;let R=!1,k=$>=re,D=$,L=this._workCell;if(f.length>0&&$===f[0][0]&&k){let ue=f.shift(),Ea=this._isCellInSelection(ue[0],t);for(T=ue[0]+1;T<ue[1];T++)k&&(k=Ea===this._isCellInSelection(T,t));k&&(k=!s||o<ue[0]||o>=ue[1]),k?(R=!0,L=new _b(this._workCell,e.translateToString(!0,ue[0],ue[1]),ue[1]-ue[0]),D=ue[1]-1,S=L.getWidth()):re=ue[1]}let N=this._isCellInSelection($,t),J=s&&$===o,ce=ye&&$>=l&&$<=h,Ge=!1;this._decorationService.forEachDecorationAtCell($,t,void 0,ue=>{Ge=!0});let ut=L.getChars()||js;if(ut===" "&&(L.isUnderline()||L.isOverline())&&(ut="\xA0"),te=S*a-c.get(ut,L.isBold(),L.isItalic()),!_)_=this._document.createElement("span");else if(b&&(N&&U||!N&&!U&&L.bg===w)&&(N&&U&&p.selectionForeground||L.fg===v)&&L.extended.ext===B&&ce===P&&te===F&&!J&&!R&&!Ge&&k){L.isInvisible()?C+=js:C+=ut,b++;continue}else b&&(_.textContent=C),_=this._document.createElement("span"),b=0,C="";if(w=L.bg,v=L.fg,B=L.extended.ext,P=ce,F=te,U=N,R&&o>=$&&o<=D&&(o=$),!this._coreService.isCursorHidden&&J&&this._coreService.isCursorInitialized){if(oe.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&oe.push("xterm-cursor-blink"),oe.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":oe.push("xterm-cursor-outline");break;case"block":oe.push("xterm-cursor-block");break;case"bar":oe.push("xterm-cursor-bar");break;case"underline":oe.push("xterm-cursor-underline");break;default:break}}if(L.isBold()&&oe.push("xterm-bold"),L.isItalic()&&oe.push("xterm-italic"),L.isDim()&&oe.push("xterm-dim"),L.isInvisible()?C=js:C=L.getChars()||js,L.isUnderline()&&(oe.push(`xterm-underline-${L.extended.underlineStyle}`),C===" "&&(C="\xA0"),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${ao.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let ue=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&ue<8&&(ue+=8),_.style.textDecorationColor=p.ansi[ue].css}L.isOverline()&&(oe.push("xterm-overline"),C===" "&&(C="\xA0")),L.isStrikethrough()&&oe.push("xterm-strikethrough"),ce&&(_.style.textDecoration="underline");let ve=L.getFgColor(),Nt=L.getFgColorMode(),Te=L.getBgColor(),ps=L.getBgColorMode(),oi=!!L.isInverse();if(oi){let ue=ve;ve=Te,Te=ue;let Ea=Nt;Nt=ps,ps=Ea}let Ms,qo,kr=!1;this._decorationService.forEachDecorationAtCell($,t,void 0,ue=>{ue.options.layer!=="top"&&kr||(ue.backgroundColorRGB&&(ps=50331648,Te=ue.backgroundColorRGB.rgba>>8&16777215,Ms=ue.backgroundColorRGB),ue.foregroundColorRGB&&(Nt=50331648,ve=ue.foregroundColorRGB.rgba>>8&16777215,qo=ue.foregroundColorRGB),kr=ue.options.layer==="top")}),!kr&&N&&(Ms=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,Te=Ms.rgba>>8&16777215,ps=50331648,kr=!0,p.selectionForeground&&(Nt=50331648,ve=p.selectionForeground.rgba>>8&16777215,qo=p.selectionForeground)),kr&&oe.push("xterm-decoration-top");let Bs;switch(ps){case 16777216:case 33554432:Bs=p.ansi[Te],oe.push(`xterm-bg-${Te}`);break;case 50331648:Bs=Re.toColor(Te>>16,Te>>8&255,Te&255),this._addStyle(_,`background-color:#${Hd((Te>>>0).toString(16),"0",6)}`);break;default:oi?(Bs=p.foreground,oe.push("xterm-bg-257")):Bs=p.background}switch(Ms||L.isDim()&&(Ms=ge.multiplyOpacity(Bs,.5)),Nt){case 16777216:case 33554432:L.isBold()&&ve<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ve+=8),this._applyMinimumContrast(_,Bs,p.ansi[ve],L,Ms,void 0)||oe.push(`xterm-fg-${ve}`);break;case 50331648:let ue=Re.toColor(ve>>16&255,ve>>8&255,ve&255);this._applyMinimumContrast(_,Bs,ue,L,Ms,qo)||this._addStyle(_,`color:#${Hd(ve.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(_,Bs,p.foreground,L,Ms,qo)||oi&&oe.push("xterm-fg-257")}oe.length&&(_.className=oe.join(" "),oe.length=0),!J&&!R&&!Ge&&k?b++:_.textContent=C,te!==this.defaultSpacing&&(_.style.letterSpacing=`${te}px`),d.push(_),$=D}return _&&b&&(_.textContent=C),d}_applyMinimumContrast(e,t,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||yb(i.getCode()))return!1;let n=this._getContrastCache(i),a;if(!r&&!o&&(a=n.getColor(t.rgba,s.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ge.ensureContrastRatio(r||t,o||s,c),n.setColor((r||t).rgba,(o||s).rgba,a??null)}return a?(this._addStyle(e,`color:${a.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};zl=xe([H(1,ku),H(2,ct),H(3,xs),H(4,Si),H(5,lo),H(6,Qi)],zl);Sb=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let n=this._measure(e,0);return n>0&&(this._flat[i]=n),n}let r=e;t&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let n=0;t&&(n|=1),s&&(n|=2),o=this._measure(e,n),o>0&&this._holey.set(r,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},Cb=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,n=s[1]-r,a=Math.max(o,0),c=Math.min(n,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};al="xterm-dom-renderer-owner-",Rt="xterm-rows",dn="xterm-fg-",Wd="xterm-bg-",Vr="xterm-focus",un="xterm-selection",kb=1,Nl=class extends se{constructor(e,t,s,i,r,o,n,a,c,l,h,d,f,p){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=n,this._charSizeService=c,this._optionsService=l,this._bufferService=h,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=kb++,this._rowElements=[],this._selectionRenderModel=xb(),this.onRequestRedraw=this._register(new z).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Rt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(un),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=wb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(zl,document),this._element.classList.add(al+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(_e(()=>{this._element.classList.remove(al+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Sb(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Rt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Rt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Rt} .xterm-dim { color: ${ge.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Rt}.${Vr} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Rt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${un} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${un} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${un} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,n]of e.ansi.entries())t+=`${this._terminalSelector} .${dn}${o} { color: ${n.css}; }${this._terminalSelector} .${dn}${o}.xterm-dim { color: ${ge.multiplyOpacity(n,.5).css}; }${this._terminalSelector} .${Wd}${o} { background-color: ${n.css}; }`;t+=`${this._terminalSelector} .${dn}257 { color: ${ge.opaque(e.background).css}; }${this._terminalSelector} .${dn}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(e.background),.5).css}; }${this._terminalSelector} .${Wd}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Vr),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Vr),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(o,c?t[0]:e[0],c?e[0]:t[0],n-o+1))}else{let c=i===o?e[0]:0,l=o===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));let h=n-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==n){let d=r===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-t);return o+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${n}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let l=c+s.ydisp,h=this._rowElements[c],d=s.lines.get(l);if(!h||!d)break;h.replaceChildren(...this._rowFactory.createRow(d,l,l===i,n,a,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${al}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,o){s<0&&(e=0),i<0&&(t=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),i=Math.max(Math.min(i,n),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,l=Math.min(a.x,r-1),h=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=s;p<=i;++p){let m=p+a.ydisp,_=this._rowElements[p],b=a.lines.get(m);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,m,m===c,d,f,l,h,this.dimensions.css.cell.width,this._widthCache,o?p===s?e:0:-1,o?(p===i?t:r)-1:-1))}}};Nl=xe([H(7,Ql),H(8,Mn),H(9,ct),H(10,lt),H(11,Si),H(12,xs),H(13,Qi)],Nl);Fl=class extends se{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new z),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Eb(this._optionsService))}catch{this._measureStrategy=this._register(new $b(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Fl=xe([H(2,ct)],Fl);Qu=class extends se{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},$b=class extends Qu{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Eb=class extends Qu{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Tb=class extends se{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Ab(this._window)),this._onDprChange=this._register(new z),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new z),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Xe.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,"focus",()=>this._isFocused=!0)),this._register(q(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Ab=class extends se{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Zi),this._onDprChange=this._register(new z),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_e(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Rb=class extends se{constructor(){super(),this.linkProviders=[],this._register(_e(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};Hl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return Lb(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=ac(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Hl=xe([H(0,ks),H(1,Mn)],Hl);Db=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},ep={};m_(ep,{getSafariVersion:()=>Mb,isChromeOS:()=>rp,isFirefox:()=>tp,isIpad:()=>Bb,isIphone:()=>Ob,isLegacyEdge:()=>Pb,isLinux:()=>lc,isMac:()=>Rn,isNode:()=>In,isSafari:()=>sp,isWindows:()=>ip});In=typeof process<"u"&&"title"in process,co=In?"node":navigator.userAgent,ho=In?"node":navigator.platform,tp=co.includes("Firefox"),Pb=co.includes("Edge"),sp=/^((?!chrome|android).)*safari/i.test(co);Rn=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ho),Bb=ho==="iPad",Ob=ho==="iPhone",ip=["Windows","Win16","Win32","WinCE"].includes(ho),lc=ho.indexOf("Linux")>=0,rp=/\bCrOS\b/.test(co),op=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},Ib=class extends op{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},zb=class extends op{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Ln=!In&&"requestIdleCallback"in window?zb:Ib,Nb=class{constructor(){this._queue=new Ln}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Wl=class extends se{constructor(e,t,s,i,r,o,n,a,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Zi),this._pausedResizeTask=new Nb,this._observerDisposable=this._register(new Zi),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new z),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new z),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new z),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new z),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Db((l,h)=>this._renderRows(l,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Fb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_e(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(n.onResize(()=>this._fullRefresh())),this._register(n.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(n.buffer.y,n.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=_e(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Wl=xe([H(2,ct),H(3,Mn),H(4,Si),H(5,lo),H(6,lt),H(7,xs),H(8,Qi)],Wl);Fb=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};Gb=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};ll=50,Yb=15,Xb=50,Jb=500,Zb="\xA0",Qb=new RegExp(Zb,"g"),jl=class extends se{constructor(e,t,s,i,r,o,n,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=n,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Pt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new z),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new z),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new z),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new Gb(this._bufferService),this._activeSelectionMode=0,this._register(_e(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let n=e[1];n<=t[1];n++){let a=s.translateBufferLineToString(n,!0,r,o);i.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let n=s.lines.get(o),a=s.translateBufferLineToString(o,!0);n?.isWrapped?i[i.length-1]+=a:i.push(a)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),n=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(r=>r.replace(Qb," ")).join(ip?`\r
32
32
  `:`
33
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),lc&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=jd(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ac(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-ll),ll),t/=ll,t/Math.abs(t)+Math.round(t*(Yb-1)))}shouldForceSelection(e){return Rn?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Xb)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Rn&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Jb&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Hb(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let n=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e[0]),c=a,l=e[0]-a,h=0,d=0,f=0,p=0;if(n.charAt(a)===" "){for(;a>0&&n.charAt(a-1)===" ";)a--;for(;c<n.length&&n.charAt(c+1)===" ";)c++}else{let b=e[0],C=e[0];o.getWidth(b)===0&&(h++,b--),o.getWidth(C)===2&&(d++,C++);let T=o.getString(C).length;for(T>1&&(p+=T-1,c+=T-1);b>0&&a>0&&!this._isCharWordSeparator(o.loadCell(b-1,this._workCell));){o.loadCell(b-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,b--):w>1&&(f+=w-1,a-=w-1),a--,b--}for(;C<o.length&&c+1<n.length&&!this._isCharWordSeparator(o.loadCell(C+1,this._workCell));){o.loadCell(C+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,C++):w>1&&(p+=w-1,c+=w-1),c++,C++}}c++;let m=a+l-h+f,_=Math.min(this._bufferService.cols,c-a+h+d-f-p);if(!(!t&&n.slice(a,c).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let b=r.lines.get(e[1]-1);if(b&&o.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let T=this._bufferService.cols-C.start;m-=T,_+=T}}}if(i&&m+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let b=r.lines.get(e[1]+1);if(b?.isWrapped&&b.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(_+=C.length)}}return{start:m,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=jd(s,this._bufferService.cols)}};jl=xe([H(3,lt),H(4,Si),H(5,ec),H(6,ct),H(7,ks),H(8,xs)],jl);Vd=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ud=class{constructor(){this._color=new Vd,this._css=new Vd}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Me=Object.freeze((()=>{let e=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],o=t[s%6];e.push({css:Le.toCss(i,r,o),rgba:Le.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Le.toCss(i,i,i),rgba:Le.toRgba(i,i,i)})}return e})()),gi=Se.toColor("#ffffff"),Jr=Se.toColor("#000000"),qd=Se.toColor("#ffffff"),Kd=Jr,Ur={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},e0=gi,Vl=class extends se{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ud,this._halfContrastCache=new Ud,this._onChangeColors=this._register(new z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:gi,background:Jr,cursor:qd,cursorAccent:Kd,selectionForeground:void 0,selectionBackgroundTransparent:Ur,selectionBackgroundOpaque:ge.blend(Jr,Ur),selectionInactiveBackgroundTransparent:Ur,selectionInactiveBackgroundOpaque:ge.blend(Jr,Ur),scrollbarSliderBackground:ge.opacity(gi,.2),scrollbarSliderHoverBackground:ge.opacity(gi,.4),scrollbarSliderActiveBackground:ge.opacity(gi,.5),overviewRulerBorder:gi,ansi:Me.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=fe(e.foreground,gi),t.background=fe(e.background,Jr),t.cursor=ge.blend(t.background,fe(e.cursor,qd)),t.cursorAccent=ge.blend(t.background,fe(e.cursorAccent,Kd)),t.selectionBackgroundTransparent=fe(e.selectionBackground,Ur),t.selectionBackgroundOpaque=ge.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ge.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fe(e.selectionForeground,Fd):void 0,t.selectionForeground===Fd&&(t.selectionForeground=void 0),ge.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ge.opacity(t.selectionBackgroundTransparent,.3)),ge.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ge.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=fe(e.scrollbarSliderBackground,ge.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fe(e.scrollbarSliderHoverBackground,ge.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fe(e.scrollbarSliderActiveBackground,ge.opacity(t.foreground,.5)),t.overviewRulerBorder=fe(e.overviewRulerBorder,e0),t.ansi=Me.slice(),t.ansi[0]=fe(e.black,Me[0]),t.ansi[1]=fe(e.red,Me[1]),t.ansi[2]=fe(e.green,Me[2]),t.ansi[3]=fe(e.yellow,Me[3]),t.ansi[4]=fe(e.blue,Me[4]),t.ansi[5]=fe(e.magenta,Me[5]),t.ansi[6]=fe(e.cyan,Me[6]),t.ansi[7]=fe(e.white,Me[7]),t.ansi[8]=fe(e.brightBlack,Me[8]),t.ansi[9]=fe(e.brightRed,Me[9]),t.ansi[10]=fe(e.brightGreen,Me[10]),t.ansi[11]=fe(e.brightYellow,Me[11]),t.ansi[12]=fe(e.brightBlue,Me[12]),t.ansi[13]=fe(e.brightMagenta,Me[13]),t.ansi[14]=fe(e.brightCyan,Me[14]),t.ansi[15]=fe(e.brightWhite,Me[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=fe(e.extendedAnsi[i],Me[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Vl=xe([H(0,ct)],Vl);t0=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},s0=class{constructor(){this._services=new t0,this._services.set(Ql,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=S_(e).sort((o,n)=>o.index-n.index),i=[];for(let o of s){let n=this._services.get(o.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(n)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},i0={trace:0,debug:1,info:2,warn:3,error:4,off:5},r0="xterm.js: ",Ul=class extends se{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),o0=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=i0[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":r0)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Ul=xe([H(0,ct)],Ul);Gd=class extends se{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new z),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ne=3,Re=Object.freeze(new ao),pn=0,cl=2,Zr=class lp{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ne);let r=s||Pt.fromCharData([0,vu,1,0]);for(let o=0;o<t;++o)this.setCell(o,r);this.length=t}get(t){let s=this._data[t*ne+0],i=s&2097151;return[this._data[t*ne+1],s&2097152?this._combined[t]:i?Ws(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ne+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ne+0]=t|2097152|s[2]<<22):this._data[t*ne+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ne+0]>>22}hasWidth(t){return this._data[t*ne+0]&12582912}getFg(t){return this._data[t*ne+1]}getBg(t){return this._data[t*ne+2]}hasContent(t){return this._data[t*ne+0]&4194303}getCodePoint(t){let s=this._data[t*ne+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ne+0]&2097152}getString(t){let s=this._data[t*ne+0];return s&2097152?this._combined[t]:s&2097151?Ws(s&2097151):""}isProtected(t){return this._data[t*ne+2]&536870912}loadCell(t,s){return pn=t*ne,s.content=this._data[pn+0],s.fg=this._data[pn+1],s.bg=this._data[pn+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ne+0]=s.content,this._data[t*ne+1]=s.fg,this._data[t*ne+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ne+0]=s|i<<22,this._data[t*ne+1]=r.fg,this._data[t*ne+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*ne+0];r&2097152?this._combined[t]+=Ws(s):r&2097151?(this._combined[t]=Ws(r&2097151)+Ws(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*ne+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new Pt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,r));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new Pt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*cl<this._data.buffer.byteLength;let i=t*ne;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let n=0;n<r.length;n++){let a=parseInt(r[n],10);a>=t&&delete this._combined[a]}let o=Object.keys(this._extendedAttrs);for(let n=0;n<o.length;n++){let a=parseInt(o[n],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*cl<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*cl<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new lp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ne+0]&4194303)return t+(this._data[t*ne+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ne+0]&4194303||this._data[t*ne+2]&50331648)return t+(this._data[t*ne+0]>>22);return 0}copyCellsFrom(t,s,i,r,o){let n=t._data;if(o)for(let c=r-1;c>=0;c--){for(let l=0;l<ne;l++)this._data[(i+c)*ne+l]=n[(s+c)*ne+l];n[(s+c)*ne+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let l=0;l<ne;l++)this._data[(i+c)*ne+l]=n[(s+c)*ne+l];n[(s+c)*ne+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let l=parseInt(a[c],10);l>=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let n=this._data[s*ne+0],a=n&2097151,c=n&2097152?this._combined[s]:a?Ws(a):js;if(o+=c,r)for(let l=0;l<c.length;++l)r.push(s);s+=n>>22||1}return r&&r.push(s),o}};cp=class hp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=hp._nextId++,this._onDispose=this.register(new z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),yi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};cp._nextId=1;h0=cp,Oe={},_i=Oe.B;Oe[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};Oe.A={"#":"\xA3"};Oe.B=void 0;Oe[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};Oe.C=Oe[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};Oe.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};Oe.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};Oe.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};Oe.E=Oe[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};Oe.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};Oe.H=Oe[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};Yd=4294967295,Xd=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Re.clone(),this.savedCharset=_i,this.markers=[],this._nullCell=Pt.fromCharData([0,vu,1,0]),this._whitespaceCell=Pt.fromCharData([0,js,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ln,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Gd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new xn),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new xn),this._whitespaceCell}getBlankLine(e,t){return new Zr(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Yd?Yd:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Re);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Gd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Re),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(e,s);let o=0;if(this._rows<t)for(let n=this._rows;n<t;n++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Zr(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Zr(e,s)));else for(let n=this._rows;n>t;n--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let n=this.lines.length-r;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=n0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Re),s);if(i.length>0){let r=a0(this.lines,i);l0(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Re),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Zr(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Re),r=[],o=0;for(let n=this.lines.length-1;n>=0;n--){let a=this.lines.get(n);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&n>0;)a=this.lines.get(--n),c.unshift(a);if(!s){let w=this.ybase+this.y;if(w>=n&&w<n+c.length)continue}let l=c[c.length-1].getTrimmedLength(),h=c0(c,this._cols,e),d=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+d):f=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let w=0;w<d;w++){let v=this.getBlankLine(Re,!0);p.push(v)}p.length>0&&(r.push({start:n+c.length+o,newLines:p}),o+=p.length),c.push(...p);let m=h.length-1,_=h[m];_===0&&(m--,_=h[m]);let b=c.length-d-1,C=l;for(;b>=0;){let w=Math.min(C,_);if(c[m]===void 0)break;if(c[m].copyCellsFrom(c[b],C-w,_-w,w,!0),_-=w,_===0&&(m--,_=h[m]),C-=w,C===0){b--;let v=Math.max(b,0);C=no(c,v,this._cols)}}for(let w=0;w<c.length;w++)h[w]<e&&c[w].setCell(h[w],i);let T=d-f;for(;T-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(r.length>0){let n=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let c=this.lines.length,l=c-1,h=0,d=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,c+o-1);_>=0;_--)if(d&&d.start>l+f){for(let b=d.newLines.length-1;b>=0;b--)this.lines.set(_--,d.newLines[b]);_++,n.push({index:l+1,amount:d.newLines.length}),f+=d.newLines.length,d=r[++h]}else this.lines.set(_,a[l--]);let p=0;for(let _=n.length-1;_>=0;_--)n[_].index+=p,this.lines.onInsertEmitter.fire(n[_]),p+=n[_].amount;let m=Math.max(0,c+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new h0(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},d0=class extends se{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new z),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 Xd(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xd(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},dp=2,up=1,ql=class extends se{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new z),this.onResize=this._onResize.event,this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,dp),this.rows=Math.max(e.rawOptions.rows||0,up),this.buffers=this._register(new d0(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let n=s.lines.isFull;o===s.lines.length-1?n?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),n?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let n=o-r+1;s.lines.shiftElements(r+1,n-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};ql=xe([H(0,ct)],ql);Xi={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:Rn,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},u0=["normal","bold","100","200","300","400","500","600","700","800","900"],p0=class extends se{constructor(e){super(),this._onOptionChange=this._register(new z),this.onOptionChange=this._onOptionChange.event;let t={...Xi};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(_e(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Xi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Xi))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Xi[e]),!f0(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Xi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=u0.includes(t)?t:Xi[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};Jd=Object.freeze({insertMode:!1}),Zd=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Kl=class extends se{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new z),this.onData=this._onData.event,this._onUserInput=this._register(new z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Qr(Jd),this.decPrivateModes=Qr(Zd)}reset(){this.modes=Qr(Jd),this.decPrivateModes=Qr(Zd)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Kl=xe([H(0,lt),H(1,Cu),H(2,ct)],Kl);Qd={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};dl=String.fromCharCode,eu={DEFAULT:e=>{let t=[hl(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${dl(t[0])}${dl(t[1])}${dl(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hl(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hl(e,!0)};${e.x};${e.y}${t}`}},Gl=class extends se{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new z),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Qd))this.addProtocol(i,Qd[i]);for(let i of Object.keys(eu))this.addEncoding(i,eu[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Gl=xe([H(0,lt),H(1,Si),H(2,ct)],Gl);ul=[[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]],m0=[[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]];_0=class{constructor(){if(this.version="6",!Be){Be=new Uint8Array(65536),Be.fill(1),Be[0]=0,Be.fill(0,1,32),Be.fill(0,127,160),Be.fill(2,4352,4448),Be[9001]=2,Be[9002]=2,Be.fill(2,11904,42192),Be[12351]=1,Be.fill(2,44032,55204),Be.fill(2,63744,64256),Be.fill(2,65040,65050),Be.fill(2,65072,65136),Be.fill(2,65280,65377),Be.fill(2,65504,65511);for(let e=0;e<ul.length;++e)Be.fill(0,ul[e][0],ul[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Be[e]:g0(e,m0)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=vi.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return vi.createPropertyValue(0,s,i)}},vi=class Cn{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new z,this.onChange=this._onChange.event;let t=new _0;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let o=0;o<r;++o){let n=t.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return s+this.wcwidth(n);let l=t.charCodeAt(o);56320<=l&&l<=57343?n=(n-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(n,i),c=Cn.extractWidth(a);Cn.extractShouldJoin(a)&&(c-=Cn.extractWidth(i)),s+=c,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},v0=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};qr=2147483647,b0=256,pp=class Yl{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>b0)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Yl;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let t=new Yl(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>qr?qr:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>qr?qr:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,qr):t}},Kr=[],y0=class{constructor(){this._state=0,this._active=Kr,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Kr}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Kr,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Kr,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Pn(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Kr,this._id=-1,this._state=0}}},Ct=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Pn(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Gr=[],w0=class{constructor(){this._handlers=Object.create(null),this._active=Gr,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gr}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gr,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gr,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Pn(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gr,this._ident=0}},eo=new pp;eo.addParam(0);su=class{constructor(e){this._handler=e,this._data="",this._params=eo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():eo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Pn(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=eo,this._data="",this._hitLimit=!1,s));return this._params=eo,this._data="",this._hitLimit=!1,t}},S0=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},Dt=160,C0=(function(){let e=new S0(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),s=(a,c)=>t.slice(a,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),n;e.setDefault(1,0),e.addMany(i,0,2,0);for(n in o)e.addMany([24,26,153,154],n,3,0),e.addMany(s(128,144),n,3,0),e.addMany(s(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Dt,0,2,0),e.add(Dt,8,5,8),e.add(Dt,6,0,6),e.add(Dt,11,0,11),e.add(Dt,13,13,13),e})(),x0=class extends se{constructor(e=C0){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new pp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_e(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new y0),this._dcsParser=this._register(new w0),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,o=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](this._params),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],n=this._oscParser.end(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=o;a<t;++a){switch(i=e[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Dt)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(n=c[l](this._params),n!==!0);l--)if(n instanceof Promise)return this._preserveStack(3,c,l,r,a),n;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<t&&(i=e[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],d=h?h.length-1:-1;for(;d>=0&&(n=h[d](),n!==!0);d--)if(n instanceof Promise)return this._preserveStack(4,h,d,r,a),n;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<Dt){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(n=this._dcsParser.unhook(i!==24&&i!==26),n)return this._preserveStack(6,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<Dt){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(n=this._oscParser.end(i!==24&&i!==26),n)return this._preserveStack(5,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},k0=/^([\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})$/,$0=/^[\da-f]+$/;T0={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Hs=131072,ru=10;nu=5e3,au=0,A0=class extends se{constructor(e,t,s,i,r,o,n,a,c=new x0){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=n,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new y_,this._utf8Decoder=new w_,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Re.clone(),this._eraseAttrDataInternal=Re.clone(),this._onRequestBell=this._register(new z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new z),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 Xl(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:h.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,h,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:h,data:d})}),this._parser.setDcsHandlerFallback((l,h,d)=>{h==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:h,payload:d})}),this._parser.setPrintHandler((l,h,d)=>this.print(l,h,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(wn.IND,()=>this.index()),this._parser.setExecuteHandler(wn.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(wn.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ct(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Ct(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Ct(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Ct(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Ct(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Ct(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Ct(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Ct(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Ct(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Ct(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Ct(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Ct(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in Oe)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new su((l,h)=>this.requestStatusString(l,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),nu))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${nu} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Hs&&(o=this._parseStack.position+Hs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Hs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Hs))),n||this._dirtyRowTracker.clearRange(),e.length>Hs)for(let l=o;l<e.length;l+=Hs){let h=l+Hs<e.length?l+Hs:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,l),this._logSlowResolvingAsync(s),s}else if(!n){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,r,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,s){let i,r,o=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,h=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let p=t;p<s;++p){if(i=e[p],i<127&&o){let C=o[String.fromCharCode(i)];C&&(i=C.charCodeAt(0))}let m=this._unicodeService.charProperties(i,f);r=vi.extractWidth(m);let _=vi.extractShouldJoin(m),b=_?vi.extractWidth(f):0;if(f=m,n&&this._onA11yChar.fire(Ws(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-b>a){if(c){let C=d,T=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&d instanceof Zr&&d.copyCellsFrom(C,T,0,b,!1);T<a;)C.setCellFromCodepoint(T++,0,1,h)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let C=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-C,i,r);for(let T=r-b;--T>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-b,this._activeBuffer.getNullCell(h)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,h)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&s-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>ou(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new su(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ct(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Re));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=vi.extractWidth(t),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),n=new Uint32Array(o.length*s),a=0;for(let l=0;l<o.length;){let h=o.codePointAt(l)||0;n[a++]=h,l+=h>65535?2:1}let c=a;for(let l=1;l<s;++l)n.copyWithin(c,0,a),c+=a;return this.print(n,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,_i),this._charsetService.setgCharset(1,_i),this._charsetService.setgCharset(2,_i),this._charsetService.setgCharset(3,_i);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,n=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:l,alt:h}=a,d=this._optionsService.rawOptions,f=(_,b)=>(n.triggerDataEvent(`${M.ESC}[${t?"":"?"}${_};${b}$y`),!0),p=_=>_?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(n.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(i.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?f(m,p(i.origin)):m===7?f(m,p(i.wraparound)):m===8?f(m,3):m===9?f(m,p(r==="X10")):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!n.isCursorHidden)):m===45?f(m,p(i.reverseWraparound)):m===66?f(m,p(i.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(r==="VT200")):m===1002?f(m,p(r==="DRAG")):m===1003?f(m,p(r==="ANY")):m===1004?f(m,p(i.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(o==="SGR")):m===1015?f(m,4):m===1016?f(m,p(o==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===h)):m===2004?f(m,p(i.bracketedPasteMode)):m===2026?f(m,p(i.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=ao.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=e.params[t+o],e.hasSubParams(t+o)){let n=e.getSubParams(t+o),a=0;do i[1]===5&&(r=1),i[o+a+1+r]=n[a];while(++a<n.length&&a+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+t<e.length&&o+r<i.length);for(let n=2;n<i.length;++n)i[n]===-1&&(i[n]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Re.fg,e.bg=Re.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Re.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Re.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Re.fg&16777215,i.bg&=-67108864,i.bg|=Re.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Re.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ou(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ru&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ru&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(lu(o))if(r==="?")t.push({type:0,index:o});else{let n=iu(r);n&&t.push({type:1,index:o,color:n})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=iu(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);lu(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,_i),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(T0[e[0]],Oe[e[1]]||_i),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Re.clone(),this._eraseAttrDataInternal=Re.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Pt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=n=>(this._coreService.triggerDataEvent(`${M.ESC}${n}${M.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Xl=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(au=e,e=t,t=au),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Xl=xe([H(0,lt)],Xl);R0=5e7,cu=12,L0=50,D0=class extends se{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>R0)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let n=a=>performance.now()-s>=cu?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(n);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=cu)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>L0&&(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()}},Jl=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(n,o)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jl=xe([H(0,lt)],Jl);hu=!1,P0=class extends se{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zi),this._onBinary=this._register(new z),this.onBinary=this._onBinary.event,this._onData=this._register(new z),this.onData=this._onData.event,this._onLineFeed=this._register(new z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new z),this._instantiationService=new s0,this.optionsService=this._register(new p0(e)),this._instantiationService.setService(ct,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ql)),this._instantiationService.setService(lt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ul)),this._instantiationService.setService(Cu,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Kl)),this._instantiationService.setService(Si,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gl)),this._instantiationService.setService(Su,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(vi)),this._instantiationService.setService(k_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v0),this._instantiationService.setService(x_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jl),this._instantiationService.setService(xu,this._oscLinkService),this._inputHandler=this._register(new A0(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Xe.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Xe.forward(this._bufferService.onResize,this._onResize)),this._register(Xe.forward(this.coreService.onData,this._onData)),this._register(Xe.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 D0((t,s)=>this._inputHandler.parse(t,s))),this._register(Xe.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!hu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),hu=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,dp),t=Math.max(t,up),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(tu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(tu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_e(()=>{for(let t of e)t.dispose()})}}},M0={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:["'",'"']};$e=0,O0=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ln,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ln,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($e=this._search(t),$e===-1)||this._getKey(this._array[$e])!==t)return!1;do if(this._array[$e]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($e),!0;while(++$e<this._array.length&&this._getKey(this._array[$e])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($e=this._search(e),!($e<0||$e>=this._array.length)&&this._getKey(this._array[$e])===e))do yield this._array[$e];while(++$e<this._array.length&&this._getKey(this._array[$e])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($e=this._search(e),!($e<0||$e>=this._array.length)&&this._getKey(this._array[$e])===e))do t(this._array[$e]);while(++$e<this._array.length&&this._getKey(this._array[$e])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},fl=0,du=0,I0=class extends se{constructor(){super(),this._decorations=new O0(e=>e?.marker.line),this._onDecorationRegistered=this._register(new z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_e(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new z0(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,r=i+(o.options.width??1),e>=i&&e<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{fl=r.options.x??0,du=fl+(r.options.width??1),e>=fl&&e<du&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},z0=class extends Vs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},N0=1e3,F0=class{constructor(e,t=N0){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},uu=20,pu=!1,Dn=class extends se{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new F0(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");pu?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=r.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(r.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(r.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
33
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),lc&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=jd(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ac(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-ll),ll),t/=ll,t/Math.abs(t)+Math.round(t*(Yb-1)))}shouldForceSelection(e){return Rn?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Xb)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Rn&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Jb&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Hb(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let n=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e[0]),c=a,l=e[0]-a,h=0,d=0,f=0,p=0;if(n.charAt(a)===" "){for(;a>0&&n.charAt(a-1)===" ";)a--;for(;c<n.length&&n.charAt(c+1)===" ";)c++}else{let b=e[0],C=e[0];o.getWidth(b)===0&&(h++,b--),o.getWidth(C)===2&&(d++,C++);let T=o.getString(C).length;for(T>1&&(p+=T-1,c+=T-1);b>0&&a>0&&!this._isCharWordSeparator(o.loadCell(b-1,this._workCell));){o.loadCell(b-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,b--):w>1&&(f+=w-1,a-=w-1),a--,b--}for(;C<o.length&&c+1<n.length&&!this._isCharWordSeparator(o.loadCell(C+1,this._workCell));){o.loadCell(C+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,C++):w>1&&(p+=w-1,c+=w-1),c++,C++}}c++;let m=a+l-h+f,_=Math.min(this._bufferService.cols,c-a+h+d-f-p);if(!(!t&&n.slice(a,c).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let b=r.lines.get(e[1]-1);if(b&&o.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let T=this._bufferService.cols-C.start;m-=T,_+=T}}}if(i&&m+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let b=r.lines.get(e[1]+1);if(b?.isWrapped&&b.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(_+=C.length)}}return{start:m,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=jd(s,this._bufferService.cols)}};jl=xe([H(3,lt),H(4,Si),H(5,ec),H(6,ct),H(7,ks),H(8,xs)],jl);Vd=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Ud=class{constructor(){this._color=new Vd,this._css=new Vd}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Pe=Object.freeze((()=>{let e=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],o=t[s%6];e.push({css:Re.toCss(i,r,o),rgba:Re.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Re.toCss(i,i,i),rgba:Re.toRgba(i,i,i)})}return e})()),gi=Se.toColor("#ffffff"),Jr=Se.toColor("#000000"),qd=Se.toColor("#ffffff"),Kd=Jr,Ur={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},e0=gi,Vl=class extends se{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ud,this._halfContrastCache=new Ud,this._onChangeColors=this._register(new z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:gi,background:Jr,cursor:qd,cursorAccent:Kd,selectionForeground:void 0,selectionBackgroundTransparent:Ur,selectionBackgroundOpaque:ge.blend(Jr,Ur),selectionInactiveBackgroundTransparent:Ur,selectionInactiveBackgroundOpaque:ge.blend(Jr,Ur),scrollbarSliderBackground:ge.opacity(gi,.2),scrollbarSliderHoverBackground:ge.opacity(gi,.4),scrollbarSliderActiveBackground:ge.opacity(gi,.5),overviewRulerBorder:gi,ansi:Pe.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=fe(e.foreground,gi),t.background=fe(e.background,Jr),t.cursor=ge.blend(t.background,fe(e.cursor,qd)),t.cursorAccent=ge.blend(t.background,fe(e.cursorAccent,Kd)),t.selectionBackgroundTransparent=fe(e.selectionBackground,Ur),t.selectionBackgroundOpaque=ge.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ge.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fe(e.selectionForeground,Fd):void 0,t.selectionForeground===Fd&&(t.selectionForeground=void 0),ge.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ge.opacity(t.selectionBackgroundTransparent,.3)),ge.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ge.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=fe(e.scrollbarSliderBackground,ge.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fe(e.scrollbarSliderHoverBackground,ge.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fe(e.scrollbarSliderActiveBackground,ge.opacity(t.foreground,.5)),t.overviewRulerBorder=fe(e.overviewRulerBorder,e0),t.ansi=Pe.slice(),t.ansi[0]=fe(e.black,Pe[0]),t.ansi[1]=fe(e.red,Pe[1]),t.ansi[2]=fe(e.green,Pe[2]),t.ansi[3]=fe(e.yellow,Pe[3]),t.ansi[4]=fe(e.blue,Pe[4]),t.ansi[5]=fe(e.magenta,Pe[5]),t.ansi[6]=fe(e.cyan,Pe[6]),t.ansi[7]=fe(e.white,Pe[7]),t.ansi[8]=fe(e.brightBlack,Pe[8]),t.ansi[9]=fe(e.brightRed,Pe[9]),t.ansi[10]=fe(e.brightGreen,Pe[10]),t.ansi[11]=fe(e.brightYellow,Pe[11]),t.ansi[12]=fe(e.brightBlue,Pe[12]),t.ansi[13]=fe(e.brightMagenta,Pe[13]),t.ansi[14]=fe(e.brightCyan,Pe[14]),t.ansi[15]=fe(e.brightWhite,Pe[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=fe(e.extendedAnsi[i],Pe[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Vl=xe([H(0,ct)],Vl);t0=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},s0=class{constructor(){this._services=new t0,this._services.set(Ql,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=S_(e).sort((o,n)=>o.index-n.index),i=[];for(let o of s){let n=this._services.get(o.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(n)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},i0={trace:0,debug:1,info:2,warn:3,error:4,off:5},r0="xterm.js: ",Ul=class extends se{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),o0=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=i0[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":r0)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Ul=xe([H(0,ct)],Ul);Gd=class extends se{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new z),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ne=3,Ae=Object.freeze(new ao),pn=0,cl=2,Zr=class lp{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ne);let r=s||Pt.fromCharData([0,vu,1,0]);for(let o=0;o<t;++o)this.setCell(o,r);this.length=t}get(t){let s=this._data[t*ne+0],i=s&2097151;return[this._data[t*ne+1],s&2097152?this._combined[t]:i?Ws(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ne+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ne+0]=t|2097152|s[2]<<22):this._data[t*ne+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ne+0]>>22}hasWidth(t){return this._data[t*ne+0]&12582912}getFg(t){return this._data[t*ne+1]}getBg(t){return this._data[t*ne+2]}hasContent(t){return this._data[t*ne+0]&4194303}getCodePoint(t){let s=this._data[t*ne+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ne+0]&2097152}getString(t){let s=this._data[t*ne+0];return s&2097152?this._combined[t]:s&2097151?Ws(s&2097151):""}isProtected(t){return this._data[t*ne+2]&536870912}loadCell(t,s){return pn=t*ne,s.content=this._data[pn+0],s.fg=this._data[pn+1],s.bg=this._data[pn+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ne+0]=s.content,this._data[t*ne+1]=s.fg,this._data[t*ne+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ne+0]=s|i<<22,this._data[t*ne+1]=r.fg,this._data[t*ne+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*ne+0];r&2097152?this._combined[t]+=Ws(s):r&2097151?(this._combined[t]=Ws(r&2097151)+Ws(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*ne+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new Pt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,r));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new Pt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*cl<this._data.buffer.byteLength;let i=t*ne;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let n=0;n<r.length;n++){let a=parseInt(r[n],10);a>=t&&delete this._combined[a]}let o=Object.keys(this._extendedAttrs);for(let n=0;n<o.length;n++){let a=parseInt(o[n],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*cl<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*cl<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new lp(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ne+0]&4194303)return t+(this._data[t*ne+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ne+0]&4194303||this._data[t*ne+2]&50331648)return t+(this._data[t*ne+0]>>22);return 0}copyCellsFrom(t,s,i,r,o){let n=t._data;if(o)for(let c=r-1;c>=0;c--){for(let l=0;l<ne;l++)this._data[(i+c)*ne+l]=n[(s+c)*ne+l];n[(s+c)*ne+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let l=0;l<ne;l++)this._data[(i+c)*ne+l]=n[(s+c)*ne+l];n[(s+c)*ne+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let l=parseInt(a[c],10);l>=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let n=this._data[s*ne+0],a=n&2097151,c=n&2097152?this._combined[s]:a?Ws(a):js;if(o+=c,r)for(let l=0;l<c.length;++l)r.push(s);s+=n>>22||1}return r&&r.push(s),o}};cp=class hp{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=hp._nextId++,this._onDispose=this.register(new z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),yi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};cp._nextId=1;h0=cp,Be={},_i=Be.B;Be[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};Be.A={"#":"\xA3"};Be.B=void 0;Be[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};Be.C=Be[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Be.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};Be.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};Be.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};Be.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};Be.E=Be[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};Be.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};Be.H=Be[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Be["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};Yd=4294967295,Xd=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ae.clone(),this.savedCharset=_i,this.markers=[],this._nullCell=Pt.fromCharData([0,vu,1,0]),this._whitespaceCell=Pt.fromCharData([0,js,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Ln,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Gd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new xn),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new xn),this._whitespaceCell}getBlankLine(e,t){return new Zr(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Yd?Yd:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ae);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Gd(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Ae),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(e,s);let o=0;if(this._rows<t)for(let n=this._rows;n<t;n++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Zr(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Zr(e,s)));else for(let n=this._rows;n>t;n--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let n=this.lines.length-r;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=n0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ae),s);if(i.length>0){let r=a0(this.lines,i);l0(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Ae),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Zr(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ae),r=[],o=0;for(let n=this.lines.length-1;n>=0;n--){let a=this.lines.get(n);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&n>0;)a=this.lines.get(--n),c.unshift(a);if(!s){let w=this.ybase+this.y;if(w>=n&&w<n+c.length)continue}let l=c[c.length-1].getTrimmedLength(),h=c0(c,this._cols,e),d=h.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+d):f=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let w=0;w<d;w++){let v=this.getBlankLine(Ae,!0);p.push(v)}p.length>0&&(r.push({start:n+c.length+o,newLines:p}),o+=p.length),c.push(...p);let m=h.length-1,_=h[m];_===0&&(m--,_=h[m]);let b=c.length-d-1,C=l;for(;b>=0;){let w=Math.min(C,_);if(c[m]===void 0)break;if(c[m].copyCellsFrom(c[b],C-w,_-w,w,!0),_-=w,_===0&&(m--,_=h[m]),C-=w,C===0){b--;let v=Math.max(b,0);C=no(c,v,this._cols)}}for(let w=0;w<c.length;w++)h[w]<e&&c[w].setCell(h[w],i);let T=d-f;for(;T-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(r.length>0){let n=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let c=this.lines.length,l=c-1,h=0,d=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let _=Math.min(this.lines.maxLength-1,c+o-1);_>=0;_--)if(d&&d.start>l+f){for(let b=d.newLines.length-1;b>=0;b--)this.lines.set(_--,d.newLines[b]);_++,n.push({index:l+1,amount:d.newLines.length}),f+=d.newLines.length,d=r[++h]}else this.lines.set(_,a[l--]);let p=0;for(let _=n.length-1;_>=0;_--)n[_].index+=p,this.lines.onInsertEmitter.fire(n[_]),p+=n[_].amount;let m=Math.max(0,c+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new h0(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},d0=class extends se{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new z),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 Xd(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Xd(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},dp=2,up=1,ql=class extends se{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new z),this.onResize=this._onResize.event,this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,dp),this.rows=Math.max(e.rawOptions.rows||0,up),this.buffers=this._register(new d0(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let n=s.lines.isFull;o===s.lines.length-1?n?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),n?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let n=o-r+1;s.lines.shiftElements(r+1,n-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};ql=xe([H(0,ct)],ql);Xi={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:Rn,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},u0=["normal","bold","100","200","300","400","500","600","700","800","900"],p0=class extends se{constructor(e){super(),this._onOptionChange=this._register(new z),this.onOptionChange=this._onOptionChange.event;let t={...Xi};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(_e(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Xi))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Xi))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Xi[e]),!f0(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Xi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=u0.includes(t)?t:Xi[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};Jd=Object.freeze({insertMode:!1}),Zd=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Kl=class extends se{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new z),this.onData=this._onData.event,this._onUserInput=this._register(new z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Qr(Jd),this.decPrivateModes=Qr(Zd)}reset(){this.modes=Qr(Jd),this.decPrivateModes=Qr(Zd)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Kl=xe([H(0,lt),H(1,Cu),H(2,ct)],Kl);Qd={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};dl=String.fromCharCode,eu={DEFAULT:e=>{let t=[hl(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${dl(t[0])}${dl(t[1])}${dl(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hl(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hl(e,!0)};${e.x};${e.y}${t}`}},Gl=class extends se{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new z),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(Qd))this.addProtocol(i,Qd[i]);for(let i of Object.keys(eu))this.addEncoding(i,eu[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Gl=xe([H(0,lt),H(1,Si),H(2,ct)],Gl);ul=[[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]],m0=[[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]];_0=class{constructor(){if(this.version="6",!Me){Me=new Uint8Array(65536),Me.fill(1),Me[0]=0,Me.fill(0,1,32),Me.fill(0,127,160),Me.fill(2,4352,4448),Me[9001]=2,Me[9002]=2,Me.fill(2,11904,42192),Me[12351]=1,Me.fill(2,44032,55204),Me.fill(2,63744,64256),Me.fill(2,65040,65050),Me.fill(2,65072,65136),Me.fill(2,65280,65377),Me.fill(2,65504,65511);for(let e=0;e<ul.length;++e)Me.fill(0,ul[e][0],ul[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Me[e]:g0(e,m0)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=vi.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return vi.createPropertyValue(0,s,i)}},vi=class Cn{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new z,this.onChange=this._onChange.event;let t=new _0;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let o=0;o<r;++o){let n=t.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return s+this.wcwidth(n);let l=t.charCodeAt(o);56320<=l&&l<=57343?n=(n-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(n,i),c=Cn.extractWidth(a);Cn.extractShouldJoin(a)&&(c-=Cn.extractWidth(i)),s+=c,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},v0=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};qr=2147483647,b0=256,pp=class Yl{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>b0)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Yl;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let t=new Yl(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>qr?qr:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>qr?qr:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,qr):t}},Kr=[],y0=class{constructor(){this._state=0,this._active=Kr,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Kr}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Kr,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Kr,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Pn(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Kr,this._id=-1,this._state=0}}},Ct=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Pn(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Gr=[],w0=class{constructor(){this._handlers=Object.create(null),this._active=Gr,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Gr}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Gr,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Gr,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Pn(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Gr,this._ident=0}},eo=new pp;eo.addParam(0);su=class{constructor(e){this._handler=e,this._data="",this._params=eo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():eo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Pn(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=eo,this._data="",this._hitLimit=!1,s));return this._params=eo,this._data="",this._hitLimit=!1,t}},S0=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},Dt=160,C0=(function(){let e=new S0(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),s=(a,c)=>t.slice(a,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),n;e.setDefault(1,0),e.addMany(i,0,2,0);for(n in o)e.addMany([24,26,153,154],n,3,0),e.addMany(s(128,144),n,3,0),e.addMany(s(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Dt,0,2,0),e.add(Dt,8,5,8),e.add(Dt,6,0,6),e.add(Dt,11,0,11),e.add(Dt,13,13,13),e})(),x0=class extends se{constructor(e=C0){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new pp,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_e(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new y0),this._dcsParser=this._register(new w0),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,o=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let a=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](this._params),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],n=this._oscParser.end(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=o;a<t;++a){switch(i=e[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Dt)],r>>4){case 2:for(let f=a+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<Dt){this._printHandler(e,a,f),a=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(n=c[l](this._params),n!==!0);l--)if(n instanceof Promise)return this._preserveStack(3,c,l,r,a),n;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<t&&(i=e[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],d=h?h.length-1:-1;for(;d>=0&&(n=h[d](),n!==!0);d--)if(n instanceof Promise)return this._preserveStack(4,h,d,r,a),n;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let f=a+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<Dt){this._dcsParser.put(e,a,f),a=f-1;break}break;case 14:if(n=this._dcsParser.unhook(i!==24&&i!==26),n)return this._preserveStack(6,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=a+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<Dt){this._oscParser.put(e,a,f),a=f-1;break}break;case 6:if(n=this._oscParser.end(i!==24&&i!==26),n)return this._preserveStack(5,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},k0=/^([\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})$/,$0=/^[\da-f]+$/;T0={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Hs=131072,ru=10;nu=5e3,au=0,A0=class extends se{constructor(e,t,s,i,r,o,n,a,c=new x0){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=n,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new y_,this._utf8Decoder=new w_,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ae.clone(),this._eraseAttrDataInternal=Ae.clone(),this._onRequestBell=this._register(new z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new z),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 Xl(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:h.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,h,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:h,data:d})}),this._parser.setDcsHandlerFallback((l,h,d)=>{h==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:h,payload:d})}),this._parser.setPrintHandler((l,h,d)=>this.print(l,h,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(wn.IND,()=>this.index()),this._parser.setExecuteHandler(wn.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(wn.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ct(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Ct(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Ct(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Ct(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Ct(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Ct(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Ct(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Ct(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Ct(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Ct(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Ct(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Ct(l=>this.restoreCursorColor(l))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let l in Be)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new su((l,h)=>this.requestStatusString(l,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),nu))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${nu} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Hs&&(o=this._parseStack.position+Hs)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Hs&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Hs))),n||this._dirtyRowTracker.clearRange(),e.length>Hs)for(let l=o;l<e.length;l+=Hs){let h=l+Hs<e.length?l+Hs:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,l),this._logSlowResolvingAsync(s),s}else if(!n){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,r,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,s){let i,r,o=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,h=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let f=this._parser.precedingJoinState;for(let p=t;p<s;++p){if(i=e[p],i<127&&o){let C=o[String.fromCharCode(i)];C&&(i=C.charCodeAt(0))}let m=this._unicodeService.charProperties(i,f);r=vi.extractWidth(m);let _=vi.extractShouldJoin(m),b=_?vi.extractWidth(f):0;if(f=m,n&&this._onA11yChar.fire(Ws(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-b>a){if(c){let C=d,T=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&d instanceof Zr&&d.copyCellsFrom(C,T,0,b,!1);T<a;)C.setCellFromCodepoint(T++,0,1,h)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let C=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-C,i,r);for(let T=r-b;--T>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-b,this._activeBuffer.getNullCell(h)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,h)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=f,this._activeBuffer.x<a&&s-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>ou(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new su(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ct(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ae));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=vi.extractWidth(t),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),n=new Uint32Array(o.length*s),a=0;for(let l=0;l<o.length;){let h=o.codePointAt(l)||0;n[a++]=h,l+=h>65535?2:1}let c=a;for(let l=1;l<s;++l)n.copyWithin(c,0,a),c+=a;return this.print(n,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,_i),this._charsetService.setgCharset(1,_i),this._charsetService.setgCharset(2,_i),this._charsetService.setgCharset(3,_i);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,n=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:l,alt:h}=a,d=this._optionsService.rawOptions,f=(_,b)=>(n.triggerDataEvent(`${M.ESC}[${t?"":"?"}${_};${b}$y`),!0),p=_=>_?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(n.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(i.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):m===6?f(m,p(i.origin)):m===7?f(m,p(i.wraparound)):m===8?f(m,3):m===9?f(m,p(r==="X10")):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!n.isCursorHidden)):m===45?f(m,p(i.reverseWraparound)):m===66?f(m,p(i.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(r==="VT200")):m===1002?f(m,p(r==="DRAG")):m===1003?f(m,p(r==="ANY")):m===1004?f(m,p(i.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(o==="SGR")):m===1015?f(m,4):m===1016?f(m,p(o==="SGR_PIXELS")):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===h)):m===2004?f(m,p(i.bracketedPasteMode)):m===2026?f(m,p(i.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=ao.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=e.params[t+o],e.hasSubParams(t+o)){let n=e.getSubParams(t+o),a=0;do i[1]===5&&(r=1),i[o+a+1+r]=n[a];while(++a<n.length&&a+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+t<e.length&&o+r<i.length);for(let n=2;n<i.length;++n)i[n]===-1&&(i[n]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ae.fg,e.bg=Ae.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ae.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ae.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ae.fg&16777215,i.bg&=-67108864,i.bg|=Ae.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ae.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ou(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ru&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ru&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(lu(o))if(r==="?")t.push({type:0,index:o});else{let n=iu(r);n&&t.push({type:1,index:o,color:n})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=iu(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);lu(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,_i),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(T0[e[0]],Be[e[1]]||_i),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ae.clone(),this._eraseAttrDataInternal=Ae.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Pt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=n=>(this._coreService.triggerDataEvent(`${M.ESC}${n}${M.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Xl=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(au=e,e=t,t=au),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Xl=xe([H(0,lt)],Xl);R0=5e7,cu=12,L0=50,D0=class extends se{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>R0)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let n=a=>performance.now()-s>=cu?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(n);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=cu)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>L0&&(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()}},Jl=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let a=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(n,o)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jl=xe([H(0,lt)],Jl);hu=!1,P0=class extends se{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Zi),this._onBinary=this._register(new z),this.onBinary=this._onBinary.event,this._onData=this._register(new z),this.onData=this._onData.event,this._onLineFeed=this._register(new z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new z),this._instantiationService=new s0,this.optionsService=this._register(new p0(e)),this._instantiationService.setService(ct,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ql)),this._instantiationService.setService(lt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ul)),this._instantiationService.setService(Cu,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Kl)),this._instantiationService.setService(Si,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gl)),this._instantiationService.setService(Su,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(vi)),this._instantiationService.setService(k_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v0),this._instantiationService.setService(x_,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jl),this._instantiationService.setService(xu,this._oscLinkService),this._inputHandler=this._register(new A0(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Xe.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Xe.forward(this._bufferService.onResize,this._onResize)),this._register(Xe.forward(this.coreService.onData,this._onData)),this._register(Xe.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 D0((t,s)=>this._inputHandler.parse(t,s))),this._register(Xe.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!hu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),hu=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,dp),t=Math.max(t,up),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(tu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(tu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_e(()=>{for(let t of e)t.dispose()})}}},M0={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:["'",'"']};$e=0,O0=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Ln,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Ln,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||($e=this._search(t),$e===-1)||this._getKey(this._array[$e])!==t)return!1;do if(this._array[$e]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push($e),!0;while(++$e<this._array.length&&this._getKey(this._array[$e])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($e=this._search(e),!($e<0||$e>=this._array.length)&&this._getKey(this._array[$e])===e))do yield this._array[$e];while(++$e<this._array.length&&this._getKey(this._array[$e])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&($e=this._search(e),!($e<0||$e>=this._array.length)&&this._getKey(this._array[$e])===e))do t(this._array[$e]);while(++$e<this._array.length&&this._getKey(this._array[$e])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},fl=0,du=0,I0=class extends se{constructor(){super(),this._decorations=new O0(e=>e?.marker.line),this._onDecorationRegistered=this._register(new z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_e(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new z0(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,r=i+(o.options.width??1),e>=i&&e<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{fl=r.options.x??0,du=fl+(r.options.width??1),e>=fl&&e<du&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},z0=class extends Vs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},N0=1e3,F0=class{constructor(e,t=N0){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},uu=20,pu=!1,Dn=class extends se{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new F0(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");pu?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=r.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(r.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(r.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
34
34
  `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(q(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_e(()=>{pu?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<uu+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===uu+1&&(this._liveRegion.textContent+=gl.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let o=s.lines.get(s.ydisp+r),n=[],a=o?.translateToString(!0,void 0,void 0,n)||"",c=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent="\xA0",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,n)),l.setAttribute("aria-posinset",c),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==i)return;let n,a;if(t===0?(n=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(n=this._rowElements.shift(),a=s,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:a,offset:c})=>{let l=a instanceof Text?a.parentNode:a,h=parseInt(l?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(l);if(!d)return console.warn("columns is null. Race condition?"),null;let f=c<d.length?d[c]:d.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=r(t),n=r(s);if(!(!o||!n)){if(o.row>n.row||o.row===n.row&&o.column>=n.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(n.row-o.row)*this._terminal.cols-o.column+n.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};Dn=xe([H(1,Ql),H(2,xs),H(3,ks)],Dn);Zl=class extends se{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_e(()=>{yi(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(q(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(q(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(q(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):r.provideLinks(e.y,o=>{if(this._isMouseOut)return;let n=o?.map(a=>({link:a}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let o=0;o<r.length;o++){let n=r[o],a=n.link.range.start.y<e?0:n.link.range.start.x,c=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let l=a;l<=c;l++){if(s.has(l)){r.splice(o--,1);break}s.add(l)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(n=>this._linkAtPosition(n.link,t));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let n=this._activeProviderReplies.get(o)?.find(a=>this._linkAtPosition(a.link,t));if(n){s=!0,this._handleNewLink(n);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&H0(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,yi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Zl=xe([H(1,ec),H(2,ks),H(3,lt),H(4,$u)],Zl);W0=class extends P0{constructor(e={}){super(e),this._linkifier=this._register(new Zi),this.browser=ep,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zi),this._onCursorMove=this._register(new z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new z),this.onKey=this._onKey.event,this._onRender=this._register(new z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new z),this.onBell=this._onBell.event,this._onFocus=this._register(new z),this._onBlur=this._register(new z),this._onA11yCharEmitter=this._register(new z),this._onA11yTabEmitter=this._register(new z),this._onWillOpen=this._register(new z),this._setup(),this._decorationService=this._instantiationService.createInstance(I0),this._instantiationService.setService(lo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Rb),this._instantiationService.setService($u,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(vl)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Xe.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Xe.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Xe.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Xe.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(_e(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=ge.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${E0(r)}${Zu.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Le.toColor(...t.color));else{let o=s;this._themeService.modifyColors(n=>n[o]=Le.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Dn,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.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(M.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,n=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=n+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(q(this.element,"copy",t=>{this.hasSelection()&&v_(t,this._selectionService)}));let e=t=>b_(t,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,"paste",e)),this._register(q(this.element,"paste",e)),tp?this._register(q(this.element,"mousedown",t=>{t.button===2&&fd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,"contextmenu",t=>{fd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),lc&&this._register(q(this.element,"auxclick",t=>{t.button===1&&_u(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(q(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(q(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(q(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(q(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(q(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ml.get()),rp||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Tb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xs,this._coreBrowserService),this._register(q(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(q(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Fl,this._document,this._helperContainer),this._instantiationService.setService(Mn,this._charSizeService),this._themeService=this._instantiationService.createInstance(Vl),this._instantiationService.setService(Qi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(An),this._instantiationService.setService(ku,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Wl,this.rows,this.screenElement)),this._instantiationService.setService(ks,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Il,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hl),this._instantiationService.setService(ec,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Zl,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Bl,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jl,this.element,this.screenElement,i)),this._instantiationService.setService(E_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(Xe.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ol,this.screenElement)),this._register(q(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(Dn,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tn,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tn,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Nl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){let n=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!n)return!1;let a,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(a=3,o.button!==void 0&&(a=o.button<3?o.button:3)):a=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,a=o.button<3?o.button:3;break;case"mousedown":c=1,a=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let l=o.deltaY;if(l===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=l<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:a,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(q(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(q(t,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let n=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){gu(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=B0(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(j0(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Re));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};V0=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},U0=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Pt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},fu=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new U0(t)}getNullCell(){return new Pt}},q0=class extends se{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new z),this.onBufferChange=this._onBufferChange.event,this._normal=new fu(this._core.buffers.normal,"normal"),this._alternate=new fu(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},K0=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},G0=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y0=["cols","rows"],ts=0,X0=class extends se{constructor(e){super(),this._core=this._register(new W0(e)),this._addonManager=this._register(new V0),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(Y0.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new K0(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new G0(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 q0(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
35
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===uu+1&&(this._liveRegion.textContent+=gl.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let o=s.lines.get(s.ydisp+r),n=[],a=o?.translateToString(!0,void 0,void 0,n)||"",c=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent="\xA0",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,n)),l.setAttribute("aria-posinset",c),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==i)return;let n,a;if(t===0?(n=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(n=this._rowElements.shift(),a=s,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:a,offset:c})=>{let l=a instanceof Text?a.parentNode:a,h=parseInt(l?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(l);if(!d)return console.warn("columns is null. Race condition?"),null;let f=c<d.length?d[c]:d.slice(-1)[0]+1;return f>=this._terminal.cols&&(++h,f=0),{row:h,column:f}},o=r(t),n=r(s);if(!(!o||!n)){if(o.row>n.row||o.row===n.row&&o.column>=n.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(n.row-o.row)*this._terminal.cols-o.column+n.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};Dn=xe([H(1,Ql),H(2,xs),H(3,ks)],Dn);Zl=class extends se{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_e(()=>{yi(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(q(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(q(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(q(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):r.provideLinks(e.y,o=>{if(this._isMouseOut)return;let n=o?.map(a=>({link:a}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let o=0;o<r.length;o++){let n=r[o],a=n.link.range.start.y<e?0:n.link.range.start.x,c=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let l=a;l<=c;l++){if(s.has(l)){r.splice(o--,1);break}s.add(l)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&i){let o=i.find(n=>this._linkAtPosition(n.link,t));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let n=this._activeProviderReplies.get(o)?.find(a=>this._linkAtPosition(a.link,t));if(n){s=!0,this._handleNewLink(n);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&H0(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,yi(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Zl=xe([H(1,ec),H(2,ks),H(3,lt),H(4,$u)],Zl);W0=class extends P0{constructor(e={}){super(e),this._linkifier=this._register(new Zi),this.browser=ep,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Zi),this._onCursorMove=this._register(new z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new z),this.onKey=this._onKey.event,this._onRender=this._register(new z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new z),this.onBell=this._onBell.event,this._onFocus=this._register(new z),this._onBlur=this._register(new z),this._onA11yCharEmitter=this._register(new z),this._onA11yTabEmitter=this._register(new z),this._onWillOpen=this._register(new z),this._setup(),this._decorationService=this._instantiationService.createInstance(I0),this._instantiationService.setService(lo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Rb),this._instantiationService.setService($u,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(vl)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Xe.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Xe.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Xe.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Xe.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(_e(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=ge.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${E0(r)}${Zu.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Re.toColor(...t.color));else{let o=s;this._themeService.modifyColors(n=>n[o]=Re.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Dn,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.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(M.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,n=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=n+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(q(this.element,"copy",t=>{this.hasSelection()&&v_(t,this._selectionService)}));let e=t=>b_(t,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,"paste",e)),this._register(q(this.element,"paste",e)),tp?this._register(q(this.element,"mousedown",t=>{t.button===2&&fd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,"contextmenu",t=>{fd(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),lc&&this._register(q(this.element,"auxclick",t=>{t.button===1&&_u(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(q(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(q(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(q(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(q(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(q(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ml.get()),rp||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Tb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xs,this._coreBrowserService),this._register(q(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(q(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Fl,this._document,this._helperContainer),this._instantiationService.setService(Mn,this._charSizeService),this._themeService=this._instantiationService.createInstance(Vl),this._instantiationService.setService(Qi,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(An),this._instantiationService.setService(ku,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Wl,this.rows,this.screenElement)),this._instantiationService.setService(ks,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Il,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hl),this._instantiationService.setService(ec,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Zl,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Bl,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(jl,this.element,this.screenElement,i)),this._instantiationService.setService(E_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(Xe.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Ol,this.screenElement)),this._register(q(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(Dn,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tn,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Tn,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Nl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){let n=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!n)return!1;let a,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(a=3,o.button!==void 0&&(a=o.button<3?o.button:3)):a=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,a=o.button<3?o.button:3;break;case"mousedown":c=1,a=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let l=o.deltaY;if(l===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=l<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:a,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(q(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(q(t,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let n=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){gu(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=B0(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(j0(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ae));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};V0=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},U0=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Pt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},fu=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new U0(t)}getNullCell(){return new Pt}},q0=class extends se{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new z),this.onBufferChange=this._onBufferChange.event,this._normal=new fu(this._core.buffers.normal,"normal"),this._alternate=new fu(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},K0=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},G0=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Y0=["cols","rows"],ts=0,X0=class extends se{constructor(e){super(),this._core=this._register(new W0(e)),this._addonManager=this._register(new V0),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(Y0.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new K0(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new G0(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 q0(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
36
36
  `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return ml.get()},set promptLabel(e){ml.set(e)},get tooMuchOutput(){return gl.get()},set tooMuchOutput(e){gl.set(e)}}}_verifyIntegers(...e){for(ts of e)if(ts===1/0||isNaN(ts)||ts%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ts of e)if(ts&&(ts===1/0||isNaN(ts)||ts%1!==0||ts<0))throw new Error("This API only accepts positive integers")}}});var dc={};Aa(dc,{FitAddon:()=>Q0});var J0,Z0,Q0,uc=Ta(()=>{J0=2,Z0=1,Q0=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),n={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},a=n.top+n.bottom,c=n.right+n.left,l=i-a,h=r-c-t;return{cols:Math.max(J0,Math.floor(h/e.css.cell.width)),rows:Math.max(Z0,Math.floor(l/e.css.cell.height))}}}});var Vp={};Aa(Vp,{SearchAddon:()=>Qy});function bc(e){ny(e)||oy.onUnexpectedError(e)}function ny(e){return e instanceof ay?!0:e instanceof Error&&e.name===Sc&&e.message===Sc}function ly(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function hy(e,t){return(s,i)=>t(e(s),e(i))}function uy(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function fy(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function _y(e){ir=e}function Kn(e){return ir?.trackDisposable(e),e}function Gn(e){ir?.markAsDisposed(e)}function fo(e,t){ir?.setParent(e,t)}function vy(e,t){if(ir)for(let s of e)ir.setParent(s,t)}function po(e){if(Lp.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Pp(...e){let t=rr(()=>po(e));return vy(e,t),t}function rr(e){let t=Kn({dispose:fy(()=>{Gn(t),e()})});return t}function jp(e,t=0,s){let i=setTimeout(()=>{e(),s&&r.dispose()},t),r=rr(()=>{clearTimeout(i),s?.deleteAndLeak(r)});return s?.add(r),r}var ry,oy,Sc,ay,yp,cy,Rp,dy,wp,Sp,Cp,_E,py,Lp,my,ir,gy,Mp,Lc,ns,qn,xp,by,yy,wy,kp,Sy,Dc,$c,Cy,$p,Ip,xy,Tc,ky,$y,Ey,Wn,Ty,Ay,jn,os,Ry,Fp,Ly,Dy,sr,Ac,Rc,Vn,Py,My,Hp,By,Oy,Iy,zy,Hn,Un,Ep,Ny,$s,Es,$t,Wp,Fy,yc,Hy,vE,as,qs,Wy,jy,Vy,Uy,bE,yE,wE,SE,qy,wc,Ky,Tp,Gy,Yy,Xy,Jy,Zy,Qy,Up=Ta(()=>{ry=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?yp.isErrorNoTelemetry(e)?new yp(e.message+`
37
37
 
38
38
  `+e.stack):new Error(e.message+`
@@ -61,8 +61,8 @@ ${h.join(`
61
61
  `).slice(2,3).join(`
62
62
  `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);jn.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Ty<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||bc;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Wn)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Ry=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Fp=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Dy?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Dc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Fp})})(Ly||(Ly={}));Dy=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Fp:(this._emitter||(this._emitter=new os),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},sr="en",Ac=!1,Rc=!1,Vn=!1,Py=!1,My=!1,Hp=!1,By=!1,Oy=!1,Iy=!1,zy=!1,Un=sr,Ep=sr,Es=globalThis;typeof Es.vscode<"u"&&typeof Es.vscode.process<"u"?$t=Es.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&($t=process);Wp=typeof $t?.versions?.electron=="string",Fy=Wp&&$t?.type==="renderer";if(typeof $t=="object"){Ac=$t.platform==="win32",Rc=$t.platform==="darwin",Vn=$t.platform==="linux",Py=Vn&&!!$t.env.SNAP&&!!$t.env.SNAP_REVISION,By=Wp,Iy=!!$t.env.CI||!!$t.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Hn=sr,Un=sr;let e=$t.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Hn=t.userLocale,Ep=t.osLocale,Un=t.resolvedLanguage||sr,Ny=t.languagePack?.translationsConfigFile}catch{}My=!0}else typeof navigator=="object"&&!Fy?($s=navigator.userAgent,Ac=$s.indexOf("Windows")>=0,Rc=$s.indexOf("Macintosh")>=0,Oy=($s.indexOf("Macintosh")>=0||$s.indexOf("iPad")>=0||$s.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Vn=$s.indexOf("Linux")>=0,zy=$s?.indexOf("Mobi")>=0,Hp=!0,Un=globalThis._VSCODE_NLS_LANGUAGE||sr,Hn=navigator.language.toLowerCase(),Ep=Hn):console.error("Unable to resolve platform.");yc=0;Rc?yc=1:Ac?yc=3:Vn&&(yc=2);Hy=Hp&&typeof Es.importScripts=="function",vE=Hy?Es.origin:void 0,as=$s,qs=Un;(e=>{function t(){return qs}e.value=t;function s(){return qs.length===2?qs==="en":qs.length>=3?qs[0]==="e"&&qs[1]==="n"&&qs[2]==="-":!1}e.isDefaultVariant=s;function i(){return qs==="en"}e.isDefault=i})(Wy||(Wy={}));jy=typeof Es.postMessage=="function"&&!Es.importScripts,Vy=(()=>{if(jy){let e=[];Es.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Es.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),Uy=!!(as&&as.indexOf("Chrome")>=0),bE=!!(as&&as.indexOf("Firefox")>=0),yE=!!(!Uy&&as&&as.indexOf("Safari")>=0),wE=!!(as&&as.indexOf("Edg/")>=0),SE=!!(as&&as.indexOf("Android")>=0);(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?wc=(e,t)=>{Vy(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:wc=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},qy=e=>wc(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(Ky||(Ky={}));Tp=class Mt{static fromArray(t){return new Mt(s=>{s.emitMany(t)})}static fromPromise(t){return new Mt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Mt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Mt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new os,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Dc.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Mt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Mt.map(this,t)}static filter(t,s){return new Mt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Mt.filter(this,t)}static coalesce(t){return Mt.filter(t,s=>!!s)}coalesce(){return Mt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Mt.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Tp.EMPTY=Tp.fromArray([]);Gy=class extends ns{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new qn),this._linesCacheDisposables=this._register(new qn),this._register(rr(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Pp(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=jp(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let s=[],i=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let o=this._terminal.buffer.active.getLine(e+1),n=o?o.isWrapped:!1,a=r.translateToString(!n&&t);if(n&&o){let c=r.getCell(r.length-1);c&&c.getCode()===0&&c.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(s.push(a),n)i.push(i[i.length-1]+a.length);else break;e++,r=o}return[s.join(""),i]}},Yy=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},Xy=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,s,i){if(!e||e.length===0){this._terminal.clearSelection();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:s},o=this._findInLine(e,r,i);if(!o)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=n,r.startCol=0,o=this._findInLine(e,r,i),!o);n++);return o}findNextWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,o=0;i&&(s===e?(r=i.end.x,o=i.end.y):(r=i.start.x,o=i.start.y)),this._lineCache.initLinesCache();let n={startRow:o,startCol:r},a=this._findInLine(e,n,t);if(!a)for(let c=o+1;c<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);if(!a&&o!==0)for(let c=0;c<o&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);return!a&&i&&(n.startRow=i.start.y,n.startCol=0,a=this._findInLine(e,n,t)),a}findPreviousWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,o=this._terminal.cols,n=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:o},c;if(i&&(a.startRow=r=i.start.y,a.startCol=o=i.start.x,s!==e&&(c=this._findInLine(e,a,t,!1),c||(a.startRow=r=i.end.y,a.startCol=o=i.end.x))),c||(c=this._findInLine(e,a,t,n)),!c){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let l=r-1;l>=0&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);}if(!c&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let l=this._terminal.buffer.active.baseY+this._terminal.rows-1;l>=r&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);return c}_isWholeWord(e,t,s){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+s.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+s.length]))}_findInLine(e,t,s={},i=!1){let r=t.startRow,o=t.startCol;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(i){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,s)}let n=this._lineCache.getLineFromCache(r);n||(n=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,n));let[a,c]=n,l=this._bufferColsToStringOffset(r,o),h=e,d=a;s.regex||(h=s.caseSensitive?e:e.toLowerCase(),d=s.caseSensitive?a:a.toLowerCase());let f=-1;if(s.regex){let p=RegExp(h,s.caseSensitive?"g":"gi"),m;if(i)for(;m=p.exec(d.slice(0,l));)f=p.lastIndex-m[0].length,e=m[0],p.lastIndex-=e.length-1;else m=p.exec(d.slice(l)),m&&m[0].length>0&&(f=l+(p.lastIndex-m[0].length),e=m[0])}else i?l-h.length>=0&&(f=d.lastIndexOf(h,l-h.length)):f=d.indexOf(h,l);if(f>=0){if(s.wholeWord&&!this._isWholeWord(f,d,e))return;let p=0;for(;p<c.length-1&&f>=c[p+1];)p++;let m=p;for(;m<c.length-1&&f+e.length>=c[m+1];)m++;let _=f-c[p],b=f+e.length-c[m],C=this._stringLengthToBufferSize(r+p,_),T=this._stringLengthToBufferSize(r+m,b)-C+this._terminal.cols*(m-p);return{term:e,col:C,row:r+p,size:T}}}_stringLengthToBufferSize(e,t){let s=this._terminal.buffer.active.getLine(e);if(!s)return 0;for(let i=0;i<t;i++){let r=s.getCell(i);if(!r)break;let o=r.getChars();o.length>1&&(t-=o.length-1);let n=s.getCell(i+1);n&&n.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let s=e,i=0,r=this._terminal.buffer.active.getLine(s);for(;t>0&&r;){for(let o=0;o<t&&o<this._terminal.cols;o++){let n=r.getCell(o);if(!n)break;n.getWidth()&&(i+=n.getCode()===0?1:n.getChars().length)}if(s++,r=this._terminal.buffer.active.getLine(s),r&&!r.isWrapped)break;t-=this._terminal.cols}return i}},Jy=class extends ns{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(rr(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let s of e){let i=this._createResultDecorations(s,t,!1);if(i)for(let r of i)this._storeDecoration(r,s)}}createActiveDecoration(e,t){let s=this._createResultDecorations(e,t,!0);if(s)return{decorations:s,match:e,dispose(){po(s)}}}clearHighlightDecorations(){po(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,s){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),s&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,s){let i=[],r=e.col,o=e.size,n=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;o>0;){let c=Math.min(this._terminal.cols-r,o);i.push([n,r,c]),r=0,o-=c,n++}let a=[];for(let c of i){let l=this._terminal.registerMarker(c[0]),h=this._terminal.registerDecoration({marker:l,x:c[1],width:c[2],backgroundColor:s?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(l.line)?void 0:{color:s?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(h){let d=[];d.push(l),d.push(h.onRender(f=>this._applyStyles(f,s?t.activeMatchBorder:t.matchBorder,!1))),d.push(h.onDispose(()=>po(d))),a.push(h)}}return a.length===0?void 0:a}},Zy=class extends ns{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new os)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let s=this._searchResults[t];if(s.row===e.row&&s.col===e.col&&s.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Qy=class extends ns{constructor(e){super(),this._highlightTimeout=this._register(new qn),this._lineCache=this._register(new qn),this._state=new Yy,this._resultTracker=this._register(new Zy),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Gy(e),this._engine=new Xy(e,this._lineCache.value),this._decorationManager=new Jy(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(rr(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=jp(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findNextAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let s=[],i,r=this._engine.find(e,0,0,t);for(;r&&(i?.row!==r.row||i?.col!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(s,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(s,t.decorations)}_findNextAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}findPrevious(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findPreviousAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}_selectResult(e,t,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!s&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let i=e.row-this._terminal.buffer.active.viewportY;i-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(i)}return!0}}});var Er=globalThis,Mh=e=>e,Ko=Er.trustedTypes,Bh=Ko?Ko.createPolicy("lit-html",{createHTML:e=>e}):void 0,La="$lit$",fs=`lit$${Math.random().toFixed(9).slice(2)}$`,Da="?"+fs,Pg=`<${Da}>`,li=document,Tr=()=>li.createComment(""),Ar=e=>e===null||typeof e!="object"&&typeof e!="function",Pa=Array.isArray,Hh=e=>Pa(e)||typeof e?.[Symbol.iterator]=="function",Ra=`[
63
63
  \f\r]`,$r=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Oh=/-->/g,Ih=/>/g,ni=RegExp(`>|${Ra}(?:([^\\s"'>=/]+)(${Ra}*=${Ra}*(?:[^
64
- \f\r"'\`<>=]|("|')|))|$)`,"g"),zh=/'/g,Nh=/"/g,Wh=/^(?:script|style|textarea|title)$/i,Ma=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),u=Ma(1),jh=Ma(2),Vh=Ma(3),tt=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),Fh=new WeakMap,ai=li.createTreeWalker(li,129);function Uh(e,t){if(!Pa(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Bh!==void 0?Bh.createHTML(t):t}var qh=(e,t)=>{let s=e.length-1,i=[],r,o=t===2?"<svg>":t===3?"<math>":"",n=$r;for(let a=0;a<s;a++){let c=e[a],l,h,d=-1,f=0;for(;f<c.length&&(n.lastIndex=f,h=n.exec(c),h!==null);)f=n.lastIndex,n===$r?h[1]==="!--"?n=Oh:h[1]!==void 0?n=Ih:h[2]!==void 0?(Wh.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=ni):h[3]!==void 0&&(n=ni):n===ni?h[0]===">"?(n=r??$r,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?ni:h[3]==='"'?Nh:zh):n===Nh||n===zh?n=ni:n===Oh||n===Ih?n=$r:(n=ni,r=void 0);let p=n===ni&&e[a+1].startsWith("/>")?" ":"";o+=n===$r?c+Pg:d>=0?(i.push(l),c.slice(0,d)+La+c.slice(d)+fs+p):c+fs+(d===-2?a:p)}return[Uh(e,o+(e[s]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},Rr=class e{constructor({strings:t,_$litType$:s},i){let r;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[l,h]=qh(t,s);if(this.el=e.createElement(l,i),ai.currentNode=this.el.content,s===2||s===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=ai.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let d of r.getAttributeNames())if(d.endsWith(La)){let f=h[n++],p=r.getAttribute(d).split(fs),m=/([.?@])?(.*)/.exec(f);c.push({type:1,index:o,name:m[2],strings:p,ctor:m[1]==="."?Yo:m[1]==="?"?Xo:m[1]==="@"?Jo:hi}),r.removeAttribute(d)}else d.startsWith(fs)&&(c.push({type:6,index:o}),r.removeAttribute(d));if(Wh.test(r.tagName)){let d=r.textContent.split(fs),f=d.length-1;if(f>0){r.textContent=Ko?Ko.emptyScript:"";for(let p=0;p<f;p++)r.append(d[p],Tr()),ai.nextNode(),c.push({type:2,index:++o});r.append(d[f],Tr())}}}else if(r.nodeType===8)if(r.data===Da)c.push({type:2,index:o});else{let d=-1;for(;(d=r.data.indexOf(fs,d+1))!==-1;)c.push({type:7,index:o}),d+=fs.length-1}o++}}static createElement(t,s){let i=li.createElement("template");return i.innerHTML=t,i}};function ci(e,t,s=e,i){if(t===tt)return t;let r=i!==void 0?s._$Co?.[i]:s._$Cl,o=Ar(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,s,i)),i!==void 0?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),r!==void 0&&(t=ci(e,r._$AS(e,t.values),r,i)),t}var Go=class{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:s},parts:i}=this._$AD,r=(t?.creationScope??li).importNode(s,!0);ai.currentNode=r;let o=ai.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let l;c.type===2?l=new Fi(o,o.nextSibling,this,t):c.type===1?l=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(l=new Zo(o,this,t)),this._$AV.push(l),c=i[++a]}n!==c?.index&&(o=ai.nextNode(),n++)}return ai.currentNode=li,r}p(t){let s=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,s),s+=i.strings.length-2):i._$AI(t[s])),s++}},Fi=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,i,r){this.type=2,this._$AH=x,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,s=this._$AM;return s!==void 0&&t?.nodeType===11&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=ci(this,t,s),Ar(t)?t===x||t==null||t===""?(this._$AH!==x&&this._$AR(),this._$AH=x):t!==this._$AH&&t!==tt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Hh(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==x&&Ar(this._$AH)?this._$AA.nextSibling.data=t:this.T(li.createTextNode(t)),this._$AH=t}$(t){let{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Rr.createElement(Uh(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{let o=new Go(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(t){let s=Fh.get(t.strings);return s===void 0&&Fh.set(t.strings,s=new Rr(t)),s}k(t){Pa(this._$AH)||(this._$AH=[],this._$AR());let s=this._$AH,i,r=0;for(let o of t)r===s.length?s.push(i=new e(this.O(Tr()),this.O(Tr()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){let i=Mh(t).nextSibling;Mh(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},hi=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,i,r,o){this.type=1,this._$AH=x,this._$AN=void 0,this.element=t,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=x}_$AI(t,s=this,i,r){let o=this.strings,n=!1;if(o===void 0)t=ci(this,t,s,0),n=!Ar(t)||t!==this._$AH&&t!==tt,n&&(this._$AH=t);else{let a=t,c,l;for(t=o[0],c=0;c<o.length-1;c++)l=ci(this,a[i+c],s,c),l===tt&&(l=this._$AH[c]),n||(n=!Ar(l)||l!==this._$AH[c]),l===x?t=x:t!==x&&(t+=(l??"")+o[c+1]),this._$AH[c]=l}n&&!r&&this.j(t)}j(t){t===x?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Yo=class extends hi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===x?void 0:t}},Xo=class extends hi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==x)}},Jo=class extends hi{constructor(t,s,i,r,o){super(t,s,i,r,o),this.type=5}_$AI(t,s=this){if((t=ci(this,t,s,0)??x)===tt)return;let i=this._$AH,r=t===x&&i!==x||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==x&&(i===x||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Zo=class{constructor(t,s,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){ci(this,t)}},Kh={M:La,P:fs,A:Da,C:1,L:qh,R:Go,D:Hh,V:ci,I:Fi,H:hi,N:Xo,U:Jo,B:Yo,F:Zo},Mg=Er.litHtmlPolyfillSupport;Mg?.(Rr,Fi),(Er.litHtmlVersions??(Er.litHtmlVersions=[])).push("3.3.2");var Qo=(e,t,s)=>{let i=s?.renderBefore??t,r=i._$litPart$;if(r===void 0){let o=s?.renderBefore??null;i._$litPart$=r=new Fi(t.insertBefore(Tr(),o),o,void 0,s??{})}return r._$AI(e),r};var Ft={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Hi=e=>(...t)=>({_$litDirective$:e,values:t}),Os=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,i){this._$Ct=t,this._$AM=s,this._$Ci=i}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}};var Lr=class extends Os{constructor(t){if(super(t),this.it=x,t.type!==Ft.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===x||t==null)return this._t=void 0,this.it=t;if(t===tt)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}};Lr.directiveName="unsafeHTML",Lr.resultType=1;var E=Hi(Lr);function Ba(e){let t=(e||"").replace(/^#\/?/,""),[s,i]=t.split("?"),r=s.split("/").filter(Boolean);if(r[0]==="project"&&r.length>=3)return{section:r[2],runId:r[3]||null,projectId:r[1]};let o=r[0]||"active",n=r[1]||null,a=new URLSearchParams(i||"");return{section:o,runId:n||a.get("run")||null,projectId:a.get("project")||null}}function Bg(e,t,s){if(s){let r=`#/project/${s}/${e}`;return t?`${r}/${t}`:r}let i=`#/${e}`;return t?`${i}/${t}`:i}function Gh(e){let t=()=>e(Ba(location.hash));return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function Ae(e,t,s){location.hash=Bg(e,t,s)}var Wi={run_completed:{severity:"info",title:"Pipeline Complete",requireInteraction:!1},run_failed:{severity:"critical",title:"Pipeline Failed",requireInteraction:!1},approval_needed:{severity:"critical",title:"Approval Required",requireInteraction:!0},test_failures:{severity:"warning",title:"Tests Failed",requireInteraction:!1},loop_limit_warning:{severity:"warning",title:"Loop Limit Warning",requireInteraction:!1}};function Og(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{};if(Object.values(n).some(h=>h.status==="error"))return null;let c=Dr(t),l=i?`[${i}] "${c}" finished successfully`:`"${c}" finished successfully`;return{event:"run_completed",title:Wi.run_completed.title,body:l,tag:`worca-complete-${e}`,requireInteraction:!1,runId:e}}function Ig(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{},a=Object.entries(n).find(([,h])=>h.status==="error");if(!a)return null;let c=Dr(t),l=i?`[${i}] "${c}" failed at ${a[0]} stage`:`"${c}" failed at ${a[0]} stage`;return{event:"run_failed",title:Wi.run_failed.title,body:l,tag:`worca-failed-${e}`,requireInteraction:!1,runId:e}}function zg(e,t,s,i){if(!t)return null;let r=t.stages||{},o=s?.stages||{};for(let[n,a]of Object.entries(r))if(a.status==="waiting_approval"&&o[n]?.status!=="waiting_approval"){let l=Dr(t),h=n==="pr"?"PR":n,d=i?`[${i}] "${l}" is waiting for ${h} approval`:`"${l}" is waiting for ${h} approval`;return{event:"approval_needed",title:Wi.approval_needed.title,body:d,tag:`worca-approval-${e}-${n}`,requireInteraction:!0,runId:e}}return null}function Ng(e,t,s,i){if(!t)return null;let r=t.stages?.test;if(!r)return null;let o=r.iterations||[],n=s?.stages?.test?.iterations||[];if(o.length>n.length){let a=o[o.length-1];if(a&&a.result==="failed"){let c=Dr(t),l=i?`[${i}] "${c}" test iteration ${o.length} failed`:`"${c}" test iteration ${o.length} failed`;return{event:"test_failures",title:Wi.test_failures.title,body:l,tag:`worca-test-${e}-iter${o.length}`,requireInteraction:!1,runId:e}}}return null}function Fg(e,t,s,i,r){if(!t||!i)return null;let o=i?.worca?.loops;if(!o)return null;let n=t.stages||{},a={implement_test:["implement","test"],pr_changes:["pr"],restart_planning:["plan"],plan_review:["plan_review"]};for(let[c,l]of Object.entries(o)){if(!l||l<2)continue;let h=a[c];if(h)for(let d of h){let f=n[d];if(!f)continue;let p=(f.iterations||[]).length;if(p===l-1){let m=`${e}-${d}`;if(r.has(m))continue;r.add(m);let _=Dr(t);return{event:"loop_limit_warning",title:Wi.loop_limit_warning.title,body:`"${_}" ${d} stage approaching loop limit (${p}/${l})`,tag:`worca-loop-${e}-${d}`,requireInteraction:!1,runId:e}}}}return null}function Dr(e){let s=(e?.work_request?.title||e?.id||"Pipeline").split(`
65
- `)[0];return s.length>60?`${s.slice(0,60)}\u2026`:s}var ms=null;function Hg(){try{ms||(ms=new AudioContext);let e=ms.createOscillator(),t=ms.createGain();e.type="sine",e.frequency.value=440,t.gain.value=.3,e.connect(t),t.connect(ms.destination),e.start(),e.stop(ms.currentTime+.2)}catch{}}var en={enabled:!0,sound:!1,events:{run_completed:!0,run_failed:!0,approval_needed:!0,test_failures:!0,loop_limit_warning:!0}};function Yh({store:e,ws:t,getSettings:s}){let i=typeof Notification<"u"?Notification.permission:"denied",r=new Set,o=!1,n=null;function a(_){n=_}function c(){return typeof Notification<"u"&&(i=Notification.permission),i}async function l(){if(typeof Notification>"u")return"denied";let _=await Notification.requestPermission();return i=_,n&&n(),_}function h(){let _=e.getState().preferences.notifications;return _?{enabled:_.enabled??en.enabled,sound:_.sound??en.sound,events:{...en.events,..._.events||{}}}:{...en}}function d({event:_,title:b,body:C,tag:T,requireInteraction:w,runId:v}){if(typeof Notification>"u")return;let B=new Notification(b,{body:C,icon:"/favicon.svg",tag:T,requireInteraction:w});B.onclick=()=>{window.focus(),Ae("active",v),B.close()};let P=h(),F=Wi[_];P.sound&&F&&F.severity==="critical"&&Hg()}function f(_,b,C){if(typeof Notification>"u"||Notification.permission!=="granted")return;let T=h();if(!T.enabled)return;let w=s(),v=e.getState(),B=v.projects?.length>1?v.projectName:null,P=[Og,Ig,zg,Ng];for(let U of P){let te=U(_,b,C,B);te&&T.events[te.event]&&d(te)}let F=Fg(_,b,C,w,r);F&&T.events[F.event]&&d(F)}function p(){return typeof Notification>"u"?x:(c(),i==="default"?u`
64
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),zh=/'/g,Nh=/"/g,Wh=/^(?:script|style|textarea|title)$/i,Ma=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),u=Ma(1),jh=Ma(2),Vh=Ma(3),tt=Symbol.for("lit-noChange"),x=Symbol.for("lit-nothing"),Fh=new WeakMap,ai=li.createTreeWalker(li,129);function Uh(e,t){if(!Pa(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Bh!==void 0?Bh.createHTML(t):t}var qh=(e,t)=>{let s=e.length-1,i=[],r,o=t===2?"<svg>":t===3?"<math>":"",n=$r;for(let a=0;a<s;a++){let c=e[a],l,h,d=-1,f=0;for(;f<c.length&&(n.lastIndex=f,h=n.exec(c),h!==null);)f=n.lastIndex,n===$r?h[1]==="!--"?n=Oh:h[1]!==void 0?n=Ih:h[2]!==void 0?(Wh.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=ni):h[3]!==void 0&&(n=ni):n===ni?h[0]===">"?(n=r??$r,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?ni:h[3]==='"'?Nh:zh):n===Nh||n===zh?n=ni:n===Oh||n===Ih?n=$r:(n=ni,r=void 0);let p=n===ni&&e[a+1].startsWith("/>")?" ":"";o+=n===$r?c+Pg:d>=0?(i.push(l),c.slice(0,d)+La+c.slice(d)+fs+p):c+fs+(d===-2?a:p)}return[Uh(e,o+(e[s]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},Rr=class e{constructor({strings:t,_$litType$:s},i){let r;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[l,h]=qh(t,s);if(this.el=e.createElement(l,i),ai.currentNode=this.el.content,s===2||s===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=ai.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let d of r.getAttributeNames())if(d.endsWith(La)){let f=h[n++],p=r.getAttribute(d).split(fs),m=/([.?@])?(.*)/.exec(f);c.push({type:1,index:o,name:m[2],strings:p,ctor:m[1]==="."?Yo:m[1]==="?"?Xo:m[1]==="@"?Jo:hi}),r.removeAttribute(d)}else d.startsWith(fs)&&(c.push({type:6,index:o}),r.removeAttribute(d));if(Wh.test(r.tagName)){let d=r.textContent.split(fs),f=d.length-1;if(f>0){r.textContent=Ko?Ko.emptyScript:"";for(let p=0;p<f;p++)r.append(d[p],Tr()),ai.nextNode(),c.push({type:2,index:++o});r.append(d[f],Tr())}}}else if(r.nodeType===8)if(r.data===Da)c.push({type:2,index:o});else{let d=-1;for(;(d=r.data.indexOf(fs,d+1))!==-1;)c.push({type:7,index:o}),d+=fs.length-1}o++}}static createElement(t,s){let i=li.createElement("template");return i.innerHTML=t,i}};function ci(e,t,s=e,i){if(t===tt)return t;let r=i!==void 0?s._$Co?.[i]:s._$Cl,o=Ar(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,s,i)),i!==void 0?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),r!==void 0&&(t=ci(e,r._$AS(e,t.values),r,i)),t}var Go=class{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:s},parts:i}=this._$AD,r=(t?.creationScope??li).importNode(s,!0);ai.currentNode=r;let o=ai.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let l;c.type===2?l=new Fi(o,o.nextSibling,this,t):c.type===1?l=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(l=new Zo(o,this,t)),this._$AV.push(l),c=i[++a]}n!==c?.index&&(o=ai.nextNode(),n++)}return ai.currentNode=li,r}p(t){let s=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,s),s+=i.strings.length-2):i._$AI(t[s])),s++}},Fi=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,i,r){this.type=2,this._$AH=x,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,s=this._$AM;return s!==void 0&&t?.nodeType===11&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=ci(this,t,s),Ar(t)?t===x||t==null||t===""?(this._$AH!==x&&this._$AR(),this._$AH=x):t!==this._$AH&&t!==tt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Hh(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==x&&Ar(this._$AH)?this._$AA.nextSibling.data=t:this.T(li.createTextNode(t)),this._$AH=t}$(t){let{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Rr.createElement(Uh(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{let o=new Go(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(t){let s=Fh.get(t.strings);return s===void 0&&Fh.set(t.strings,s=new Rr(t)),s}k(t){Pa(this._$AH)||(this._$AH=[],this._$AR());let s=this._$AH,i,r=0;for(let o of t)r===s.length?s.push(i=new e(this.O(Tr()),this.O(Tr()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){let i=Mh(t).nextSibling;Mh(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},hi=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,i,r,o){this.type=1,this._$AH=x,this._$AN=void 0,this.element=t,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=x}_$AI(t,s=this,i,r){let o=this.strings,n=!1;if(o===void 0)t=ci(this,t,s,0),n=!Ar(t)||t!==this._$AH&&t!==tt,n&&(this._$AH=t);else{let a=t,c,l;for(t=o[0],c=0;c<o.length-1;c++)l=ci(this,a[i+c],s,c),l===tt&&(l=this._$AH[c]),n||(n=!Ar(l)||l!==this._$AH[c]),l===x?t=x:t!==x&&(t+=(l??"")+o[c+1]),this._$AH[c]=l}n&&!r&&this.j(t)}j(t){t===x?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Yo=class extends hi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===x?void 0:t}},Xo=class extends hi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==x)}},Jo=class extends hi{constructor(t,s,i,r,o){super(t,s,i,r,o),this.type=5}_$AI(t,s=this){if((t=ci(this,t,s,0)??x)===tt)return;let i=this._$AH,r=t===x&&i!==x||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==x&&(i===x||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Zo=class{constructor(t,s,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){ci(this,t)}},Kh={M:La,P:fs,A:Da,C:1,L:qh,R:Go,D:Hh,V:ci,I:Fi,H:hi,N:Xo,U:Jo,B:Yo,F:Zo},Mg=Er.litHtmlPolyfillSupport;Mg?.(Rr,Fi),(Er.litHtmlVersions??(Er.litHtmlVersions=[])).push("3.3.2");var Qo=(e,t,s)=>{let i=s?.renderBefore??t,r=i._$litPart$;if(r===void 0){let o=s?.renderBefore??null;i._$litPart$=r=new Fi(t.insertBefore(Tr(),o),o,void 0,s??{})}return r._$AI(e),r};var Ft={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Hi=e=>(...t)=>({_$litDirective$:e,values:t}),Os=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,i){this._$Ct=t,this._$AM=s,this._$Ci=i}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}};var Lr=class extends Os{constructor(t){if(super(t),this.it=x,t.type!==Ft.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===x||t==null)return this._t=void 0,this.it=t;if(t===tt)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}};Lr.directiveName="unsafeHTML",Lr.resultType=1;var E=Hi(Lr);function Ba(e){let t=(e||"").replace(/^#\/?/,""),[s,i]=t.split("?"),r=s.split("/").filter(Boolean);if(r[0]==="project"&&r.length>=3)return{section:r[2],runId:r[3]||null,projectId:r[1]};let o=r[0]||"active",n=r[1]||null,a=new URLSearchParams(i||"");return{section:o,runId:n||a.get("run")||null,projectId:a.get("project")||null}}function Bg(e,t,s){if(s){let r=`#/project/${s}/${e}`;return t?`${r}/${t}`:r}let i=`#/${e}`;return t?`${i}/${t}`:i}function Gh(e){let t=()=>e(Ba(location.hash));return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function Oe(e,t,s){location.hash=Bg(e,t,s)}var Wi={run_completed:{severity:"info",title:"Pipeline Complete",requireInteraction:!1},run_failed:{severity:"critical",title:"Pipeline Failed",requireInteraction:!1},approval_needed:{severity:"critical",title:"Approval Required",requireInteraction:!0},test_failures:{severity:"warning",title:"Tests Failed",requireInteraction:!1},loop_limit_warning:{severity:"warning",title:"Loop Limit Warning",requireInteraction:!1}};function Og(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{};if(Object.values(n).some(h=>h.status==="error"))return null;let c=Dr(t),l=i?`[${i}] "${c}" finished successfully`:`"${c}" finished successfully`;return{event:"run_completed",title:Wi.run_completed.title,body:l,tag:`worca-complete-${e}`,requireInteraction:!1,runId:e}}function Ig(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{},a=Object.entries(n).find(([,h])=>h.status==="error");if(!a)return null;let c=Dr(t),l=i?`[${i}] "${c}" failed at ${a[0]} stage`:`"${c}" failed at ${a[0]} stage`;return{event:"run_failed",title:Wi.run_failed.title,body:l,tag:`worca-failed-${e}`,requireInteraction:!1,runId:e}}function zg(e,t,s,i){if(!t)return null;let r=t.stages||{},o=s?.stages||{};for(let[n,a]of Object.entries(r))if(a.status==="waiting_approval"&&o[n]?.status!=="waiting_approval"){let l=Dr(t),h=n==="pr"?"PR":n,d=i?`[${i}] "${l}" is waiting for ${h} approval`:`"${l}" is waiting for ${h} approval`;return{event:"approval_needed",title:Wi.approval_needed.title,body:d,tag:`worca-approval-${e}-${n}`,requireInteraction:!0,runId:e}}return null}function Ng(e,t,s,i){if(!t)return null;let r=t.stages?.test;if(!r)return null;let o=r.iterations||[],n=s?.stages?.test?.iterations||[];if(o.length>n.length){let a=o[o.length-1];if(a&&a.result==="failed"){let c=Dr(t),l=i?`[${i}] "${c}" test iteration ${o.length} failed`:`"${c}" test iteration ${o.length} failed`;return{event:"test_failures",title:Wi.test_failures.title,body:l,tag:`worca-test-${e}-iter${o.length}`,requireInteraction:!1,runId:e}}}return null}function Fg(e,t,s,i,r){if(!t||!i)return null;let o=i?.worca?.loops;if(!o)return null;let n=t.stages||{},a={implement_test:["implement","test"],pr_changes:["pr"],restart_planning:["plan"],plan_review:["plan_review"]};for(let[c,l]of Object.entries(o)){if(!l||l<2)continue;let h=a[c];if(h)for(let d of h){let f=n[d];if(!f)continue;let p=(f.iterations||[]).length;if(p===l-1){let m=`${e}-${d}`;if(r.has(m))continue;r.add(m);let _=Dr(t);return{event:"loop_limit_warning",title:Wi.loop_limit_warning.title,body:`"${_}" ${d} stage approaching loop limit (${p}/${l})`,tag:`worca-loop-${e}-${d}`,requireInteraction:!1,runId:e}}}}return null}function Dr(e){let s=(e?.work_request?.title||e?.id||"Pipeline").split(`
65
+ `)[0];return s.length>60?`${s.slice(0,60)}\u2026`:s}var ms=null;function Hg(){try{ms||(ms=new AudioContext);let e=ms.createOscillator(),t=ms.createGain();e.type="sine",e.frequency.value=440,t.gain.value=.3,e.connect(t),t.connect(ms.destination),e.start(),e.stop(ms.currentTime+.2)}catch{}}var en={enabled:!0,sound:!1,events:{run_completed:!0,run_failed:!0,approval_needed:!0,test_failures:!0,loop_limit_warning:!0}};function Yh({store:e,ws:t,getSettings:s}){let i=typeof Notification<"u"?Notification.permission:"denied",r=new Set,o=!1,n=null;function a(_){n=_}function c(){return typeof Notification<"u"&&(i=Notification.permission),i}async function l(){if(typeof Notification>"u")return"denied";let _=await Notification.requestPermission();return i=_,n&&n(),_}function h(){let _=e.getState().preferences.notifications;return _?{enabled:_.enabled??en.enabled,sound:_.sound??en.sound,events:{...en.events,..._.events||{}}}:{...en}}function d({event:_,title:b,body:C,tag:T,requireInteraction:w,runId:v}){if(typeof Notification>"u")return;let B=new Notification(b,{body:C,icon:"/favicon.svg",tag:T,requireInteraction:w});B.onclick=()=>{window.focus(),Oe("active",v),B.close()};let P=h(),F=Wi[_];P.sound&&F&&F.severity==="critical"&&Hg()}function f(_,b,C){if(typeof Notification>"u"||Notification.permission!=="granted")return;let T=h();if(!T.enabled)return;let w=s(),v=e.getState(),B=v.projects?.length>1?v.projectName:null,P=[Og,Ig,zg,Ng];for(let U of P){let te=U(_,b,C,B);te&&T.events[te.event]&&d(te)}let F=Fg(_,b,C,w,r);F&&T.events[F.event]&&d(F)}function p(){return typeof Notification>"u"?x:(c(),i==="default"?u`
66
66
  <div class="notification-banner notification-banner--info">
67
67
  <span class="notification-banner-text">
68
68
  Enable browser notifications to stay informed about pipeline events
@@ -86,7 +86,7 @@ ${h.join(`
86
86
  <sl-button variant=${i} @click=${()=>Oa(o)}>${s}</sl-button>
87
87
  </div>
88
88
  </sl-dialog>
89
- `}var di=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var Ia=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}],["path",{d:"M10 12h4"}]];var za=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Na=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Fa=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var Ha=[["path",{d:"m9 18 6-6-6-6"}]];var gs=[["circle",{cx:"12",cy:"12",r:"10"}]];var _s=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]];var vs=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var Mr=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9"}]];var st=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var Wt=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var At=[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48"}],["path",{d:"M15 6h1v4"}],["path",{d:"m6.134 14.768.866-.5 2 3.464"}],["circle",{cx:"16",cy:"8",r:"6"}]];var ji=[["path",{d:"M12 20v2"}],["path",{d:"M12 2v2"}],["path",{d:"M17 20v2"}],["path",{d:"M17 2v2"}],["path",{d:"M2 12h2"}],["path",{d:"M2 17h2"}],["path",{d:"M2 7h2"}],["path",{d:"M20 12h2"}],["path",{d:"M20 17h2"}],["path",{d:"M20 7h2"}],["path",{d:"M7 20v2"}],["path",{d:"M7 2v2"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}]];var Wa=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]];var Br=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Or=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var Ir=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];var ja=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Va=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}],["path",{d:"M9 18h6"}],["path",{d:"M10 22h4"}]];var Vi=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];var it=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var Ua=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var nt=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var Ui=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var Qt=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Pe=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var qa=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}]];var zr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var bs=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var Is=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var Nr=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Ka=[["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"}]];var Ga=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];var ui=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Ya=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var Fr=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var pi=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var qi=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var rn=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}],["circle",{cx:"9",cy:"7",r:"4"}]];var Ki=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var pt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function Wg(e){return e.map(([t,s])=>{let i=Object.entries(s).map(([r,o])=>`${r}="${o}"`).join(" ");return`<${t} ${i}/>`}).join("")}function A(e,t=16,s=""){let i=s?` class="${s}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"${i}>${Wg(e)}</svg>`}function yt(e){return[...e].sort((t,s)=>{let i=t.started_at||"",r=s.started_at||"";return!i&&!r?0:i?r?r.localeCompare(i):-1:1})}var jg={pending:"status-pending",running:"status-running",paused:"status-paused",completed:"status-completed",failed:"status-failed",resuming:"status-resuming",skipped:"status-skipped",in_progress:"status-in-progress",error:"status-error",interrupted:"status-interrupted"},Vg={pending:gs,running:it,paused:nt,completed:vs,failed:_s,resuming:zr,skipped:Mr,in_progress:it,error:_s,interrupted:nt};function Gi(e,t){return e==="in_progress"&&t===!1?"interrupted":e}function Yi(e){return jg[e]||"status-unknown"}function jt(e,t=14){let s=Vg[e];return s?A(s,t,e==="in_progress"||e==="running"||e==="resuming"?"icon-spin":""):"?"}function Hr(e){document.documentElement.setAttribute("data-theme",e),document.documentElement.classList.toggle("sl-theme-dark",e==="dark")}function Zh(e){return e?`${e} \u2014 worca`:"worca"}var on="",Xa=!1;function fi(e){on=e;let t=document.getElementById("add-project-error");t&&(t.textContent=e,t.style.display=e?"block":"none")}function Qh(e,{onProjectAdd:t,onClose:s,rerender:i}){let{addProjectDialogOpen:r}=e;if(!r)return x;function o(d){d.preventDefault();let f=document.getElementById("add-project-name"),p=document.getElementById("add-project-path"),m=f?.value?.trim()||"",_=p?.value?.trim()||"";if(!m){fi("Name is required");return}if(!_||!_.startsWith("/")){fi("Path must be an absolute path");return}let b=_.replace(/\/+$/,""),T=(e.projects||[]).find(w=>(w.path||"").replace(/\/+$/,"")===b);if(T){fi(`A project with this path already exists: "${T.name}"`);return}fi(""),fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:m,path:_})}).then(w=>w.json()).then(w=>{w.ok?(fi(""),t?.(w.project),Ug(m,i)):fi(w.error||"Failed to add project")}).catch(w=>{fi(w.message||"Network error")})}function n(d){if(Xa)return;let f=document.getElementById("add-project-name");if(!f)return;let p=d.replace(/\/+$/,"").split("/"),_=(p[p.length-1]||"").toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/^-+/,"").replace(/-+$/,"");f.value=_}function a(d){n(d.target.value||"")}function c(){Xa=!0}async function l(){try{let f=await(await fetch("/api/choose-directory",{method:"POST"})).json();if(f.ok&&f.path){let p=document.getElementById("add-project-path");p&&(p.value=f.path),n(f.path)}}catch{}}function h(d){d.target.isConnected&&(on="",Xa=!1,s?.())}return u`
89
+ `}var di=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var Ia=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}],["path",{d:"M10 12h4"}]];var za=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Na=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Fa=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var Ha=[["path",{d:"m9 18 6-6-6-6"}]];var gs=[["circle",{cx:"12",cy:"12",r:"10"}]];var _s=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]];var vs=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var Mr=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9"}]];var st=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var Wt=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var At=[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48"}],["path",{d:"M15 6h1v4"}],["path",{d:"m6.134 14.768.866-.5 2 3.464"}],["circle",{cx:"16",cy:"8",r:"6"}]];var ji=[["path",{d:"M12 20v2"}],["path",{d:"M12 2v2"}],["path",{d:"M17 20v2"}],["path",{d:"M17 2v2"}],["path",{d:"M2 12h2"}],["path",{d:"M2 17h2"}],["path",{d:"M2 7h2"}],["path",{d:"M20 12h2"}],["path",{d:"M20 17h2"}],["path",{d:"M20 7h2"}],["path",{d:"M7 20v2"}],["path",{d:"M7 2v2"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}]];var Wa=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]];var Br=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var Or=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var Ir=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];var ja=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Va=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}],["path",{d:"M9 18h6"}],["path",{d:"M10 22h4"}]];var Vi=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];var it=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var Ua=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var nt=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var Ui=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var Qt=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var De=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var qa=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}]];var zr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]];var bs=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var Is=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var Nr=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Ka=[["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"}]];var Ga=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];var ui=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Ya=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var Fr=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var pi=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var qi=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var rn=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}],["circle",{cx:"9",cy:"7",r:"4"}]];var Ki=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var pt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function Wg(e){return e.map(([t,s])=>{let i=Object.entries(s).map(([r,o])=>`${r}="${o}"`).join(" ");return`<${t} ${i}/>`}).join("")}function A(e,t=16,s=""){let i=s?` class="${s}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"${i}>${Wg(e)}</svg>`}function yt(e){return[...e].sort((t,s)=>{let i=t.started_at||"",r=s.started_at||"";return!i&&!r?0:i?r?r.localeCompare(i):-1:1})}var jg={pending:"status-pending",running:"status-running",paused:"status-paused",completed:"status-completed",failed:"status-failed",resuming:"status-resuming",skipped:"status-skipped",in_progress:"status-in-progress",error:"status-error",interrupted:"status-interrupted"},Vg={pending:gs,running:it,paused:nt,completed:vs,failed:_s,resuming:zr,skipped:Mr,in_progress:it,error:_s,interrupted:nt};function Gi(e,t){return e==="in_progress"&&t===!1?"interrupted":e}function Yi(e){return jg[e]||"status-unknown"}function jt(e,t=14){let s=Vg[e];return s?A(s,t,e==="in_progress"||e==="running"||e==="resuming"?"icon-spin":""):"?"}function Hr(e){document.documentElement.setAttribute("data-theme",e),document.documentElement.classList.toggle("sl-theme-dark",e==="dark")}function Zh(e){return e?`${e} \u2014 worca`:"worca"}var on="",Xa=!1;function fi(e){on=e;let t=document.getElementById("add-project-error");t&&(t.textContent=e,t.style.display=e?"block":"none")}function Qh(e,{onProjectAdd:t,onClose:s,rerender:i}){let{addProjectDialogOpen:r}=e;if(!r)return x;function o(d){d.preventDefault();let f=document.getElementById("add-project-name"),p=document.getElementById("add-project-path"),m=f?.value?.trim()||"",_=p?.value?.trim()||"";if(!m){fi("Name is required");return}if(!_||!_.startsWith("/")){fi("Path must be an absolute path");return}let b=_.replace(/\/+$/,""),T=(e.projects||[]).find(w=>(w.path||"").replace(/\/+$/,"")===b);if(T){fi(`A project with this path already exists: "${T.name}"`);return}fi(""),fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:m,path:_})}).then(w=>w.json()).then(w=>{w.ok?(fi(""),t?.(w.project),Ug(m,i)):fi(w.error||"Failed to add project")}).catch(w=>{fi(w.message||"Network error")})}function n(d){if(Xa)return;let f=document.getElementById("add-project-name");if(!f)return;let p=d.replace(/\/+$/,"").split("/"),_=(p[p.length-1]||"").toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/^-+/,"").replace(/-+$/,"");f.value=_}function a(d){n(d.target.value||"")}function c(){Xa=!0}async function l(){try{let f=await(await fetch("/api/choose-directory",{method:"POST"})).json();if(f.ok&&f.path){let p=document.getElementById("add-project-path");p&&(p.value=f.path),n(f.path)}}catch{}}function h(d){d.target.isConnected&&(on="",Xa=!1,s?.())}return u`
90
90
  <sl-dialog
91
91
  label="Add Project"
92
92
  open
@@ -545,7 +545,7 @@ ${h.join(`
545
545
  ${an(n,null)}
546
546
  </div>
547
547
  <sl-button variant="warning" size="small" @click=${t.onRunLearn}>
548
- ${E(A(Pe,14))} Retry
548
+ ${E(A(De,14))} Retry
549
549
  </sl-button>
550
550
  </div>
551
551
  `:c=u`
@@ -569,7 +569,7 @@ ${h.join(`
569
569
  ${an(n,a)}
570
570
  </div>
571
571
  <sl-button variant="warning" size="small" @click=${t.onRunLearn}>
572
- ${E(A(Pe,14))} Retry Learning Analysis
572
+ ${E(A(De,14))} Retry Learning Analysis
573
573
  </sl-button>
574
574
  </div>
575
575
  `;else if(r){let f=e?.iterations?.[0],p=f?.turns,m=f?.cost_usd,_=f?.duration_api_ms,b=n&&a?Ye(n,a):0;c=u`
@@ -585,7 +585,7 @@ ${h.join(`
585
585
  ${d_(i.recurring_patterns)}
586
586
  <div class="learnings-rerun">
587
587
  <sl-button variant="text" size="small" @click=${t.onRunLearn}>
588
- ${E(A(Pe,12))} Re-run Analysis
588
+ ${E(A(De,12))} Re-run Analysis
589
589
  </sl-button>
590
590
  </div>
591
591
  `}else c=u`
@@ -810,7 +810,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
810
810
  Save
811
811
  </sl-button>
812
812
  <sl-button variant="default" size="small" outline @click=${()=>vo("agents",t)}>
813
- ${E(A(Pe,14))}
813
+ ${E(A(De,14))}
814
814
  Reset
815
815
  </sl-button>
816
816
  </div>
@@ -897,7 +897,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
897
897
  Save
898
898
  </sl-button>
899
899
  <sl-button variant="default" size="small" outline @click=${()=>vo("pipeline",t)}>
900
- ${E(A(Pe,14))}
900
+ ${E(A(De,14))}
901
901
  Reset
902
902
  </sl-button>
903
903
  </div>
@@ -956,7 +956,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
956
956
  Save
957
957
  </sl-button>
958
958
  <sl-button variant="default" size="small" outline @click=${()=>vo("governance",s)}>
959
- ${E(A(Pe,14))}
959
+ ${E(A(De,14))}
960
960
  Reset
961
961
  </sl-button>
962
962
  </div>
@@ -983,7 +983,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
983
983
  <div class="settings-muted">Failed to load versions: ${lr}</div>
984
984
  <div class="version-refresh">
985
985
  <sl-button size="small" @click=${()=>Jn(e,!0)}>
986
- ${E(A(Pe,14))}
986
+ ${E(A(De,14))}
987
987
  Retry
988
988
  </sl-button>
989
989
  </div>
@@ -1018,7 +1018,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1018
1018
  </div>
1019
1019
  <div class="version-refresh">
1020
1020
  <sl-button size="small" @click=${()=>Jn(e,!0)} ?loading=${ar}>
1021
- ${E(A(Pe,14))}
1021
+ ${E(A(De,14))}
1022
1022
  Refresh
1023
1023
  </sl-button>
1024
1024
  <span class="version-refresh-hint">Updated ${yw(r)}</span>
@@ -1136,7 +1136,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1136
1136
  Save
1137
1137
  </sl-button>
1138
1138
  <sl-button variant="default" size="small" outline @click=${()=>vo("pricing",t)}>
1139
- ${E(A(Pe,14))}
1139
+ ${E(A(De,14))}
1140
1140
  Reset
1141
1141
  </sl-button>
1142
1142
  </div>
@@ -1289,7 +1289,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1289
1289
  Save
1290
1290
  </sl-button>
1291
1291
  <sl-button variant="default" size="small" outline @click=${()=>vo("webhooks",t)}>
1292
- ${E(A(Pe,14))}
1292
+ ${E(A(De,14))}
1293
1293
  Reset
1294
1294
  </sl-button>
1295
1295
  </div>
@@ -1319,7 +1319,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1319
1319
  outline
1320
1320
  @click=${()=>c(h.name)}
1321
1321
  >
1322
- ${E(A(Pe,14))}
1322
+ ${E(A(De,14))}
1323
1323
  Update
1324
1324
  </sl-button>
1325
1325
  <sl-button
@@ -1503,7 +1503,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1503
1503
  <div class="stage-node ${Yi(a)} ${h?"pulse":""}">
1504
1504
  <div class="stage-icon">${E(A(c,22,f))}</div>
1505
1505
  <div class="stage-label">${l}</div>
1506
- ${d>1?u`<span class="loop-indicator">${E(A(Pe,10))}${d}</span>`:""}
1506
+ ${d>1?u`<span class="loop-indicator">${E(A(De,10))}${d}</span>`:""}
1507
1507
  </div>
1508
1508
  `})}
1509
1509
  </div>
@@ -1708,13 +1708,13 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
1708
1708
  <span class="stage-panel-meta">
1709
1709
  ${B?u`
1710
1710
  <span class="stage-meta-item stage-meta-iteration">
1711
- <span class="stage-meta-icon">${E(A(Pe,11))}</span>
1711
+ <span class="stage-meta-icon">${E(A(De,11))}</span>
1712
1712
  <span class="meta-value">${v.length} iterations</span>
1713
1713
  </span>
1714
1714
  `:x}
1715
1715
  ${(()=>{let F=v.reduce((U,te)=>U+(te.turns||0),0);return F>0?u`
1716
1716
  <span class="stage-meta-item">
1717
- <span class="stage-meta-icon">${E(A(Pe,11))}</span>
1717
+ <span class="stage-meta-icon">${E(A(De,11))}</span>
1718
1718
  <span class="meta-value">${F} turns</span>
1719
1719
  </span>
1720
1720
  `:x})()}
@@ -2371,9 +2371,9 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
2371
2371
  [hidden] {
2372
2372
  display: none !important;
2373
2373
  }
2374
- `;var M1={attribute:!0,type:String,converter:Qs,reflect:!1,hasChanged:oa},B1=(e=M1,t,s)=>{let{kind:i,metadata:r}=s,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),i==="accessor"){let{name:n}=s;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(i==="setter"){let{name:n}=s;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function y(e){return(t,s)=>typeof s=="object"?B1(e,t,s):((i,r,o)=>{let n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,s)}function he(e){return y({...e,state:!0,attribute:!1})}function hm(e){return(t,s)=>{let i=typeof t=="function"?t:t[s];Object.assign(i,e)}}var Ri=(e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,s),s);function Z(e,t){return(s,i,r)=>{let o=n=>n.renderRoot?.querySelector(e)??null;if(t){let{get:n,set:a}=typeof i=="object"?s:r??(()=>{let c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return Ri(s,i,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return Ri(s,i,{get(){return o(this)}})}}var aa,X=class extends ei{constructor(){super(),Kf(this,aa,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach(([e,t])=>{this.constructor.define(e,t)})}emit(e,t){let s=new CustomEvent(e,ot({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}static define(e,t=this,s={}){let i=customElements.get(e);if(!i){try{customElements.define(e,t,s)}catch{customElements.define(e,class extends t{},s)}return}let r=" (unknown version)",o=r;"version"in t&&t.version&&(r=" v"+t.version),"version"in i&&i.version&&(o=" v"+i.version),!(r&&o&&r===o)&&console.warn(`Attempted to register <${e}>${r}, but <${e}>${o} has already been registered.`)}attributeChangedCallback(e,t,s){qf(this,aa)||(this.constructor.elementProperties.forEach((i,r)=>{i.reflect&&this[r]!=null&&this.initialReflectedProperties.set(r,this[r])}),Gf(this,aa,!0)),super.attributeChangedCallback(e,t,s)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((t,s)=>{e.has(s)&&this[s]==null&&(this[s]=t)})}};aa=new WeakMap;X.version="2.20.1";X.dependencies={};g([y()],X.prototype,"dir",2);g([y()],X.prototype,"lang",2);var{I:bR}=Kh;var dm=(e,t)=>t===void 0?e?._$litType$!==void 0:e?._$litType$===t;var um=e=>e.strings===void 0;var O1={},pm=(e,t=O1)=>e._$AH=t;var xo=Symbol(),la=Symbol(),sh,ih=new Map,De=class extends X{constructor(){super(...arguments),this.initialRender=!1,this.svg=null,this.label="",this.library="default"}async resolveIcon(e,t){var s;let i;if(t?.spriteSheet)return this.svg=u`<svg part="svg">
2374
+ `;var M1={attribute:!0,type:String,converter:Qs,reflect:!1,hasChanged:oa},B1=(e=M1,t,s)=>{let{kind:i,metadata:r}=s,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),i==="accessor"){let{name:n}=s;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(i==="setter"){let{name:n}=s;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function y(e){return(t,s)=>typeof s=="object"?B1(e,t,s):((i,r,o)=>{let n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,s)}function he(e){return y({...e,state:!0,attribute:!1})}function hm(e){return(t,s)=>{let i=typeof t=="function"?t:t[s];Object.assign(i,e)}}var Ri=(e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,s),s);function Z(e,t){return(s,i,r)=>{let o=n=>n.renderRoot?.querySelector(e)??null;if(t){let{get:n,set:a}=typeof i=="object"?s:r??(()=>{let c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return Ri(s,i,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return Ri(s,i,{get(){return o(this)}})}}var aa,X=class extends ei{constructor(){super(),Kf(this,aa,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach(([e,t])=>{this.constructor.define(e,t)})}emit(e,t){let s=new CustomEvent(e,ot({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}static define(e,t=this,s={}){let i=customElements.get(e);if(!i){try{customElements.define(e,t,s)}catch{customElements.define(e,class extends t{},s)}return}let r=" (unknown version)",o=r;"version"in t&&t.version&&(r=" v"+t.version),"version"in i&&i.version&&(o=" v"+i.version),!(r&&o&&r===o)&&console.warn(`Attempted to register <${e}>${r}, but <${e}>${o} has already been registered.`)}attributeChangedCallback(e,t,s){qf(this,aa)||(this.constructor.elementProperties.forEach((i,r)=>{i.reflect&&this[r]!=null&&this.initialReflectedProperties.set(r,this[r])}),Gf(this,aa,!0)),super.attributeChangedCallback(e,t,s)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((t,s)=>{e.has(s)&&this[s]==null&&(this[s]=t)})}};aa=new WeakMap;X.version="2.20.1";X.dependencies={};g([y()],X.prototype,"dir",2);g([y()],X.prototype,"lang",2);var{I:bR}=Kh;var dm=(e,t)=>t===void 0?e?._$litType$!==void 0:e?._$litType$===t;var um=e=>e.strings===void 0;var O1={},pm=(e,t=O1)=>e._$AH=t;var xo=Symbol(),la=Symbol(),sh,ih=new Map,Le=class extends X{constructor(){super(...arguments),this.initialRender=!1,this.svg=null,this.label="",this.library="default"}async resolveIcon(e,t){var s;let i;if(t?.spriteSheet)return this.svg=u`<svg part="svg">
2375
2375
  <use part="use" href="${e}"></use>
2376
- </svg>`,this.svg;try{if(i=await fetch(e,{mode:"cors"}),!i.ok)return i.status===410?xo:la}catch{return la}try{let r=document.createElement("div");r.innerHTML=await i.text();let o=r.firstElementChild;if(((s=o?.tagName)==null?void 0:s.toLowerCase())!=="svg")return xo;sh||(sh=new DOMParser);let a=sh.parseFromString(o.outerHTML,"text/html").body.querySelector("svg");return a?(a.part.add("svg"),document.adoptNode(a)):xo}catch{return xo}}connectedCallback(){super.connectedCallback(),am(this)}firstUpdated(){this.initialRender=!0,this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),lm(this)}getIconSource(){let e=th(this.library);return this.name&&e?{url:e.resolver(this.name),fromLibrary:!0}:{url:this.src,fromLibrary:!1}}handleLabelChange(){typeof this.label=="string"&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var e;let{url:t,fromLibrary:s}=this.getIconSource(),i=s?th(this.library):void 0;if(!t){this.svg=null;return}let r=ih.get(t);if(r||(r=this.resolveIcon(t,i),ih.set(t,r)),!this.initialRender)return;let o=await r;if(o===la&&ih.delete(t),t===this.getIconSource().url){if(dm(o)){if(this.svg=o,i){await this.updateComplete;let n=this.shadowRoot.querySelector("[part='svg']");typeof i.mutator=="function"&&n&&i.mutator(n)}return}switch(o){case la:case xo:this.svg=null,this.emit("sl-error");break;default:this.svg=o.cloneNode(!0),(e=i?.mutator)==null||e.call(i,this.svg),this.emit("sl-load")}}}render(){return this.svg}};De.styles=[Q,cm];g([he()],De.prototype,"svg",2);g([y({reflect:!0})],De.prototype,"name",2);g([y()],De.prototype,"src",2);g([y()],De.prototype,"label",2);g([y({reflect:!0})],De.prototype,"library",2);g([G("label")],De.prototype,"handleLabelChange",1);g([G(["name","src","library"])],De.prototype,"setIcon",1);var ee=Hi(class extends Os{constructor(e){if(super(e),e.type!==Ft.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(let i in t)t[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(t)}let s=e.element.classList;for(let i of this.st)i in t||(s.remove(i),this.st.delete(i));for(let i in t){let r=!!t[i];r===this.st.has(i)||this.nt?.has(i)||(r?(s.add(i),this.st.add(i)):(s.remove(i),this.st.delete(i)))}return tt}});var Bt=class extends X{constructor(){super(...arguments),this.localize=new me(this),this.open=!1,this.disabled=!1}firstUpdated(){this.body.style.height=this.open?"auto":"0",this.open&&(this.details.open=!0),this.detailsObserver=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName==="open"&&(this.details.open?this.show():this.hide())}),this.detailsObserver.observe(this.details,{attributes:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.detailsObserver)==null||e.disconnect()}handleSummaryClick(e){e.preventDefault(),this.disabled||(this.open?this.hide():this.show(),this.header.focus())}handleSummaryKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.open?this.hide():this.show()),(e.key==="ArrowUp"||e.key==="ArrowLeft")&&(e.preventDefault(),this.hide()),(e.key==="ArrowDown"||e.key==="ArrowRight")&&(e.preventDefault(),this.show())}async handleOpenChange(){if(this.open){if(this.details.open=!0,this.emit("sl-show",{cancelable:!0}).defaultPrevented){this.open=!1,this.details.open=!1;return}await Qe(this.body);let{keyframes:t,options:s}=je(this,"details.show",{dir:this.localize.dir()});await Ve(this.body,Yc(t,this.body.scrollHeight),s),this.body.style.height="auto",this.emit("sl-after-show")}else{if(this.emit("sl-hide",{cancelable:!0}).defaultPrevented){this.details.open=!0,this.open=!0;return}await Qe(this.body);let{keyframes:t,options:s}=je(this,"details.hide",{dir:this.localize.dir()});await Ve(this.body,Yc(t,this.body.scrollHeight),s),this.body.style.height="auto",this.details.open=!1,this.emit("sl-after-hide")}}async show(){if(!(this.open||this.disabled))return this.open=!0,ht(this,"sl-after-show")}async hide(){if(!(!this.open||this.disabled))return this.open=!1,ht(this,"sl-after-hide")}render(){let e=this.localize.dir()==="rtl";return u`
2376
+ </svg>`,this.svg;try{if(i=await fetch(e,{mode:"cors"}),!i.ok)return i.status===410?xo:la}catch{return la}try{let r=document.createElement("div");r.innerHTML=await i.text();let o=r.firstElementChild;if(((s=o?.tagName)==null?void 0:s.toLowerCase())!=="svg")return xo;sh||(sh=new DOMParser);let a=sh.parseFromString(o.outerHTML,"text/html").body.querySelector("svg");return a?(a.part.add("svg"),document.adoptNode(a)):xo}catch{return xo}}connectedCallback(){super.connectedCallback(),am(this)}firstUpdated(){this.initialRender=!0,this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),lm(this)}getIconSource(){let e=th(this.library);return this.name&&e?{url:e.resolver(this.name),fromLibrary:!0}:{url:this.src,fromLibrary:!1}}handleLabelChange(){typeof this.label=="string"&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var e;let{url:t,fromLibrary:s}=this.getIconSource(),i=s?th(this.library):void 0;if(!t){this.svg=null;return}let r=ih.get(t);if(r||(r=this.resolveIcon(t,i),ih.set(t,r)),!this.initialRender)return;let o=await r;if(o===la&&ih.delete(t),t===this.getIconSource().url){if(dm(o)){if(this.svg=o,i){await this.updateComplete;let n=this.shadowRoot.querySelector("[part='svg']");typeof i.mutator=="function"&&n&&i.mutator(n)}return}switch(o){case la:case xo:this.svg=null,this.emit("sl-error");break;default:this.svg=o.cloneNode(!0),(e=i?.mutator)==null||e.call(i,this.svg),this.emit("sl-load")}}}render(){return this.svg}};Le.styles=[Q,cm];g([he()],Le.prototype,"svg",2);g([y({reflect:!0})],Le.prototype,"name",2);g([y()],Le.prototype,"src",2);g([y()],Le.prototype,"label",2);g([y({reflect:!0})],Le.prototype,"library",2);g([G("label")],Le.prototype,"handleLabelChange",1);g([G(["name","src","library"])],Le.prototype,"setIcon",1);var ee=Hi(class extends Os{constructor(e){if(super(e),e.type!==Ft.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(let i in t)t[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(t)}let s=e.element.classList;for(let i of this.st)i in t||(s.remove(i),this.st.delete(i));for(let i in t){let r=!!t[i];r===this.st.has(i)||this.nt?.has(i)||(r?(s.add(i),this.st.add(i)):(s.remove(i),this.st.delete(i)))}return tt}});var Bt=class extends X{constructor(){super(...arguments),this.localize=new me(this),this.open=!1,this.disabled=!1}firstUpdated(){this.body.style.height=this.open?"auto":"0",this.open&&(this.details.open=!0),this.detailsObserver=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName==="open"&&(this.details.open?this.show():this.hide())}),this.detailsObserver.observe(this.details,{attributes:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.detailsObserver)==null||e.disconnect()}handleSummaryClick(e){e.preventDefault(),this.disabled||(this.open?this.hide():this.show(),this.header.focus())}handleSummaryKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.open?this.hide():this.show()),(e.key==="ArrowUp"||e.key==="ArrowLeft")&&(e.preventDefault(),this.hide()),(e.key==="ArrowDown"||e.key==="ArrowRight")&&(e.preventDefault(),this.show())}async handleOpenChange(){if(this.open){if(this.details.open=!0,this.emit("sl-show",{cancelable:!0}).defaultPrevented){this.open=!1,this.details.open=!1;return}await Qe(this.body);let{keyframes:t,options:s}=je(this,"details.show",{dir:this.localize.dir()});await Ve(this.body,Yc(t,this.body.scrollHeight),s),this.body.style.height="auto",this.emit("sl-after-show")}else{if(this.emit("sl-hide",{cancelable:!0}).defaultPrevented){this.details.open=!0,this.open=!0;return}await Qe(this.body);let{keyframes:t,options:s}=je(this,"details.hide",{dir:this.localize.dir()});await Ve(this.body,Yc(t,this.body.scrollHeight),s),this.body.style.height="auto",this.details.open=!1,this.emit("sl-after-hide")}}async show(){if(!(this.open||this.disabled))return this.open=!0,ht(this,"sl-after-show")}async hide(){if(!(!this.open||this.disabled))return this.open=!1,ht(this,"sl-after-hide")}render(){let e=this.localize.dir()==="rtl";return u`
2377
2377
  <details
2378
2378
  part="base"
2379
2379
  class=${ee({details:!0,"details--open":this.open,"details--disabled":this.disabled,"details--rtl":e})}
@@ -2406,7 +2406,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
2406
2406
  <slot part="content" id="content" class="details__content"></slot>
2407
2407
  </div>
2408
2408
  </details>
2409
- `}};Bt.styles=[Q,Hf];Bt.dependencies={"sl-icon":De};g([Z(".details")],Bt.prototype,"details",2);g([Z(".details__header")],Bt.prototype,"header",2);g([Z(".details__body")],Bt.prototype,"body",2);g([Z(".details__expand-icon-slot")],Bt.prototype,"expandIconSlot",2);g([y({type:Boolean,reflect:!0})],Bt.prototype,"open",2);g([y()],Bt.prototype,"summary",2);g([y({type:Boolean,reflect:!0})],Bt.prototype,"disabled",2);g([G("open",{waitUntilFirstUpdate:!0})],Bt.prototype,"handleOpenChange",1);We("details.show",{keyframes:[{height:"0",opacity:"0"},{height:"auto",opacity:"1"}],options:{duration:250,easing:"linear"}});We("details.hide",{keyframes:[{height:"auto",opacity:"1"},{height:"0",opacity:"0"}],options:{duration:250,easing:"linear"}});Bt.define("sl-details");var fm=K`
2409
+ `}};Bt.styles=[Q,Hf];Bt.dependencies={"sl-icon":Le};g([Z(".details")],Bt.prototype,"details",2);g([Z(".details__header")],Bt.prototype,"header",2);g([Z(".details__body")],Bt.prototype,"body",2);g([Z(".details__expand-icon-slot")],Bt.prototype,"expandIconSlot",2);g([y({type:Boolean,reflect:!0})],Bt.prototype,"open",2);g([y()],Bt.prototype,"summary",2);g([y({type:Boolean,reflect:!0})],Bt.prototype,"disabled",2);g([G("open",{waitUntilFirstUpdate:!0})],Bt.prototype,"handleOpenChange",1);We("details.show",{keyframes:[{height:"0",opacity:"0"},{height:"auto",opacity:"1"}],options:{duration:250,easing:"linear"}});We("details.hide",{keyframes:[{height:"auto",opacity:"1"},{height:"0",opacity:"0"}],options:{duration:250,easing:"linear"}});Bt.define("sl-details");var fm=K`
2410
2410
  :host {
2411
2411
  display: inline-block;
2412
2412
  }
@@ -2593,7 +2593,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
2593
2593
  aria-hidden="true"
2594
2594
  ></sl-icon>
2595
2595
  </${t}>
2596
- `}};ke.styles=[Q,mm];ke.dependencies={"sl-icon":De};g([Z(".icon-button")],ke.prototype,"button",2);g([he()],ke.prototype,"hasFocus",2);g([y()],ke.prototype,"name",2);g([y()],ke.prototype,"library",2);g([y()],ke.prototype,"src",2);g([y()],ke.prototype,"href",2);g([y()],ke.prototype,"target",2);g([y()],ke.prototype,"download",2);g([y()],ke.prototype,"label",2);g([y({type:Boolean,reflect:!0})],ke.prototype,"disabled",2);var ti=class extends X{constructor(){super(...arguments),this.localize=new me(this),this.variant="neutral",this.size="medium",this.pill=!1,this.removable=!1}handleRemoveClick(){this.emit("sl-remove")}render(){return u`
2596
+ `}};ke.styles=[Q,mm];ke.dependencies={"sl-icon":Le};g([Z(".icon-button")],ke.prototype,"button",2);g([he()],ke.prototype,"hasFocus",2);g([y()],ke.prototype,"name",2);g([y()],ke.prototype,"library",2);g([y()],ke.prototype,"src",2);g([y()],ke.prototype,"href",2);g([y()],ke.prototype,"target",2);g([y()],ke.prototype,"download",2);g([y()],ke.prototype,"label",2);g([y({type:Boolean,reflect:!0})],ke.prototype,"disabled",2);var ti=class extends X{constructor(){super(...arguments),this.localize=new me(this),this.variant="neutral",this.size="medium",this.pill=!1,this.removable=!1}handleRemoveClick(){this.emit("sl-remove")}render(){return u`
2597
2597
  <span
2598
2598
  part="base"
2599
2599
  class=${ee({tag:!0,"tag--primary":this.variant==="primary","tag--success":this.variant==="success","tag--neutral":this.variant==="neutral","tag--warning":this.variant==="warning","tag--danger":this.variant==="danger","tag--text":this.variant==="text","tag--small":this.size==="small","tag--medium":this.size==="medium","tag--large":this.size==="large","tag--pill":this.pill,"tag--removable":this.removable})}
@@ -3223,7 +3223,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
3223
3223
  <slot name="help-text">${this.helpText}</slot>
3224
3224
  </div>
3225
3225
  </div>
3226
- `}};ae.styles=[Q,si,vm];ae.dependencies={"sl-icon":De,"sl-popup":pe,"sl-tag":ti};g([Z(".select")],ae.prototype,"popup",2);g([Z(".select__combobox")],ae.prototype,"combobox",2);g([Z(".select__display-input")],ae.prototype,"displayInput",2);g([Z(".select__value-input")],ae.prototype,"valueInput",2);g([Z(".select__listbox")],ae.prototype,"listbox",2);g([he()],ae.prototype,"hasFocus",2);g([he()],ae.prototype,"displayLabel",2);g([he()],ae.prototype,"currentOption",2);g([he()],ae.prototype,"selectedOptions",2);g([he()],ae.prototype,"valueHasChanged",2);g([y()],ae.prototype,"name",2);g([he()],ae.prototype,"value",1);g([y({attribute:"value"})],ae.prototype,"defaultValue",2);g([y({reflect:!0})],ae.prototype,"size",2);g([y()],ae.prototype,"placeholder",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"multiple",2);g([y({attribute:"max-options-visible",type:Number})],ae.prototype,"maxOptionsVisible",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"disabled",2);g([y({type:Boolean})],ae.prototype,"clearable",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"open",2);g([y({type:Boolean})],ae.prototype,"hoist",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"filled",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"pill",2);g([y()],ae.prototype,"label",2);g([y({reflect:!0})],ae.prototype,"placement",2);g([y({attribute:"help-text"})],ae.prototype,"helpText",2);g([y({reflect:!0})],ae.prototype,"form",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"required",2);g([y()],ae.prototype,"getTag",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ae.prototype,"handleDisabledChange",1);g([G(["defaultValue","value"],{waitUntilFirstUpdate:!0})],ae.prototype,"handleValueChange",1);g([G("open",{waitUntilFirstUpdate:!0})],ae.prototype,"handleOpenChange",1);We("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}});We("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});ae.define("sl-select");var eg=K`
3226
+ `}};ae.styles=[Q,si,vm];ae.dependencies={"sl-icon":Le,"sl-popup":pe,"sl-tag":ti};g([Z(".select")],ae.prototype,"popup",2);g([Z(".select__combobox")],ae.prototype,"combobox",2);g([Z(".select__display-input")],ae.prototype,"displayInput",2);g([Z(".select__value-input")],ae.prototype,"valueInput",2);g([Z(".select__listbox")],ae.prototype,"listbox",2);g([he()],ae.prototype,"hasFocus",2);g([he()],ae.prototype,"displayLabel",2);g([he()],ae.prototype,"currentOption",2);g([he()],ae.prototype,"selectedOptions",2);g([he()],ae.prototype,"valueHasChanged",2);g([y()],ae.prototype,"name",2);g([he()],ae.prototype,"value",1);g([y({attribute:"value"})],ae.prototype,"defaultValue",2);g([y({reflect:!0})],ae.prototype,"size",2);g([y()],ae.prototype,"placeholder",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"multiple",2);g([y({attribute:"max-options-visible",type:Number})],ae.prototype,"maxOptionsVisible",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"disabled",2);g([y({type:Boolean})],ae.prototype,"clearable",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"open",2);g([y({type:Boolean})],ae.prototype,"hoist",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"filled",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"pill",2);g([y()],ae.prototype,"label",2);g([y({reflect:!0})],ae.prototype,"placement",2);g([y({attribute:"help-text"})],ae.prototype,"helpText",2);g([y({reflect:!0})],ae.prototype,"form",2);g([y({type:Boolean,reflect:!0})],ae.prototype,"required",2);g([y()],ae.prototype,"getTag",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ae.prototype,"handleDisabledChange",1);g([G(["defaultValue","value"],{waitUntilFirstUpdate:!0})],ae.prototype,"handleValueChange",1);g([G("open",{waitUntilFirstUpdate:!0})],ae.prototype,"handleOpenChange",1);We("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}});We("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});ae.define("sl-select");var eg=K`
3227
3227
  :host {
3228
3228
  display: block;
3229
3229
  user-select: none;
@@ -3319,7 +3319,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
3319
3319
  <slot part="label" class="option__label" @slotchange=${this.handleDefaultSlotChange}></slot>
3320
3320
  <slot part="suffix" name="suffix" class="option__suffix"></slot>
3321
3321
  </div>
3322
- `}};Et.styles=[Q,eg];Et.dependencies={"sl-icon":De};g([Z(".option__label")],Et.prototype,"defaultSlot",2);g([he()],Et.prototype,"current",2);g([he()],Et.prototype,"selected",2);g([he()],Et.prototype,"hasHover",2);g([y({reflect:!0})],Et.prototype,"value",2);g([y({type:Boolean,reflect:!0})],Et.prototype,"disabled",2);g([G("disabled")],Et.prototype,"handleDisabledChange",1);g([G("selected")],Et.prototype,"handleSelectedChange",1);g([G("value")],Et.prototype,"handleValueChange",1);Et.define("sl-option");var tg=K`
3322
+ `}};Et.styles=[Q,eg];Et.dependencies={"sl-icon":Le};g([Z(".option__label")],Et.prototype,"defaultSlot",2);g([he()],Et.prototype,"current",2);g([he()],Et.prototype,"selected",2);g([he()],Et.prototype,"hasHover",2);g([y({reflect:!0})],Et.prototype,"value",2);g([y({type:Boolean,reflect:!0})],Et.prototype,"disabled",2);g([G("disabled")],Et.prototype,"handleDisabledChange",1);g([G("selected")],Et.prototype,"handleSelectedChange",1);g([G("value")],Et.prototype,"handleValueChange",1);Et.define("sl-option");var tg=K`
3323
3323
  :host {
3324
3324
  display: block;
3325
3325
  }
@@ -3712,7 +3712,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
3712
3712
  <slot name="help-text">${this.helpText}</slot>
3713
3713
  </div>
3714
3714
  </div>
3715
- `}};ie.styles=[Q,si,tg];ie.dependencies={"sl-icon":De};g([Z(".input__control")],ie.prototype,"input",2);g([he()],ie.prototype,"hasFocus",2);g([y()],ie.prototype,"title",2);g([y({reflect:!0})],ie.prototype,"type",2);g([y()],ie.prototype,"name",2);g([y()],ie.prototype,"value",2);g([wr()],ie.prototype,"defaultValue",2);g([y({reflect:!0})],ie.prototype,"size",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"filled",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"pill",2);g([y()],ie.prototype,"label",2);g([y({attribute:"help-text"})],ie.prototype,"helpText",2);g([y({type:Boolean})],ie.prototype,"clearable",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"disabled",2);g([y()],ie.prototype,"placeholder",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"readonly",2);g([y({attribute:"password-toggle",type:Boolean})],ie.prototype,"passwordToggle",2);g([y({attribute:"password-visible",type:Boolean})],ie.prototype,"passwordVisible",2);g([y({attribute:"no-spin-buttons",type:Boolean})],ie.prototype,"noSpinButtons",2);g([y({reflect:!0})],ie.prototype,"form",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"required",2);g([y()],ie.prototype,"pattern",2);g([y({type:Number})],ie.prototype,"minlength",2);g([y({type:Number})],ie.prototype,"maxlength",2);g([y()],ie.prototype,"min",2);g([y()],ie.prototype,"max",2);g([y()],ie.prototype,"step",2);g([y()],ie.prototype,"autocapitalize",2);g([y()],ie.prototype,"autocorrect",2);g([y()],ie.prototype,"autocomplete",2);g([y({type:Boolean})],ie.prototype,"autofocus",2);g([y()],ie.prototype,"enterkeyhint",2);g([y({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],ie.prototype,"spellcheck",2);g([y()],ie.prototype,"inputmode",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ie.prototype,"handleDisabledChange",1);g([G("step",{waitUntilFirstUpdate:!0})],ie.prototype,"handleStepChange",1);g([G("value",{waitUntilFirstUpdate:!0})],ie.prototype,"handleValueChange",1);ie.define("sl-input");var sg=K`
3715
+ `}};ie.styles=[Q,si,tg];ie.dependencies={"sl-icon":Le};g([Z(".input__control")],ie.prototype,"input",2);g([he()],ie.prototype,"hasFocus",2);g([y()],ie.prototype,"title",2);g([y({reflect:!0})],ie.prototype,"type",2);g([y()],ie.prototype,"name",2);g([y()],ie.prototype,"value",2);g([wr()],ie.prototype,"defaultValue",2);g([y({reflect:!0})],ie.prototype,"size",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"filled",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"pill",2);g([y()],ie.prototype,"label",2);g([y({attribute:"help-text"})],ie.prototype,"helpText",2);g([y({type:Boolean})],ie.prototype,"clearable",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"disabled",2);g([y()],ie.prototype,"placeholder",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"readonly",2);g([y({attribute:"password-toggle",type:Boolean})],ie.prototype,"passwordToggle",2);g([y({attribute:"password-visible",type:Boolean})],ie.prototype,"passwordVisible",2);g([y({attribute:"no-spin-buttons",type:Boolean})],ie.prototype,"noSpinButtons",2);g([y({reflect:!0})],ie.prototype,"form",2);g([y({type:Boolean,reflect:!0})],ie.prototype,"required",2);g([y()],ie.prototype,"pattern",2);g([y({type:Number})],ie.prototype,"minlength",2);g([y({type:Number})],ie.prototype,"maxlength",2);g([y()],ie.prototype,"min",2);g([y()],ie.prototype,"max",2);g([y()],ie.prototype,"step",2);g([y()],ie.prototype,"autocapitalize",2);g([y()],ie.prototype,"autocorrect",2);g([y()],ie.prototype,"autocomplete",2);g([y({type:Boolean})],ie.prototype,"autofocus",2);g([y()],ie.prototype,"enterkeyhint",2);g([y({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],ie.prototype,"spellcheck",2);g([y()],ie.prototype,"inputmode",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ie.prototype,"handleDisabledChange",1);g([G("step",{waitUntilFirstUpdate:!0})],ie.prototype,"handleStepChange",1);g([G("value",{waitUntilFirstUpdate:!0})],ie.prototype,"handleValueChange",1);ie.define("sl-input");var sg=K`
3716
3716
  :host {
3717
3717
  --track-width: 2px;
3718
3718
  --track-color: rgb(128 128 128 / 25%);
@@ -4394,7 +4394,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
4394
4394
  ${this.caret?gr` <sl-icon part="caret" class="button__caret" library="system" name="caret"></sl-icon> `:""}
4395
4395
  ${this.loading?gr`<sl-spinner part="spinner"></sl-spinner>`:""}
4396
4396
  </${t}>
4397
- `}};de.styles=[Q,ig];de.dependencies={"sl-icon":De,"sl-spinner":gh};g([Z(".button")],de.prototype,"button",2);g([he()],de.prototype,"hasFocus",2);g([he()],de.prototype,"invalid",2);g([y()],de.prototype,"title",2);g([y({reflect:!0})],de.prototype,"variant",2);g([y({reflect:!0})],de.prototype,"size",2);g([y({type:Boolean,reflect:!0})],de.prototype,"caret",2);g([y({type:Boolean,reflect:!0})],de.prototype,"disabled",2);g([y({type:Boolean,reflect:!0})],de.prototype,"loading",2);g([y({type:Boolean,reflect:!0})],de.prototype,"outline",2);g([y({type:Boolean,reflect:!0})],de.prototype,"pill",2);g([y({type:Boolean,reflect:!0})],de.prototype,"circle",2);g([y()],de.prototype,"type",2);g([y()],de.prototype,"name",2);g([y()],de.prototype,"value",2);g([y()],de.prototype,"href",2);g([y()],de.prototype,"target",2);g([y()],de.prototype,"rel",2);g([y()],de.prototype,"download",2);g([y()],de.prototype,"form",2);g([y({attribute:"formaction"})],de.prototype,"formAction",2);g([y({attribute:"formenctype"})],de.prototype,"formEnctype",2);g([y({attribute:"formmethod"})],de.prototype,"formMethod",2);g([y({attribute:"formnovalidate",type:Boolean})],de.prototype,"formNoValidate",2);g([y({attribute:"formtarget"})],de.prototype,"formTarget",2);g([G("disabled",{waitUntilFirstUpdate:!0})],de.prototype,"handleDisabledChange",1);de.define("sl-button");var rg=K`
4397
+ `}};de.styles=[Q,ig];de.dependencies={"sl-icon":Le,"sl-spinner":gh};g([Z(".button")],de.prototype,"button",2);g([he()],de.prototype,"hasFocus",2);g([he()],de.prototype,"invalid",2);g([y()],de.prototype,"title",2);g([y({reflect:!0})],de.prototype,"variant",2);g([y({reflect:!0})],de.prototype,"size",2);g([y({type:Boolean,reflect:!0})],de.prototype,"caret",2);g([y({type:Boolean,reflect:!0})],de.prototype,"disabled",2);g([y({type:Boolean,reflect:!0})],de.prototype,"loading",2);g([y({type:Boolean,reflect:!0})],de.prototype,"outline",2);g([y({type:Boolean,reflect:!0})],de.prototype,"pill",2);g([y({type:Boolean,reflect:!0})],de.prototype,"circle",2);g([y()],de.prototype,"type",2);g([y()],de.prototype,"name",2);g([y()],de.prototype,"value",2);g([y()],de.prototype,"href",2);g([y()],de.prototype,"target",2);g([y()],de.prototype,"rel",2);g([y()],de.prototype,"download",2);g([y()],de.prototype,"form",2);g([y({attribute:"formaction"})],de.prototype,"formAction",2);g([y({attribute:"formenctype"})],de.prototype,"formEnctype",2);g([y({attribute:"formmethod"})],de.prototype,"formMethod",2);g([y({attribute:"formnovalidate",type:Boolean})],de.prototype,"formNoValidate",2);g([y({attribute:"formtarget"})],de.prototype,"formTarget",2);g([G("disabled",{waitUntilFirstUpdate:!0})],de.prototype,"handleDisabledChange",1);de.define("sl-button");var rg=K`
4398
4398
  :host {
4399
4399
  display: inline-flex;
4400
4400
  }
@@ -5763,7 +5763,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5763
5763
  <slot name="help-text">${this.helpText}</slot>
5764
5764
  </div>
5765
5765
  </div>
5766
- `}};le.styles=[Q,si,yg];g([Z(".textarea__control")],le.prototype,"input",2);g([Z(".textarea__size-adjuster")],le.prototype,"sizeAdjuster",2);g([he()],le.prototype,"hasFocus",2);g([y()],le.prototype,"title",2);g([y()],le.prototype,"name",2);g([y()],le.prototype,"value",2);g([y({reflect:!0})],le.prototype,"size",2);g([y({type:Boolean,reflect:!0})],le.prototype,"filled",2);g([y()],le.prototype,"label",2);g([y({attribute:"help-text"})],le.prototype,"helpText",2);g([y()],le.prototype,"placeholder",2);g([y({type:Number})],le.prototype,"rows",2);g([y()],le.prototype,"resize",2);g([y({type:Boolean,reflect:!0})],le.prototype,"disabled",2);g([y({type:Boolean,reflect:!0})],le.prototype,"readonly",2);g([y({reflect:!0})],le.prototype,"form",2);g([y({type:Boolean,reflect:!0})],le.prototype,"required",2);g([y({type:Number})],le.prototype,"minlength",2);g([y({type:Number})],le.prototype,"maxlength",2);g([y()],le.prototype,"autocapitalize",2);g([y()],le.prototype,"autocorrect",2);g([y()],le.prototype,"autocomplete",2);g([y({type:Boolean})],le.prototype,"autofocus",2);g([y()],le.prototype,"enterkeyhint",2);g([y({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],le.prototype,"spellcheck",2);g([y()],le.prototype,"inputmode",2);g([wr()],le.prototype,"defaultValue",2);g([G("disabled",{waitUntilFirstUpdate:!0})],le.prototype,"handleDisabledChange",1);g([G("rows",{waitUntilFirstUpdate:!0})],le.prototype,"handleRowsChange",1);g([G("value",{waitUntilFirstUpdate:!0})],le.prototype,"handleValueChange",1);le.define("sl-textarea");var I=Xh();function Zt(e){let t=I.getState().currentProjectId;return t?`/api/projects/${t}${e}`:`/api${e}`}var W=Bf(),Uo=Yh({store:I,ws:W,getSettings:()=>Jt}),O=Ba(location.hash),Eg=W.getState(),yh=!0,Jt={},Ke=null,Ho=null,ri=null,Wo=null,bt="*",Ca="",ii=null,Ps={},zo=new Set,wh="all",Sh="all",No=null,jo=null,Ch=new Map,xh={},kh=[],Fo=!1,ka=new Map,$h={},xa=null,$a=!1,Ni=null,Eh="all",Th=null,Ah="",wa="all";function yS(){Jt={},Ke=null,Ho=null,ri=null,Wo=null,bt="*",Ca="",ii=null;for(let e of Object.keys(Ps))delete Ps[e];zo.clear(),wh="all",Sh="all",No=null,jo=null,Ch.clear(),xh={},kh=[],Fo=!1,ka.clear(),$h={},xa=null,$a=!1,Ni=null,Eh="all",Th=null,Ah="",wa="all"}function wS(e,t){ka.set(e,t)}function Rh(e){e&&W.send("list-beads-by-run",{runId:e}).then(t=>{Ch.set(e,t.issues||[]),j()}).catch(()=>{})}function SS(e,t){if(!(!e||!t)){Ps[e]||(Ps[e]={});for(let[s,i]of Object.entries(t)){if(i.status==="pending")continue;let r=`${e}:${s}`;Ps[e][s]||zo.has(r)||(zo.add(r),W.send("get-agent-prompt",{runId:e,stage:s}).then(o=>{Ps[e][s]=o,zo.delete(r),j()}).catch(()=>{zo.delete(r)}))}}}function wg(e){if(!e||!e.stages)return null;for(let[t,s]of Object.entries(e.stages))if(s.status==="in_progress")return t;return null}function Tg(e,t){let s=wg(e),i=wg(t);i&&s!==i&&(bt="*",ii=null,nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:null,runId:t.id}).catch(()=>{}))}W.on("runs-list",(e,t)=>{if((I.getState().projects||[]).length>1){let i={...I.getState().runs},r=new Set((e.runs||[]).map(c=>c.id)),o=t?.project||null;if(o)for(let[c,l]of Object.entries(i))l._project===o&&!r.has(c)&&delete i[c];let n={...I.getState().archivedRuns};if(o)for(let[c,l]of Object.entries(n))l._project===o&&!r.has(c)&&delete n[c];let a=Date.now();for(let c of e.runs||[])if(o&&(c._project=o),c.archived){if(tn(c,a))continue;n[c.id]=c,delete i[c.id]}else i[c.id]=c,delete n[c.id];e.settings&&(Jt=e.settings),I.setState({runs:i,archivedRuns:n});return}e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])});W.on("run-snapshot",e=>{if(e?.id){let t=I.getRunById(e.id)??null;if(e.archived===!0||I.getState().archivedRuns[e.id]||Uo.handleRunUpdate(e.id,e,t),t&&Ps[e.id])for(let[i,r]of Object.entries(e.stages||{})){let o=t.stages?.[i]?.iterations?.length||0;(r.iterations?.length||0)>o&&delete Ps[e.id][i]}I.setRun(e.id,e),O.runId===e.id&&(Tg(t,e),Fn(e)),Ke&&(Ke=null,j())}});W.on("run-update",e=>{if(e?.id){let t=I.getRunById(e.id)??null;e.archived===!0||I.getState().archivedRuns[e.id]||Uo.handleRunUpdate(e.id,e,t),I.setRun(e.id,e),O.runId===e.id&&(Tg(t,e),Fn(e)),Ke&&(Ke=null,j())}});W.on("log-line",e=>{e&&(I.appendLog(e),e.iteration&&e.iteration>1&&e._iterStart&&gp(e.iteration),gc(e))});W.on("log-bulk",e=>{if(e&&Array.isArray(e.lines))for(let t of e.lines){let s={stage:e.stage,iteration:e.iteration,line:t,timestamp:new Date().toISOString()};I.appendLog(s),bt!=="*"&&Gp(s),gc(s)}});W.on("preferences",e=>{e&&(I.setState({preferences:e}),Hr(e.theme||"light"))});W.on("beads-update",(e,t)=>{let s=I.getState().currentProjectId;t?.project&&s&&t.project!==s||e&&(I.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}}),O.runId&&O.section!=="beads"&&Rh(O.runId),Lh(),O.section==="beads"&&O.runId&&Dh(O.runId))});function Vo(){return W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])})}W.on("run-started",()=>{Vo().catch(()=>{}),setTimeout(()=>Vo().catch(()=>{}),2e3)});W.on("run-archived",e=>{if(e?.runId){let t=I.getState().runs[e.runId]??I.getState().archivedRuns[e.runId];t?I.setRun(e.runId,{...t,archived:!0,archived_at:e.archived_at||new Date().toISOString()}):Vo().catch(()=>{})}});W.on("run-unarchived",e=>{if(e?.runId){let t=I.getState().runs[e.runId]??I.getState().archivedRuns[e.runId];if(t){let{archived:s,archived_at:i,...r}=t;I.setRun(e.runId,r)}else Vo().catch(()=>{})}});W.on("run-stopped",()=>{Ke=null,W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{})});W.on("stage-restarted",()=>{W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{})});W.on("learn-started",e=>{e?.runId&&e.runId===O.runId&&W.send("subscribe-run",{runId:e.runId}).catch(()=>{})});W.on("webhook-inbox-event",e=>{if(e){let t=I.getState().currentProjectId;if(!e.projectId||!t||e.projectId===t){let s=I.getState().webhookInbox;I.setState({webhookInbox:{...s,events:[...s.events,e]}})}}});W.on("webhook-control-changed",e=>{if(e){let t=I.getState().webhookInbox;I.setState({webhookInbox:{...t,controlAction:e.action}})}});W.on("webhook-inbox-cleared",()=>{let e=I.getState().webhookInbox;I.setState({webhookInbox:{...e,events:[]}}),Ni=null});W.on("pipeline-status-changed",e=>{let t=I.getState().currentProjectId;if(e.project&&t&&e.project!==t)return;let s={...I.getState().pipelines};e.status==="removed"?delete s[e.runId]:s[e.runId]={run_id:e.runId,status:e.status,stage:e.stage,title:e.title,worktree_path:e.worktree_path,started_at:e.started_at,pid:e.pid},I.setState({pipelines:s})});function CS(e){if(!(e?.capabilities||[]).includes("multi-project")){W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:null}}),Sg();return}fetch("/api/projects").then(i=>i.json()).then(i=>{let r=i.projects||[];I.setState({projects:r});let o=O.projectId||(r.length===1?r[0].name:null);I.setState({currentProjectId:o}),W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:o}}),Sg()}).catch(()=>{})}function Ag(){let e=I.getState().projects||[];Promise.all(e.map(t=>fetch(`/api/projects/${t.name}/runs`).then(s=>s.json()).then(s=>({runs:(s.runs||[]).map(i=>({...i,project:i.project||t.name})),settings:s.settings||null,projectName:t.name})).catch(()=>({runs:[],settings:null,projectName:t.name})))).then(t=>{let s={},i={},r=Date.now();for(let{runs:o,settings:n}of t){n&&(Jt=n);for(let a of o)if(a.archived){if(tn(a,r))continue;i[a.id]=a}else s[a.id]=a}I.setState({runs:s,archivedRuns:i,runsLoaded:!0}),j()})}function Sg(){(I.getState().projects||[]).length>1?Ag():W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{}),W.send("list-beads-issues").then(e=>{I.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}})}).catch(()=>{}),W.send("get-webhook-inbox").then(e=>{I.setState({webhookInbox:{events:e.events||[],controlAction:e.controlAction||"continue"}})}).catch(()=>{}),W.send("list-pipelines").then(e=>{let t={};for(let s of e.pipelines||[])t[s.run_id]=s;I.setState({pipelines:t})}).catch(()=>{}),Lh(),Ph(),O.runId&&(O.section!=="beads"&&(W.send("subscribe-run",{runId:O.runId}).catch(()=>{}),W.send("subscribe-log",{stage:bt==="*"?null:bt,runId:O.runId}).catch(()=>{})),Rh(O.runId),O.section==="beads"&&Dh(O.runId))}W.on("hello",CS);W.on("projects-updated",e=>{e?.projects&&I.setState({projects:e.projects})});function xS(e){W.send("unsubscribe-run").catch(()=>{}),W.send("unsubscribe-log").catch(()=>{}),W.send("unsubscribe-events").catch(()=>{}),W.send("unsubscribe-pipeline").catch(()=>{}),I.clearLog(),I.setState({currentProjectId:e,runs:{},archivedRuns:{},logLines:[],activeRunId:null,pipelines:{}}),yS(),W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:e}}),(I.getState().projects||[]).length>1?Ag():W.send("list-runs").then(t=>{t.settings&&(Jt=t.settings),I.setRunsBulk(t.runs||[])}).catch(()=>{}),W.send("list-beads-issues").then(t=>{I.setState({beads:{issues:t.issues||[],dbExists:t.dbExists??!1,dbPath:t.dbPath||null,loading:!1}})}).catch(()=>{}),I.setState({webhookInbox:{events:[],controlAction:I.getState().webhookInbox?.controlAction||"continue"}}),W.send("get-webhook-inbox").then(t=>{I.setState({webhookInbox:{events:t.events||[],controlAction:t.controlAction||"continue"}})}).catch(()=>{}),Lh(),Ph()}W.onConnection(e=>{Eg=e,e==="open"&&W.send("get-preferences").then(t=>{I.setState({preferences:t}),Hr(t.theme||"light")}).catch(()=>{}),j()});Gh(e=>{let t=O.runId,s=O.projectId;O=e,e.projectId!==s&&xS(e.projectId),t&&t!==O.runId&&(ka.clear(),W.send("unsubscribe-run").catch(()=>{}),W.send("unsubscribe-log").catch(()=>{}),I.clearLog(),nr(),_c()),O.runId&&O.runId!==t&&(O.section==="beads"?Dh(O.runId):(bt="*",ii=null,W.send("subscribe-run",{runId:O.runId}).catch(()=>{}),W.send("subscribe-log",{stage:null,runId:O.runId}).catch(()=>{}),Rh(O.runId))),O.section==="settings"&&Js(null).then(()=>j()),O.section==="project-settings"&&Js(I.getState().currentProjectId||null).then(()=>j()),O.section==="costs"&&($a=!1,Rg()),!O.runId&&t&&(Yp(),_p()),j()});function kS(e){Ae(e,null,O.projectId)}function Sa(e){Ae(O.section,e,O.projectId)}function $S(e){e?Ae(O.section,null,e):Ae("dashboard",null,null)}function ES(){let t=I.getState().preferences.theme==="dark"?"light":"dark";W.send("set-preferences",{theme:t}).catch(()=>{}),I.setState({preferences:{theme:t}}),Hr(t)}function TS(e){W.send("set-preferences",{notifications:e}).catch(()=>{}),I.setState({preferences:{notifications:e}})}function AS(e){W.send("set-preferences",{source_repo:e}).catch(()=>{}),I.setState({preferences:{source_repo:e}})}function RS(e){if(bt=e,e!=="*"){let i=I.getRunById(O.runId)?.stages?.[e]?.iterations?.length||0;ii=i>0?i:null}else ii=null;nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:e==="*"?null:e,runId:O.runId,iteration:ii}).catch(()=>{}),j()}function LS(e){ii=e,nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:bt==="*"?null:bt,runId:O.runId,iteration:e}).catch(()=>{}),j()}function DS(e){Ca=e,Xp(e)}function PS(){yh=!yh,j()}function Ee(e){ri=e,j(),requestAnimationFrame(()=>{let t=document.getElementById("action-error-dialog");t&&t.show()})}function MS(){ri=null,j()}function Cg(){Ht({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:BS},j)}async function BS(){Ke="stopping",ri=null,j();try{let t=Object.values(I.getState().runs).find(r=>r.active)?.id||"current",i=await(await fetch(Zt(`/runs/${t}`),{method:"DELETE"})).json();i.ok||(Ke=null,Ee(i.error||"Failed to stop pipeline"))}catch(e){Ke=null,Ee(e?.message||"Failed to stop pipeline")}}async function OS(e){try{let s=await(await fetch(Zt(`/runs/${e}/cancel`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to cancel run")}catch(t){Ee(t?.message||"Failed to cancel run")}}function IS(){Ke="resuming",ri=null,j(),W.send("resume-run",{runId:O.runId}).then(()=>{Ke=null,j()}).catch(e=>{Ke=null,Ee(e?.message||"Failed to resume pipeline")})}async function zS(){let t=Object.values(I.getState().runs).find(s=>s.active)?.id||"current";Ke="pausing",ri=null,j();try{let i=await(await fetch(Zt(`/runs/${t}/pause`),{method:"POST"})).json();i.ok||(Ke=null,Ee(i.error||"Failed to pause pipeline"))}catch(s){Ke=null,Ee(s?.message||"Failed to pause pipeline")}}async function xg(e){Ho={action:"pause",runId:e},j();try{let s=await(await fetch(Zt(`/runs/${e}/pause`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to pause run")}catch(t){Ee(t?.message||"Failed to pause run")}finally{Ho=null,j()}}async function vh(e){Ho={action:"resume",runId:e},j();try{let s=await(await fetch(Zt(`/runs/${e}/resume`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to resume run")}catch(t){Ee(t?.message||"Failed to resume run")}finally{Ho=null,j()}}var{archiveRun:bh,unarchiveRun:NS}=Jh({showConfirm:Ht,showActionError:Ee,projectUrl:Zt,store:I,rerender:j});async function FS(e){try{let s=await(await fetch(Zt(`/pipelines/${e}/pause`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to pause pipeline")}catch(t){Ee(t?.message||"Failed to pause pipeline")}}async function HS(e){try{let s=await(await fetch(Zt(`/pipelines/${e}/stop`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to stop pipeline")}catch(t){Ee(t?.message||"Failed to stop pipeline")}}async function WS(e){try{await W.send("resume-run",{runId:e})}catch(t){Ee(t?.message||"Failed to resume pipeline")}}function jS(e){Wo=e,Ht({label:"Restart Stage?",message:`Restart the "${e}" stage? The pipeline will resume from this point.`,confirmLabel:"Restart",confirmVariant:"warning",onConfirm:VS,onCancel:()=>{Wo=null}},j)}async function VS(){let e=Wo;Wo=null,j();try{let s=Object.values(I.getState().runs).find(o=>!o.active)?.id||"current",r=await(await fetch(Zt(`/runs/${s}/stages/${e}/restart`),{method:"POST"})).json();r.ok?Ae("active",null,O.projectId):Ee(r.error||"Failed to restart stage")}catch(t){Ee(t?.message||"Failed to restart stage")}}function US(){if(O.runId){let t=Object.values(I.getState().runs).filter(s=>s.active);O.section==="active"&&t.length<=1?Ae("dashboard",null,O.projectId):Ae(O.section,null,O.projectId)}else O.section&&O.section!=="dashboard"&&Ae("dashboard",null,O.projectId)}function qS(e){wh=e,j()}function KS(e){Sh=e,j()}async function GS(e){No=e,jo=null,j();try{await W.send("start-beads-issue",{issueId:e}),No=null,Ae("active",null,O.projectId)}catch(t){No=null,jo=t?.message||"Failed to start pipeline",j()}}function YS(){jo=null,j()}function Lh(){W.send("list-beads-counts").then(e=>{xh=e.counts||{},j()}).catch(()=>{})}function Dh(e){Fo=!0,j(),W.send("list-beads-by-run",{runId:e}).then(t=>{kh=t.issues||[],Fo=!1,j()}).catch(()=>{Fo=!1,j()})}function Rg(){fetch(Zt("/costs")).then(e=>e.json()).then(e=>{e.ok&&($h=e.tokenData||{},$a=!0,j())}).catch(()=>{})}function Ph(){let e=I.getState().currentProjectId,t=e?`/api/projects/${e}/info`:"/api/project-info";fetch(t).then(s=>s.json()).then(s=>{let i=s.project?.name??s.name;i!==void 0&&(I.setState({projectName:i}),document.title=Zh(i))}).catch(()=>{})}function XS(e){xa=xa===e?null:e,j()}function JS(e){Ni=Ni===e?null:e,j()}function ZS(e){Eh=e,j()}function QS(e){Th=e,j()}function eC(e){Ah=e,j()}function tC(e){W.send("set-webhook-control",{action:e}).catch(()=>{})}function Lg(){W.send("clear-webhook-inbox").catch(()=>{}),Ni=null}function sC(e){try{navigator.clipboard.writeText(JSON.stringify(e.envelope,null,2))}catch{}}function iC(){Ni=null,j()}function rC(){let t=I.getRunById(O.runId)?.stages?.learn?.status;if(t==="completed"||t==="error"){Ht({label:"Re-run Learning Analysis?",message:"This will replace existing learnings. Continue?",confirmLabel:"Re-run",confirmVariant:"warning",onConfirm:kg},j);return}kg()}async function kg(){j();try{let e=O.runId,s=await(await fetch(Zt(`/runs/${e}/learn`),{method:"POST"})).json();if(!s.ok)Ee(s.error||"Failed to run learning analysis");else{let i=I.getRunById(e);if(i){let r=new Date().toISOString();I.setRun(e,{...i,stages:{...i.stages||{},learn:{status:"in_progress",pid:s.pid,started_at:r,iterations:[{number:1,status:"in_progress",started_at:r,trigger:"manual"}]}}})}}}catch(e){Ee(e?.message||"Failed to run learning analysis")}}function oC(){let e=I.getState(),t="Dashboard",s=!1,i=null,r=null;if(O.section==="beads"&&O.runId){let a=(I.getRunById(O.runId)?.work_request?.title||O.runId).split(`
5766
+ `}};le.styles=[Q,si,yg];g([Z(".textarea__control")],le.prototype,"input",2);g([Z(".textarea__size-adjuster")],le.prototype,"sizeAdjuster",2);g([he()],le.prototype,"hasFocus",2);g([y()],le.prototype,"title",2);g([y()],le.prototype,"name",2);g([y()],le.prototype,"value",2);g([y({reflect:!0})],le.prototype,"size",2);g([y({type:Boolean,reflect:!0})],le.prototype,"filled",2);g([y()],le.prototype,"label",2);g([y({attribute:"help-text"})],le.prototype,"helpText",2);g([y()],le.prototype,"placeholder",2);g([y({type:Number})],le.prototype,"rows",2);g([y()],le.prototype,"resize",2);g([y({type:Boolean,reflect:!0})],le.prototype,"disabled",2);g([y({type:Boolean,reflect:!0})],le.prototype,"readonly",2);g([y({reflect:!0})],le.prototype,"form",2);g([y({type:Boolean,reflect:!0})],le.prototype,"required",2);g([y({type:Number})],le.prototype,"minlength",2);g([y({type:Number})],le.prototype,"maxlength",2);g([y()],le.prototype,"autocapitalize",2);g([y()],le.prototype,"autocorrect",2);g([y()],le.prototype,"autocomplete",2);g([y({type:Boolean})],le.prototype,"autofocus",2);g([y()],le.prototype,"enterkeyhint",2);g([y({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],le.prototype,"spellcheck",2);g([y()],le.prototype,"inputmode",2);g([wr()],le.prototype,"defaultValue",2);g([G("disabled",{waitUntilFirstUpdate:!0})],le.prototype,"handleDisabledChange",1);g([G("rows",{waitUntilFirstUpdate:!0})],le.prototype,"handleRowsChange",1);g([G("value",{waitUntilFirstUpdate:!0})],le.prototype,"handleValueChange",1);le.define("sl-textarea");var I=Xh();function Zt(e){let t=I.getState().currentProjectId;return t?`/api/projects/${t}${e}`:`/api${e}`}var W=Bf(),Uo=Yh({store:I,ws:W,getSettings:()=>Jt}),O=Ba(location.hash),Eg=W.getState(),yh=!0,Jt={},Ke=null,Ho=null,ri=null,Wo=null,bt="*",Ca="",ii=null,Ps={},zo=new Set,wh="all",Sh="all",No=null,jo=null,Ch=new Map,xh={},kh=[],Fo=!1,ka=new Map,$h={},xa=null,$a=!1,Ni=null,Eh="all",Th=null,Ah="",wa="all";function yS(){Jt={},Ke=null,Ho=null,ri=null,Wo=null,bt="*",Ca="",ii=null;for(let e of Object.keys(Ps))delete Ps[e];zo.clear(),wh="all",Sh="all",No=null,jo=null,Ch.clear(),xh={},kh=[],Fo=!1,ka.clear(),$h={},xa=null,$a=!1,Ni=null,Eh="all",Th=null,Ah="",wa="all"}function wS(e,t){ka.set(e,t)}function Rh(e){e&&W.send("list-beads-by-run",{runId:e}).then(t=>{Ch.set(e,t.issues||[]),j()}).catch(()=>{})}function SS(e,t){if(!(!e||!t)){Ps[e]||(Ps[e]={});for(let[s,i]of Object.entries(t)){if(i.status==="pending")continue;let r=`${e}:${s}`;Ps[e][s]||zo.has(r)||(zo.add(r),W.send("get-agent-prompt",{runId:e,stage:s}).then(o=>{Ps[e][s]=o,zo.delete(r),j()}).catch(()=>{zo.delete(r)}))}}}function wg(e){if(!e||!e.stages)return null;for(let[t,s]of Object.entries(e.stages))if(s.status==="in_progress")return t;return null}function Tg(e,t){let s=wg(e),i=wg(t);i&&s!==i&&(bt="*",ii=null,nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:null,runId:t.id}).catch(()=>{}))}W.on("runs-list",(e,t)=>{if((I.getState().projects||[]).length>1){let i={...I.getState().runs},r=new Set((e.runs||[]).map(c=>c.id)),o=t?.project||null;if(o)for(let[c,l]of Object.entries(i))l._project===o&&!r.has(c)&&delete i[c];let n={...I.getState().archivedRuns};if(o)for(let[c,l]of Object.entries(n))l._project===o&&!r.has(c)&&delete n[c];let a=Date.now();for(let c of e.runs||[])if(o&&(c._project=o),c.archived){if(tn(c,a))continue;n[c.id]=c,delete i[c.id]}else i[c.id]=c,delete n[c.id];e.settings&&(Jt=e.settings),I.setState({runs:i,archivedRuns:n});return}e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])});W.on("run-snapshot",e=>{if(e?.id){let t=I.getRunById(e.id)??null;if(e.archived===!0||I.getState().archivedRuns[e.id]||Uo.handleRunUpdate(e.id,e,t),t&&Ps[e.id])for(let[i,r]of Object.entries(e.stages||{})){let o=t.stages?.[i]?.iterations?.length||0;(r.iterations?.length||0)>o&&delete Ps[e.id][i]}I.setRun(e.id,e),O.runId===e.id&&(Tg(t,e),Fn(e)),Ke&&(Ke=null,j())}});W.on("run-update",e=>{if(e?.id){let t=I.getRunById(e.id)??null;e.archived===!0||I.getState().archivedRuns[e.id]||Uo.handleRunUpdate(e.id,e,t),I.setRun(e.id,e),O.runId===e.id&&(Tg(t,e),Fn(e)),Ke&&(Ke=null,j())}});W.on("log-line",e=>{e&&(I.appendLog(e),e.iteration&&e.iteration>1&&e._iterStart&&gp(e.iteration),gc(e))});W.on("log-bulk",e=>{if(e&&Array.isArray(e.lines))for(let t of e.lines){let s={stage:e.stage,iteration:e.iteration,line:t,timestamp:new Date().toISOString()};I.appendLog(s),bt!=="*"&&Gp(s),gc(s)}});W.on("preferences",e=>{e&&(I.setState({preferences:e}),Hr(e.theme||"light"))});W.on("beads-update",(e,t)=>{let s=I.getState().currentProjectId;t?.project&&s&&t.project!==s||e&&(I.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}}),O.runId&&O.section!=="beads"&&Rh(O.runId),Lh(),O.section==="beads"&&O.runId&&Dh(O.runId))});function Vo(){return W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])})}W.on("run-started",()=>{Vo().catch(()=>{}),setTimeout(()=>Vo().catch(()=>{}),2e3)});W.on("run-archived",e=>{if(e?.runId){let t=I.getState().runs[e.runId]??I.getState().archivedRuns[e.runId];t?I.setRun(e.runId,{...t,archived:!0,archived_at:e.archived_at||new Date().toISOString()}):Vo().catch(()=>{})}});W.on("run-unarchived",e=>{if(e?.runId){let t=I.getState().runs[e.runId]??I.getState().archivedRuns[e.runId];if(t){let{archived:s,archived_at:i,...r}=t;I.setRun(e.runId,r)}else Vo().catch(()=>{})}});W.on("run-stopped",()=>{Ke=null,W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{})});W.on("stage-restarted",()=>{W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{})});W.on("learn-started",e=>{e?.runId&&e.runId===O.runId&&W.send("subscribe-run",{runId:e.runId}).catch(()=>{})});W.on("webhook-inbox-event",e=>{if(e){let t=I.getState().currentProjectId;if(!e.projectId||!t||e.projectId===t){let s=I.getState().webhookInbox;I.setState({webhookInbox:{...s,events:[...s.events,e]}})}}});W.on("webhook-control-changed",e=>{if(e){let t=I.getState().webhookInbox;I.setState({webhookInbox:{...t,controlAction:e.action}})}});W.on("webhook-inbox-cleared",()=>{let e=I.getState().webhookInbox;I.setState({webhookInbox:{...e,events:[]}}),Ni=null});W.on("pipeline-status-changed",e=>{let t=I.getState().currentProjectId;if(e.project&&t&&e.project!==t)return;let s={...I.getState().pipelines};e.status==="removed"?delete s[e.runId]:s[e.runId]={run_id:e.runId,status:e.status,stage:e.stage,title:e.title,worktree_path:e.worktree_path,started_at:e.started_at,pid:e.pid},I.setState({pipelines:s})});function CS(e){if(!(e?.capabilities||[]).includes("multi-project")){W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:null}}),Sg();return}fetch("/api/projects").then(i=>i.json()).then(i=>{let r=i.projects||[];I.setState({projects:r});let o=O.projectId||(r.length===1?r[0].name:null);I.setState({currentProjectId:o}),W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:o}}),Sg()}).catch(()=>{})}function Ag(){let e=I.getState().projects||[];Promise.all(e.map(t=>fetch(`/api/projects/${t.name}/runs`).then(s=>s.json()).then(s=>({runs:(s.runs||[]).map(i=>({...i,project:i.project||t.name})),settings:s.settings||null,projectName:t.name})).catch(()=>({runs:[],settings:null,projectName:t.name})))).then(t=>{let s={},i={},r=Date.now();for(let{runs:o,settings:n}of t){n&&(Jt=n);for(let a of o)if(a.archived){if(tn(a,r))continue;i[a.id]=a}else s[a.id]=a}I.setState({runs:s,archivedRuns:i,runsLoaded:!0}),j()})}function Sg(){(I.getState().projects||[]).length>1?Ag():W.send("list-runs").then(e=>{e.settings&&(Jt=e.settings),I.setRunsBulk(e.runs||[])}).catch(()=>{}),W.send("list-beads-issues").then(e=>{I.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}})}).catch(()=>{}),W.send("get-webhook-inbox").then(e=>{I.setState({webhookInbox:{events:e.events||[],controlAction:e.controlAction||"continue"}})}).catch(()=>{}),W.send("list-pipelines").then(e=>{let t={};for(let s of e.pipelines||[])t[s.run_id]=s;I.setState({pipelines:t})}).catch(()=>{}),Lh(),Ph(),O.runId&&(O.section!=="beads"&&(W.send("subscribe-run",{runId:O.runId}).catch(()=>{}),W.send("subscribe-log",{stage:bt==="*"?null:bt,runId:O.runId}).catch(()=>{})),Rh(O.runId),O.section==="beads"&&Dh(O.runId))}W.on("hello",CS);W.on("projects-updated",e=>{e?.projects&&I.setState({projects:e.projects})});function xS(e){W.send("unsubscribe-run").catch(()=>{}),W.send("unsubscribe-log").catch(()=>{}),W.send("unsubscribe-events").catch(()=>{}),W.send("unsubscribe-pipeline").catch(()=>{}),I.clearLog(),I.setState({currentProjectId:e,runs:{},archivedRuns:{},logLines:[],activeRunId:null,pipelines:{}}),yS(),W.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:e}}),(I.getState().projects||[]).length>1?Ag():W.send("list-runs").then(t=>{t.settings&&(Jt=t.settings),I.setRunsBulk(t.runs||[])}).catch(()=>{}),W.send("list-beads-issues").then(t=>{I.setState({beads:{issues:t.issues||[],dbExists:t.dbExists??!1,dbPath:t.dbPath||null,loading:!1}})}).catch(()=>{}),I.setState({webhookInbox:{events:[],controlAction:I.getState().webhookInbox?.controlAction||"continue"}}),W.send("get-webhook-inbox").then(t=>{I.setState({webhookInbox:{events:t.events||[],controlAction:t.controlAction||"continue"}})}).catch(()=>{}),Lh(),Ph()}W.onConnection(e=>{Eg=e,e==="open"&&W.send("get-preferences").then(t=>{I.setState({preferences:t}),Hr(t.theme||"light")}).catch(()=>{}),j()});Gh(e=>{let t=O.runId,s=O.projectId;O=e,e.projectId!==s&&xS(e.projectId),t&&t!==O.runId&&(ka.clear(),W.send("unsubscribe-run").catch(()=>{}),W.send("unsubscribe-log").catch(()=>{}),I.clearLog(),nr(),_c()),O.runId&&O.runId!==t&&(O.section==="beads"?Dh(O.runId):(bt="*",ii=null,W.send("subscribe-run",{runId:O.runId}).catch(()=>{}),W.send("subscribe-log",{stage:null,runId:O.runId}).catch(()=>{}),Rh(O.runId))),O.section==="settings"&&Js(null).then(()=>j()),O.section==="project-settings"&&Js(I.getState().currentProjectId||null).then(()=>j()),O.section==="costs"&&($a=!1,Rg()),!O.runId&&t&&(Yp(),_p()),j()});function kS(e){Oe(e,null,O.projectId)}function Sa(e){Oe(O.section,e,O.projectId)}function $S(e){e?Oe(O.section,null,e):Oe("dashboard",null,null)}function ES(){let t=I.getState().preferences.theme==="dark"?"light":"dark";W.send("set-preferences",{theme:t}).catch(()=>{}),I.setState({preferences:{theme:t}}),Hr(t)}function TS(e){W.send("set-preferences",{notifications:e}).catch(()=>{}),I.setState({preferences:{notifications:e}})}function AS(e){W.send("set-preferences",{source_repo:e}).catch(()=>{}),I.setState({preferences:{source_repo:e}})}function RS(e){if(bt=e,e!=="*"){let i=I.getRunById(O.runId)?.stages?.[e]?.iterations?.length||0;ii=i>0?i:null}else ii=null;nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:e==="*"?null:e,runId:O.runId,iteration:ii}).catch(()=>{}),j()}function LS(e){ii=e,nr(),I.clearLog(),W.send("unsubscribe-log").catch(()=>{}),W.send("subscribe-log",{stage:bt==="*"?null:bt,runId:O.runId,iteration:e}).catch(()=>{}),j()}function DS(e){Ca=e,Xp(e)}function PS(){yh=!yh,j()}function Ee(e){ri=e,j(),requestAnimationFrame(()=>{let t=document.getElementById("action-error-dialog");t&&t.show()})}function MS(){ri=null,j()}function Cg(){Ht({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:BS},j)}async function BS(){Ke="stopping",ri=null,j();try{let t=Object.values(I.getState().runs).find(r=>r.active)?.id||"current",i=await(await fetch(Zt(`/runs/${t}`),{method:"DELETE"})).json();i.ok||(Ke=null,Ee(i.error||"Failed to stop pipeline"))}catch(e){Ke=null,Ee(e?.message||"Failed to stop pipeline")}}async function OS(e){try{let s=await(await fetch(Zt(`/runs/${e}/cancel`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to cancel run")}catch(t){Ee(t?.message||"Failed to cancel run")}}function IS(){Ke="resuming",ri=null,j(),W.send("resume-run",{runId:O.runId}).then(()=>{Ke=null,j()}).catch(e=>{Ke=null,Ee(e?.message||"Failed to resume pipeline")})}async function zS(){let t=Object.values(I.getState().runs).find(s=>s.active)?.id||"current";Ke="pausing",ri=null,j();try{let i=await(await fetch(Zt(`/runs/${t}/pause`),{method:"POST"})).json();i.ok||(Ke=null,Ee(i.error||"Failed to pause pipeline"))}catch(s){Ke=null,Ee(s?.message||"Failed to pause pipeline")}}async function xg(e){Ho={action:"pause",runId:e},j();try{let s=await(await fetch(Zt(`/runs/${e}/pause`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to pause run")}catch(t){Ee(t?.message||"Failed to pause run")}finally{Ho=null,j()}}async function vh(e){Ho={action:"resume",runId:e},j();try{let s=await(await fetch(Zt(`/runs/${e}/resume`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to resume run")}catch(t){Ee(t?.message||"Failed to resume run")}finally{Ho=null,j()}}var{archiveRun:bh,unarchiveRun:NS}=Jh({showConfirm:Ht,showActionError:Ee,projectUrl:Zt,store:I,rerender:j});async function FS(e){try{let s=await(await fetch(Zt(`/pipelines/${e}/pause`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to pause pipeline")}catch(t){Ee(t?.message||"Failed to pause pipeline")}}async function HS(e){try{let s=await(await fetch(Zt(`/pipelines/${e}/stop`),{method:"POST"})).json();s.ok||Ee(s.error||"Failed to stop pipeline")}catch(t){Ee(t?.message||"Failed to stop pipeline")}}async function WS(e){try{await W.send("resume-run",{runId:e})}catch(t){Ee(t?.message||"Failed to resume pipeline")}}function jS(e){Wo=e,Ht({label:"Restart Stage?",message:`Restart the "${e}" stage? The pipeline will resume from this point.`,confirmLabel:"Restart",confirmVariant:"warning",onConfirm:VS,onCancel:()=>{Wo=null}},j)}async function VS(){let e=Wo;Wo=null,j();try{let s=Object.values(I.getState().runs).find(o=>!o.active)?.id||"current",r=await(await fetch(Zt(`/runs/${s}/stages/${e}/restart`),{method:"POST"})).json();r.ok?Oe("active",null,O.projectId):Ee(r.error||"Failed to restart stage")}catch(t){Ee(t?.message||"Failed to restart stage")}}function US(){O.runId?Oe(O.section,null,O.projectId):O.section&&O.section!=="dashboard"&&Oe("dashboard",null,O.projectId)}function qS(e){wh=e,j()}function KS(e){Sh=e,j()}async function GS(e){No=e,jo=null,j();try{await W.send("start-beads-issue",{issueId:e}),No=null,Oe("active",null,O.projectId)}catch(t){No=null,jo=t?.message||"Failed to start pipeline",j()}}function YS(){jo=null,j()}function Lh(){W.send("list-beads-counts").then(e=>{xh=e.counts||{},j()}).catch(()=>{})}function Dh(e){Fo=!0,j(),W.send("list-beads-by-run",{runId:e}).then(t=>{kh=t.issues||[],Fo=!1,j()}).catch(()=>{Fo=!1,j()})}function Rg(){fetch(Zt("/costs")).then(e=>e.json()).then(e=>{e.ok&&($h=e.tokenData||{},$a=!0,j())}).catch(()=>{})}function Ph(){let e=I.getState().currentProjectId,t=e?`/api/projects/${e}/info`:"/api/project-info";fetch(t).then(s=>s.json()).then(s=>{let i=s.project?.name??s.name;i!==void 0&&(I.setState({projectName:i}),document.title=Zh(i))}).catch(()=>{})}function XS(e){xa=xa===e?null:e,j()}function JS(e){Ni=Ni===e?null:e,j()}function ZS(e){Eh=e,j()}function QS(e){Th=e,j()}function eC(e){Ah=e,j()}function tC(e){W.send("set-webhook-control",{action:e}).catch(()=>{})}function Lg(){W.send("clear-webhook-inbox").catch(()=>{}),Ni=null}function sC(e){try{navigator.clipboard.writeText(JSON.stringify(e.envelope,null,2))}catch{}}function iC(){Ni=null,j()}function rC(){let t=I.getRunById(O.runId)?.stages?.learn?.status;if(t==="completed"||t==="error"){Ht({label:"Re-run Learning Analysis?",message:"This will replace existing learnings. Continue?",confirmLabel:"Re-run",confirmVariant:"warning",onConfirm:kg},j);return}kg()}async function kg(){j();try{let e=O.runId,s=await(await fetch(Zt(`/runs/${e}/learn`),{method:"POST"})).json();if(!s.ok)Ee(s.error||"Failed to run learning analysis");else{let i=I.getRunById(e);if(i){let r=new Date().toISOString();I.setRun(e,{...i,stages:{...i.stages||{},learn:{status:"in_progress",pid:s.pid,started_at:r,iterations:[{number:1,status:"in_progress",started_at:r,trigger:"manual"}]}}})}}}catch(e){Ee(e?.message||"Failed to run learning analysis")}}function oC(){let e=I.getState(),t="Dashboard",s=!1,i=null,r=null;if(O.section==="beads"&&O.runId){let a=(I.getRunById(O.runId)?.work_request?.title||O.runId).split(`
5767
5767
  `)[0];t=a.length>80?`${a.slice(0,80)}\u2026`:a,s=!0}else if(O.section==="beads"&&!O.runId){t="Beads Issues",s=!0;let o=e.beads?.dbPath;o&&(r=u`<span class="beads-db-path">${E(A(Wa,12))} Beads DB<br><code>${o}</code></span>`)}else if(O.runId){let o=I.getRunById(O.runId),a=(o?.work_request?.title||"Pipeline Details").split(`
5768
5768
  `)[0];if(t=a.length>80?`${a.slice(0,80)}\u2026`:a,s=!0,o){let c=o.pipeline_status||(o.active?"running":"completed"),h={running:"warning",resuming:"warning",paused:"warning",completed:"success",failed:"danger"}[c]||"neutral",d=c.charAt(0).toUpperCase()+c.slice(1);i=u`<sl-badge variant="${h}" pill>
5769
5769
  ${E(jt(c,12))}
@@ -5802,7 +5802,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5802
5802
  Cancel
5803
5803
  </button>`)}}else if(O.section==="new-run"){t="New Pipeline",s=!0;let o=hf();r=u`
5804
5804
  <button class="action-btn action-btn--primary" ?disabled=${o.isSubmitting}
5805
- @click=${()=>df({rerender:j,onStarted:()=>Ae("active",null,O.projectId),projectId:I.getState().currentProjectId,refreshRuns:Vo})}>
5805
+ @click=${()=>df({rerender:j,onStarted:()=>Oe("active",null,O.projectId),projectId:I.getState().currentProjectId,refreshRuns:Vo})}>
5806
5806
 
5807
5807
  ${E(A(Ui,14))}
5808
5808
  ${o.isSubmitting?"Starting\u2026":"Start"}
@@ -5811,7 +5811,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5811
5811
  ${E(A(pi,14))}
5812
5812
  Clear
5813
5813
  </button>`)):O.section==="costs"?(t="Token & Cost Dashboard",s=!0):O.section==="settings"?(t="Settings",s=!0):O.section==="project-settings"&&(t="Project Settings",s=!0);return!O.section&&!O.runId&&(r=u`
5814
- <button class="action-btn action-btn--primary" @click=${()=>Ae("new-run",null,O.projectId)}>
5814
+ <button class="action-btn action-btn--primary" @click=${()=>Oe("new-run",null,O.projectId)}>
5815
5815
  ${E(A(Qt,14))}
5816
5816
  New Pipeline
5817
5817
  </button>`),u`
@@ -5827,7 +5827,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5827
5827
  ${r}
5828
5828
  </div>`:""}
5829
5829
  </div>
5830
- `}function nC(){let e=I.getState(),t=Object.values(e.runs),s=e.currentProjectId,i=s&&(e.projects||[]).length>1?t.filter(l=>(l.project||l._project)===s):t,r={};for(let l of i)r[l.id]=l;let o=Object.values(e.archivedRuns),n=s&&(e.projects||[]).length>1?o.filter(l=>(l.project||l._project)===s):o,a={};for(let l of n)a[l.id]=l;let c={...e,runs:r,archivedRuns:a};if(O.section==="beads")return O.runId?ad(kh,{statusFilter:wh,priorityFilter:Sh,starting:No,startError:jo,onStatusFilter:qS,onPriorityFilter:KS,onStartIssue:GS,onDismissError:YS,loading:Fo,run:I.getRunById(O.runId),runId:O.runId}):nd(i,{onSelectRun:Sa,beadsCounts:xh});if(O.runId){let l=I.getRunById(O.runId);if(!l&&e.runsLoaded&&s&&(e.projects||[]).length>1)return Ae(O.section,null,O.projectId),u``;let h={};if(l?.stages){for(let[b,C]of Object.entries(l.stages)){let T=C.iterations||[];T.length>0&&(h[b]=T.length)}SS(O.runId,l.stages)}let d=aC(e);d.currentLogStage=bt==="*"?null:bt,d.currentLogIteration=ii;let f=!!l?.active,p=vc();l&&!p&&Fn(l);let{overview:m,stages:_}=Sf(l,Jt,{promptCache:Ps[O.runId]||{},onRestartStage:jS,stageIterationTab:ka,onStageTabChange:wS});return u`
5830
+ `}function nC(){let e=I.getState(),t=Object.values(e.runs),s=e.currentProjectId,i=s&&(e.projects||[]).length>1?t.filter(l=>(l.project||l._project)===s):t,r={};for(let l of i)r[l.id]=l;let o=Object.values(e.archivedRuns),n=s&&(e.projects||[]).length>1?o.filter(l=>(l.project||l._project)===s):o,a={};for(let l of n)a[l.id]=l;let c={...e,runs:r,archivedRuns:a};if(O.section==="beads")return O.runId?ad(kh,{statusFilter:wh,priorityFilter:Sh,starting:No,startError:jo,onStatusFilter:qS,onPriorityFilter:KS,onStartIssue:GS,onDismissError:YS,loading:Fo,run:I.getRunById(O.runId),runId:O.runId}):nd(i,{onSelectRun:Sa,beadsCounts:xh});if(O.runId){let l=I.getRunById(O.runId);if(!l&&e.runsLoaded&&s&&(e.projects||[]).length>1)return Oe(O.section,null,O.projectId),u``;let h={};if(l?.stages){for(let[b,C]of Object.entries(l.stages)){let T=C.iterations||[];T.length>0&&(h[b]=T.length)}SS(O.runId,l.stages)}let d=aC(e);d.currentLogStage=bt==="*"?null:bt,d.currentLogIteration=ii;let f=!!l?.active,p=vc();l&&!p&&Fn(l);let{overview:m,stages:_}=Sf(l,Jt,{promptCache:Ps[O.runId]||{},onRestartStage:jS,stageIterationTab:ka,onStageTabChange:wS});return u`
5831
5831
  <div class="run-detail run-detail-layout">
5832
5832
  <div class="run-detail-layout__overview">
5833
5833
  ${m}
@@ -5844,7 +5844,7 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5844
5844
  ${dd(l?.stages?.learn,{onRunLearn:rC})}
5845
5845
  </div>
5846
5846
  </div>
5847
- `}if(O.section==="webhooks")return Df(e,{selectedId:Ni,categoryFilter:Eh,runFilter:Th,searchTerm:Ah,onSelectEvent:JS,onCategoryFilter:ZS,onRunFilter:QS,onSearch:eC,onSetControl:tC,onClear:Lg,onCopyJson:sC,onDismissDetail:iC});if(O.section==="costs")return $a||Rg(),Tf(c,{expandedRun:xa,tokenData:$h,onToggleRun:XS});if(O.section==="new-run")return uf(e,{rerender:j});if(O.section==="project-settings")return lf(e.preferences,{rerender:j,currentProjectId:e.currentProjectId||null});if(O.section==="settings")return af(e.preferences,{rerender:j,onThemeToggle:ES,onSaveSourceRepo:AS,onSaveNotifications:TS,onRequestPermission:()=>Uo.requestPermission(),projects:e.projects||[],onProjectAdd:l=>{l?.openDialog?(I.setState({addProjectDialogOpen:!0}),j()):l?.name&&fetch("/api/projects").then(h=>h.json()).then(h=>{I.setState({projects:h.projects||[]}),j()}).catch(()=>{})},onProjectRemove:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{I.setState({projects:l.projects||[]}),j()}).catch(()=>{})},onProjectsRefresh:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{I.setState({projects:l.projects||[]}),j()}).catch(()=>{})}});if(O.section==="history")return Cf(i,"history",{onSelectRun:Sa,onResume:vh,onArchive:bh,onUnarchive:NS,archivedRuns:n,statusFilter:wa,onStatusFilter:l=>{wa=l,j()}});if(O.section==="active"){let l=yt(i.filter(h=>h.active));return l.length===1?(Ae("active",l[0].id,O.projectId),u``):u`
5847
+ `}if(O.section==="webhooks")return Df(e,{selectedId:Ni,categoryFilter:Eh,runFilter:Th,searchTerm:Ah,onSelectEvent:JS,onCategoryFilter:ZS,onRunFilter:QS,onSearch:eC,onSetControl:tC,onClear:Lg,onCopyJson:sC,onDismissDetail:iC});if(O.section==="costs")return $a||Rg(),Tf(c,{expandedRun:xa,tokenData:$h,onToggleRun:XS});if(O.section==="new-run")return uf(e,{rerender:j});if(O.section==="project-settings")return lf(e.preferences,{rerender:j,currentProjectId:e.currentProjectId||null});if(O.section==="settings")return af(e.preferences,{rerender:j,onThemeToggle:ES,onSaveSourceRepo:AS,onSaveNotifications:TS,onRequestPermission:()=>Uo.requestPermission(),projects:e.projects||[],onProjectAdd:l=>{l?.openDialog?(I.setState({addProjectDialogOpen:!0}),j()):l?.name&&fetch("/api/projects").then(h=>h.json()).then(h=>{I.setState({projects:h.projects||[]}),j()}).catch(()=>{})},onProjectRemove:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{I.setState({projects:l.projects||[]}),j()}).catch(()=>{})},onProjectsRefresh:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{I.setState({projects:l.projects||[]}),j()}).catch(()=>{})}});if(O.section==="history")return Cf(i,"history",{onSelectRun:Sa,onResume:vh,onArchive:bh,onUnarchive:NS,archivedRuns:n,statusFilter:wa,onStatusFilter:l=>{wa=l,j()}});if(O.section==="active"){let l=yt(i.filter(h=>h.active));return u`
5848
5848
  <h3 class="dashboard-section-title">Active Runs</h3>
5849
5849
  ${l.length>0?u`
5850
5850
  <div class="active-group">
@@ -5854,8 +5854,8 @@ ${mc}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Nn}
5854
5854
  </div>
5855
5855
  `:u`<div class="empty-state">No running pipelines</div>`}
5856
5856
  `}return u`
5857
- ${ld(c,{onSelectRun:l=>Ae("active",l,O.projectId),onArchive:bh,onNavigate:(l,h,d)=>{h&&typeof h=="object"&&h.statusFilter?(wa=h.statusFilter,Ae(l,null,O.projectId)):Ae(l,h||null,d||O.projectId)},onPause:xg,onResume:vh})}
5858
- ${ef(e.pipelines,{onPause:FS,onStop:HS,onResume:WS,onClick:l=>Ae("active",l,O.projectId)})}
5857
+ ${ld(c,{onSelectRun:l=>Oe("active",l,O.projectId),onArchive:bh,onNavigate:(l,h,d)=>{h&&typeof h=="object"&&h.statusFilter?(wa=h.statusFilter,Oe(l,null,O.projectId)):Oe(l,h||null,d||O.projectId)},onPause:xg,onResume:vh})}
5858
+ ${ef(e.pipelines,{onPause:FS,onStop:HS,onResume:WS,onClick:l=>Oe("active",l,O.projectId)})}
5859
5859
  `}function aC(e){let t=e.logLines;if(bt!=="*"&&(t=t.filter(s=>s.stage===bt)),Ca){let s=Ca.toLowerCase();t=t.filter(i=>(i.line||"").toLowerCase().includes(s))}return{...e,logLines:t}}function j(){let e=I.getState(),t=document.getElementById("app");t&&(Qo(u`
5860
5860
  <div class="app-shell">
5861
5861
  ${xf(e,O,Eg,{onNavigate:kS,onSelectRun:Sa,onProjectChange:$S,onAddProject:()=>{I.setState({addProjectDialogOpen:!0}),j()}})}