9remote 2.0.26 → 2.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +47 -47
- package/dist/server.cjs +57 -57
- package/dist/ui/assets/index-Casn8c07.css +1798 -0
- package/dist/ui/assets/index-DiqZaXWJ.js +18424 -0
- package/dist/ui/index.html +2 -2
- package/package.json +3 -2
- package/dist/ui/assets/index-BZm3GUhX.js +0 -47
- package/dist/ui/assets/index-UgZubVKT.css +0 -32
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();var Rs,fe,hl,Ht,ao,cl,dl,Us,es,Ai,ul,An,Rr,Ar,fs={},_s=[],Ih=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,As=Array.isArray;function Dt(e,t){for(var i in t)e[i]=t[i];return e}function Tn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Oh(e,t,i){var s,r,n,o={};for(n in t)n=="key"?s=t[n]:n=="ref"?r=t[n]:o[n]=t[n];if(arguments.length>2&&(o.children=arguments.length>3?Rs.call(arguments,2):i),typeof e=="function"&&e.defaultProps!=null)for(n in e.defaultProps)o[n]===void 0&&(o[n]=e.defaultProps[n]);return ts(e,o,s,r,null)}function ts(e,t,i,s,r){var n={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++hl,__i:-1,__u:0};return r==null&&fe.vnode!=null&&fe.vnode(n),n}function Be(e){return e.children}function is(e,t){this.props=e,this.context=t}function ci(e,t){if(t==null)return e.__?ci(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if((i=e.__k[t])!=null&&i.__e!=null)return i.__e;return typeof e.type=="function"?ci(e):null}function zh(e){if(e.__P&&e.__d){var t=e.__v,i=t.__e,s=[],r=[],n=Dt({},t);n.__v=t.__v+1,fe.vnode&&fe.vnode(n),Nn(e.__P,n,t,e.__n,e.__P.namespaceURI,32&t.__u?[i]:null,s,i??ci(t),!!(32&t.__u),r),n.__v=t.__v,n.__.__k[n.__i]=n,gl(s,n,r),t.__e=t.__=null,n.__e!=i&&fl(n)}}function fl(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),fl(e)}function lo(e){(!e.__d&&(e.__d=!0)&&Ht.push(e)&&!ps.__r++||ao!=fe.debounceRendering)&&((ao=fe.debounceRendering)||cl)(ps)}function ps(){try{for(var e,t=1;Ht.length;)Ht.length>t&&Ht.sort(dl),e=Ht.shift(),t=Ht.length,zh(e)}finally{Ht.length=ps.__r=0}}function _l(e,t,i,s,r,n,o,a,h,l,u){var f,c,_,p,g,y,m,E=s&&s.__k||_s,b=t.length;for(h=Hh(i,t,E,h,b),f=0;f<b;f++)(_=i.__k[f])!=null&&(c=_.__i!=-1&&E[_.__i]||fs,_.__i=f,y=Nn(e,_,c,r,n,o,a,h,l,u),p=_.__e,_.ref&&c.ref!=_.ref&&(c.ref&&Pn(c.ref,null,_),u.push(_.ref,_.__c||p,_)),g==null&&p!=null&&(g=p),(m=!!(4&_.__u))||c.__k===_.__k?(h=pl(_,h,e,m),m&&c.__e&&(c.__e=null)):typeof _.type=="function"&&y!==void 0?h=y:p&&(h=p.nextSibling),_.__u&=-7);return i.__e=g,h}function Hh(e,t,i,s,r){var n,o,a,h,l,u=i.length,f=u,c=0;for(e.__k=new Array(r),n=0;n<r;n++)(o=t[n])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[n]=ts(null,o,null,null,null):As(o)?o=e.__k[n]=ts(Be,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[n]=ts(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[n]=o,h=n+c,o.__=e,o.__b=e.__b+1,a=null,(l=o.__i=Wh(o,i,h,f))!=-1&&(f--,(a=i[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(r>u?c--:r<u&&c++),typeof o.type!="function"&&(o.__u|=4)):l!=h&&(l==h-1?c--:l==h+1?c++:(l>h?c--:c++,o.__u|=4))):e.__k[n]=null;if(f)for(n=0;n<u;n++)(a=i[n])!=null&&(2&a.__u)==0&&(a.__e==s&&(s=ci(a)),vl(a,a));return s}function pl(e,t,i,s){var r,n;if(typeof e.type=="function"){for(r=e.__k,n=0;r&&n<r.length;n++)r[n]&&(r[n].__=e,t=pl(r[n],t,i,s));return t}e.__e!=t&&(s&&(t&&e.type&&!t.parentNode&&(t=ci(e)),i.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Wh(e,t,i,s){var r,n,o,a=e.key,h=e.type,l=t[i],u=l!=null&&(2&l.__u)==0;if(l===null&&a==null||u&&a==l.key&&h==l.type)return i;if(s>(u?1:0)){for(r=i-1,n=i+1;r>=0||n<t.length;)if((l=t[o=r>=0?r--:n++])!=null&&(2&l.__u)==0&&a==l.key&&h==l.type)return o}return-1}function ho(e,t,i){t[0]=="-"?e.setProperty(t,i??""):e[t]=i==null?"":typeof i!="number"||Ih.test(t)?i:i+"px"}function Ui(e,t,i,s,r){var n,o;e:if(t=="style")if(typeof i=="string")e.style.cssText=i;else{if(typeof s=="string"&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||ho(e.style,t,"");if(i)for(t in i)s&&i[t]==s[t]||ho(e.style,t,i[t])}else if(t[0]=="o"&&t[1]=="n")n=t!=(t=t.replace(ul,"$1")),o=t.toLowerCase(),t=o in e||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+n]=i,i?s?i[Ai]=s[Ai]:(i[Ai]=An,e.addEventListener(t,n?Ar:Rr,n)):e.removeEventListener(t,n?Ar:Rr,n);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=i??"";break e}catch{}typeof i=="function"||(i==null||i===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&i==1?"":i))}}function co(e){return function(t){if(this.l){var i=this.l[t.type+e];if(t[es]==null)t[es]=An++;else if(t[es]<i[Ai])return;return i(fe.event?fe.event(t):t)}}}function Nn(e,t,i,s,r,n,o,a,h,l){var u,f,c,_,p,g,y,m,E,b,S,D,k,R,P,A,H=t.type;if(t.constructor!==void 0)return null;128&i.__u&&(h=!!(32&i.__u),n=[a=t.__e=i.__e]),(u=fe.__b)&&u(t);e:if(typeof H=="function"){f=o.length;try{if(E=t.props,b=H.prototype&&H.prototype.render,S=(u=H.contextType)&&s[u.__c],D=u?S?S.props.value:u.__:s,i.__c?m=(c=t.__c=i.__c).__=c.__E:(b?t.__c=c=new H(E,D):(t.__c=c=new is(E,D),c.constructor=H,c.render=Uh),S&&S.sub(c),c.state||(c.state={}),c.__n=s,_=c.__d=!0,c.__h=[],c._sb=[]),b&&c.__s==null&&(c.__s=c.state),b&&H.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Dt({},c.__s)),Dt(c.__s,H.getDerivedStateFromProps(E,c.__s))),p=c.props,g=c.state,c.__v=t,_)b&&H.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),b&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(b&&H.getDerivedStateFromProps==null&&E!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(E,D),t.__v==i.__v||!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(E,c.__s,D)===!1){t.__v!=i.__v&&(c.props=E,c.state=c.__s,c.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.some(function(C){C&&(C.__=t)}),_s.push.apply(c.__h,c._sb),c._sb=[],c.__h.length&&o.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(E,c.__s,D),b&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,y)})}if(c.context=D,c.props=E,c.__P=e,c.__e=!1,k=fe.__r,R=0,b)c.state=c.__s,c.__d=!1,k&&k(t),u=c.render(c.props,c.state,c.context),_s.push.apply(c.__h,c._sb),c._sb=[];else do c.__d=!1,k&&k(t),u=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++R<25);c.state=c.__s,c.getChildContext!=null&&(s=Dt(Dt({},s),c.getChildContext())),b&&!_&&c.getSnapshotBeforeUpdate!=null&&(y=c.getSnapshotBeforeUpdate(p,g)),P=u!=null&&u.type===Be&&u.key==null?ml(u.props.children):u,a=_l(e,As(P)?P:[P],t,i,s,r,n,o,a,h,l),c.base=t.__e,t.__u&=-161,c.__h.length&&o.push(c),m&&(c.__E=c.__=null)}catch(C){if(o.length=f,t.__v=null,h||n!=null)if(C.then){for(t.__u|=h?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;n!=null&&(n[n.indexOf(a)]=null),t.__e=a}else{if(n!=null)for(A=n.length;A--;)Tn(n[A]);Tr(t)}else t.__e=i.__e,!t.__k&&i.__k&&(t.__k=i.__k),C.then||Tr(t);fe.__e(C,t,i)}}else n==null&&t.__v==i.__v?(t.__k=i.__k,t.__e=i.__e):a=t.__e=Fh(i.__e,t,i,s,r,n,o,h,l);return(u=fe.diffed)&&u(t),128&t.__u?void 0:a}function Tr(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Tr))}function gl(e,t,i){for(var s=0;s<i.length;s++)Pn(i[s],i[++s],i[++s]);fe.__c&&fe.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(n){n.call(r)})}catch(n){fe.__e(n,r.__v)}})}function ml(e){return typeof e!="object"||e==null||e.__b>0?e:As(e)?e.map(ml):e.constructor!==void 0?null:Dt({},e)}function Fh(e,t,i,s,r,n,o,a,h){var l,u,f,c,_,p,g,y=i.props||fs,m=t.props,E=t.type;if(E=="svg"?r="http://www.w3.org/2000/svg":E=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),n!=null){for(l=0;l<n.length;l++)if((_=n[l])&&"setAttribute"in _==!!E&&(E?_.localName==E:_.nodeType==3)){e=_,n[l]=null;break}}if(e==null){if(E==null)return document.createTextNode(m);e=document.createElementNS(r,E,m.is&&m),a&&(fe.__m&&fe.__m(t,n),a=!1),n=null}if(E==null)y===m||a&&e.data==m||(e.data=m);else{if(n=E=="textarea"&&m.defaultValue!=null?null:n&&Rs.call(e.childNodes),!a&&n!=null)for(y={},l=0;l<e.attributes.length;l++)y[(_=e.attributes[l]).name]=_.value;for(l in y)_=y[l],l=="dangerouslySetInnerHTML"?f=_:l=="children"||l in m||l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m||Ui(e,l,null,_,r);for(l in m)_=m[l],l=="children"?c=_:l=="dangerouslySetInnerHTML"?u=_:l=="value"?p=_:l=="checked"?g=_:a&&typeof _!="function"||y[l]===_||Ui(e,l,_,y[l],r);if(u)a||f&&(u.__html==f.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(f&&(e.innerHTML=""),_l(t.type=="template"?e.content:e,As(c)?c:[c],t,i,s,E=="foreignObject"?"http://www.w3.org/1999/xhtml":r,n,o,n?n[0]:i.__k&&ci(i,0),a,h),n!=null)for(l=n.length;l--;)Tn(n[l]);a&&E!="textarea"||(l="value",E=="progress"&&p==null?e.removeAttribute("value"):p!=null&&(p!==e[l]||E=="progress"&&!p||E=="option"&&p!=y[l])&&Ui(e,l,p,y[l],r),l="checked",g!=null&&g!=e[l]&&Ui(e,l,g,y[l],r))}return e}function Pn(e,t,i){try{if(typeof e=="function"){var s=typeof e.__u=="function";s&&e.__u(),s&&t==null||(e.__u=e(t))}else e.current=t}catch(r){fe.__e(r,i)}}function vl(e,t,i){var s,r;if(fe.unmount&&fe.unmount(e),(s=e.ref)&&(s.current&&s.current!=e.__e||Pn(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(n){fe.__e(n,t)}s.base=s.__P=s.__n=null}if(s=e.__k)for(r=0;r<s.length;r++)s[r]&&vl(s[r],t,i||typeof e.type!="function");i||Tn(e.__e),e.__c=e.__=e.__e=void 0}function Uh(e,t,i){return this.constructor(e,i)}function qh(e,t,i){var s,r,n,o;t==document&&(t=document.documentElement),fe.__&&fe.__(e,t),r=(s=!1)?null:t.__k,n=[],o=[],Nn(t,e=t.__k=Oh(Be,null,[e]),r||fs,fs,t.namespaceURI,r?null:t.firstChild?Rs.call(t.childNodes):null,n,r?r.__e:t.firstChild,s,o),gl(n,e,o),e.props.children=null}Rs=_s.slice,fe={__e:function(e,t,i,s){for(var r,n,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&n.getDerivedStateFromError!=null&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,s||{}),o=r.__d),o)return r.__E=r}catch(a){e=a}throw e}},hl=0,is.prototype.setState=function(e,t){var i;i=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Dt({},this.state),typeof e=="function"&&(e=e(Dt({},i),this.props)),e&&Dt(i,e),e!=null&&this.__v&&(t&&this._sb.push(t),lo(this))},is.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),lo(this))},is.prototype.render=Be,Ht=[],cl=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,dl=function(e,t){return e.__v.__b-t.__v.__b},ps.__r=0,Us=Math.random().toString(8),es="__d"+Us,Ai="__a"+Us,ul=/(PointerCapture)$|Capture$/i,An=0,Rr=co(!1),Ar=co(!0);var Kh=0;function d(e,t,i,s,r,n){t||(t={});var o,a,h=t;if("ref"in h)for(a in h={},t)a=="ref"?o=t[a]:h[a]=t[a];var l={type:e,props:h,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Kh,__i:-1,__u:0,__source:r,__self:n};if(typeof e=="function"&&(o=e.defaultProps))for(a in o)h[a]===void 0&&(h[a]=o[a]);return fe.vnode&&fe.vnode(l),l}var Ni,Le,qs,uo,gs=0,yl=[],De=fe,fo=De.__b,_o=De.__r,po=De.diffed,go=De.__c,mo=De.unmount,vo=De.__;function In(e,t){De.__h&&De.__h(Le,e,gs||t),gs=0;var i=Le.__H||(Le.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function K(e){return gs=1,$h(wl,e)}function $h(e,t,i){var s=In(Ni++,2);if(s.t=e,!s.__c&&(s.__=[wl(void 0,t),function(a){var h=s.__N?s.__N[0]:s.__[0],l=s.t(h,a);h!==l&&(s.__N=[l,s.__[1]],s.__c.setState({}))}],s.__c=Le,!Le.__f)){var r=function(a,h,l){if(!s.__c.__H)return!0;var u=!1,f=s.__c.props!==a;if(s.__c.__H.__.some(function(_){if(_.__N){u=!0;var p=_.__[0];_.__=_.__N,_.__N=void 0,p!==_.__[0]&&(f=!0)}}),n){var c=n.call(this,a,h,l);return u?c||f:c}return!u||f};Le.__f=!0;var n=Le.shouldComponentUpdate,o=Le.componentWillUpdate;Le.componentWillUpdate=function(a,h,l){if(this.__e){var u=n;n=void 0,r(a,h,l),n=u}o&&o.call(this,a,h,l)},Le.shouldComponentUpdate=r}return s.__N||s.__}function ce(e,t){var i=In(Ni++,3);!De.__s&&Sl(i.__H,t)&&(i.__=e,i.u=t,Le.__H.__h.push(i))}function $e(e){return gs=5,Vh(function(){return{current:e}},[])}function Vh(e,t){var i=In(Ni++,7);return Sl(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function yo(){for(var e;e=yl.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Nr),t.__h.some(bl),t.__h=[]}catch(i){t.__h=[],De.__e(i,e.__v)}}}De.__b=function(e){Le=null,fo&&fo(e)},De.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),vo&&vo(e,t)},De.__r=function(e){_o&&_o(e),Ni=0;var t=(Le=e.__c).__H;t&&(qs===Le?(t.__h=[],Le.__h=[],t.__.some(function(i){i.__N&&(i.__=i.__N),i.u=i.__N=void 0})):(t.__h.length&&yo(),Ni=0)),qs=Le},De.diffed=function(e){po&&po(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(yl.push(t)!==1&&uo===De.requestAnimationFrame||((uo=De.requestAnimationFrame)||jh)(yo)),t.__H.__.some(function(i){i.u&&(i.__H=i.u,i.u=void 0)})),qs=Le=null},De.__c=function(e,t){t.some(function(i){try{i.__h.some(Nr),i.__h=i.__h.filter(function(s){return!s.__||bl(s)})}catch(s){t.some(function(r){r.__h&&(r.__h=[])}),t=[],De.__e(s,i.__v)}}),go&&go(e,t)},De.unmount=function(e){mo&&mo(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.some(function(s){try{Nr(s)}catch(r){t=r}}),i.__H=void 0,t&&De.__e(t,i.__v))};var bo=typeof requestAnimationFrame=="function";function jh(e){var t,i=function(){clearTimeout(s),bo&&cancelAnimationFrame(t),setTimeout(e)},s=setTimeout(i,35);bo&&(t=requestAnimationFrame(i))}function Nr(e){var t=Le,i=e.__c;typeof i=="function"&&(e.__c=void 0,i()),Le=t}function bl(e){var t=Le;e.__c=e.__(),Le=t}function Sl(e,t){return!e||e.length!==t.length||t.some(function(i,s){return i!==e[s]})}function wl(e,t){return typeof t=="function"?t(e):t}const Gh=e=>[{icon:"download",label:e("steps.preparing"),desc:e("steps.checkingTunnel")},{icon:"cloud_sync",label:e("steps.connecting"),desc:e("steps.creatingSession")},{icon:"lan",label:e("steps.tunneling"),desc:e("steps.startingTunnel")},{icon:"verified",label:e("steps.verifying"),desc:e("steps.healthCheck")},{icon:"check_circle",label:e("steps.ready"),desc:e("steps.connected")}],Yh=3;function Jh({currentStep:e,activeDesc:t="",healthCheck:i,t:s}){var a;const r=e-1,n=(a=i==null?void 0:i.logs)!=null&&a.length?i.logs[i.logs.length-1]:null,o=Gh(s);return d("div",{className:"glass-card p-5 flex flex-col gap-4",children:[d("span",{className:"text-xs font-medium uppercase tracking-wider",style:{color:"var(--text-muted)"},children:s("steps.setupConnection")}),d("div",{className:"flex flex-col gap-3",children:o.map((h,l)=>{const u=l<r,f=l===r,c=f&&l===Yh;let _=f&&t?t:h.desc,p="var(--text-muted)";if(c&&n){const g=/^\d{3}$/.test(String(n.status));_=`#${n.attempt} → ${n.status}`,p=n.ok||n.waiting?"#22c55e":g?"#eab308":"#ef4444"}return d("div",{className:"flex items-center gap-3",children:[d("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{background:u?"var(--brand-500)":f?"rgba(255,87,10,0.15)":"var(--glass-bg)",border:f?"1.5px solid var(--brand-500)":"1.5px solid transparent"},children:u?d("span",{className:"material-symbols-outlined text-white",style:{fontSize:16},children:"check"}):f?d("span",{className:"flex gap-0.5 items-center",children:[0,1,2].map(g=>d("span",{className:"w-1 h-1 rounded-full bg-orange-400 dot-bounce",style:{animationDelay:`${g*.18}s`}},g))}):d("span",{className:"material-symbols-outlined",style:{fontSize:16,color:"var(--text-muted)",opacity:.3},children:h.icon})}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-sm font-medium",style:{color:u?"var(--text-muted)":f?"var(--text-main)":"var(--text-muted)",opacity:u||f?1:.4},children:h.label}),d("p",{className:"text-xs mt-0.5 truncate",style:{color:p,opacity:f?c&&n?.95:.7:.4,fontFamily:c&&n?"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace":void 0},children:_})]}),u&&d("span",{className:"text-xs flex-shrink-0",style:{color:"var(--text-muted)"},children:s("steps.done")}),f&&d("span",{className:"text-xs flex-shrink-0 px-2 py-0.5 rounded-full",style:{background:"rgba(255,87,10,0.15)",color:"var(--brand-400)"},children:s("steps.running")})]},l)})})]})}function Zh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ri={},Ks,So;function Xh(){return So||(So=1,Ks=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ks}var $s={},Nt={},wo;function Qt(){if(wo)return Nt;wo=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Nt.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Nt.getSymbolTotalCodewords=function(s){return t[s]},Nt.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Nt.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Nt.isKanjiModeEnabled=function(){return typeof e<"u"},Nt.toSJIS=function(s){return e(s)},Nt}var Vs={},xo;function On(){return xo||(xo=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,r){if(e.isValid(s))return s;try{return t(s)}catch{return r}}})(Vs)),Vs}var js,Co;function Qh(){if(Co)return js;Co=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},js=e,js}var Gs,ko;function ec(){if(ko)return Gs;ko=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,r){const n=t*this.size+i;this.data[n]=s,r&&(this.reservedBit[n]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},Gs=e,Gs}var Ys={},Eo;function tc(){return Eo||(Eo=1,(function(e){const t=Qt().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const r=Math.floor(s/7)+2,n=t(s),o=n===145?26:Math.ceil((n-13)/(2*r-2))*2,a=[n-7];for(let h=1;h<r-1;h++)a[h]=a[h-1]-o;return a.push(6),a.reverse()},e.getPositions=function(s){const r=[],n=e.getRowColCoords(s),o=n.length;for(let a=0;a<o;a++)for(let h=0;h<o;h++)a===0&&h===0||a===0&&h===o-1||a===o-1&&h===0||r.push([n[a],n[h]]);return r}})(Ys)),Ys}var Js={},Bo;function ic(){if(Bo)return Js;Bo=1;const e=Qt().getSymbolSize,t=7;return Js.getPositions=function(s){const r=e(s);return[[0,0],[r-t,0],[0,r-t]]},Js}var Zs={},Lo;function sc(){return Lo||(Lo=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const n=r.size;let o=0,a=0,h=0,l=null,u=null;for(let f=0;f<n;f++){a=h=0,l=u=null;for(let c=0;c<n;c++){let _=r.get(f,c);_===l?a++:(a>=5&&(o+=t.N1+(a-5)),l=_,a=1),_=r.get(c,f),_===u?h++:(h>=5&&(o+=t.N1+(h-5)),u=_,h=1)}a>=5&&(o+=t.N1+(a-5)),h>=5&&(o+=t.N1+(h-5))}return o},e.getPenaltyN2=function(r){const n=r.size;let o=0;for(let a=0;a<n-1;a++)for(let h=0;h<n-1;h++){const l=r.get(a,h)+r.get(a,h+1)+r.get(a+1,h)+r.get(a+1,h+1);(l===4||l===0)&&o++}return o*t.N2},e.getPenaltyN3=function(r){const n=r.size;let o=0,a=0,h=0;for(let l=0;l<n;l++){a=h=0;for(let u=0;u<n;u++)a=a<<1&2047|r.get(l,u),u>=10&&(a===1488||a===93)&&o++,h=h<<1&2047|r.get(u,l),u>=10&&(h===1488||h===93)&&o++}return o*t.N3},e.getPenaltyN4=function(r){let n=0;const o=r.data.length;for(let h=0;h<o;h++)n+=r.data[h];return Math.abs(Math.ceil(n*100/o/5)-10)*t.N4};function i(s,r,n){switch(s){case e.Patterns.PATTERN000:return(r+n)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return n%3===0;case e.Patterns.PATTERN011:return(r+n)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case e.Patterns.PATTERN101:return r*n%2+r*n%3===0;case e.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case e.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(r,n){const o=n.size;for(let a=0;a<o;a++)for(let h=0;h<o;h++)n.isReserved(h,a)||n.xor(h,a,i(r,h,a))},e.getBestMask=function(r,n){const o=Object.keys(e.Patterns).length;let a=0,h=1/0;for(let l=0;l<o;l++){n(l),e.applyMask(l,r);const u=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(l,r),u<h&&(h=u,a=l)}return a}})(Zs)),Zs}var qi={},Mo;function xl(){if(Mo)return qi;Mo=1;const e=On(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return qi.getBlocksCount=function(r,n){switch(n){case e.L:return t[(r-1)*4+0];case e.M:return t[(r-1)*4+1];case e.Q:return t[(r-1)*4+2];case e.H:return t[(r-1)*4+3];default:return}},qi.getTotalCodewordsCount=function(r,n){switch(n){case e.L:return i[(r-1)*4+0];case e.M:return i[(r-1)*4+1];case e.Q:return i[(r-1)*4+2];case e.H:return i[(r-1)*4+3];default:return}},qi}var Xs={},gi={},Do;function rc(){if(Do)return gi;Do=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let r=0;r<255;r++)e[r]=s,t[s]=r,s<<=1,s&256&&(s^=285);for(let r=255;r<512;r++)e[r]=e[r-255]})(),gi.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},gi.exp=function(s){return e[s]},gi.mul=function(s,r){return s===0||r===0?0:e[t[s]+t[r]]},gi}var Ro;function nc(){return Ro||(Ro=1,(function(e){const t=rc();e.mul=function(s,r){const n=new Uint8Array(s.length+r.length-1);for(let o=0;o<s.length;o++)for(let a=0;a<r.length;a++)n[o+a]^=t.mul(s[o],r[a]);return n},e.mod=function(s,r){let n=new Uint8Array(s);for(;n.length-r.length>=0;){const o=n[0];for(let h=0;h<r.length;h++)n[h]^=t.mul(r[h],o);let a=0;for(;a<n.length&&n[a]===0;)a++;n=n.slice(a)}return n},e.generateECPolynomial=function(s){let r=new Uint8Array([1]);for(let n=0;n<s;n++)r=e.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(Xs)),Xs}var Qs,Ao;function oc(){if(Ao)return Qs;Ao=1;const e=nc();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(s.length+this.degree);r.set(s);const n=e.mod(r,this.genPoly),o=this.degree-n.length;if(o>0){const a=new Uint8Array(this.degree);return a.set(n,o),a}return n},Qs=t,Qs}var er={},tr={},ir={},To;function Cl(){return To||(To=1,ir.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),ir}var gt={},No;function kl(){if(No)return gt;No=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
2
|
-
]))+`;gt.KANJI=new RegExp(i,"g"),gt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),gt.BYTE=new RegExp(s,"g"),gt.NUMERIC=new RegExp(e,"g"),gt.ALPHANUMERIC=new RegExp(t,"g");const r=new RegExp("^"+i+"$"),n=new RegExp("^"+e+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return gt.testKanji=function(h){return r.test(h)},gt.testNumeric=function(h){return n.test(h)},gt.testAlphanumeric=function(h){return o.test(h)},gt}var Po;function ei(){return Po||(Po=1,(function(e){const t=Cl(),i=kl();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(n,o){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?n.ccBits[0]:o<27?n.ccBits[1]:n.ccBits[2]},e.getBestModeForData=function(n){return i.testNumeric(n)?e.NUMERIC:i.testAlphanumeric(n)?e.ALPHANUMERIC:i.testKanji(n)?e.KANJI:e.BYTE},e.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},e.isValid=function(n){return n&&n.bit&&n.ccBits};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(n,o){if(e.isValid(n))return n;try{return s(n)}catch{return o}}})(tr)),tr}var Io;function ac(){return Io||(Io=1,(function(e){const t=Qt(),i=xl(),s=On(),r=ei(),n=Cl(),o=7973,a=t.getBCHDigit(o);function h(c,_,p){for(let g=1;g<=40;g++)if(_<=e.getCapacity(g,p,c))return g}function l(c,_){return r.getCharCountIndicator(c,_)+4}function u(c,_){let p=0;return c.forEach(function(g){const y=l(g.mode,_);p+=y+g.getBitsLength()}),p}function f(c,_){for(let p=1;p<=40;p++)if(u(c,p)<=e.getCapacity(p,_,r.MIXED))return p}e.from=function(_,p){return n.isValid(_)?parseInt(_,10):p},e.getCapacity=function(_,p,g){if(!n.isValid(_))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=r.BYTE);const y=t.getSymbolTotalCodewords(_),m=i.getTotalCodewordsCount(_,p),E=(y-m)*8;if(g===r.MIXED)return E;const b=E-l(g,_);switch(g){case r.NUMERIC:return Math.floor(b/10*3);case r.ALPHANUMERIC:return Math.floor(b/11*2);case r.KANJI:return Math.floor(b/13);case r.BYTE:default:return Math.floor(b/8)}},e.getBestVersionForData=function(_,p){let g;const y=s.from(p,s.M);if(Array.isArray(_)){if(_.length>1)return f(_,y);if(_.length===0)return 1;g=_[0]}else g=_;return h(g.mode,g.getLength(),y)},e.getEncodedBits=function(_){if(!n.isValid(_)||_<7)throw new Error("Invalid QR Code version");let p=_<<12;for(;t.getBCHDigit(p)-a>=0;)p^=o<<t.getBCHDigit(p)-a;return _<<12|p}})(er)),er}var sr={},Oo;function lc(){if(Oo)return sr;Oo=1;const e=Qt(),t=1335,i=21522,s=e.getBCHDigit(t);return sr.getEncodedBits=function(n,o){const a=n.bit<<3|o;let h=a<<10;for(;e.getBCHDigit(h)-s>=0;)h^=t<<e.getBCHDigit(h)-s;return(a<<10|h)^i},sr}var rr={},nr,zo;function hc(){if(zo)return nr;zo=1;const e=ei();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let r,n,o;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),o=parseInt(n,10),s.put(o,10);const a=this.data.length-r;a>0&&(n=this.data.substr(r),o=parseInt(n,10),s.put(o,a*3+1))},nr=t,nr}var or,Ho;function cc(){if(Ho)return or;Ho=1;const e=ei(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let o=t.indexOf(this.data[n])*45;o+=t.indexOf(this.data[n+1]),r.put(o,11)}this.data.length%2&&r.put(t.indexOf(this.data[n]),6)},or=i,or}var ar,Wo;function dc(){if(Wo)return ar;Wo=1;const e=ei();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,r=this.data.length;s<r;s++)i.put(this.data[s],8)},ar=t,ar}var lr,Fo;function uc(){if(Fo)return lr;Fo=1;const e=ei(),t=Qt();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(r){return r*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let r;for(r=0;r<this.data.length;r++){let n=t.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
|
|
3
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),s.put(n,13)}},lr=i,lr}var hr={exports:{}},Uo;function fc(){return Uo||(Uo=1,(function(e){var t={single_source_shortest_paths:function(i,s,r){var n={},o={};o[s]=0;var a=t.PriorityQueue.make();a.push(s,0);for(var h,l,u,f,c,_,p,g,y;!a.empty();){h=a.pop(),l=h.value,f=h.cost,c=i[l]||{};for(u in c)c.hasOwnProperty(u)&&(_=c[u],p=f+_,g=o[u],y=typeof o[u]>"u",(y||g>p)&&(o[u]=p,a.push(u,p),n[u]=l))}if(typeof r<"u"&&typeof o[r]>"u"){var m=["Could not find a path from ",s," to ",r,"."].join("");throw new Error(m)}return n},extract_shortest_path_from_predecessor_list:function(i,s){for(var r=[],n=s;n;)r.push(n),i[n],n=i[n];return r.reverse(),r},find_path:function(i,s,r){var n=t.single_source_shortest_paths(i,s,r);return t.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,r={},n;i=i||{};for(n in s)s.hasOwnProperty(n)&&(r[n]=s[n]);return r.queue=[],r.sorter=i.sorter||s.default_sorter,r},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var r={value:i,cost:s};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(hr)),hr.exports}var qo;function _c(){return qo||(qo=1,(function(e){const t=ei(),i=hc(),s=cc(),r=dc(),n=uc(),o=kl(),a=Qt(),h=fc();function l(m){return unescape(encodeURIComponent(m)).length}function u(m,E,b){const S=[];let D;for(;(D=m.exec(b))!==null;)S.push({data:D[0],index:D.index,mode:E,length:D[0].length});return S}function f(m){const E=u(o.NUMERIC,t.NUMERIC,m),b=u(o.ALPHANUMERIC,t.ALPHANUMERIC,m);let S,D;return a.isKanjiModeEnabled()?(S=u(o.BYTE,t.BYTE,m),D=u(o.KANJI,t.KANJI,m)):(S=u(o.BYTE_KANJI,t.BYTE,m),D=[]),E.concat(b,S,D).sort(function(R,P){return R.index-P.index}).map(function(R){return{data:R.data,mode:R.mode,length:R.length}})}function c(m,E){switch(E){case t.NUMERIC:return i.getBitsLength(m);case t.ALPHANUMERIC:return s.getBitsLength(m);case t.KANJI:return n.getBitsLength(m);case t.BYTE:return r.getBitsLength(m)}}function _(m){return m.reduce(function(E,b){const S=E.length-1>=0?E[E.length-1]:null;return S&&S.mode===b.mode?(E[E.length-1].data+=b.data,E):(E.push(b),E)},[])}function p(m){const E=[];for(let b=0;b<m.length;b++){const S=m[b];switch(S.mode){case t.NUMERIC:E.push([S,{data:S.data,mode:t.ALPHANUMERIC,length:S.length},{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.ALPHANUMERIC:E.push([S,{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.KANJI:E.push([S,{data:S.data,mode:t.BYTE,length:l(S.data)}]);break;case t.BYTE:E.push([{data:S.data,mode:t.BYTE,length:l(S.data)}])}}return E}function g(m,E){const b={},S={start:{}};let D=["start"];for(let k=0;k<m.length;k++){const R=m[k],P=[];for(let A=0;A<R.length;A++){const H=R[A],C=""+k+A;P.push(C),b[C]={node:H,lastCount:0},S[C]={};for(let w=0;w<D.length;w++){const v=D[w];b[v]&&b[v].node.mode===H.mode?(S[v][C]=c(b[v].lastCount+H.length,H.mode)-c(b[v].lastCount,H.mode),b[v].lastCount+=H.length):(b[v]&&(b[v].lastCount=H.length),S[v][C]=c(H.length,H.mode)+4+t.getCharCountIndicator(H.mode,E))}}D=P}for(let k=0;k<D.length;k++)S[D[k]].end=0;return{map:S,table:b}}function y(m,E){let b;const S=t.getBestModeForData(m);if(b=t.from(E,S),b!==t.BYTE&&b.bit<S.bit)throw new Error('"'+m+'" cannot be encoded with mode '+t.toString(b)+`.
|
|
4
|
-
Suggested mode is: `+t.toString(S));switch(b===t.KANJI&&!a.isKanjiModeEnabled()&&(b=t.BYTE),b){case t.NUMERIC:return new i(m);case t.ALPHANUMERIC:return new s(m);case t.KANJI:return new n(m);case t.BYTE:return new r(m)}}e.fromArray=function(E){return E.reduce(function(b,S){return typeof S=="string"?b.push(y(S,null)):S.data&&b.push(y(S.data,S.mode)),b},[])},e.fromString=function(E,b){const S=f(E,a.isKanjiModeEnabled()),D=p(S),k=g(D,b),R=h.find_path(k.map,"start","end"),P=[];for(let A=1;A<R.length-1;A++)P.push(k.table[R[A]].node);return e.fromArray(_(P))},e.rawSplit=function(E){return e.fromArray(f(E,a.isKanjiModeEnabled()))}})(rr)),rr}var Ko;function pc(){if(Ko)return $s;Ko=1;const e=Qt(),t=On(),i=Qh(),s=ec(),r=tc(),n=ic(),o=sc(),a=xl(),h=oc(),l=ac(),u=lc(),f=ei(),c=_c();function _(k,R){const P=k.size,A=n.getPositions(R);for(let H=0;H<A.length;H++){const C=A[H][0],w=A[H][1];for(let v=-1;v<=7;v++)if(!(C+v<=-1||P<=C+v))for(let x=-1;x<=7;x++)w+x<=-1||P<=w+x||(v>=0&&v<=6&&(x===0||x===6)||x>=0&&x<=6&&(v===0||v===6)||v>=2&&v<=4&&x>=2&&x<=4?k.set(C+v,w+x,!0,!0):k.set(C+v,w+x,!1,!0))}}function p(k){const R=k.size;for(let P=8;P<R-8;P++){const A=P%2===0;k.set(P,6,A,!0),k.set(6,P,A,!0)}}function g(k,R){const P=r.getPositions(R);for(let A=0;A<P.length;A++){const H=P[A][0],C=P[A][1];for(let w=-2;w<=2;w++)for(let v=-2;v<=2;v++)w===-2||w===2||v===-2||v===2||w===0&&v===0?k.set(H+w,C+v,!0,!0):k.set(H+w,C+v,!1,!0)}}function y(k,R){const P=k.size,A=l.getEncodedBits(R);let H,C,w;for(let v=0;v<18;v++)H=Math.floor(v/3),C=v%3+P-8-3,w=(A>>v&1)===1,k.set(H,C,w,!0),k.set(C,H,w,!0)}function m(k,R,P){const A=k.size,H=u.getEncodedBits(R,P);let C,w;for(C=0;C<15;C++)w=(H>>C&1)===1,C<6?k.set(C,8,w,!0):C<8?k.set(C+1,8,w,!0):k.set(A-15+C,8,w,!0),C<8?k.set(8,A-C-1,w,!0):C<9?k.set(8,15-C-1+1,w,!0):k.set(8,15-C-1,w,!0);k.set(A-8,8,1,!0)}function E(k,R){const P=k.size;let A=-1,H=P-1,C=7,w=0;for(let v=P-1;v>0;v-=2)for(v===6&&v--;;){for(let x=0;x<2;x++)if(!k.isReserved(H,v-x)){let M=!1;w<R.length&&(M=(R[w]>>>C&1)===1),k.set(H,v-x,M),C--,C===-1&&(w++,C=7)}if(H+=A,H<0||P<=H){H-=A,A=-A;break}}}function b(k,R,P){const A=new i;P.forEach(function(x){A.put(x.mode.bit,4),A.put(x.getLength(),f.getCharCountIndicator(x.mode,k)),x.write(A)});const H=e.getSymbolTotalCodewords(k),C=a.getTotalCodewordsCount(k,R),w=(H-C)*8;for(A.getLengthInBits()+4<=w&&A.put(0,4);A.getLengthInBits()%8!==0;)A.putBit(0);const v=(w-A.getLengthInBits())/8;for(let x=0;x<v;x++)A.put(x%2?17:236,8);return S(A,k,R)}function S(k,R,P){const A=e.getSymbolTotalCodewords(R),H=a.getTotalCodewordsCount(R,P),C=A-H,w=a.getBlocksCount(R,P),v=A%w,x=w-v,M=Math.floor(A/w),z=Math.floor(C/w),U=z+1,T=M-z,Z=new h(T);let ne=0;const pe=new Array(w),we=new Array(w);let _e=0;const oe=new Uint8Array(k.buffer);for(let re=0;re<w;re++){const je=re<x?z:U;pe[re]=oe.slice(ne,ne+je),we[re]=Z.encode(pe[re]),ne+=je,_e=Math.max(_e,je)}const W=new Uint8Array(A);let ee=0,V,de;for(V=0;V<_e;V++)for(de=0;de<w;de++)V<pe[de].length&&(W[ee++]=pe[de][V]);for(V=0;V<T;V++)for(de=0;de<w;de++)W[ee++]=we[de][V];return W}function D(k,R,P,A){let H;if(Array.isArray(k))H=c.fromArray(k);else if(typeof k=="string"){let M=R;if(!M){const z=c.rawSplit(k);M=l.getBestVersionForData(z,P)}H=c.fromString(k,M||40)}else throw new Error("Invalid data");const C=l.getBestVersionForData(H,P);if(!C)throw new Error("The amount of data is too big to be stored in a QR Code");if(!R)R=C;else if(R<C)throw new Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+C+`.
|
|
7
|
-
`);const w=b(R,P,H),v=e.getSymbolSize(R),x=new s(v);return _(x,R),p(x),g(x,R),m(x,P,0),R>=7&&y(x,R),E(x,w),isNaN(A)&&(A=o.getBestMask(x,m.bind(null,x,P))),o.applyMask(A,x),m(x,P,A),{modules:x,version:R,errorCorrectionLevel:P,maskPattern:A,segments:H}}return $s.create=function(R,P){if(typeof R>"u"||R==="")throw new Error("No input text");let A=t.M,H,C;return typeof P<"u"&&(A=t.from(P.errorCorrectionLevel,t.M),H=l.from(P.version),C=o.from(P.maskPattern),P.toSJISFunc&&e.setToSJISFunction(P.toSJISFunc)),D(R,H,A,C)},$s}var cr={},dr={},$o;function El(){return $o||($o=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(n){return[n,n]}))),s.length===6&&s.push("F","F");const r=parseInt(s.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const r=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,n=s.width&&s.width>=21?s.width:void 0,o=s.scale||4;return{width:n,scale:n?4:o,margin:r,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,r){return r.width&&r.width>=s+r.margin*2?r.width/(s+r.margin*2):r.scale},e.getImageWidth=function(s,r){const n=e.getScale(s,r);return Math.floor((s+r.margin*2)*n)},e.qrToImageData=function(s,r,n){const o=r.modules.size,a=r.modules.data,h=e.getScale(o,n),l=Math.floor((o+n.margin*2)*h),u=n.margin*h,f=[n.color.light,n.color.dark];for(let c=0;c<l;c++)for(let _=0;_<l;_++){let p=(c*l+_)*4,g=n.color.light;if(c>=u&&_>=u&&c<l-u&&_<l-u){const y=Math.floor((c-u)/h),m=Math.floor((_-u)/h);g=f[a[y*o+m]?1:0]}s[p++]=g.r,s[p++]=g.g,s[p++]=g.b,s[p]=g.a}}})(dr)),dr}var Vo;function gc(){return Vo||(Vo=1,(function(e){const t=El();function i(r,n,o){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=o,n.width=o,n.style.height=o+"px",n.style.width=o+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(n,o,a){let h=a,l=o;typeof h>"u"&&(!o||!o.getContext)&&(h=o,o=void 0),o||(l=s()),h=t.getOptions(h);const u=t.getImageWidth(n.modules.size,h),f=l.getContext("2d"),c=f.createImageData(u,u);return t.qrToImageData(c.data,n,h),i(f,l,u),f.putImageData(c,0,0),l},e.renderToDataURL=function(n,o,a){let h=a;typeof h>"u"&&(!o||!o.getContext)&&(h=o,o=void 0),h||(h={});const l=e.render(n,o,h),u=h.type||"image/png",f=h.rendererOpts||{};return l.toDataURL(u,f.quality)}})(cr)),cr}var ur={},jo;function mc(){if(jo)return ur;jo=1;const e=El();function t(r,n){const o=r.a/255,a=n+'="'+r.hex+'"';return o<1?a+" "+n+'-opacity="'+o.toFixed(2).slice(1)+'"':a}function i(r,n,o){let a=r+n;return typeof o<"u"&&(a+=" "+o),a}function s(r,n,o){let a="",h=0,l=!1,u=0;for(let f=0;f<r.length;f++){const c=Math.floor(f%n),_=Math.floor(f/n);!c&&!l&&(l=!0),r[f]?(u++,f>0&&c>0&&r[f-1]||(a+=l?i("M",c+o,.5+_+o):i("m",h,0),h=0,l=!1),c+1<n&&r[f+1]||(a+=i("h",u),u=0)):h++}return a}return ur.render=function(n,o,a){const h=e.getOptions(o),l=n.modules.size,u=n.modules.data,f=l+h.margin*2,c=h.color.light.a?"<path "+t(h.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",_="<path "+t(h.color.dark,"stroke")+' d="'+s(u,l,h.margin)+'"/>',p='viewBox="0 0 '+f+" "+f+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+p+' shape-rendering="crispEdges">'+c+_+`</svg>
|
|
8
|
-
`;return typeof a=="function"&&a(null,y),y},ur}var Go;function vc(){if(Go)return ri;Go=1;const e=Xh(),t=pc(),i=gc(),s=mc();function r(n,o,a,h,l){const u=[].slice.call(arguments,1),f=u.length,c=typeof u[f-1]=="function";if(!c&&!e())throw new Error("Callback required as last argument");if(c){if(f<2)throw new Error("Too few arguments provided");f===2?(l=a,a=o,o=h=void 0):f===3&&(o.getContext&&typeof l>"u"?(l=h,h=void 0):(l=h,h=a,a=o,o=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(a=o,o=h=void 0):f===2&&!o.getContext&&(h=a,a=o,o=void 0),new Promise(function(_,p){try{const g=t.create(a,h);_(n(g,o,h))}catch(g){p(g)}})}try{const _=t.create(a,h);l(null,n(_,o,h))}catch(_){l(_)}}return ri.create=t.create,ri.toCanvas=r.bind(null,i.render),ri.toDataURL=r.bind(null,i.renderToDataURL),ri.toString=r.bind(null,function(n,o,a){return s.render(n,a)}),ri}var yc=vc();const bc=Zh(yc);function Ft({message:e,confirmLabel:t="Confirm",confirmDanger:i=!1,inputValue:s,onInput:r,inputPlaceholder:n="",onConfirm:o,onCancel:a}){const h=r!==void 0,l=$e(null);return ce(()=>{var u;(u=l.current)==null||u.focus()},[]),d("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},onClick:a,children:d("div",{className:"glass-card p-5 flex flex-col gap-4 w-72",onClick:u=>u.stopPropagation(),children:[d("p",{className:"text-sm text-center",style:{color:"var(--text-main)"},children:e}),h&&d("input",{ref:l,value:s,placeholder:n,onInput:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&o(),className:"w-full px-3 py-2 text-sm rounded-xl",style:{background:"var(--glass-bg)",color:"var(--text-main)",border:"1px solid var(--border)"}}),d("div",{className:"flex gap-2",children:[d("button",{onClick:a,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Cancel"}),d("button",{onClick:o,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:i?"rgba(220,53,69,0.8)":"var(--brand-500)",color:"#fff"},children:t})]})]})})}const Yo="9remote.cc";function Sc(e){if(e<=0)return"Expired";const t=Math.floor(e/1e3),i=Math.floor(t/60),s=t%60;return`${String(i).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Ki({icon:e,onClick:t,title:i,danger:s}){return d("button",{onClick:t,title:i,className:"glass-btn w-7 h-7 flex items-center justify-center flex-shrink-0",style:s?{color:"rgba(255,100,100,0.7)"}:{color:"var(--text-muted)"},children:d("span",{className:"material-symbols-outlined",style:{fontSize:15},children:e})})}function wc({qrUrl:e,oneTimeKey:t,oneTimeKeyExpiresAt:i,permanentKey:s,onGenerateOneTimeKey:r,onRegenerateKey:n}){const o=$e(null),[a,h]=K(null),[l,u]=K(null),[f,c]=K(null);ce(()=>{!e||!o.current||bc.toCanvas(o.current,e,{width:160,margin:1,color:{dark:"#0f1923",light:"#ffffff"}}).catch(()=>{})},[e]),ce(()=>{if(!i){h(null);return}const p=()=>h(i-Date.now());p();const g=setInterval(p,1e3);return()=>clearInterval(g)},[i]);const _=(p,g)=>{navigator.clipboard.writeText(p).catch(()=>{}),u(g),setTimeout(()=>u(null),2e3)};return d(Be,{children:[f==="oneTime"&&d(Ft,{message:"Generate a new one-time key? The current one will expire immediately.",confirmLabel:"Generate",onConfirm:()=>{c(null),r==null||r()},onCancel:()=>c(null)}),f==="regen"&&d(Ft,{message:"Regenerate permanent key? All existing sessions will be disconnected.",confirmLabel:"Regenerate",confirmDanger:!0,onConfirm:()=>{c(null),n==null||n()},onCancel:()=>c(null)}),d("div",{className:"glass-card conn-card p-4 flex flex-col items-center gap-4 h-full",children:[d("div",{className:"w-44 h-44 rounded-xl overflow-hidden bg-white p-2 flex items-center justify-center flex-shrink-0",children:e?d("canvas",{ref:o}):d("span",{className:"material-symbols-outlined text-gray-300 text-6xl",children:"qr_code_2"})}),d("div",{className:"flex flex-col items-center gap-1",children:[d("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Scan QR or open link to sign in"}),d("a",{href:`https://${Yo}/login`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 hover:underline transition-opacity",children:[d("span",{className:"w-2 h-2 rounded-full bg-green-400 flex-shrink-0"}),d("span",{className:"text-sm font-bold",style:{color:"var(--brand-500)"},children:[Yo,"/login"]}),d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:14,color:"var(--brand-500)"},children:"open_in_new"})]})]}),d("div",{className:"w-full h-px",style:{background:"var(--border)"}}),d("div",{className:"w-full flex flex-col gap-1.5",children:[d("div",{className:"flex items-center justify-between px-0.5",children:[d("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"One-Time Key"}),d("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Single use · expires"})]}),d("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"timer"}),d("span",{className:"flex-1 font-mono font-bold tracking-[0.18em] text-base truncate",style:{color:t?"var(--brand-500)":"var(--border)"},children:t||"• • • • • •"}),a!==null&&d("span",{className:`text-xs font-mono flex-shrink-0 ${a<=0?"text-red-400":""}`,style:a>0?{color:"var(--text-muted)"}:{},children:Sc(a)}),t&&d(Ki,{icon:l==="oneTime"?"check":"content_copy",onClick:()=>_(t,"oneTime"),title:"Copy one-time key"}),d(Ki,{icon:"refresh",onClick:()=>c("oneTime"),title:"New one-time key"})]})]}),d("div",{className:"w-full flex flex-col gap-1.5",children:[d("div",{className:"flex items-center justify-between px-0.5",children:[d("span",{className:"text-xs font-medium",style:{color:"var(--text-muted)"},children:"Permanent Key"}),d("span",{className:"text-xs",style:{color:"var(--text-muted)"},children:"Reusable · no expiry"})]}),d("div",{className:"w-full flex items-center gap-2 dark-card px-3 py-2.5",children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:16,color:"var(--text-muted)"},children:"key"}),d("span",{className:"flex-1 font-mono text-xs truncate",style:{color:"var(--text-muted)"},children:s||"— not set —"}),s&&d(Ki,{icon:l==="permanent"?"check":"content_copy",onClick:()=>_(s,"permanent"),title:"Copy permanent key"}),d(Ki,{icon:"autorenew",onClick:()=>c("regen"),title:"Regenerate permanent key",danger:!0})]})]})]})]})}const xc={terminal:d(Be,{children:[d("path",{d:"m4 17 6-6-6-6"}),d("path",{d:"M12 19h8"})]}),pencil:d(Be,{children:d("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"})}),trash:d(Be,{children:[d("path",{d:"M3 6h18"}),d("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),d("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),d("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),d("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]}),plus:d(Be,{children:[d("path",{d:"M5 12h14"}),d("path",{d:"M12 5v14"})]}),folderPlus:d(Be,{children:[d("path",{d:"M12 10v6"}),d("path",{d:"M9 13h6"}),d("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})]}),folder:d(Be,{children:d("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),chevronDown:d(Be,{children:d("path",{d:"m6 9 6 6 6-6"})}),chevronRight:d(Be,{children:d("path",{d:"m9 18 6-6-6-6"})}),chevronLeft:d(Be,{children:d("path",{d:"m15 18-6-6 6-6"})}),zap:d(Be,{children:d("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"})}),arrowLeft:d(Be,{children:[d("path",{d:"m12 19-7-7 7-7"}),d("path",{d:"M19 12H5"})]}),cornerDownLeft:d(Be,{children:[d("path",{d:"M20 4v7a4 4 0 0 1-4 4H4"}),d("path",{d:"m9 10-5 5 5 5"})]}),language:d(Be,{children:[d("circle",{cx:"12",cy:"12",r:"10"}),d("path",{d:"M2 12h20"}),d("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})};function ze({name:e,size:t=20,color:i,className:s="",...r}){return d("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:i||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:s,...r,children:xc[e]})}function Et(e,t){e=e-312;var i=ms(),s=i[e];if(Et.NYLazG===void 0){var r=function(h){for(var l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",u="",f="",c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(var y=0,m=u.length;y<m;y++)f+="%"+("00"+u.charCodeAt(y).toString(16)).slice(-2);return decodeURIComponent(f)};Et.yNRWyR=r,Et.JeOcua={},Et.NYLazG=!0}var n=i[0],o=e+n,a=Et.JeOcua[o];return a?s=a:(s=Et.yNRWyR(s),Et.JeOcua[o]=s),s}function ms(){var e=["uMvTB3zLigrLDMLJzsb7Awr9lI4UpYbjDcb3AwXSig5LzwqGyxbWCM92ywWGywDHAw4GBMv4Dcb0Aw1LlG","q29UBMvJDgLVBG","uhjLDMvUDcbZBgvLCa","uMvUyw1LihrOAxmGzgv2AwnL","uMvTB3rLihnJCMvLBIbJB250CM9S","u3DPDgnOihrVigXPz2H0ig1Vzgu","rgLZy29UBMvJDcaMifjLBw92zq","q29UBMvJDgvK","qwrKieDYB3vW","uNvUBMLUzW","uMvXDwLYzsbTyw51ywWGyxbWCM92ywWGzM9Yig5LDYbKzxzPy2vZ","r3jHBNqGywXSihbLCM1PC3nPB25ZigjLBg93ihrVigvUywjSzq","t2zMBgLUzsdcTYbHChbYB3zLzcb7zgf0zx0","q2fWDhvYzsbZy3jLzw4Gy29UDgvUDa","uMvQzwn0","mJCZmZKZmhf1DKf0DW","u3DPDgnOihrVigrHCMSGBw9Kzq","mJKZntCZodbzu29isem","tg9NCW","r3jVDxaGBMfTzq","vgvYBwLUywW","uMvUyw1LigDYB3vW","u3rHCNqGDgHLihr1BM5LBcb0BYbNzxqGysbruIbJB2rLigfUzcbJB25Uzwn0ihLVDxiGzgv2AwnLCYbMCM9TigfUExDOzxjLlG","tMv3ieDYB3vW","t25SAw5L","tM8GBg9NCYb5zxq","mteYndyYCMfhDK1X","qw55ig5LDYbKzxzPy2uGy29UBMvJDhmGD2L0Ag91DcbHChbYB3zHBa","tMv2zxiGB2zM","t2zMigfMDgvYidqGAg91CNmGAwrSzq","q3jLyxrL","uMvZzxqGDgHLihr1BM5LBcbHBMqGCMvJB25Uzwn0ignSAwvUDhm","rg9Uzq","tMv3ierLDMLJzsbdB25Uzwn0Aw9U","nZm1nJiXm3jjvM9NCa","vgvYBwLUywXZ","u2vYDMvYigfJDgL2Axr5igfUzcbKAwfNBM9ZDgLJCW","nta1mdC3CLnmsxvO","vMvYAwz5Aw5N","q29UDhjVBcbTB3vZzsaMigTLEwjVyxjK","rgLZy29UBMvJDcbHBMqGCMvTB3zLigrLDMLJzsb7Awr9lI4UpYbuAguGy2XPzw50ihDPBgWGyMuGzgLZy29UBMvJDgvKigfUzcbUzwvKigfWChjVDMfSigfNywLUig5LEhqGDgLTzs4","qNjVD3nLicyGzwrPDcbMAwXLCW","qMfJAYb0BYbZzxnZAw9UCW","u3DPDgnOigDYB3vW","u3rHCNrPBMCGC2vJDxjLihr1BM5LBa","q2XPzw50CYaOE29UBgLUzx0VE3rVDgfSFsbVBMXPBMuP","q2XPzw50CW","u2H1DgrVD24","ugvUzgLUzYdcTYb3ywL0Aw5NigzVCIbHChbYB3zHBa","qxv0BY1HChbYB3zLig5LDYbKzxzPy2vZ","rNvSBcbZAgvSBcbHy2nLC3m","uMvUyw1L","t2zMigfMDgvYidiGAg91CNmGAwrSzq","u2v0DgLUz3m","rgvSzxrLihrLCM1PBMfSihTUyw1LFt8","tMv3ihrLCM1PBMfS","sgvHBhrOignOzwnR","ugfPCIbKzxzPy2vZigfUzcbTyw5Hz2uGEw91CIbZzwn1CMuGDhvUBMvS","nuDhAMjgDG","tgfUz3vHz2u","rgvSzxrLigDYB3vW","t2zMigfMDgvYidi0igHVDxjZigLKBgu","qxbWCM92zq","vhvUBMvSig9MzMXPBMu","uMvZzxqGyw5Kihn0B3aGDgHLihr1BM5LBd8GuMvTB3rLignSAwvUDhmGD2LSBcbIzsbKAxnJB25Uzwn0zwqU","rgvZA3rVCa","q2fUy2vS","ndi0CwTUwfnX","rgLZy29UBMvJDa","q2XLyxi","q29UBMvJDgLUz+kaPG","zs5NlIbnEsbnywncB29R","rgLZywjSzwqG4Ocuihn0yxj0ig1HBNvHBgX5","u2vUza","vxbKyxrL","rMLSzxm","mJC4ndCYng5cCfLiBq","uMvZzxq","qxbWCM92zsb0AgLZigrLDMLJzq","uhjLCgfYAw5N","uNvUCYbPBIbIywnRz3jVDw5KihDOzw4GEw91igXVzYbPBG","u2v0DgLUzYb1CcbJB25Uzwn0Aw9U","mtf0CvbgELe","u2H1DgrVD24GovjLBw90zsaOC3rVCcbZzxj2zxiSignSB3nLihr1BM5LBcbHBMqGCxvPDcK","t2zMigfMDgvYidmWig1PBIbPzgXL","u3rHCNr1Ca","uMvTB3zLihbLBMrPBMCGzgv2AwnLihTPzh0UlI4/ieL0ihDPBgWGBMvLzcbHigzYzxnOigfWChjVDMfSihjLCxvLC3qGDg8Gy29UBMvJDcbHz2fPBI4","rg9JDw1LBNrHDgLVBG","tgL2zsb0zxjTAw5HBcbZzxnZAw9UCYbYDw5UAw5Nig9UihrOAxmGAg9ZDa","q29UBMvJDgvKimk3ihT0Aw1LFq","uMvTB3rLierLC2T0B3a","rgvSzxrLihnLC3nPB24GE25HBwv9pYbuAgLZihDPBgWGA2LSBcb0AguGDgvYBwLUywWU","nZy4ndaWEfH4zfbb","m2vLseXPzG","qwnJzxnZAwjPBgL0Eq","rgvSzxrL","tMfTzsbMB3iGzgv2AwnLihTPzh0UlI4","t2zMBgLUzq"];return ms=function(){return e},ms()}var N=Et;(function(e,t){for(var i=Et,s=e();;)try{var r=-parseInt(i(370))/1+parseInt(i(409))/2*(-parseInt(i(328))/3)+parseInt(i(327))/4+-parseInt(i(391))/5*(parseInt(i(348))/6)+parseInt(i(359))/7*(-parseInt(i(400))/8)+parseInt(i(367))/9+parseInt(i(350))/10*(parseInt(i(317))/11);if(r===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(ms,740603);const Cc={common:{create:N(363),cancel:N(399),delete:N(330),rename:N(384),language:N(392)},terminal:{backToSessions:N(375),switchGroup:N(376),newTerminal:N(388),send:N(406),typeCommand:"Enter to send • Shift+Enter for new line",deleteConfirm:N(387)},sessions:{newTerminal:"New Terminal",addGroup:N(341),newGroup:N(356),groupName:N(352),renameGroup:N(354),deleteGroup:N(393),ungrouped:"Ungrouped",deleteSessionConfirm:N(326),deleteGroupConfirm:"Delete group {name}? All terminals inside will be closed."},menu:{connection:N(334),connectionDesc:N(390),terminals:N(368),terminalsDesc:N(323),logs:"Logs",logsDesc:N(369)},header:{settings:N(386),language:N(392),documentation:N(322),reset:N(364),resetShort:N(312),shutdown:N(318),shutdownShort:N(380),lightMode:N(338),darkMode:N(349)},remote:{remoteDesktop:N(325),controlScreen:"Control screen, mouse & keyboard",screenRecording:"Screen Recording",captureScreen:N(346),accessibility:N(329),controlMouseKeyboard:N(372),startup:N(320),launchOnStartup:"Launch on system startup",launchDesc:N(315),disabledStart:N(405),preventSleep:N(335),blockSleep:"Block system sleep so the network stays alive",sleepModes:{"30m":N(319),"1h":"Off after 1 hour idle","2h":N(385),"4h":N(362),"24h":N(394),never:N(361)}},clients:{clients:N(379),clientCount:N(378),noClients:"No clients yet",autoApprove:N(382),anyDevice:N(360),requireManual:N(343),online:N(357),offline:N(332),pending:"Pending approval",connected:N(340),connectedAt:N(324),pendingApproval:N(381),offlineAt:N(345),disconnect:N(401),disconnectRemove:N(339),remove:"Remove",renameDevice:N(336),approveDevice:N(313),approveBtn:N(395),rejectBtn:N(347),newDevice:N(366),deviceId:"Device",deviceIp:"IP"},logs:{logs:N(351),noLogs:N(358),clear:N(402)},connection:{tunnelOffline:N(396),startTunnel:N(355),connect:"Connect",connecting:N(403),features:{terminal:N(353),fullShell:N(383),desktop:N(398),remoteScreen:N(337),files:N(408),browseEdit:N(374)}},dialogs:{resetConfirm:N(397),shutdownConfirm:"Shutdown 9Remote completely? This will stop the server, close the tunnel and quit the app.",deviceDisconnect:N(373),deviceRemovePending:N(321),deviceRemoveOffline:N(333),grantPermissions:N(344),deviceName:N(331),nameExample:N(404)},buttons:{update:N(407),approve:N(395),reject:"Reject",save:"Save"},steps:{setupConnection:N(316),preparing:N(314),checkingTunnel:"Checking tunnel binary",connecting:"Connecting",creatingSession:"Creating session",tunneling:"Tunneling",startingTunnel:N(377),verifying:N(371),healthCheck:N(389),ready:"Ready",connected:"Connected",done:N(365),running:N(342)}},kc={},Ec={},Bc={},Lc={},Mc={},Dc={},Rc={},Ac={},Tc={},Nc={},Pc={},Ic={},Oc={},zc={},Hc={},Wc={},Fc={},Uc={},qc={},Kc={};var ye=Bt;(function(e,t){for(var i=Bt,s=e();;)try{var r=-parseInt(i(124))/1*(parseInt(i(127))/2)+parseInt(i(140))/3+-parseInt(i(148))/4*(-parseInt(i(151))/5)+parseInt(i(129))/6*(parseInt(i(142))/7)+parseInt(i(125))/8+parseInt(i(133))/9+parseInt(i(147))/10*(-parseInt(i(131))/11);if(r===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(vs,734526);function Bt(e,t){e=e-122;var i=vs(),s=i[e];if(Bt.YbynMg===void 0){var r=function(h){for(var l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",u="",f="",c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(var y=0,m=u.length;y<m;y++)f+="%"+("00"+u.charCodeAt(y).toString(16)).slice(-2);return decodeURIComponent(f)};Bt.MAMrMT=r,Bt.QlRgvQ={},Bt.YbynMg=!0}var n=i[0],o=e+n,a=Bt.QlRgvQ[o];return a?s=a:(s=Bt.MAMrMT(s),Bt.QlRgvQ[o]=s),s}const $c={common:{create:ye(135),cancel:ye(143),delete:ye(155),rename:ye(149),language:ye(139)},terminal:{backToSessions:ye(137),switchGroup:"Chuyển nhóm",newTerminal:ye(150),send:ye(122),typeCommand:ye(154),deleteConfirm:ye(153)},sessions:{newTerminal:"Terminal mới",addGroup:ye(123),newGroup:ye(146),groupName:ye(132),renameGroup:ye(145),deleteGroup:ye(126),ungrouped:"Chưa phân nhóm",deleteSessionConfirm:ye(144),deleteGroupConfirm:ye(152)},menu:{connection:"Kết nối",connectionDesc:"Ghép nối thiết bị và quản lý tunnel bảo mật",terminals:ye(138),terminalsDesc:ye(130),logs:"Nhật ký",logsDesc:ye(136)},header:{documentation:ye(128),reset:"Đặt lại tunnel và kết nối lại thiết bị",shutdown:ye(141),lightMode:"Chuyển sang giao diện sáng",darkMode:ye(134)}};function vs(){var e=["tMFdTg4GBMFHU68","ndiYmtC4m3HQv1nutq","vog6R3qGovjLBw90zsaOzog7Q25Nig3dOxKGy2JHU6CSimsrW7nUzYb0Dw5UzwWGDSoGihrOB8oHDcK","mtrpreLPvu8","sog7P3K","wmoZysbWAgNdQM4GE25HBwv9pYbwAEg7H2mGBSoGEsbZ4BQ9ihtHUQ90ihrLCM1PBMfSlG","XjdHU5vPihtdQM4GBMJdS20","tMJdS20GBEg7M2K","odqYntGXmeTVCKz2yG","ndyYmJaWCLPUAe5Q","XjdHU5vPihtdQM4","vgvYBwLUywWGBEg7M2K","nuHrzwPnEG","wmoZysbUAmoZBsb7BMfTzx0/iftHUQv0igpHUQmGDgvYBwLUywWGySoQBIb0CM9UzYbZ4BQ9iglHU4SGXjhdS25NlG","wmoZysb0zxjTAw5HBcb7BMfTzx0/","tMJHUQ1WigZHU4DUAokaPG","wmoZyq","r+g7RwK","vgJdQM0GBMJdS20","nduWndDiEujfAgS","mJu3nZu1mNPoq0jWuG","wmoZysbUAmoZBq","mtHuqMvgEKy","vmoGAsbSAEg7H3u","mtC4nZmZnffluMLXAG","q8oHyYbWAgNdQM4GDgvYBwLUywWGXjfHBMCGy2JHUQf5ihrYW6PUig3dOxKGBSoGEq","mJjivMvTEMG","vmoQBIbUAmoZBq","mZq1odK1mK1YDgPHCW","q2H1EEg7G24GC2fUzYbNAwfVigrP4BUhBIb04BUrAq","vog6Ow8","sg/HUQf0imsr4BUzBMCGDSoGignO4BQPBIdeKw/dOw4GBCoHEsbJAog7PW","uxvHEsbS4BQHAsbKyw5OihpdOwnOihbOACoQBG","vgvYBwLUywW"];return vs=function(){return e},vs()}const Vc={};(function(e,t){const i=zt,s=e();for(;;)try{if(parseInt(i(300))/1+parseInt(i(299))/2*(parseInt(i(296))/3)+parseInt(i(301))/4*(parseInt(i(298))/5)+parseInt(i(302))/6+-parseInt(i(304))/7*(-parseInt(i(303))/8)+parseInt(i(297))/9+-parseInt(i(295))/10===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(ys,691409);function ys(){const e=["nJq2muTtqvzrsW","ndmZmJG3mJbIANnbC24","mtKWnxHruuHcCa","mta0odiWmJf3thLmu0O","ntaZmty1te1yCNnQ","ntyYywrMA3H1","otm3mZiZvwTysNzl","ndrtA2fzv1m","nZCZmZuYmgDKEfjuvW","mZaXnMvOtLPuAW"];return ys=function(){return e},ys()}function zt(e,t){e=e-295;const i=ys();let s=i[e];if(zt.vtMckj===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};zt.TAVzqi=r,zt.hCQFcU={},zt.vtMckj=!0}const n=i[0],o=e+n,a=zt.hCQFcU[o];return a?s=a:(s=zt.TAVzqi(s),zt.hCQFcU[o]=s),s}const hi={en:Cc,ar:kc,de:Ec,es:Bc,fa:Lc,fr:Mc,he:Dc,hi:Rc,id:Ac,it:Tc,ja:Nc,ko:Pc,ms:Ic,nl:Oc,pl:zc,pt:Hc,ru:Wc,sv:Fc,th:Uc,tr:qc,uk:Kc,vi:$c,zh:Vc},he=Lt;(function(e,t){const i=Lt,s=e();for(;;)try{if(parseInt(i(224))/1+parseInt(i(210))/2+-parseInt(i(221))/3+-parseInt(i(207))/4+parseInt(i(236))/5+-parseInt(i(217))/6+-parseInt(i(231))/7===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(bs,103258);function Lt(e,t){e=e-207;const i=bs();let s=i[e];if(Lt.hCKbvr===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};Lt.qpHDyX=r,Lt.OLtkCs={},Lt.hCKbvr=!0}const n=i[0],o=e+n,a=Lt.OLtkCs[o];return a?s=a:(s=Lt.qpHDyX(s),Lt.OLtkCs[o]=s),s}const Pr=[{code:"en",label:he(229),flag:he(235)},{code:"vi",label:"Tiếng Việt",flag:he(234)},{code:"zh",label:"中文",flag:"🇨🇳"},{code:"es",label:he(211),flag:he(233)},{code:"hi",label:"हिन्दी",flag:he(244)},{code:"ar",label:he(228),flag:he(226)},{code:"pt",label:he(212),flag:he(209)},{code:"ru",label:he(239),flag:"🇷🇺"},{code:"ja",label:he(213),flag:he(230)},{code:"de",label:he(232),flag:"🇩🇪"},{code:"fr",label:he(241),flag:"🇫🇷"},{code:"ko",label:"한국어",flag:he(240)},{code:"it",label:"Italiano",flag:he(222)},{code:"tr",label:he(242),flag:he(215)},{code:"id",label:"Bahasa Indonesia",flag:"🇮🇩"},{code:"th",label:he(216),flag:he(218)},{code:"pl",label:he(223),flag:he(208)},{code:"nl",label:he(237),flag:he(219)},{code:"sv",label:he(225),flag:"🇸🇪"},{code:"uk",label:"Українська",flag:he(238)},{code:"fa",label:he(243),flag:"🇮🇷"},{code:"he",label:he(227),flag:he(220)},{code:"ms",label:"Bahasa Melayu",flag:he(214)}];function bs(){const e=["8j+hUFcFH7C","4lMe4lIx4lII","mtiXmJe0ne9jAxHwvW","8j+hUFcFH60","8j+hS/cFH7e","8j+hRVcFH7e","mtmYnZe3y3bXthjb","8j+hRVcFH7K","ug9SC2TP","mteXoda3vxLLCg55","u3zLBNnRyq","8j+hUpcFH6y","16lxKDEO15NxQG","2kFzHnI52lhyQnMk2kK","rw5NBgLZAa","8j+hR/cFH7u","mJy2ntGXu2XXD1jz","rgv1DhnJAa","8j+hQVcFH7G","8j+hU/cFH7m","8j+hUVcFH7G","nZaYodqWwu9kEMj6","tMvKzxjSyw5KCW","8j+hUVcFH6y","0kdrG9gb0yhqUTc40lK","8j+hSpcFH7C","rNjHBSoNywLZ","vmo8CMVdP2u","2yhyP9IX2lpBJa","8j+hRVcFH7m","otG1mtzuDM1WyNG","8j+hTFcFH7e","8j+hP/cFH7C","mZe5nZe2DePSsff0","rxnWyCoXB2W","ug9YDhvNDCoQCW","5PEL5PYS6kQE","8j+hSVcFH74"];return bs=function(){return e},bs()}const Ir="en",Bl="agentLocale";(function(e,t){const i=nt,s=e();for(;;)try{if(-parseInt(i(122))/1*(-parseInt(i(114))/2)+-parseInt(i(112))/3*(parseInt(i(125))/4)+-parseInt(i(106))/5*(parseInt(i(111))/6)+parseInt(i(117))/7*(-parseInt(i(118))/8)+parseInt(i(116))/9*(-parseInt(i(109))/10)+parseInt(i(126))/11*(parseInt(i(115))/12)+parseInt(i(107))/13*(-parseInt(i(121))/14)===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ss,796557);function Jo(e,t){const i=nt;if(e)return t.split(".")[i(105)]((s,r)=>s==null?s:s[r],e)}function jc(e,t){return typeof e!==nt(119)||!t?e:e.replace(/\{(\w+)\}/g,(s,r)=>t[r]!=null?t[r]:"{"+r+"}")}function Gc(){const e=nt;try{const t=localStorage[e(113)](Bl);if(t&&hi[t])return t;const i=(navigator[e(110)]||"")[e(120)](0,2);if(hi[i])return i}catch{}return Ir}let Or=Gc();const zr=new Set;function Yc(e){const t=nt;if(!(e===Or||!hi[e])){Or=e;try{localStorage[t(123)](Bl,e)}catch{}zr[t(124)](i=>i(e))}}function nt(e,t){e=e-105;const i=Ss();let s=i[e];if(nt.MMACWK===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};nt.pkSAip=r,nt.lQUCZI={},nt.MMACWK=!0}const n=i[0],o=e+n,a=nt.lQUCZI[o];return a?s=a:(s=nt.pkSAip(s),nt.lQUCZI[o]=s),s}function Ss(){const e=["BgfUz3vHz2u","mJe2mtHlENfovwS","mZaWDMLeAfnl","z2v0sxrLBq","mtbzEvbkvNq","mtGZnJy4mJHpqLLMD0C","mJC2ntDPwKDMyKG","n0zoCKvwuG","mZi1mdG4oeTIvejqyW","C3rYAw5N","C2XPy2u","odCYmJi4A0jXsfne","mJm5ndG1zNLpD2Lk","C2v0sxrLBq","zM9YrwfJAa","odi0v3f6B0LW","mtfmr2rZsxi","zgvSzxrL","CMvKDwnL","otvhvfjztLi","mJK5rMTrCujN","ywrK","mtbvCwXju3e"];return Ss=function(){return e},Ss()}function Jc(e,t,i){const s=hi[e]||hi[Ir],r=hi[Ir],n=Jo(s,t)??Jo(r,t)??t;return jc(n,i)}function ti(){const[e,t]=K(Or);return ce(()=>{const s=nt,r=n=>t(n);return zr[s(108)](r),()=>zr[s(127)](r)},[]),{t:(s,r)=>Jc(e,s,r),locale:e,setLocale:Yc}}const Zc="ungrouped";function Xc({sessions:e,groups:t,connected:i,finishedIds:s,onSelect:r,onCreate:n,onCreateNamed:o,onDelete:a,onRename:h,onCreateGroup:l,onRenameGroup:u,onDeleteGroup:f}){const{t:c}=ti(),[_,p]=K(null),[g,y]=K(""),[m,E]=K(null),[b,S]=K(null),[D,k]=K(""),[R,P]=K(null),[A,H]=K(!1),[C,w]=K(""),[v,x]=K({open:!1,groupId:null}),[M,z]=K(""),U=W=>{if(W){W.focus();const ee=W.value.length;W.setSelectionRange(ee,ee)}},T=W=>{g.trim()&&h(W,g.trim()),p(null),y("")},Z=W=>{D.trim()&&(u==null||u(W,D.trim())),S(null),k("")},ne=()=>{const W=C.trim();W&&(l==null||l(W,ee=>{var V;ee!=null&&ee.success&&((V=ee.group)!=null&&V.id)&&n(ee.group.id)}),w(""),H(!1))},pe=()=>{const W=M.trim()||null;o?o(v.groupId,W):n==null||n(v.groupId),z(""),x({open:!1,groupId:null})},we=W=>`Term ${e.filter(V=>(V.groupId||null)===W).length+1}`,_e=[...t.map(W=>({key:W.id,id:W.id,name:W.name,isUngrouped:!1})),{key:Zc,id:null,name:c("sessions.ungrouped"),isUngrouped:!0}],oe=W=>e.filter(ee=>(ee.groupId||null)===W);return d("div",{className:"flex flex-col",children:[d("div",{className:"space-y-8",children:[_e.map(W=>{const ee=oe(W.id);return W.isUngrouped&&ee.length===0?null:d("div",{children:[d("div",{className:"flex items-center gap-2 mb-2 px-1",children:[d("div",{className:"flex items-center gap-1.5 text-sm",style:{color:"var(--text-muted)"},children:[d(ze,{name:"folder",size:16}),b===W.id?d("input",{type:"text",value:D,ref:U,onClick:V=>V.stopPropagation(),onInput:V=>k(V.target.value),onKeyDown:V=>{V.key==="Enter"&&Z(W.id),V.key==="Escape"&&S(null)},onBlur:()=>Z(W.id),className:"px-2 py-0.5 rounded-lg text-sm focus:outline-none",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}):d("span",{style:{color:"var(--text-main)",fontWeight:500},children:W.name})]}),!W.isUngrouped&&d(Be,{children:[d("button",{onMouseDown:V=>V.preventDefault(),onClick:()=>{S(W.id),k(W.name)},title:c("sessions.renameGroup"),className:"card-act p-1 rounded-lg",children:d(ze,{name:"pencil",size:14})}),d("button",{onClick:()=>P({id:W.id,name:W.name}),title:c("sessions.deleteGroup"),className:"card-del p-1 rounded-lg",children:d(ze,{name:"trash",size:14})})]})]}),d("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[ee.map(V=>d("div",{className:`session-card relative rounded-2xl p-3 flex items-center justify-between ${s!=null&&s.has(V.id)?"terminal-done-border":""}`,children:[d("div",{className:"flex-1 flex items-center gap-3 min-w-0 cursor-pointer",onClick:()=>{_!==V.id&&r(V)},children:[d("div",{className:"p-2 rounded-xl flex-shrink-0",style:{background:"var(--brand-tint)"},children:d(ze,{name:"terminal",size:20,color:"var(--brand-500)"})}),d("div",{className:"flex-1 min-w-0",children:_===V.id?d("input",{type:"text",value:g,ref:U,onInput:de=>y(de.target.value),onKeyDown:de=>{de.key==="Enter"&&T(V.id),de.key==="Escape"&&(p(null),y(""))},onBlur:()=>T(V.id),className:"w-full px-2 py-1 rounded-lg text-sm focus:outline-none",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}):d(Be,{children:[d("h3",{className:"text-sm font-medium truncate",style:{color:"var(--text-main)"},children:V.name||V.id}),d("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:V.createdAt?`Created ${new Date(V.createdAt).toLocaleTimeString()}`:""})]})})]}),d("div",{className:"flex gap-0.5 ml-1",children:[d("button",{onMouseDown:de=>de.preventDefault(),onClick:()=>{p(V.id),y(V.name||"")},title:c("common.rename"),className:"card-act p-1.5 rounded-lg",children:d(ze,{name:"pencil",size:16})}),d("button",{onClick:()=>E({id:V.id,name:V.name}),title:c("common.delete"),className:"card-del p-1.5 rounded-lg",children:d(ze,{name:"trash",size:16})})]})]},V.id)),d("button",{onClick:()=>{z(we(W.id)),x({open:!0,groupId:W.id})},className:"dashed-card min-h-[58px] rounded-2xl p-3 flex items-center justify-center gap-1.5 text-sm",children:[d(ze,{className:"text-brand-500",name:"plus",size:16})," ",d("span",{style:{color:"var(--brand-500)"},children:c("sessions.newTerminal")})]})]})]},W.key)}),d("button",{onClick:()=>H(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150 ease-out",style:{border:"1px dashed var(--brand-500)",color:"var(--brand-500)",background:"var(--brand-tint)"},children:[d(ze,{name:"folderPlus",size:16})," ",c("sessions.addGroup")]})]}),A&&d("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.6)"},onClick:()=>H(!1),children:d("div",{className:"glass-card p-5 w-80",onClick:W=>W.stopPropagation(),children:[d("p",{className:"text-sm font-semibold mb-3",style:{color:"var(--text-main)"},children:c("sessions.newGroup")}),d("input",{type:"text",value:C,autoFocus:!0,placeholder:c("sessions.groupName"),onInput:W=>w(W.target.value),onKeyDown:W=>{W.key==="Enter"&&ne(),W.key==="Escape"&&H(!1)},className:"w-full px-3 py-2 rounded-lg text-sm mb-4 focus:outline-none",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}),d("div",{className:"flex gap-2",children:[d("button",{onClick:ne,disabled:!C.trim(),className:"btn-primary flex-1 py-2 text-sm font-semibold",style:{borderRadius:"var(--radius-brand)",opacity:C.trim()?1:.6},children:c("common.create")}),d("button",{onClick:()=>{w(""),H(!1)},className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:c("common.cancel")})]})]})}),v.open&&d("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.6)"},onClick:()=>x({open:!1,groupId:null}),children:d("div",{className:"glass-card p-5 w-80",onClick:W=>W.stopPropagation(),children:[d("p",{className:"text-sm font-semibold mb-3",style:{color:"var(--text-main)"},children:c("sessions.newTerminal")}),d("div",{className:"relative mb-4",children:[d("input",{type:"text",value:M,ref:U,placeholder:we(v.groupId),onInput:W=>z(W.target.value),onKeyDown:W=>{W.key==="Enter"&&pe(),W.key==="Escape"&&x({open:!1,groupId:null})},className:"w-full px-3 py-2 pr-8 rounded-lg text-sm focus:outline-none",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}),M&&d("button",{onMouseDown:W=>W.preventDefault(),onClick:()=>z(""),className:"absolute right-2 top-1/2 -translate-y-1/2 w-5 h-5 flex items-center justify-center rounded-full",style:{color:"var(--text-muted)"},children:d(ze,{name:"plus",size:14,className:"rotate-45"})})]}),d("div",{className:"flex gap-2",children:[d("button",{onClick:pe,className:"btn-primary flex-1 py-2 text-sm font-semibold",style:{borderRadius:"var(--radius-brand)"},children:c("common.create")}),d("button",{onClick:()=>{z(""),x({open:!1,groupId:null})},className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:c("common.cancel")})]})]})}),m&&d(Ft,{message:c("sessions.deleteSessionConfirm",{name:m.name||m.id}),confirmLabel:c("common.delete"),confirmDanger:!0,onConfirm:()=>{a(m.id),E(null)},onCancel:()=>E(null)}),R&&d(Ft,{message:c("sessions.deleteGroupConfirm",{name:R.name}),confirmLabel:c("common.delete"),confirmDanger:!0,onConfirm:()=>{f==null||f(R.id),P(null)},onCancel:()=>P(null)})]})}/**
|
|
9
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
10
|
-
* @license MIT
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
13
|
-
* @license MIT
|
|
14
|
-
*
|
|
15
|
-
* Originally forked from (with the author's permission):
|
|
16
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
17
|
-
* http://bellard.org/jslinux/
|
|
18
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
19
|
-
*/var Ll=Object.defineProperty,Qc=Object.getOwnPropertyDescriptor,ed=(e,t)=>{for(var i in t)Ll(e,i,{get:t[i],enumerable:!0})},ke=(e,t,i,s)=>{for(var r=s>1?void 0:s?Qc(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Ll(t,i,r),r},F=(e,t)=>(i,s)=>t(i,s,e),Zo="Terminal input",Hr={get:()=>Zo,set:e=>Zo=e},Xo="Too much output to announce, navigate to rows manually to read",Wr={get:()=>Xo,set:e=>Xo=e};function td(e){return e.replace(/\r?\n/g,"\r")}function id(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function sd(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function rd(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Ml(r,t,i,s)}}function Ml(e,t,i,s){e=td(e),e=id(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Dl(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Qo(e,t,i,s,r){Dl(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Wt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ts(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var nd=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},od=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let c=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)_<<=6,_|=g;let y=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,m=y-p;for(;l<m;){if(l>=i)return 0;if(g=e[l++],(g&192)!==128){l--,c=!0;break}else this.interim[p++]=g,_<<=6,_|=g&63}c||(y===2?_<128?l--:t[s++]=_:y===3?_<2048||_>=55296&&_<=57343||_===65279||(t[s++]=_):_<65536||_>1114111||(t[s++]=_)),this.interim.fill(0)}let u=i-4,f=l;for(;f<i;){for(;f<u&&!((r=e[f])&128)&&!((n=e[f+1])&128)&&!((o=e[f+2])&128)&&!((a=e[f+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,f+=4;if(r=e[f++],r<128)t[s++]=r;else if((r&224)===192){if(f>=i)return this.interim[0]=r,s;if(n=e[f++],(n&192)!==128){f--;continue}if(h=(r&31)<<6|n&63,h<128){f--;continue}t[s++]=h}else if((r&240)===224){if(f>=i)return this.interim[0]=r,s;if(n=e[f++],(n&192)!==128){f--;continue}if(f>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[f++],(o&192)!==128){f--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(f>=i)return this.interim[0]=r,s;if(n=e[f++],(n&192)!==128){f--;continue}if(f>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[f++],(o&192)!==128){f--;continue}if(f>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[f++],(a&192)!==128){f--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Rl="",Ut=" ",zi=class Al{constructor(){this.fg=0,this.bg=0,this.extended=new ws}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 Al;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}},ws=class Tl{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 Tl(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},dt=class Nl extends zi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ws,this.combinedData=""}static fromCharData(t){let i=new Nl;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Wt(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ea="di$target",Fr="di$dependencies",fr=new Map;function ad(e){return e[Fr]||[]}function Ue(e){if(fr.has(e))return fr.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");ld(t,i,r)};return t._id=e,fr.set(e,t),t}function ld(e,t,i){t[ea]===t?t[Fr].push({id:e,index:i}):(t[Fr]=[{id:e,index:i}],t[ea]=t)}var Ze=Ue("BufferService"),Pl=Ue("CoreMouseService"),ii=Ue("CoreService"),hd=Ue("CharsetService"),zn=Ue("InstantiationService"),Il=Ue("LogService"),Xe=Ue("OptionsService"),Ol=Ue("OscLinkService"),cd=Ue("UnicodeService"),Hi=Ue("DecorationService"),Ur=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var u;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new dt,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let f=0;f<o;f++)if(!(h===-1&&!i.hasContent(f))){if(i.loadCell(f,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=f,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&f===o-1){let c=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(c){let _={start:{x:h+1,y:e},end:{x:f+(!l&&f===o-1?1:0),y:e}},p=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let g=new URL(c);["http:","https:"].includes(g.protocol)||(p=!0)}catch{p=!0}p||s.push({text:c,range:_,activate:(g,y)=>r?r.activate(g,y,_):dd(g,y),hover:(g,y)=>{var m;return(m=r==null?void 0:r.hover)==null?void 0:m.call(r,g,y,_)},leave:(g,y)=>{var m;return(m=r==null?void 0:r.leave)==null?void 0:m.call(r,g,y,_)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=f,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Ur=ke([F(0,Ze),F(1,Xe),F(2,Ol)],Ur);function dd(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
20
|
-
|
|
21
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ns=Ue("CharSizeService"),At=Ue("CoreBrowserService"),Hn=Ue("MouseService"),Tt=Ue("RenderService"),ud=Ue("SelectionService"),zl=Ue("CharacterJoinerService"),ui=Ue("ThemeService"),Hl=Ue("LinkProviderService"),fd=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ta.isErrorNoTelemetry(e)?new ta(e.message+`
|
|
22
|
-
|
|
23
|
-
`+e.stack):new Error(e.message+`
|
|
24
|
-
|
|
25
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},_d=new fd;function ss(e){pd(e)||_d.onUnexpectedError(e)}var qr="Canceled";function pd(e){return e instanceof gd?!0:e instanceof Error&&e.name===qr&&e.message===qr}var gd=class extends Error{constructor(){super(qr),this.name=this.message}};function md(e){return new Error(`Illegal argument: ${e}`)}var ta=class Kr extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Kr)return t;let i=new Kr;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},$r=class Wl extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Wl.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var vd;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(vd||(vd={}));function yd(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Fl;(e=>{function t(S){return S&&typeof S=="object"&&typeof S[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(S){yield S}e.single=r;function n(S){return t(S)?S:r(S)}e.wrap=n;function o(S){return S||i}e.from=o;function*a(S){for(let D=S.length-1;D>=0;D--)yield S[D]}e.reverse=a;function h(S){return!S||S[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(S){return S[Symbol.iterator]().next().value}e.first=l;function u(S,D){let k=0;for(let R of S)if(D(R,k++))return!0;return!1}e.some=u;function f(S,D){for(let k of S)if(D(k))return k}e.find=f;function*c(S,D){for(let k of S)D(k)&&(yield k)}e.filter=c;function*_(S,D){let k=0;for(let R of S)yield D(R,k++)}e.map=_;function*p(S,D){let k=0;for(let R of S)yield*D(R,k++)}e.flatMap=p;function*g(...S){for(let D of S)yield*D}e.concat=g;function y(S,D,k){let R=k;for(let P of S)R=D(R,P);return R}e.reduce=y;function*m(S,D,k=S.length){for(D<0&&(D+=S.length),k<0?k+=S.length:k>S.length&&(k=S.length);D<k;D++)yield S[D]}e.slice=m;function E(S,D=Number.POSITIVE_INFINITY){let k=[];if(D===0)return[k,S];let R=S[Symbol.iterator]();for(let P=0;P<D;P++){let A=R.next();if(A.done)return[k,e.empty()];k.push(A.value)}return[k,{[Symbol.iterator](){return R}}]}e.consume=E;async function b(S){let D=[];for await(let k of S)D.push(k);return Promise.resolve(D)}e.asyncToArray=b})(Fl||(Fl={}));function Zt(e){if(Fl.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 bd(...e){return me(()=>Zt(e))}function me(e){return{dispose:yd(()=>{e()})}}var Ul=class ql{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Zt(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?ql.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Ul.DISABLE_DISPOSED_WARNING=!1;var qt=Ul,Q=class{constructor(){this._store=new qt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Q.None=Object.freeze({dispose(){}});var di=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Rt=typeof window=="object"?window:globalThis,Vr=class jr{constructor(t){this.element=t,this.next=jr.Undefined,this.prev=jr.Undefined}};Vr.Undefined=new Vr(void 0);var be=Vr,ia=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new be(e);if(this._first===be.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},Sd=globalThis.performance&&typeof globalThis.performance.now=="function",wd=class Kl{static create(t){return new Kl(t)}constructor(t){this._now=Sd&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ve;(e=>{e.None=()=>Q.None;function t(w,v){return f(w,()=>{},0,void 0,!0,void 0,v)}e.defer=t;function i(w){return(v,x=null,M)=>{let z=!1,U;return U=w(T=>{if(!z)return U?U.dispose():z=!0,v.call(x,T)},null,M),z&&U.dispose(),U}}e.once=i;function s(w,v,x){return l((M,z=null,U)=>w(T=>M.call(z,v(T)),null,U),x)}e.map=s;function r(w,v,x){return l((M,z=null,U)=>w(T=>{v(T),M.call(z,T)},null,U),x)}e.forEach=r;function n(w,v,x){return l((M,z=null,U)=>w(T=>v(T)&&M.call(z,T),null,U),x)}e.filter=n;function o(w){return w}e.signal=o;function a(...w){return(v,x=null,M)=>{let z=bd(...w.map(U=>U(T=>v.call(x,T))));return u(z,M)}}e.any=a;function h(w,v,x,M){let z=x;return s(w,U=>(z=v(z,U),z),M)}e.reduce=h;function l(w,v){let x,M={onWillAddFirstListener(){x=w(z.fire,z)},onDidRemoveLastListener(){x==null||x.dispose()}},z=new I(M);return v==null||v.add(z),z.event}function u(w,v){return v instanceof Array?v.push(w):v&&v.add(w),w}function f(w,v,x=100,M=!1,z=!1,U,T){let Z,ne,pe,we=0,_e,oe={leakWarningThreshold:U,onWillAddFirstListener(){Z=w(ee=>{we++,ne=v(ne,ee),M&&!pe&&(W.fire(ne),ne=void 0),_e=()=>{let V=ne;ne=void 0,pe=void 0,(!M||we>1)&&W.fire(V),we=0},typeof x=="number"?(clearTimeout(pe),pe=setTimeout(_e,x)):pe===void 0&&(pe=0,queueMicrotask(_e))})},onWillRemoveListener(){z&&we>0&&(_e==null||_e())},onDidRemoveLastListener(){_e=void 0,Z.dispose()}},W=new I(oe);return T==null||T.add(W),W.event}e.debounce=f;function c(w,v=0,x){return e.debounce(w,(M,z)=>M?(M.push(z),M):[z],v,void 0,!0,void 0,x)}e.accumulate=c;function _(w,v=(M,z)=>M===z,x){let M=!0,z;return n(w,U=>{let T=M||!v(U,z);return M=!1,z=U,T},x)}e.latch=_;function p(w,v,x){return[e.filter(w,v,x),e.filter(w,M=>!v(M),x)]}e.split=p;function g(w,v=!1,x=[],M){let z=x.slice(),U=w(ne=>{z?z.push(ne):Z.fire(ne)});M&&M.add(U);let T=()=>{z==null||z.forEach(ne=>Z.fire(ne)),z=null},Z=new I({onWillAddFirstListener(){U||(U=w(ne=>Z.fire(ne)),M&&M.add(U))},onDidAddFirstListener(){z&&(v?setTimeout(T):T())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return M&&M.add(Z),Z.event}e.buffer=g;function y(w,v){return(x,M,z)=>{let U=v(new E);return w(function(T){let Z=U.evaluate(T);Z!==m&&x.call(M,Z)},void 0,z)}}e.chain=y;let m=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(v){return this.steps.push(v),this}forEach(v){return this.steps.push(x=>(v(x),x)),this}filter(v){return this.steps.push(x=>v(x)?x:m),this}reduce(v,x){let M=x;return this.steps.push(z=>(M=v(M,z),M)),this}latch(v=(x,M)=>x===M){let x=!0,M;return this.steps.push(z=>{let U=x||!v(z,M);return x=!1,M=z,U?z:m}),this}evaluate(v){for(let x of this.steps)if(v=x(v),v===m)break;return v}}function b(w,v,x=M=>M){let M=(...Z)=>T.fire(x(...Z)),z=()=>w.on(v,M),U=()=>w.removeListener(v,M),T=new I({onWillAddFirstListener:z,onDidRemoveLastListener:U});return T.event}e.fromNodeEventEmitter=b;function S(w,v,x=M=>M){let M=(...Z)=>T.fire(x(...Z)),z=()=>w.addEventListener(v,M),U=()=>w.removeEventListener(v,M),T=new I({onWillAddFirstListener:z,onDidRemoveLastListener:U});return T.event}e.fromDOMEventEmitter=S;function D(w){return new Promise(v=>i(w)(v))}e.toPromise=D;function k(w){let v=new I;return w.then(x=>{v.fire(x)},()=>{v.fire(void 0)}).finally(()=>{v.dispose()}),v.event}e.fromPromise=k;function R(w,v){return w(x=>v.fire(x))}e.forward=R;function P(w,v,x){return v(x),w(M=>v(M))}e.runAndSubscribe=P;class A{constructor(v,x){this._observable=v,this._counter=0,this._hasChanged=!1;let M={onWillAddFirstListener:()=>{v.addObserver(this)},onDidRemoveLastListener:()=>{v.removeObserver(this)}};this.emitter=new I(M),x&&x.add(this.emitter)}beginUpdate(v){this._counter++}handlePossibleChange(v){}handleChange(v,x){this._hasChanged=!0}endUpdate(v){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function H(w,v){return new A(w,v).emitter.event}e.fromObservable=H;function C(w){return(v,x,M)=>{let z=0,U=!1,T={beginUpdate(){z++},endUpdate(){z--,z===0&&(w.reportChanges(),U&&(U=!1,v.call(x)))},handlePossibleChange(){},handleChange(){U=!0}};w.addObserver(T),w.reportChanges();let Z={dispose(){w.removeObserver(T)}};return M instanceof qt?M.add(Z):Array.isArray(M)&&M.push(Z),Z}}e.fromObservableLight=C})(Ve||(Ve={}));var Gr=class Yr{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Yr._idPool++}`,Yr.all.add(this)}start(t){this._stopWatch=new wd,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Gr.all=new Set,Gr._idPool=0;var xd=Gr,Cd=-1,$l=class Vl{constructor(t,i,s=(Vl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new Bd(a,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};$l._idPool=1;var kd=$l,Ed=class jl{constructor(t){this.value=t}static create(){let t=new Error;return new jl(t.stack??"")}print(){console.warn(this.value.split(`
|
|
26
|
-
`).slice(2).join(`
|
|
27
|
-
`))}},Bd=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Ld=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Md=0,_r=class{constructor(e){this.value=e,this.id=Md++}},Dd=2,Rd,I=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new kd((e==null?void 0:e.onListenerError)??ss,((i=this._options)==null?void 0:i.leakWarningThreshold)??Cd):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new xd(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,a,h,l,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],_=new Ld(`${f}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(((o=this._options)==null?void 0:o.onListenerError)||ss)(_),Q.None}if(this._disposed)return Q.None;t&&(e=e.bind(t));let s=new _r(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Ed.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof _r?(this._deliveryQueue??(this._deliveryQueue=new Ad),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||h.call(a,this),this._listeners=s,(u=(l=this._options)==null?void 0:l.onDidAddFirstListener)==null||u.call(l,this)),this._size++;let n=me(()=>{r==null||r(),this._removeListener(s)});return i instanceof qt?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-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[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Dd<=t.length){let h=0;for(let l=0;l<t.length;l++)t[l]?t[h++]=t[l]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||ss;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof _r)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},Ad=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Jr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new I,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new I,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Jr.INSTANCE=new Jr;var Wn=Jr;function Td(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Wn.INSTANCE.onDidChangeZoomLevel;function Nd(e){return Wn.INSTANCE.getZoomFactor(e)}Wn.INSTANCE.onDidChangeFullscreen;var fi=typeof navigator=="object"?navigator.userAgent:"",Zr=fi.indexOf("Firefox")>=0,Pd=fi.indexOf("AppleWebKit")>=0,Fn=fi.indexOf("Chrome")>=0,Id=!Fn&&fi.indexOf("Safari")>=0;fi.indexOf("Electron/")>=0;fi.indexOf("Android")>=0;var pr=!1;if(typeof Rt.matchMedia=="function"){let e=Rt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Rt.matchMedia("(display-mode: fullscreen)");pr=e.matches,Td(Rt,e,({matches:i})=>{pr&&t.matches||(pr=i)})}var ai="en",Xr=!1,Qr=!1,rs=!1,Gl=!1,$i,ns=ai,sa=ai,Od,ut,Jt=globalThis,Ke,ol;typeof Jt.vscode<"u"&&typeof Jt.vscode.process<"u"?Ke=Jt.vscode.process:typeof process<"u"&&typeof((ol=process==null?void 0:process.versions)==null?void 0:ol.node)=="string"&&(Ke=process);var al,zd=typeof((al=Ke==null?void 0:Ke.versions)==null?void 0:al.electron)=="string",Hd=zd&&(Ke==null?void 0:Ke.type)==="renderer",ll;if(typeof Ke=="object"){Xr=Ke.platform==="win32",Qr=Ke.platform==="darwin",rs=Ke.platform==="linux",rs&&Ke.env.SNAP&&Ke.env.SNAP_REVISION,Ke.env.CI||Ke.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$i=ai,ns=ai;let e=Ke.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);$i=t.userLocale,sa=t.osLocale,ns=t.resolvedLanguage||ai,Od=(ll=t.languagePack)==null?void 0:ll.translationsConfigFile}catch{}Gl=!0}else typeof navigator=="object"&&!Hd?(ut=navigator.userAgent,Xr=ut.indexOf("Windows")>=0,Qr=ut.indexOf("Macintosh")>=0,(ut.indexOf("Macintosh")>=0||ut.indexOf("iPad")>=0||ut.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,rs=ut.indexOf("Linux")>=0,(ut==null?void 0:ut.indexOf("Mobi"))>=0,ns=globalThis._VSCODE_NLS_LANGUAGE||ai,$i=navigator.language.toLowerCase(),sa=$i):console.error("Unable to resolve platform.");var Yl=Xr,St=Qr,Wd=rs,ra=Gl,xt=ut,Pt=ns,Fd;(e=>{function t(){return Pt}e.value=t;function i(){return Pt.length===2?Pt==="en":Pt.length>=3?Pt[0]==="e"&&Pt[1]==="n"&&Pt[2]==="-":!1}e.isDefaultVariant=i;function s(){return Pt==="en"}e.isDefault=s})(Fd||(Fd={}));var Ud=typeof Jt.postMessage=="function"&&!Jt.importScripts;(()=>{if(Ud){let e=[];Jt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Jt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var qd=!!(xt&&xt.indexOf("Chrome")>=0);xt&&xt.indexOf("Firefox")>=0;!qd&&xt&&xt.indexOf("Safari")>=0;xt&&xt.indexOf("Edg/")>=0;xt&&xt.indexOf("Android")>=0;var ni=typeof navigator=="object"?navigator:{};ra||document.queryCommandSupported&&document.queryCommandSupported("copy")||ni&&ni.clipboard&&ni.clipboard.writeText,ra||ni&&ni.clipboard&&ni.clipboard.readText;var Un=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}},gr=new Un,na=new Un,oa=new Un,Kd=new Array(230),Jl;(e=>{function t(a){return gr.keyCodeToStr(a)}e.toString=t;function i(a){return gr.strToKeyCode(a)}e.fromString=i;function s(a){return na.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return oa.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return na.strToKeyCode(a)||oa.strToKeyCode(a)}e.fromUserSettings=n;function o(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 gr.keyCodeToStr(a)}e.toElectronAccelerator=o})(Jl||(Jl={}));var $d=class Zl{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Zl&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Vd([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Vd=class{constructor(e){if(e.length===0)throw md("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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}};function jd(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Jl.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Zr)switch(t){case 59:return 85;case 60:if(Wd)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(St)return 57;break}else if(Pd&&(St&&t===93||!St&&t===92))return 57;return Kd[t]||0}var Gd=St?256:2048,Yd=512,Jd=1024,Zd=St?2048:256,aa=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=jd(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|=Gd),this.altKey&&(t|=Yd),this.shiftKey&&(t|=Jd),this.metaKey&&(t|=Zd),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new $d(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},la=new WeakMap;function Xd(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Qd=class{static getSameOriginWindowChain(e){let t=la.get(e);if(!t){t=[],la.set(e,t);let i=e,s;do s=Xd(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.left}return{top:i,left:s}}},Vi=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 i=Qd.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ha=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Fn){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):this.deltaY=n.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 h=e;h.deltaMode===h.DOM_DELTA_LINE?Zr&&!St?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Id&&Yl?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):this.deltaX=n.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 h=e;h.deltaMode===h.DOM_DELTA_LINE?Zr&&!St?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Xl=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),eu;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof tu?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ve.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Xl})})(eu||(eu={}));var tu=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?Xl:(this._emitter||(this._emitter=new I),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},qn=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 $r("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new $r("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},iu=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new $r("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=me(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},su;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(su||(su={}));var ca=class lt{static fromArray(t){return new lt(i=>{i.emitMany(t)})}static fromPromise(t){return new lt(async i=>{i.emitMany(await t)})}static fromPromises(t){return new lt(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new lt(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new I,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Ve.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new lt(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return lt.map(this,t)}static filter(t,i){return new lt(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return lt.filter(this,t)}static coalesce(t){return lt.filter(t,i=>!!i)}coalesce(){return lt.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}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())}};ca.EMPTY=ca.fromArray([]);var{getWindow:bt,getWindowId:ru,onDidRegisterWindow:nu}=(function(){let e=new Map,t={window:Rt,disposables:new qt};e.set(Rt.vscodeWindowId,t);let i=new I,s=new I,r=new I;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Q.None;let a=new qt,h={window:o,disposables:a.add(new qt)};return e.set(o.vscodeWindowId,h),a.add(me(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(G(o,Oe.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:Rt},getDocument(o){return bt(o).document}}})(),ou=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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)}};function G(e,t,i,s){return new ou(e,t,i,s)}var da=function(e,t,i,s){return G(e,t,i,s)},Kn,au=class extends iu{constructor(e){super(),this.defaultTarget=e&&bt(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},ua=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){ss(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(ua.sort),o.shift().execute();s.set(n,!1)};Kn=(n,o,a=0)=>{let h=ru(n),l=new ua(o,a),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function lu(e){let t=e.getBoundingClientRect(),i=bt(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Oe={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},hu=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=et(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=et(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=et(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=et(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=et(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=et(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=et(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=et(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=et(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=et(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=et(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=et(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=et(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=et(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)}};function et(e){return typeof e=="number"?`${e}px`:e}function Ti(e){return new hu(e)}var Ql=class{constructor(){this._hooks=new qt,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(me(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=bt(e)}this._hooks.add(G(n,Oe.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(G(n,Oe.POINTER_UP,o=>this.stopMonitoring(!0)))}};function cu(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var yt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(yt||(yt={}));var Ei=class Ge extends Q{constructor(){super(),this.dispatched=!1,this.targets=new ia,this.ignoreTargets=new ia,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ve.runAndSubscribe(nu,({window:t,disposables:i})=>{i.add(G(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(G(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(G(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Rt,disposables:this._store}))}static addTarget(t){if(!Ge.isTouchDevice())return Q.None;Ge.INSTANCE||(Ge.INSTANCE=new Ge);let i=Ge.INSTANCE.targets.push(t);return me(i)}static ignoreTarget(t){if(!Ge.isTouchDevice())return Q.None;Ge.INSTANCE||(Ge.INSTANCE=new Ge);let i=Ge.INSTANCE.ignoreTargets.push(t);return me(i)}static isTouchDevice(){return"ontouchstart"in Rt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(yt.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Ge.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(yt.Tap,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(l>=Ge.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let u=this.newGestureEvent(yt.Contextmenu,h.initialTarget);u.pageX=st(h.rollingPageX),u.pageY=st(h.rollingPageY),this.dispatchEvent(u)}else if(r===1){let u=st(h.rollingPageX),f=st(h.rollingPageY),c=st(h.rollingTimestamps)-h.rollingTimestamps[0],_=u-h.rollingPageX[0],p=f-h.rollingPageY[0],g=[...this.targets].filter(y=>h.initialTarget instanceof Node&&y.contains(h.initialTarget));this.inertia(t,g,s,Math.abs(_)/c,_>0?1:-1,u,Math.abs(p)/c,p>0?1:-1,f)}this.dispatchEvent(this.newGestureEvent(yt.End,h.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===yt.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ge.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===yt.Change||t.type===yt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,a,h,l){this.handle=Kn(t,()=>{let u=Date.now(),f=u-s,c=0,_=0,p=!0;r+=Ge.SCROLL_FRICTION*f,a+=Ge.SCROLL_FRICTION*f,r>0&&(p=!1,c=n*r*f),a>0&&(p=!1,_=h*a*f);let g=this.newGestureEvent(yt.Change);g.translationX=c,g.translationY=_,i.forEach(y=>y.dispatchEvent(g)),p||this.inertia(t,i,u,r,n,o+c,a,h,l+_)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],a=this.newGestureEvent(yt.Change,o.initialTarget);a.translationX=n.pageX-st(o.rollingPageX),a.translationY=n.pageY-st(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ei.SCROLL_FRICTION=-.005,Ei.HOLD_DELAY=700,Ei.CLEAR_TAP_COUNT_TIME=400,ke([cu],Ei,"isTouchDevice",1);var du=Ei,$n=class extends Q{onclick(e,t){this._register(G(e,Oe.CLICK,i=>t(new Vi(bt(e),i))))}onmousedown(e,t){this._register(G(e,Oe.MOUSE_DOWN,i=>t(new Vi(bt(e),i))))}onmouseover(e,t){this._register(G(e,Oe.MOUSE_OVER,i=>t(new Vi(bt(e),i))))}onmouseleave(e,t){this._register(G(e,Oe.MOUSE_LEAVE,i=>t(new Vi(bt(e),i))))}onkeydown(e,t){this._register(G(e,Oe.KEY_DOWN,i=>t(new aa(i))))}onkeyup(e,t){this._register(G(e,Oe.KEY_UP,i=>t(new aa(i))))}oninput(e,t){this._register(G(e,Oe.INPUT,t))}onblur(e,t){this._register(G(e,Oe.BLUR,t))}onfocus(e,t){this._register(G(e,Oe.FOCUS,t))}onchange(e,t){this._register(G(e,Oe.CHANGE,t))}ignoreGesture(e){return du.ignoreTarget(e)}},fa=11,uu=class extends $n{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=fa+"px",this.domNode.style.height=fa+"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 Ql),this._register(da(this.bgDomNode,Oe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(da(this.domNode,Oe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new au),this._pointerdownScheduleRepeatTimer=this._register(new qn)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,bt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},fu=class en{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,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,i){return new en(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new en(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,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:h}}},_u=class extends Q{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new fu(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){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new pa(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=pa.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},_a=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function mr(e,t){let i=t-e;return function(s){return e+i*mu(s)}}function pu(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var pa=class tn{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),pu(mr(t,r),mr(n,i),.33)}return mr(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new _a(s,r,!1)}return new _a(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return tn.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new tn(t,i,r,s)}};function gu(e){return Math.pow(e,3)}function mu(e){return 1-gu(1-e)}var vu=class extends Q{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new qn)}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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},yu=140,eh=class extends $n{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 vu(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ql),this._shouldRender=!0,this.domNode=Ti(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(G(this.domNode.domNode,Oe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new uu(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Ti(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(G(this.slider.domNode,Oe.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=lu(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(Yl&&o>yu){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.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()}},th=class sn{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new sn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),u=(a-l)/(r-s),f=n*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:u,computedSliderPosition:Math.round(f)}}_refreshComputedValues(){let t=sn._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},bu=class extends eh{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new th(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.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}},Su=class extends eh{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new th(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.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}},wu=500,ga=50,xu=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},rn=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,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Fn){let i=bt(t.browserEvent),s=Nd(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new xu(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,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]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),u=Math.max(r,o),f=Math.max(n,a);u%h===0&&f%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};rn.INSTANCE=new rn;var Cu=rn,ku=class extends $n{constructor(e,t,i){super(),this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new I),this.onWillScroll=this._onWillScroll.event,this._options=Bu(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Su(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new bu(this._scrollable,this._options,s)),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=Ti(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ti(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ti(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 qn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Zt(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,St&&(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 ha(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Zt(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new ha(i))};this._mouseWheelToDispose.push(G(this._listenOnDomNode,Oe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Cu.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let a=!St&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let u=ga*n,f=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(l,f)}if(o){let u=ga*o,f=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(l,f)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),wu)}},Eu=class extends ku{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Bu(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,St&&(t.className+=" mac"),t}var nn=class extends Q{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new I),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new _u({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>Kn(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Eu(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),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(Ve.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(me(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(me(()=>this._styleElement.remove())),this._register(Ve.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
28
|
-
`)})),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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};nn=ke([F(2,Ze),F(3,At),F(4,Pl),F(5,ui),F(6,Xe),F(7,Tt)],nn);var on=class extends Q{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,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(n=>this._removeDecoration(n))),this._register(me(()=>{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){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};on=ke([F(1,Ze),F(2,At),F(3,Hi),F(4,Tt)],on);var Lu=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},mt={full:0,left:0,center:0,right:0},It={full:0,left:0,center:0,right:0},mi={full:0,left:0,center:0,right:0},xs=class extends Q{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Lu,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(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(me(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;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(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);It.full=this._canvas.width,It.left=e,It.center=t,It.right=e,this._refreshDrawHeightConstants(),mi.full=1,mi.left=1,mi.center=1+It.left,mi.right=1+It.left+It.center}_refreshDrawHeightConstants(){mt.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);mt.left=t,mt.center=t,mt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*mt.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(mi[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-mt[e.position||"full"]/2),It[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+mt[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}))}};xs=ke([F(2,Ze),F(3,Hi),F(4,Tt),F(5,Xe),F(6,ui),F(7,At)],xs);var L;(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=`
|
|
29
|
-
`,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=""))(L||(L={}));var os;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(os||(os={}));var ih;(e=>e.ST=`${L.ESC}\\`)(ih||(ih={}));var an=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${L.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),i=this._renderService.dimensions.css.cell.height,s=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=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};an=ke([F(2,Ze),F(3,Xe),F(4,ii),F(5,Tt)],an);var He=0,We=0,Fe=0,Ce=0,ma={css:"#00000000",rgba:0},Re;(e=>{function t(r,n,o,a){return a!==void 0?`#${Vt(r)}${Vt(n)}${Vt(o)}${Vt(a)}`:`#${Vt(r)}${Vt(n)}${Vt(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(Re||(Re={}));var ge;(e=>{function t(h,l){if(Ce=(l.rgba&255)/255,Ce===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,f=l.rgba>>16&255,c=l.rgba>>8&255,_=h.rgba>>24&255,p=h.rgba>>16&255,g=h.rgba>>8&255;He=_+Math.round((u-_)*Ce),We=p+Math.round((f-p)*Ce),Fe=g+Math.round((c-g)*Ce);let y=Re.toCss(He,We,Fe),m=Re.toRgba(He,We,Fe);return{css:y,rgba:m}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let f=as.ensureContrastRatio(h.rgba,l.rgba,u);if(f)return Re.toColor(f>>24&255,f>>16&255,f>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[He,We,Fe]=as.toChannels(l),{css:Re.toCss(He,We,Fe),rgba:l}}e.opaque=r;function n(h,l){return Ce=Math.round(l*255),[He,We,Fe]=as.toChannels(h.rgba),{css:Re.toCss(He,We,Fe,Ce),rgba:Re.toRgba(He,We,Fe,Ce)}}e.opacity=n;function o(h,l){return Ce=h.rgba&255,n(h,Ce*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(ge||(ge={}));var Se;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return He=parseInt(r.slice(1,2).repeat(2),16),We=parseInt(r.slice(2,3).repeat(2),16),Fe=parseInt(r.slice(3,4).repeat(2),16),Re.toColor(He,We,Fe);case 5:return He=parseInt(r.slice(1,2).repeat(2),16),We=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(He,We,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 n=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(n)return He=parseInt(n[1]),We=parseInt(n[2]),Fe=parseInt(n[3]),Ce=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Re.toColor(He,We,Fe,Ce);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[He,We,Fe,Ce]=t.getImageData(0,0,1,1).data,Ce!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Re.toRgba(He,We,Fe,Ce),css:r}}e.toColor=s})(Se||(Se={}));var Je;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+f*.0722}e.relativeLuminance2=i})(Je||(Je={}));var as;(e=>{function t(o,a){if(Ce=(a&255)/255,Ce===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,f=o>>24&255,c=o>>16&255,_=o>>8&255;return He=f+Math.round((h-f)*Ce),We=c+Math.round((l-c)*Ce),Fe=_+Math.round((u-_)*Ce),Re.toRgba(He,We,Fe)}e.blend=t;function i(o,a,h){let l=Je.relativeLuminance(o>>8),u=Je.relativeLuminance(a>>8);if(kt(l,u)<h){if(u<l){let _=s(o,a,h),p=kt(l,Je.relativeLuminance(_>>8));if(p<h){let g=r(o,a,h),y=kt(l,Je.relativeLuminance(g>>8));return p>y?_:g}return _}let f=r(o,a,h),c=kt(l,Je.relativeLuminance(f>>8));if(c<h){let _=s(o,a,h),p=kt(l,Je.relativeLuminance(_>>8));return c>p?f:_}return f}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,f=o>>8&255,c=a>>24&255,_=a>>16&255,p=a>>8&255,g=kt(Je.relativeLuminance2(c,_,p),Je.relativeLuminance2(l,u,f));for(;g<h&&(c>0||_>0||p>0);)c-=Math.max(0,Math.ceil(c*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=kt(Je.relativeLuminance2(c,_,p),Je.relativeLuminance2(l,u,f));return(c<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,f=o>>8&255,c=a>>24&255,_=a>>16&255,p=a>>8&255,g=kt(Je.relativeLuminance2(c,_,p),Je.relativeLuminance2(l,u,f));for(;g<h&&(c<255||_<255||p<255);)c=Math.min(255,c+Math.ceil((255-c)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=kt(Je.relativeLuminance2(c,_,p),Je.relativeLuminance2(l,u,f));return(c<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(as||(as={}));function Vt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function kt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Mu=class extends zi{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},Cs=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new dt}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,a=t.getFg(0),h=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!==h){if(l-r>1){let u=this._getJoinedRanges(s,o,n,t,r);for(let f=0;f<u.length;f++)i.push(u[f])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||Ut.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<l.length;u++)i.push(l[u])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)Cs._mergeRanges(o,h[l])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||Ut.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Cs=ke([F(0,Ze)],Cs);function Du(e){return 57508<=e&&e<=57558}function Ru(e){return 9472<=e&&e<=9631}function Au(e){return Du(e)||Ru(e)}function Tu(){return{css:{canvas:ji(),cell:ji()},device:{canvas:ji(),cell:ji(),char:{width:0,height:0,left:0,top:0}}}}function ji(){return{width:0,height:0}}var ln=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new dt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,a,h,l,u){let f=[],c=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let g,y=0,m="",E=0,b=0,S=0,D=0,k=!1,R=0,P=!1,A=0,H=0,C=[],w=l!==-1&&u!==-1;for(let v=0;v<p;v++){e.loadCell(v,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let M=!1,z=v>=H,U=v,T=this._workCell;if(c.length>0&&v===c[0][0]&&z){let ie=c.shift(),Ie=this._isCellInSelection(ie[0],t);for(E=ie[0]+1;E<ie[1];E++)z&&(z=Ie===this._isCellInSelection(E,t));z&&(z=!i||n<ie[0]||n>=ie[1]),z?(M=!0,T=new Mu(this._workCell,e.translateToString(!0,ie[0],ie[1]),ie[1]-ie[0]),U=ie[1]-1,x=T.getWidth()):H=ie[1]}let Z=this._isCellInSelection(v,t),ne=i&&v===n,pe=w&&v>=l&&v<=u,we=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,ie=>{we=!0});let _e=T.getChars()||Ut;if(_e===" "&&(T.isUnderline()||T.isOverline())&&(_e=" "),A=x*a-h.get(_e,T.isBold(),T.isItalic()),!g)g=this._document.createElement("span");else if(y&&(Z&&P||!Z&&!P&&T.bg===b)&&(Z&&P&&_.selectionForeground||T.fg===S)&&T.extended.ext===D&&pe===k&&A===R&&!ne&&!M&&!we&&z){T.isInvisible()?m+=Ut:m+=_e,y++;continue}else y&&(g.textContent=m),g=this._document.createElement("span"),y=0,m="";if(b=T.bg,S=T.fg,D=T.extended.ext,k=pe,R=A,P=Z,M&&n>=v&&n<=U&&(n=v),!this._coreService.isCursorHidden&&ne&&this._coreService.isCursorInitialized){if(C.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&C.push("xterm-cursor-blink"),C.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":C.push("xterm-cursor-outline");break;case"block":C.push("xterm-cursor-block");break;case"bar":C.push("xterm-cursor-bar");break;case"underline":C.push("xterm-cursor-underline");break}}if(T.isBold()&&C.push("xterm-bold"),T.isItalic()&&C.push("xterm-italic"),T.isDim()&&C.push("xterm-dim"),T.isInvisible()?m=Ut:m=T.getChars()||Ut,T.isUnderline()&&(C.push(`xterm-underline-${T.extended.underlineStyle}`),m===" "&&(m=" "),!T.isUnderlineColorDefault()))if(T.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${zi.toColorRGB(T.getUnderlineColor()).join(",")})`;else{let ie=T.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&T.isBold()&&ie<8&&(ie+=8),g.style.textDecorationColor=_.ansi[ie].css}T.isOverline()&&(C.push("xterm-overline"),m===" "&&(m=" ")),T.isStrikethrough()&&C.push("xterm-strikethrough"),pe&&(g.style.textDecoration="underline");let oe=T.getFgColor(),W=T.getFgColorMode(),ee=T.getBgColor(),V=T.getBgColorMode(),de=!!T.isInverse();if(de){let ie=oe;oe=ee,ee=ie;let Ie=W;W=V,V=Ie}let re,je,ot=!1;this._decorationService.forEachDecorationAtCell(v,t,void 0,ie=>{ie.options.layer!=="top"&&ot||(ie.backgroundColorRGB&&(V=50331648,ee=ie.backgroundColorRGB.rgba>>8&16777215,re=ie.backgroundColorRGB),ie.foregroundColorRGB&&(W=50331648,oe=ie.foregroundColorRGB.rgba>>8&16777215,je=ie.foregroundColorRGB),ot=ie.options.layer==="top")}),!ot&&Z&&(re=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,ee=re.rgba>>8&16777215,V=50331648,ot=!0,_.selectionForeground&&(W=50331648,oe=_.selectionForeground.rgba>>8&16777215,je=_.selectionForeground)),ot&&C.push("xterm-decoration-top");let qe;switch(V){case 16777216:case 33554432:qe=_.ansi[ee],C.push(`xterm-bg-${ee}`);break;case 50331648:qe=Re.toColor(ee>>16,ee>>8&255,ee&255),this._addStyle(g,`background-color:#${va((ee>>>0).toString(16),"0",6)}`);break;case 0:default:de?(qe=_.foreground,C.push("xterm-bg-257")):qe=_.background}switch(re||T.isDim()&&(re=ge.multiplyOpacity(qe,.5)),W){case 16777216:case 33554432:T.isBold()&&oe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(oe+=8),this._applyMinimumContrast(g,qe,_.ansi[oe],T,re,void 0)||C.push(`xterm-fg-${oe}`);break;case 50331648:let ie=Re.toColor(oe>>16&255,oe>>8&255,oe&255);this._applyMinimumContrast(g,qe,ie,T,re,je)||this._addStyle(g,`color:#${va(oe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,qe,_.foreground,T,re,je)||de&&C.push("xterm-fg-257")}C.length&&(g.className=C.join(" "),C.length=0),!ne&&!M&&!we&&z?y++:g.textContent=m,A!==this.defaultSpacing&&(g.style.letterSpacing=`${A}px`),f.push(g),v=U}return g&&y&&(g.textContent=m),f}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Au(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=ge.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};ln=ke([F(1,zl),F(2,Xe),F(3,At),F(4,ii),F(5,Hi),F(6,ui)],ln);function va(e,t,i){for(;e.length<i;)e=t+e;return e}var Nu=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Pu=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Iu(){return new Pu}var vr="xterm-dom-renderer-owner-",at="xterm-rows",Gi="xterm-fg-",ya="xterm-bg-",vi="xterm-focus",Yi="xterm-selection",Ou=1,hn=class extends Q{constructor(e,t,i,s,r,n,o,a,h,l,u,f,c,_){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=u,this._coreService=f,this._coreBrowserService=c,this._themeService=_,this._terminalClass=Ou++,this._rowElements=[],this._selectionRenderModel=Iu(),this.onRequestRedraw=this._register(new I).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(at),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(Yi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Tu(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(ln,document),this._element.classList.add(vr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(me(()=>{this._element.classList.remove(vr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Nu(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${at} 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} .${at} { 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} .${at} .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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${at}.${vi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${at}.${vi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${at}.${vi} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Yi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Yi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Yi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Gi}${n} { color: ${o.css}; }${this._terminalSelector} .${Gi}${n}.xterm-dim { color: ${ge.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${ya}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Gi}257 { color: ${ge.opaque(e.background).css}; }${this._terminalSelector} .${Gi}257.xterm-dim { color: ${ge.multiplyOpacity(ge.opaque(e.background),.5).css}; }${this._terminalSelector} .${ya}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(vi),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(vi),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let u=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,u)),n!==o){let f=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,f))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,u=this._rowElements[h],f=i.lines.get(l);if(!u||!f)break;u.replaceChildren(...this._rowFactory.createRow(f,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${vr}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),u=this._optionsService.rawOptions.cursorBlink,f=this._optionsService.rawOptions.cursorStyle,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=i;_<=s;++_){let p=_+a.ydisp,g=this._rowElements[_],y=a.lines.get(p);if(!g||!y)break;g.replaceChildren(...this._rowFactory.createRow(y,p,p===h,f,c,l,u,this.dimensions.css.cell.width,this._widthCache,n?_===i?e:0:-1,n?(_===s?t:r)-1:-1))}}};hn=ke([F(7,zn),F(8,Ns),F(9,Xe),F(10,Ze),F(11,ii),F(12,At),F(13,ui)],hn);var cn=class extends Q{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new I),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Hu(this._optionsService))}catch{this._measureStrategy=this._register(new zu(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())}};cn=ke([F(2,Xe)],cn);var sh=class extends Q{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)}},zu=class extends sh{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},Hu=class extends sh{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}},Wu=class extends Q{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Fu(this._window)),this._onDprChange=this._register(new I),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new I),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ve.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(G(this._textarea,"focus",()=>this._isFocused=!0)),this._register(G(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}},Fu=class extends Q{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new di),this._onDprChange=this._register(new I),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(me(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=G(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},Uu=class extends Q{constructor(){super(),this.linkProviders=[],this._register(me(()=>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)}}}};function Vn(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function qu(e,t,i,s,r,n,o,a,h){if(!n)return;let l=Vn(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var dn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return qu(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Vn(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};dn=ke([F(0,Tt),F(1,Ns)],dn);var Ku=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,i){this._rowCount=i,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=[]}},rh={};ed(rh,{getSafariVersion:()=>Vu,isChromeOS:()=>lh,isFirefox:()=>nh,isIpad:()=>ju,isIphone:()=>Gu,isLegacyEdge:()=>$u,isLinux:()=>jn,isMac:()=>ks,isNode:()=>Ps,isSafari:()=>oh,isWindows:()=>ah});var Ps=typeof process<"u"&&"title"in process,Wi=Ps?"node":navigator.userAgent,Fi=Ps?"node":navigator.platform,nh=Wi.includes("Firefox"),$u=Wi.includes("Edge"),oh=/^((?!chrome|android).)*safari/i.test(Wi);function Vu(){if(!oh)return 0;let e=Wi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ks=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Fi),ju=Fi==="iPad",Gu=Fi==="iPhone",ah=["Windows","Win16","Win32","WinCE"].includes(Fi),jn=Fi.indexOf("Linux")>=0,lh=/\bCrOS\b/.test(Wi),hh=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,i=0,s=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),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Yu=class extends hh{_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())}}},Ju=class extends hh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Es=!Ps&&"requestIdleCallback"in window?Ju:Yu,Zu=class{constructor(){this._queue=new Es}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},un=class extends Q{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new di),this._pausedResizeTask=new Zu,this._observerDisposable=this._register(new di),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 I),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new I),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new I),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new I),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Ku((l,u)=>this._renderRows(l,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Xu(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(me(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var l;return(l=this._renderer.value)==null?void 0:l.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.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 i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=me(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};un=ke([F(2,Xe),F(3,Ns),F(4,ii),F(5,Hi),F(6,Ze),F(7,At),F(8,ui)],un);var Xu=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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)}};function Qu(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return sf(r,n,e,t,i,s)+Is(n,t,i,s)+rf(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Ii(Math.abs(r-e),Pi(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=tf(n>t?e:r,i)+(a-1)*i.cols+1+ef(n>t?r:e);return Ii(h,Pi(o,s))}function ef(e,t){return e-1}function tf(e,t){return t.cols-e}function sf(e,t,i,s,r,n){return Is(t,s,r,n).length===0?"":Ii(dh(e,t,e,t-Xt(t,r),!1,r).length,Pi("D",n))}function Is(e,t,i,s){let r=e-Xt(e,i),n=t-Xt(t,i),o=Math.abs(r-n)-nf(e,t,i);return Ii(o,Pi(ch(e,t),s))}function rf(e,t,i,s,r,n){let o;Is(t,s,r,n).length>0?o=s-Xt(s,r):o=t;let a=s,h=of(e,t,i,s,r,n);return Ii(dh(e,o,i,a,h==="C",r).length,Pi(h,n))}function nf(e,t,i){var o;let s=0,r=e-Xt(e,i),n=t-Xt(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=ch(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function Xt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function of(e,t,i,s,r,n){let o;return Is(i,s,r,n).length>0?o=s-Xt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function ch(e,t){return e>t?"A":"B"}function dh(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function Pi(e,t){let i=t?"O":"[";return L.ESC+i+e}function Ii(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var af=class{constructor(t){this._bufferService=t,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 t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,i=this.selectionEnd;return!t||!i?!1:t[1]>i[1]||t[1]===i[1]&&t[0]>i[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function ba(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)}var yr=50,lf=15,hf=50,cf=500,df=" ",uf=new RegExp(df,"g"),fn=class extends Q{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new dt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new I),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new I),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new I),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new I),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 af(this._bufferService),this._activeSelectionMode=0,this._register(me(()=>{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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(uf," ")).join(ah?`\r
|
|
30
|
-
`:`
|
|
31
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),jn&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=ba(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Vn(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-yr),yr),t/=yr,t/Math.abs(t)+Math.round(t*(lf-1)))}shouldForceSelection(e){return ks?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(),hf)}_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&&!(ks&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<cf&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=Qu(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,u=0,f=0,c=0,_=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let y=e[0],m=e[0];n.getWidth(y)===0&&(u++,y--),n.getWidth(m)===2&&(f++,m++);let E=n.getString(m).length;for(E>1&&(_+=E-1,h+=E-1);y>0&&a>0&&!this._isCharWordSeparator(n.loadCell(y-1,this._workCell));){n.loadCell(y-1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,y--):b>1&&(c+=b-1,a-=b-1),a--,y--}for(;m<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(m+1,this._workCell));){n.loadCell(m+1,this._workCell);let b=this._workCell.getChars().length;this._workCell.getWidth()===2?(f++,m++):b>1&&(_+=b-1,h+=b-1),h++,m++}}h++;let p=a+l-u+c,g=Math.min(this._bufferService.cols,h-a+u+f-c-_);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&p===0&&n.getCodePoint(0)!==32){let y=r.lines.get(e[1]-1);if(y&&n.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let m=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(m){let E=this._bufferService.cols-m.start;p-=E,g+=E}}}if(s&&p+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let y=r.lines.get(e[1]+1);if(y!=null&&y.isWrapped&&y.getCodePoint(0)!==32){let m=this._getWordAt([0,e[1]+1],!1,!1,!0);m&&(g+=m.length)}}return{start:p,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=ba(i,this._bufferService.cols)}};fn=ke([F(3,Ze),F(4,ii),F(5,Hn),F(6,Xe),F(7,Tt),F(8,At)],fn);var Sa=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},wa=class{constructor(){this._color=new Sa,this._css=new Sa}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Te=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 i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:Re.toCss(s,r,n),rgba:Re.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Re.toCss(s,s,s),rgba:Re.toRgba(s,s,s)})}return e})()),jt=Se.toColor("#ffffff"),Bi=Se.toColor("#000000"),xa=Se.toColor("#ffffff"),Ca=Bi,yi={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ff=jt,_n=class extends Q{constructor(e){super(),this._optionsService=e,this._contrastCache=new wa,this._halfContrastCache=new wa,this._onChangeColors=this._register(new I),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:jt,background:Bi,cursor:xa,cursorAccent:Ca,selectionForeground:void 0,selectionBackgroundTransparent:yi,selectionBackgroundOpaque:ge.blend(Bi,yi),selectionInactiveBackgroundTransparent:yi,selectionInactiveBackgroundOpaque:ge.blend(Bi,yi),scrollbarSliderBackground:ge.opacity(jt,.2),scrollbarSliderHoverBackground:ge.opacity(jt,.4),scrollbarSliderActiveBackground:ge.opacity(jt,.5),overviewRulerBorder:jt,ansi:Te.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=ue(e.foreground,jt),t.background=ue(e.background,Bi),t.cursor=ge.blend(t.background,ue(e.cursor,xa)),t.cursorAccent=ge.blend(t.background,ue(e.cursorAccent,Ca)),t.selectionBackgroundTransparent=ue(e.selectionBackground,yi),t.selectionBackgroundOpaque=ge.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ue(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ge.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ue(e.selectionForeground,ma):void 0,t.selectionForeground===ma&&(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=ue(e.scrollbarSliderBackground,ge.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ue(e.scrollbarSliderHoverBackground,ge.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ue(e.scrollbarSliderActiveBackground,ge.opacity(t.foreground,.5)),t.overviewRulerBorder=ue(e.overviewRulerBorder,ff),t.ansi=Te.slice(),t.ansi[0]=ue(e.black,Te[0]),t.ansi[1]=ue(e.red,Te[1]),t.ansi[2]=ue(e.green,Te[2]),t.ansi[3]=ue(e.yellow,Te[3]),t.ansi[4]=ue(e.blue,Te[4]),t.ansi[5]=ue(e.magenta,Te[5]),t.ansi[6]=ue(e.cyan,Te[6]),t.ansi[7]=ue(e.white,Te[7]),t.ansi[8]=ue(e.brightBlack,Te[8]),t.ansi[9]=ue(e.brightRed,Te[9]),t.ansi[10]=ue(e.brightGreen,Te[10]),t.ansi[11]=ue(e.brightYellow,Te[11]),t.ansi[12]=ue(e.brightBlue,Te[12]),t.ansi[13]=ue(e.brightMagenta,Te[13]),t.ansi[14]=ue(e.brightCyan,Te[14]),t.ansi[15]=ue(e.brightWhite,Te[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=ue(e.extendedAnsi[s],Te[s+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()}}};_n=ke([F(0,Xe)],_n);function ue(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}var _f=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},pf=class{constructor(){this._services=new _f,this._services.set(zn,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=ad(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[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,...s)}},gf={trace:0,debug:1,info:2,warn:3,error:4,off:5},mf="xterm.js: ",pn=class extends Q{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=gf[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":mf)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};pn=ke([F(0,Xe)],pn);var ka=class extends Q{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new I),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new I),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new I),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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},X=3,Me=Object.freeze(new zi),Ji=0,br=2,Li=class uh{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*X);let r=i||dt.fromCharData([0,Rl,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*X+0],s=i&2097151;return[this._data[t*X+1],i&2097152?this._combined[t]:s?Wt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*X+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*X+0]=t|2097152|i[2]<<22):this._data[t*X+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*X+0]>>22}hasWidth(t){return this._data[t*X+0]&12582912}getFg(t){return this._data[t*X+1]}getBg(t){return this._data[t*X+2]}hasContent(t){return this._data[t*X+0]&4194303}getCodePoint(t){let i=this._data[t*X+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*X+0]&2097152}getString(t){let i=this._data[t*X+0];return i&2097152?this._combined[t]:i&2097151?Wt(i&2097151):""}isProtected(t){return this._data[t*X+2]&536870912}loadCell(t,i){return Ji=t*X,i.content=this._data[Ji+0],i.fg=this._data[Ji+1],i.bg=this._data[Ji+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*X+0]=i.content,this._data[t*X+1]=i.fg,this._data[t*X+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*X+0]=i|s<<22,this._data[t*X+1]=r.fg,this._data[t*X+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*X+0];r&2097152?this._combined[t]+=Wt(i):r&2097151?(this._combined[t]=Wt(r&2097151)+Wt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*X+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new dt;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new dt;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*br<this._data.buffer.byteLength;let s=t*X;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*br<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*br<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new uh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*X+0]&4194303)return t+(this._data[t*X+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*X+0]&4194303||this._data[t*X+2]&50331648)return t+(this._data[t*X+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<X;l++)this._data[(s+h)*X+l]=o[(i+h)*X+l];o[(i+h)*X+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<X;l++)this._data[(s+h)*X+l]=o[(i+h)*X+l];o[(i+h)*X+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*X+0],a=o&2097151,h=o&2097152?this._combined[i]:a?Wt(a):Ut;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function vf(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let u=[e.get(a)];for(;h<e.length&&l.isWrapped;)u.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=u.length-1;continue}let f=0,c=Oi(u,f,t),_=1,p=0;for(;_<u.length;){let y=Oi(u,_,t),m=y-p,E=i-c,b=Math.min(m,E);u[f].copyCellsFrom(u[_],p,c,b,!1),c+=b,c===i&&(f++,c=0),p+=b,p===y&&(_++,p=0),c===0&&f!==0&&u[f-1].getWidth(i-1)===2&&(u[f].copyCellsFrom(u[f-1],i-1,c++,1,!1),u[f-1].setCell(i-1,r))}u[f].replaceCells(c,i,r);let g=0;for(let y=u.length-1;y>0&&(y>f||u[y].getTrimmedLength()===0);y--)g++;g>0&&(o.push(a+u.length-g),o.push(g)),a+=u.length-1}return o}function yf(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function bf(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Sf(e,t,i){let s=[],r=e.map((h,l)=>Oi(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=Oi(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function Oi(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var fh=class _h{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=_h._nextId++,this._onDispose=this.register(new I),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Zt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};fh._nextId=1;var wf=fh,Pe={},Gt=Pe.B;Pe[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Pe.A={"#":"£"};Pe.B=void 0;Pe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pe.C=Pe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pe.E=Pe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pe.H=Pe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Ea=4294967295,Ba=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Me.clone(),this.savedCharset=Gt,this.markers=[],this._nullCell=dt.fromCharData([0,Rl,1,0]),this._whitespaceCell=dt.fromCharData([0,Ut,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Es,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ka(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 ws),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 ws),this._whitespaceCell}getBlankLine(e,t){return new Li(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>Ea?Ea:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Me);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 ka(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Me),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 Li(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Li(e,i)));else for(let o=this._rows;o>t;o--)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 o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=vf(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Me),i);if(s.length>0){let r=yf(this.lines,s);bf(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Me),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Li(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Me),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let b=this.ybase+this.y;if(b>=o&&b<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=Sf(h,this._cols,e),f=u.length-h.length,c;this.ybase===0&&this.y!==this.lines.length-1?c=Math.max(0,this.y-this.lines.maxLength+f):c=Math.max(0,this.lines.length-this.lines.maxLength+f);let _=[];for(let b=0;b<f;b++){let S=this.getBlankLine(Me,!0);_.push(S)}_.length>0&&(r.push({start:o+h.length+n,newLines:_}),n+=_.length),h.push(..._);let p=u.length-1,g=u[p];g===0&&(p--,g=u[p]);let y=h.length-f-1,m=l;for(;y>=0;){let b=Math.min(m,g);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[y],m-b,g-b,b,!0),g-=b,g===0&&(p--,g=u[p]),m-=b,m===0){y--;let S=Math.max(y,0);m=Oi(h,S,this._cols)}}for(let b=0;b<h.length;b++)u[b]<e&&h[b].setCell(u[b],s);let E=f-c;for(;E-- >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+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let h=this.lines.length,l=h-1,u=0,f=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let c=0;for(let g=Math.min(this.lines.maxLength-1,h+n-1);g>=0;g--)if(f&&f.start>l+c){for(let y=f.newLines.length-1;y>=0;y--)this.lines.set(g--,f.newLines[y]);g++,o.push({index:l+1,amount:f.newLines.length}),c+=f.newLines.length,f=r[++u]}else this.lines.set(g,a[l--]);let _=0;for(let g=o.length-1;g>=0;g--)o[g].index+=_,this.lines.onInsertEmitter.fire(o[g]),_+=o[g].amount;let p=Math.max(0,h+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 wf(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},xf=class extends Q{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new I),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 Ba(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ba(!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)}},ph=2,gh=1,gn=class extends Q{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new I),this.onResize=this._onResize.event,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ph),this.rows=Math.max(e.rawOptions.rows||0,gh),this.buffers=this._register(new xf(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};gn=ke([F(0,Xe)],gn);var oi={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:ks,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Cf=["normal","bold","100","200","300","400","500","600","700","800","900"],kf=class extends Q{constructor(e){super(),this._onOptionChange=this._register(new I),this.onOptionChange=this._onOptionChange.event;let t={...oi};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(me(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in oi))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in oi))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=oi[e]),!Ef(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=oi[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Cf.includes(t)?t:oi[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Ef(e){return e==="block"||e==="underline"||e==="bar"}function Mi(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Mi(e[s],t-1);return i}var La=Object.freeze({insertMode:!1}),Ma=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),mn=class extends Q{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new I),this.onData=this._onData.event,this._onUserInput=this._register(new I),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new I),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new I),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Mi(La),this.decPrivateModes=Mi(Ma)}reset(){this.modes=Mi(La),this.decPrivateModes=Mi(Ma)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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))}};mn=ke([F(0,Ze),F(1,Il),F(2,Xe)],mn);var Da={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Sr(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var wr=String.fromCharCode,Ra={DEFAULT:e=>{let t=[Sr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${wr(t[0])}${wr(t[1])}${wr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Sr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Sr(e,!0)};${e.x};${e.y}${t}`}},vn=class extends Q{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new I),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Da))this.addProtocol(s,Da[s]);for(let s of Object.keys(Ra))this.addEncoding(s,Ra[s]);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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+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,i){if(i){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)}};vn=ke([F(0,Ze),F(1,ii),F(2,Xe)],vn);var xr=[[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]],Bf=[[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]],Ne;function Lf(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Mf=class{constructor(){if(this.version="6",!Ne){Ne=new Uint8Array(65536),Ne.fill(1),Ne[0]=0,Ne.fill(0,1,32),Ne.fill(0,127,160),Ne.fill(2,4352,4448),Ne[9001]=2,Ne[9002]=2,Ne.fill(2,11904,42192),Ne[12351]=1,Ne.fill(2,44032,55204),Ne.fill(2,63744,64256),Ne.fill(2,65040,65050),Ne.fill(2,65072,65136),Ne.fill(2,65280,65377),Ne.fill(2,65504,65511);for(let e=0;e<xr.length;++e)Ne.fill(0,xr[e][0],xr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ne[e]:Lf(e,Bf)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=Yt.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return Yt.createPropertyValue(0,i,s)}},Yt=class ls{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new I,this.onChange=this._onChange.event;let t=new Mf;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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 i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=ls.extractWidth(a);ls.extractShouldJoin(a)&&(h-=ls.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Df=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Aa(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var bi=2147483647,Rf=256,mh=class yn{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Rf)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new yn;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new yn(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>bi?bi: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>bi?bi:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,bi):t}},Si=[],Af=class{constructor(){this._state=0,this._active=Si,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=Si}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=Si,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Si,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Ts(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Si,this._id=-1,this._state=0}}},rt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ts(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},wi=[],Tf=class{constructor(){this._handlers=Object.create(null),this._active=wi,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=wi}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=wi,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||wi,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Ts(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=wi,this._ident=0}},Di=new mh;Di.addParam(0);var Ta=class{constructor(e){this._handler=e,this._data="",this._params=Di,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Di,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ts(e,t,i),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(i=>(this._params=Di,this._data="",this._hitLimit=!1,i));return this._params=Di,this._data="",this._hitLimit=!1,t}},Nf=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},ht=160,Pf=(function(){let e=new Nf(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,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(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ht,0,2,0),e.add(ht,8,5,8),e.add(ht,6,0,6),e.add(ht,11,0,11),e.add(ht,13,13,13),e})(),If=class extends Q{constructor(e=Pf){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 mh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(me(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Af),this._dcsParser=this._register(new Tf),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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 n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===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,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:ht)],r>>4){case 2:for(let c=a+1;;++c){if(c>=t||(s=e[c])<32||s>126&&s<ht){this._printHandler(e,a,c),a=c-1;break}if(++c>=t||(s=e[c])<32||s>126&&s<ht){this._printHandler(e,a,c),a=c-1;break}if(++c>=t||(s=e[c])<32||s>126&&s<ht){this._printHandler(e,a,c),a=c-1;break}if(++c>=t||(s=e[c])<32||s>126&&s<ht){this._printHandler(e,a,c),a=c-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],f=u?u.length-1:-1;for(;f>=0&&(o=u[f](),o!==!0);f--)if(o instanceof Promise)return this._preserveStack(4,u,f,r,a),o;f<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let c=a+1;;++c)if(c>=t||(s=e[c])===24||s===26||s===27||s>127&&s<ht){this._dcsParser.put(e,a,c),a=c-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),o;s===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 c=a+1;;c++)if(c>=t||(s=e[c])<32||s>127&&s<ht){this._oscParser.put(e,a,c),a=c-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Of=/^([\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})$/,zf=/^[\da-f]+$/;function Na(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Of.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),zf.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Cr(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Hf(e,t=16){let[i,s,r]=e;return`rgb:${Cr(i,t)}/${Cr(s,t)}/${Cr(r,t)}`}var Wf={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ot=131072,Pa=10;function Ia(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Oa=5e3,za=0,Ff=class extends Q{constructor(e,t,i,s,r,n,o,a,h=new If){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nd,this._utf8Decoder=new od,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Me.clone(),this._eraseAttrDataInternal=Me.clone(),this._onRequestBell=this._register(new I),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new I),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new I),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new I),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new I),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new I),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new I),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new I),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new I),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new I),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new I),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new I),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 bn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.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,u,f)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:f})}),this._parser.setDcsHandlerFallback((l,u,f)=>{u==="HOOK"&&(f=f.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:f})}),this._parser.setPrintHandler((l,u,f)=>this.print(l,u,f)),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(L.BEL,()=>this.bell()),this._parser.setExecuteHandler(L.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(L.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(L.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(L.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(L.BS,()=>this.backspace()),this._parser.setExecuteHandler(L.HT,()=>this.tab()),this._parser.setExecuteHandler(L.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(L.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(os.IND,()=>this.index()),this._parser.setExecuteHandler(os.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(os.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new rt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new rt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new rt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new rt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new rt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new rt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new rt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new rt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new rt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new rt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new rt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new rt(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 Pe)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 Ta((l,u)=>this.requestStatusString(l,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Oa))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Oa} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ot&&(n=this._parseStack.position+Ot)}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<Ot&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ot))),o||this._dirtyRowTracker.clearRange(),e.length>Ot)for(let l=n;l<e.length;l+=Ot){let u=l+Ot<e.length?l+Ot:e.length,f=typeof e=="string"?this._stringDecoder.decode(e.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,u),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,r,f,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&f.getWidth(this._activeBuffer.x-1)===2&&f.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let c=this._parser.precedingJoinState;for(let _=t;_<i;++_){if(s=e[_],s<127&&n){let m=n[String.fromCharCode(s)];m&&(s=m.charCodeAt(0))}let p=this._unicodeService.charProperties(s,c);r=Yt.extractWidth(p);let g=Yt.extractShouldJoin(p),y=g?Yt.extractWidth(c):0;if(c=p,o&&this._onA11yChar.fire(Wt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-y>a){if(h){let m=f,E=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&f instanceof Li&&f.copyCellsFrom(m,E,0,y,!1);E<a;)m.setCellFromCodepoint(E++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(g&&this._activeBuffer.x){let m=f.getWidth(this._activeBuffer.x-1)?1:2;f.addCodepointToCell(this._activeBuffer.x-m,s,r);for(let E=r-y;--E>=0;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(f.insertCells(this._activeBuffer.x,r-y,this._activeBuffer.getNullCell(u)),f.getWidth(a-1)===2&&f.setCellFromCodepoint(a-1,0,1,u)),f.setCellFromCodepoint(this._activeBuffer.x++,s,r,u),r>0)for(;--r;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=c,this._activeBuffer.x<a&&i-t>0&&f.getWidth(this._activeBuffer.x)===0&&!f.hasContent(this._activeBuffer.x)&&f.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Ia(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Ta(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new rt(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,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}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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,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}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(Me));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=Yt.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(L.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(L.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(L.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(L.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(L.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,Gt),this._charsetService.setgCharset(1,Gt),this._charsetService.setgCharset(2,Gt),this._charsetService.setgCharset(3,Gt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,f=this._optionsService.rawOptions,c=(g,y)=>(o.triggerDataEvent(`${L.ESC}[${t?"":"?"}${g};${y}$y`),!0),_=g=>g?1:2,p=e.params[0];return t?p===2?c(p,4):p===4?c(p,_(o.modes.insertMode)):p===12?c(p,3):p===20?c(p,_(f.convertEol)):c(p,0):p===1?c(p,_(s.applicationCursorKeys)):p===3?c(p,f.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?c(p,_(s.origin)):p===7?c(p,_(s.wraparound)):p===8?c(p,3):p===9?c(p,_(r==="X10")):p===12?c(p,_(f.cursorBlink)):p===25?c(p,_(!o.isCursorHidden)):p===45?c(p,_(s.reverseWraparound)):p===66?c(p,_(s.applicationKeypad)):p===67?c(p,4):p===1e3?c(p,_(r==="VT200")):p===1002?c(p,_(r==="DRAG")):p===1003?c(p,_(r==="ANY")):p===1004?c(p,_(s.sendFocus)):p===1005?c(p,4):p===1006?c(p,_(n==="SGR")):p===1015?c(p,4):p===1016?c(p,_(n==="SGR_PIXELS")):p===1048?c(p,1):p===47||p===1047||p===1049?c(p,_(l===u)):p===2004?c(p,_(s.bracketedPasteMode)):p===2026?c(p,_(s.synchronizedOutput)):c(p,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=zi.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_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=Me.fg,e.bg=Me.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Me.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Me.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Me.fg&16777215,s.bg&=-67108864,s.bg|=Me.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${L.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${L.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${L.ESC}[?${t};${i}R`);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=Me.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Ia(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(`${L.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Pa&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Pa&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Ha(n))if(r==="?")t.push({type:0,index:n});else{let o=Na(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Na(i[s]);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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Ha(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,Gt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Wf[e[0]],Pe[e[1]]||Gt),!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=Me.clone(),this._eraseAttrDataInternal=Me.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 dt;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${L.ESC}${o}${L.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.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)}},bn=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&&(za=e,e=t,t=za),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};bn=ke([F(0,Ze)],bn);function Ha(e){return 0<=e&&e<256}var Uf=5e7,Wa=12,qf=50,Kf=class extends Q{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 I),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Uf)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=a=>performance.now()-i>=Wa?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Wa)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>qf&&(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()}},Sn=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),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Sn=ke([F(0,Ze)],Sn);var Fa=!1,$f=class extends Q{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new di),this._onBinary=this._register(new I),this.onBinary=this._onBinary.event,this._onData=this._register(new I),this.onData=this._onData.event,this._onLineFeed=this._register(new I),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new I),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new I),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new I),this._instantiationService=new pf,this.optionsService=this._register(new kf(e)),this._instantiationService.setService(Xe,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(gn)),this._instantiationService.setService(Ze,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(pn)),this._instantiationService.setService(Il,this._logService),this.coreService=this._register(this._instantiationService.createInstance(mn)),this._instantiationService.setService(ii,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(vn)),this._instantiationService.setService(Pl,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Yt)),this._instantiationService.setService(cd,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Df),this._instantiationService.setService(hd,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Sn),this._instantiationService.setService(Ol,this._oscLinkService),this._inputHandler=this._register(new Ff(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ve.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ve.forward(this._bufferService.onResize,this._onResize)),this._register(Ve.forward(this.coreService.onData,this._onData)),this._register(Ve.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 Kf((t,i)=>this._inputHandler.parse(t,i))),this._register(Ve.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new I),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!Fa&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Fa=!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,ph),t=Math.max(t,gh),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(Aa.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Aa(this._bufferService),!1))),this._windowsWrappingHeuristics.value=me(()=>{for(let t of e)t.dispose()})}}},Vf={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function jf(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(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=L.ESC+"OA":r.key=L.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=L.ESC+"OD":r.key=L.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=L.ESC+"OC":r.key=L.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=L.ESC+"OB":r.key=L.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":L.DEL,e.altKey&&(r.key=L.ESC+r.key);break;case 9:if(e.shiftKey){r.key=L.ESC+"[Z";break}r.key=L.HT,r.cancel=!0;break;case 13:r.key=e.altKey?L.ESC+L.CR:L.CR,r.cancel=!0;break;case 27:r.key=L.ESC,e.altKey&&(r.key=L.ESC+L.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"D":t?r.key=L.ESC+"OD":r.key=L.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"C":t?r.key=L.ESC+"OC":r.key=L.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"A":t?r.key=L.ESC+"OA":r.key=L.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=L.ESC+"[1;"+(n+1)+"B":t?r.key=L.ESC+"OB":r.key=L.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=L.ESC+"[2~");break;case 46:n?r.key=L.ESC+"[3;"+(n+1)+"~":r.key=L.ESC+"[3~";break;case 36:n?r.key=L.ESC+"[1;"+(n+1)+"H":t?r.key=L.ESC+"OH":r.key=L.ESC+"[H";break;case 35:n?r.key=L.ESC+"[1;"+(n+1)+"F":t?r.key=L.ESC+"OF":r.key=L.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=L.ESC+"[5;"+(n+1)+"~":r.key=L.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=L.ESC+"[6;"+(n+1)+"~":r.key=L.ESC+"[6~";break;case 112:n?r.key=L.ESC+"[1;"+(n+1)+"P":r.key=L.ESC+"OP";break;case 113:n?r.key=L.ESC+"[1;"+(n+1)+"Q":r.key=L.ESC+"OQ";break;case 114:n?r.key=L.ESC+"[1;"+(n+1)+"R":r.key=L.ESC+"OR";break;case 115:n?r.key=L.ESC+"[1;"+(n+1)+"S":r.key=L.ESC+"OS";break;case 116:n?r.key=L.ESC+"[15;"+(n+1)+"~":r.key=L.ESC+"[15~";break;case 117:n?r.key=L.ESC+"[17;"+(n+1)+"~":r.key=L.ESC+"[17~";break;case 118:n?r.key=L.ESC+"[18;"+(n+1)+"~":r.key=L.ESC+"[18~";break;case 119:n?r.key=L.ESC+"[19;"+(n+1)+"~":r.key=L.ESC+"[19~";break;case 120:n?r.key=L.ESC+"[20;"+(n+1)+"~":r.key=L.ESC+"[20~";break;case 121:n?r.key=L.ESC+"[21;"+(n+1)+"~":r.key=L.ESC+"[21~";break;case 122:n?r.key=L.ESC+"[23;"+(n+1)+"~":r.key=L.ESC+"[23~";break;case 123:n?r.key=L.ESC+"[24;"+(n+1)+"~":r.key=L.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=L.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=L.DEL:e.keyCode===219?r.key=L.ESC:e.keyCode===220?r.key=L.FS:e.keyCode===221&&(r.key=L.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=Vf[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=L.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=L.ESC+l}else if(e.keyCode===32)r.key=L.ESC+(e.ctrlKey?L.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=L.ESC+h,r.cancel=!0}}else i&&!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=L.US),e.key==="@"&&(r.key=L.NUL));break}return r}var Ee=0,Gf=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Es,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Es,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,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(Ee=this._search(t),Ee===-1)||this._getKey(this._array[Ee])!==t)return!1;do if(this._array[Ee]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ee),!0;while(++Ee<this._array.length&&this._getKey(this._array[Ee])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(Ee=this._search(e),!(Ee<0||Ee>=this._array.length)&&this._getKey(this._array[Ee])===e))do yield this._array[Ee];while(++Ee<this._array.length&&this._getKey(this._array[Ee])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ee=this._search(e),!(Ee<0||Ee>=this._array.length)&&this._getKey(this._array[Ee])===e))do t(this._array[Ee]);while(++Ee<this._array.length&&this._getKey(this._array[Ee])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},kr=0,Ua=0,Yf=class extends Q{constructor(){super(),this._decorations=new Gf(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new I),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new I),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(me(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Jf(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{kr=r.options.x??0,Ua=kr+(r.options.width??1),e>=kr&&e<Ua&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},Jf=class extends qt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new I),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new I),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()}},Zf=1e3,Xf=class{constructor(e,t=Zf){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},qa=20,Bs=class extends Q{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,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 n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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 Xf(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
32
|
-
`))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(G(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(me(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<qa+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
33
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===qa+1&&(this._liveRegion.textContent+=Wr.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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(){var a;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let u=h instanceof Text?h.parentNode:h,f=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(f))return console.warn("row is invalid. Race condition?"),null;let c=this._rowColumns.get(u);if(!c)return console.warn("columns is null. Race condition?"),null;let _=l<c.length?c[l]:c.slice(-1)[0]+1;return _>=this._terminal.cols&&(++f,_=0),{row:f,column:_}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Bs=ke([F(1,zn),F(2,At),F(3,Tt)],Bs);var wn=class extends Q{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new I),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new I),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(me(()=>{var n;Zt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(G(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(G(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(G(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(G(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];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){var s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,a=>{var l,u;if(this._isMouseOut)return;let h=a==null?void 0:a.map(f=>({link:f}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=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&&s){let o=s.find(a=>this._linkAtPosition(a.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Qf(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,Zt(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:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};wn=ke([F(1,Hn),F(2,Tt),F(3,Ze),F(4,Hl)],wn);function Qf(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var e_=class extends $f{constructor(e={}){super(e),this._linkifier=this._register(new di),this.browser=rh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new di),this._onCursorMove=this._register(new I),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new I),this.onKey=this._onKey.event,this._onRender=this._register(new I),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new I),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new I),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new I),this.onBell=this._onBell.event,this._onFocus=this._register(new I),this._onBlur=this._register(new I),this._onA11yCharEmitter=this._register(new I),this._onA11yTabEmitter=this._register(new I),this._onWillOpen=this._register(new I),this._setup(),this._decorationService=this._instantiationService.createInstance(Yf),this._instantiationService.setService(Hi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Uu),this._instantiationService.setService(Hl,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ur)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 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(Ve.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ve.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ve.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ve.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(me(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=ge.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${L.ESC}]${s};${Hf(r)}${ih.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Re.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=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(Bs,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(L.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(G(this.element,"copy",t=>{this.hasSelection()&&sd(t,this._selectionService)}));let e=t=>rd(t,this.textarea,this.coreService,this.optionsService);this._register(G(this.textarea,"paste",e)),this._register(G(this.element,"paste",e)),nh?this._register(G(this.element,"mousedown",t=>{t.button===2&&Qo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(G(this.element,"contextmenu",t=>{Qo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jn&&this._register(G(this.element,"auxclick",t=>{t.button===1&&Dl(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(G(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(G(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(G(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(G(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(G(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(G(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(G(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;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"),((r=this.element)==null?void 0:r.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(G(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Hr.get()),lh||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Wu,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(At,this._coreBrowserService),this._register(G(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(G(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(cn,this._document,this._helperContainer),this._instantiationService.setService(Ns,this._charSizeService),this._themeService=this._instantiationService.createInstance(_n),this._instantiationService.setService(ui,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Cs),this._instantiationService.setService(zl,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(un,this.rows,this.screenElement)),this._instantiationService.setService(Tt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(an,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(dn),this._instantiationService.setService(Hn,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(wn,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(nn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(fn,this.element,this.screenElement,s)),this._instantiationService.setService(ud,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ve.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(on,this.screenElement)),this._register(G(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(Bs,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xs,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xs,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(hn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,u,f,c,_;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(n,(c=(f=(u=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:u.device)==null?void 0:f.cell)==null?void 0:c.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;h=p<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(G(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(G(t,"wheel",n=>{var o,a,h,l,u;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let f=L.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(f,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){Ml(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,i){this._selectionService.setSelection(e,t,i)}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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.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 i=jf(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===L.ETX||i.key===L.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(t_(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){var i;(i=this._charSizeService)==null||i.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(Me));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(L.ESC+"[I"):this.coreService.triggerDataEvent(L.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${L.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function t_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var i_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},s_=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 dt)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Ka=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 s_(t)}getNullCell(){return new dt}},r_=class extends Q{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new I),this.onBufferChange=this._onBufferChange.event,this._normal=new Ka(this._core.buffers.normal,"normal"),this._alternate=new Ka(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)}},n_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},o_=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}},a_=["cols","rows"],vt=0,l_=class extends Q{constructor(e){super(),this._core=this._register(new e_(e)),this._addonManager=this._register(new i_),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(a_.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 n_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new o_(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 r_(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
|
|
34
|
-
`,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 Hr.get()},set promptLabel(e){Hr.set(e)},get tooMuchOutput(){return Wr.get()},set tooMuchOutput(e){Wr.set(e)}}}_verifyIntegers(...e){for(vt of e)if(vt===1/0||isNaN(vt)||vt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(vt of e)if(vt&&(vt===1/0||isNaN(vt)||vt%1!==0||vt<0))throw new Error("This API only accepts positive integers")}};/**
|
|
35
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
36
|
-
* @license MIT
|
|
37
|
-
*
|
|
38
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
39
|
-
* @license MIT
|
|
40
|
-
*
|
|
41
|
-
* Originally forked from (with the author's permission):
|
|
42
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
43
|
-
* http://bellard.org/jslinux/
|
|
44
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
45
|
-
*/var h_=2,c_=1,d_=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(){var f;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:((f=this._terminal.options.overviewRuler)==null?void 0:f.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,u=r-h-t;return{cols:Math.max(h_,Math.floor(u/e.css.cell.width)),rows:Math.max(c_,Math.floor(l/e.css.cell.height))}}};const J=Ye;(function(e,t){const i=Ye,s=e();for(;;)try{if(-parseInt(i(221))/1+-parseInt(i(266))/2+parseInt(i(214))/3*(parseInt(i(217))/4)+parseInt(i(246))/5+parseInt(i(210))/6+-parseInt(i(211))/7*(parseInt(i(231))/8)+parseInt(i(271))/9===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ls,937160);function Ls(){const e=["i2e0mguYnG","AgLKzgvU","i2zMntu1nq","iZi0mJKYzG","iZmXotjHyq","Bg9HzefKzg9U","iZyYnZjHna","Dg91y2HZDgfYDa","mJrTt214Bfa","iZu3nJa2yq","y29UBMvJDa","i2jKotnMoq","CM93CW","zML0","B2zMC2v0v2LKDgG","DMLZAwjPBgL0EwnOyw5Nzq","i2nMmJiYzq","i2e0zMzMzG","iZiXmJiYyW","i2zMzMzHnq","Dg91y2HTB3zL","iZa5nJLKyq","iZyZm2mWmq","mtm2otmYmenACNf5vq","y2XPzw50wq","i2yXzMe4yW","i2zKztjKnG","BM9Uzq","zgfYAW","D3jPDgu","ywjZ","iZy5zMy5na","i2zMzMzMzG","i2y4zJHMmG","i0zdrKjgoq","iZGYntbKzG","C3vJy2vZCW","i2e0nZvMoq","B2zM","Dg91y2HLBMq","BM93","zw1PDa","zxjYB3i","mJyZodaXnhfSBwHPAa","i0zgntCWqq","iZHIztLMza","C2nYB2XStgLUzxm","B2zMC2v0sgvPz2H0","ode2ndq0mgfPBvD5zG","iZfHmweXyq","AM9PBLnLC3nPB24","iZuWzMe3yG","iZiXogjMzG","iZzLnZC4mq","iZHJotu5zG","B3v0Chv0","Dhj1BMm","rMfPBgvKihrVigPVAw4GC2vZC2LVBG","i2zMnZLJnG","iZfIn2m4mW","Dg91y2HLCW","mteWmJGXmJzsy3bADeK","mtyWmdGYm3LyDNbKsq","i2zMotjKzG","B3bLBG","nZm4ownnwK1tAG","zgLZCg9Zzq","CMvZzxq","mtm2nerAthLHvW","iZfHn2yZnW","CMvTB3zLrxzLBNrmAxn0zw5LCG","yNvMzMvY","ote2nJK0CfzQCurV","iZrKmMqWma"];return Ls=function(){return e},Ls()}const $a={dark:{background:J(272),foreground:"#ededed",cursor:"#FF570A",cursorAccent:J(272),selectionBackground:"#3a3a3a",black:J(241),red:J(225),green:J(274),yellow:J(248),blue:J(234),magenta:J(207),cyan:J(268),white:J(256),brightBlack:J(229),brightRed:"#ff6e6e",brightGreen:J(254),brightYellow:J(242),brightBlue:"#d6acff",brightMagenta:J(212),brightCyan:J(240),brightWhite:J(255)},light:{background:J(257),foreground:J(272),cursor:J(267),cursorAccent:J(257),selectionBackground:J(249),black:J(226),red:J(239),green:"#116329",yellow:J(222),blue:J(244),magenta:J(258),cyan:J(208),white:J(276),brightBlack:J(232),brightRed:J(223),brightGreen:J(218),brightYellow:J(245),brightBlue:J(275),brightMagenta:J(260),brightCyan:J(227),brightWhite:J(277)}};function Ye(e,t){e=e-204;const i=Ls();let s=i[e];if(Ye.ZXRzcV===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};Ye.tgdsjI=r,Ye.nLxLSN={},Ye.ZXRzcV=!0}const n=i[0],o=e+n,a=Ye.nLxLSN[o];return a?s=a:(s=Ye.tgdsjI(s),Ye.nLxLSN[o]=s),s}const u_=5,f_=e=>!!e&&e.charCodeAt(0)!==27,__={cursorBlink:!0,fontSize:14,fontFamily:'"SF Mono", "Cascadia Code", Menlo, Monaco, "Courier New", monospace',scrollback:1e4,convertEol:!0,allowProposedApi:!0,scrollOnUserInput:!0,fastScrollModifier:J(250),smoothScrollDuration:0};function xn(e){const t=J;return $a[e]||$a[t(251)]}function p_(e,{theme:t=J(251)}={}){const i=J,s=new l_({...__,theme:xn(t)}),r=new d_;return s[i(228)](r),s[i(213)](e),{term:s,fitAddon:r,doFit:()=>{const a=i;!e[a(237)]||!e[a(270)]||r[a(236)]()},dispose:()=>{const a=i;r[a(215)](),s[a(215)]()}}}function g_(e,t,i){const s=J,r=n=>{const o=Ye;if(!n||n.sessionId!==i)return;const{data:a}=n;a instanceof ArrayBuffer||a&&a[o(220)]?e[o(252)](new Uint8Array(a)):typeof a=="string"?e[o(252)](a):e.write(String(a))};return t.on(s(204),r),()=>t[s(261)]("output",r)}function m_(e,t,{onSuccess:i,onError:s}={}){const r=J;e[r(264)](r(273),t,n=>{const o=r;n!=null&&n[o(259)]?i==null||i(n):s==null||s((n==null?void 0:n[o(265)])||o(206))})}function v_(e,t,i){const s=J,r=()=>{e[Ye(216)](),i()};return t.on(s(233),r),()=>t[s(261)](s(233),r)}function y_(e){const t=J,i=()=>{const s=Ye;document[s(224)]||e.refresh(0,e[s(235)]-1)};return document.addEventListener(t(238),i),()=>document[t(219)](t(238),i)}function b_(e,t){const i=J,s=16,r=1,n=.95,o=.05;let a=0,h=0,l=0,u=0,f=null;const c=()=>{f&&(cancelAnimationFrame(f),f=null)},_=()=>{const m=Ye;if(Math[m(253)](l)<o){f=null;return}u+=l;const E=Math[m(205)](u/s);E!==0&&(e[m(269)](E),u-=E*s),l*=n,f=requestAnimationFrame(_)},p=m=>{const E=Ye;c(),a=m[E(209)][0][E(247)],h=Date[E(263)](),l=0,u=0},g=m=>{const E=Ye,b=m[E(209)][0].clientY,S=Date[E(263)](),D=(a-b)*r,k=S-h||1;u+=D;const R=Math[E(205)](u/s);R!==0&&(e[E(269)](R),u-=R*s),l=D/k*16,a=b,h=S},y=()=>{Math[Ye(253)](l)>o&&(f=requestAnimationFrame(_))};return t.addEventListener(i(230),p,{passive:!0}),t.addEventListener(i(243),g,{passive:!0}),t.addEventListener(i(262),y,{passive:!0}),()=>{const m=i;c(),t[m(219)](m(230),p),t[m(219)]("touchmove",g),t[m(219)](m(262),y)}}function S_({socket:e,sessionId:t,theme:i="dark",isFocused:s,onActivate:r,onInput:n,showFocusBorder:o,showDoneBorder:a}){const h=$e(null),l=$e(null),u=$e(null),[f,c]=K(!1);ce(()=>{var x;if(!h.current||!e||!t)return;const{term:g,fitAddon:y,doFit:m,dispose:E}=p_(h.current,{theme:i});l.current=g,u.current=y;let b=null;const S=new ResizeObserver(()=>{b&&clearTimeout(b),b=setTimeout(()=>{requestAnimationFrame(()=>{y.fit(),e.emit("resize",{sessionId:t,cols:g.cols,rows:g.rows})})},150)});S.observe(h.current);const D=g_(g,e,t),k=()=>{const M=g.buffer.active;c(M.baseY-M.viewportY>u_)},R=g.onScroll(k),P=g.onWriteParsed(k),A=()=>{m(),e.emit("resize",{sessionId:t,cols:g.cols,rows:g.rows}),g.reset(),m_(e,t,{onSuccess:()=>setTimeout(m,100),onError:M=>g.write(`\r
|
|
46
|
-
\x1B[1;31mError: ${M}\x1B[0m\r
|
|
47
|
-
`)})};A(),s&&g.focus();const H=v_(g,e,A),C=y_(g),w=(x=g.element)==null?void 0:x.querySelector(".xterm-screen"),v=w?b_(g,w):()=>{};return()=>{S.disconnect(),D(),H(),C(),v(),b&&clearTimeout(b),R.dispose(),P.dispose(),E(),l.current=null}},[e,t]),ce(()=>{if(!l.current||!e||!t||!s)return;const g=l.current.onData(y=>{f_(y)&&(n==null||n(t)),e.emit("input",{sessionId:t,data:y})});return()=>g.dispose()},[s,e,t,n]),ce(()=>{l.current&&(l.current.options.theme=xn(i))},[i]),ce(()=>{if(!s||!l.current)return;l.current.focus();const g=setTimeout(()=>{var E;const y=u.current,m=l.current;!y||!m||!((E=h.current)!=null&&E.offsetWidth)||(y.fit(),e.emit("resize",{sessionId:t,cols:m.cols,rows:m.rows}))},100);return()=>clearTimeout(g)},[s,t,e]);const _=()=>{var g;return(g=l.current)==null?void 0:g.scrollToBottom()};return d("div",{className:`h-full w-full flex flex-col overflow-hidden relative ${a?"terminal-done-border":o&&s?"terminal-focus-glow":""}`,style:{background:xn(i).background},onMouseDown:()=>{s||r==null||r(t)},children:d("div",{className:"terminal-wrapper flex-1 min-h-0 overflow-hidden px-1 py-0.5 relative",children:[d("div",{ref:h,className:"w-full h-full"}),f&&d("button",{onMouseDown:g=>{g.preventDefault(),g.stopPropagation()},onClick:g=>{g.stopPropagation(),_()},className:"absolute bottom-5 right-7 z-50 p-2 rounded-full shadow-md transition-all duration-150 ease-out active:scale-[0.94]",style:{background:"var(--surface-2)",color:"var(--text-main)"},title:"Scroll to bottom",children:d(ze,{name:"chevronDown",size:20})})]})})}const Va=760,w_=500,ja={id:null,name:"Ungrouped"};function x_({socket:e,sessions:t,groups:i=[],openedIds:s,activeId:r,connected:n,theme:o="dark",finishedIds:a,clearFinished:h,onSwitch:l,onCreate:u,onCreateNamed:f,onRename:c,onDelete:_,onSelectGroup:p,onBack:g}){var Qe;const{t:y}=ti(),[m,E]=K(typeof window<"u"?window.innerWidth>=Va:!1),[b,S]=K(!1),[D,k]=K(""),[R,P]=K({sessionId:null,x:0,y:0}),A=$e(null),[H,C]=K(null),[w,v]=K(""),[x,M]=K(!1),[z,U]=K(""),[T,Z]=K(null),ne=$e(null),pe=$e(null),we=$e(null),_e=$e(null),oe=$e(null),W=$e({}),ee=t.find(B=>B.id===r),V=()=>{if(!e||!ee)return;const B=D===""?"\r":D;h==null||h(ee.id),e.emit("input",{sessionId:ee.id,data:B}),D!==""&&k("")};ce(()=>{if(!R.sessionId)return;const B=ve=>{A.current&&!A.current.contains(ve.target)&&P({sessionId:null,x:0,y:0})},le=ve=>{ve.key==="Escape"&&P({sessionId:null,x:0,y:0})};return document.addEventListener("mousedown",B),document.addEventListener("touchstart",B),document.addEventListener("keydown",le),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("touchstart",B),document.removeEventListener("keydown",le)}},[R.sessionId]);const de=(B,le)=>{B.preventDefault(),P({sessionId:le.id,x:B.clientX,y:B.clientY})},re=B=>{C(B.id),v(B.name||""),P({sessionId:null,x:0,y:0})},je=B=>{w.trim()&&(c==null||c(B,w.trim())),C(null),v("")},ot=()=>{const B=z.trim()||null;M(!1),U(""),f?f(Ie,B):u==null||u(Ie)},qe=B=>`Term ${t.filter(ve=>(ve.groupId||null)===B).length+1}`;ce(()=>{let B=0;const le=()=>{clearTimeout(B),B=setTimeout(()=>E(window.innerWidth>=Va),50)};return window.addEventListener("resize",le),()=>{clearTimeout(B),window.removeEventListener("resize",le)}},[]),ce(()=>{if(!b)return;const B=le=>{ne.current&&!ne.current.contains(le.target)&&S(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[b]),ce(()=>{we.current&&pe.current&&we.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[r]),ce(()=>{if(!m)return;const B=W.current[r];if(!B)return;const le=requestAnimationFrame(()=>B.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"}));return()=>cancelAnimationFrame(le)},[r,m,s]),ce(()=>{x&&requestAnimationFrame(()=>{var B,le;(B=_e.current)==null||B.focus(),(le=_e.current)==null||le.select()})},[x]),ce(()=>{H&&requestAnimationFrame(()=>{var B,le;(B=oe.current)==null||B.focus(),(le=oe.current)==null||le.select()})},[H]);const ie=t.find(B=>B.id===r),Ie=(ie==null?void 0:ie.groupId)||null,tt=t.filter(B=>(B.groupId||null)===Ie),$=tt.filter(B=>s.includes(B.id)),ae=$.length>1,O=t.some(B=>!B.groupId),j=[...i,...O?[ja]:[]],pt=((Qe=i.find(B=>B.id===Ie))==null?void 0:Qe.name)||ja.name,it=j.length>1,si=B=>t.some(le=>(le.groupId||null)===B&&(a==null?void 0:a.has(le.id)));return d("div",{className:"fixed inset-0 z-50 flex flex-col",style:{background:"var(--bg-body)"},children:[d("div",{className:"px-2 sm:px-4 pt-2 pb-1 flex items-center gap-2 flex-shrink-0 relative z-10",children:[d("button",{onClick:g,title:y("terminal.backToSessions"),className:"p-1.5 rounded-lg transition-all duration-150 ease-out active:scale-[0.94] flex-shrink-0 term-btn",style:{background:"var(--surface-2)",color:"var(--text-main)"},children:d(ze,{name:"chevronLeft",size:18})}),it&&d("div",{ref:ne,className:"relative flex-shrink-0",children:[d("button",{onClick:()=>S(B=>!B),className:"px-2 py-1.5 rounded-lg transition-all duration-150 ease-out flex items-center gap-1 max-w-[160px] term-btn",style:{background:"var(--surface-2)",color:"var(--text-main)"},title:y("terminal.switchGroup"),children:[d("span",{className:"truncate text-sm font-medium",children:pt}),j.some(B=>B.id!==Ie&&si(B.id))&&d("span",{className:"w-1.5 h-1.5 rounded-full term-tab-done-dot",style:{background:"#f59e0b"}}),d(ze,{name:"chevronDown",size:14})]}),b&&d("div",{className:"absolute left-0 top-full mt-1 z-30 rounded-lg shadow-lg py-1 min-w-[160px]",style:{background:"var(--surface)",border:"1px solid var(--border)"},children:j.map(B=>d("button",{onClick:()=>{p==null||p(B.id),S(!1)},className:"w-full text-left px-3 py-1.5 text-sm transition term-group-item flex items-center justify-between gap-2",style:{color:B.id===Ie?"var(--brand-500)":"var(--text-main)"},children:[d("span",{className:"truncate",children:B.name}),si(B.id)&&d("span",{className:"w-1.5 h-1.5 rounded-full term-tab-done-dot flex-shrink-0",style:{background:"#f59e0b"}})]},B.id||"ungrouped"))})]}),d("div",{ref:pe,className:"flex-1 overflow-x-auto overflow-y-hidden",children:d("div",{className:"flex gap-0.5 min-w-max items-center",children:[tt.map(B=>{const le=B.id===r;return d("button",{ref:le?we:null,onClick:()=>l==null?void 0:l(B.id),onContextMenu:ve=>de(ve,B),className:`px-2 py-1.5 text-sm font-medium transition-all duration-150 ease-out flex items-center gap-2 whitespace-nowrap term-tab${le?" term-tab-active":""}`,style:{color:le?"var(--brand-500)":"var(--text-muted)"},children:[d("span",{className:`w-1.5 h-1.5 rounded-full${a!=null&&a.has(B.id)?" term-tab-done-dot":""}`,style:{background:a!=null&&a.has(B.id)?"#f59e0b":n?"#22c55e":"#ef4444"}}),H===B.id?d("input",{type:"text",ref:oe,value:w,onClick:ve=>ve.stopPropagation(),onInput:ve=>v(ve.target.value),onKeyDown:ve=>{ve.key==="Enter"&&je(B.id),ve.key==="Escape"&&(C(null),v(""))},onBlur:()=>je(B.id),className:"bg-transparent border-b outline-none max-w-[120px]",style:{borderColor:"var(--brand-500)",color:"var(--text-main)"}}):d("span",{className:"truncate max-w-[120px]",children:B.name||B.id})]},B.id)}),d("button",{onClick:()=>n&&(U(qe(Ie)),M(!0)),disabled:!n,title:y("terminal.newTerminal"),className:"p-1.5 ml-1 rounded-lg transition-all duration-150 ease-out active:scale-[0.94] flex-shrink-0 term-btn",style:{background:"var(--surface-2)",color:"var(--text-muted)",opacity:n?1:.4,cursor:n?"pointer":"not-allowed"},children:d(ze,{name:"plus",size:18})})]})})]}),d("div",{className:`flex-1 min-h-0 relative z-10 ${m?"flex flex-row overflow-x-auto overflow-y-hidden":"relative"}`,children:$.map(B=>{const le=B.id===r;return d("div",{ref:ve=>{ve?W.current[B.id]=ve:delete W.current[B.id]},className:m?"flex-1 h-full border-r":`absolute inset-0 ${le?"opacity-100 z-10":"opacity-0 z-0 pointer-events-none"}`,style:m?{minWidth:`${w_}px`,borderColor:"var(--border)"}:void 0,children:d(S_,{socket:e,sessionId:B.id,theme:o,isFocused:le,onActivate:l,onInput:h,showFocusBorder:m&&ae,showDoneBorder:a==null?void 0:a.has(B.id)})},B.id)})}),ee&&d("div",{className:"flex items-center gap-2 px-2 py-1.5 flex-shrink-0 relative z-10",style:{background:"var(--surface)",borderTop:"1px solid var(--border)"},children:[d("div",{className:"relative flex-1",children:[d("textarea",{value:D,rows:Math.min(2,(D.match(/\n/g)||[]).length+1),onInput:B=>k(B.target.value),onKeyDown:B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),V())},placeholder:y("terminal.typeCommand"),className:"w-full px-3 py-1.5 pr-8 rounded-lg text-sm resize-none focus:outline-none focus:ring-2 focus:ring-brand-500/40",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}),D&&d("button",{onMouseDown:B=>B.preventDefault(),onClick:()=>k(""),className:"absolute right-2 top-1/2 -translate-y-1/2 w-5 h-5 flex items-center justify-center rounded-full",style:{color:"var(--text-muted)"},"aria-label":"Clear",children:d(ze,{name:"plus",size:14,className:"rotate-45"})})]}),d("button",{onClick:V,className:"btn-primary px-4 py-1.5 text-sm font-semibold flex-shrink-0 min-w-[72px] flex items-center justify-center",children:D.trim()?y("terminal.send"):d(ze,{name:"cornerDownLeft",size:16,strokeWidth:2.5})})]}),R.sessionId&&d("div",{ref:A,className:"fixed z-[60] py-1 min-w-[140px]",style:{left:R.x,top:R.y,background:"var(--surface-2)",border:"1px solid var(--border)",borderRadius:"var(--radius-brand)",boxShadow:"var(--header-shadow, 0 2px 12px rgba(0,0,0,0.3))"},children:[d("button",{onClick:()=>re(t.find(B=>B.id===R.sessionId)),className:"w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 card-act",style:{color:"var(--text-main)"},children:[d(ze,{name:"pencil",size:14})," ",y("common.rename")]}),d("button",{onClick:()=>{const B=t.find(le=>le.id===R.sessionId);Z({id:B==null?void 0:B.id,name:(B==null?void 0:B.name)||(B==null?void 0:B.id)}),P({sessionId:null,x:0,y:0})},className:"w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 card-del",style:{color:"var(--text-main)"},children:[d(ze,{name:"trash",size:14})," ",y("common.delete")]})]}),x&&d("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.6)"},onClick:()=>M(!1),children:d("div",{className:"glass-card p-5 w-80",onClick:B=>B.stopPropagation(),children:[d("p",{className:"text-sm font-semibold mb-3",style:{color:"var(--text-main)"},children:"New Terminal"}),d("div",{className:"relative mb-4",children:[d("input",{type:"text",ref:_e,value:z,placeholder:qe(Ie),onInput:B=>U(B.target.value),onKeyDown:B=>{B.key==="Enter"&&ot(),B.key==="Escape"&&M(!1)},className:"w-full px-3 py-2 pr-8 rounded-lg text-sm focus:outline-none",style:{background:"var(--surface-2)",color:"var(--text-main)",border:"1px solid var(--border)"}}),z&&d("button",{onMouseDown:B=>B.preventDefault(),onClick:()=>U(""),className:"absolute right-2 top-1/2 -translate-y-1/2 w-5 h-5 flex items-center justify-center rounded-full",style:{color:"var(--text-muted)"},children:d(ze,{name:"plus",size:14,className:"rotate-45"})})]}),d("div",{className:"flex gap-2",children:[d("button",{onClick:ot,className:"btn-primary flex-1 py-2 text-sm font-semibold",children:y("common.create")}),d("button",{onClick:()=>{U(""),M(!1)},className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:y("common.cancel")})]})]})}),T&&d("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.6)"},onClick:()=>Z(null),children:d("div",{className:"glass-card p-5 w-80",onClick:B=>B.stopPropagation(),children:[d("p",{className:"text-sm mb-4",style:{color:"var(--text-main)"},children:y("terminal.deleteConfirm",{name:T.name})}),d("div",{className:"flex gap-2",children:[d("button",{onClick:()=>{T!=null&&T.id&&(_==null||_(T.id)),Z(null)},className:"flex-1 py-2 text-sm font-semibold text-white rounded-lg",style:{background:"#ef4444"},children:y("common.delete")}),d("button",{onClick:()=>Z(null),className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:y("common.cancel")})]})]})})]})}const Ct=Object.create(null);Ct.open="0";Ct.close="1";Ct.ping="2";Ct.pong="3";Ct.message="4";Ct.upgrade="5";Ct.noop="6";const hs=Object.create(null);Object.keys(Ct).forEach(e=>{hs[Ct[e]]=e});const Cn={type:"error",data:"parser error"},vh=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yh=typeof ArrayBuffer=="function",bh=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Gn=({type:e,data:t},i,s)=>vh&&t instanceof Blob?i?s(t):Ga(t,s):yh&&(t instanceof ArrayBuffer||bh(t))?i?s(t):Ga(new Blob([t]),s):s(Ct[e]+(t||"")),Ga=(e,t)=>{const i=new FileReader;return i.onload=function(){const s=i.result.split(",")[1];t("b"+(s||""))},i.readAsDataURL(e)};function Ya(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Er;function C_(e,t){if(vh&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ya).then(t);if(yh&&(e.data instanceof ArrayBuffer||bh(e.data)))return t(Ya(e.data));Gn(e,!1,i=>{Er||(Er=new TextEncoder),t(Er.encode(i))})}const Ja="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ri=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ja.length;e++)Ri[Ja.charCodeAt(e)]=e;const k_=e=>{let t=e.length*.75,i=e.length,s,r=0,n,o,a,h;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const l=new ArrayBuffer(t),u=new Uint8Array(l);for(s=0;s<i;s+=4)n=Ri[e.charCodeAt(s)],o=Ri[e.charCodeAt(s+1)],a=Ri[e.charCodeAt(s+2)],h=Ri[e.charCodeAt(s+3)],u[r++]=n<<2|o>>4,u[r++]=(o&15)<<4|a>>2,u[r++]=(a&3)<<6|h&63;return l},E_=typeof ArrayBuffer=="function",Yn=(e,t)=>{if(typeof e!="string")return{type:"message",data:Sh(e,t)};const i=e.charAt(0);return i==="b"?{type:"message",data:B_(e.substring(1),t)}:hs[i]?e.length>1?{type:hs[i],data:e.substring(1)}:{type:hs[i]}:Cn},B_=(e,t)=>{if(E_){const i=k_(e);return Sh(i,t)}else return{base64:!0,data:e}},Sh=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},wh="",L_=(e,t)=>{const i=e.length,s=new Array(i);let r=0;e.forEach((n,o)=>{Gn(n,!1,a=>{s[o]=a,++r===i&&t(s.join(wh))})})},M_=(e,t)=>{const i=e.split(wh),s=[];for(let r=0;r<i.length;r++){const n=Yn(i[r],t);if(s.push(n),n.type==="error")break}return s};function D_(){return new TransformStream({transform(e,t){C_(e,i=>{const s=i.length;let r;if(s<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,s);else if(s<65536){r=new Uint8Array(3);const n=new DataView(r.buffer);n.setUint8(0,126),n.setUint16(1,s)}else{r=new Uint8Array(9);const n=new DataView(r.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(s))}e.data&&typeof e.data!="string"&&(r[0]|=128),t.enqueue(r),t.enqueue(i)})}})}let Br;function Zi(e){return e.reduce((t,i)=>t+i.length,0)}function Xi(e,t){if(e[0].length===t)return e.shift();const i=new Uint8Array(t);let s=0;for(let r=0;r<t;r++)i[r]=e[0][s++],s===e[0].length&&(e.shift(),s=0);return e.length&&s<e[0].length&&(e[0]=e[0].slice(s)),i}function R_(e,t){Br||(Br=new TextDecoder);const i=[];let s=0,r=-1,n=!1;return new TransformStream({transform(o,a){for(i.push(o);;){if(s===0){if(Zi(i)<1)break;const h=Xi(i,1);n=(h[0]&128)===128,r=h[0]&127,r<126?s=3:r===126?s=1:s=2}else if(s===1){if(Zi(i)<2)break;const h=Xi(i,2);r=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(Zi(i)<8)break;const h=Xi(i,8),l=new DataView(h.buffer,h.byteOffset,h.length),u=l.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue(Cn);break}r=u*Math.pow(2,32)+l.getUint32(4),s=3}else{if(Zi(i)<r)break;const h=Xi(i,r);a.enqueue(Yn(n?h:Br.decode(h),t)),s=0}if(r===0||r>e){a.enqueue(Cn);break}}}})}const xh=4;function Ae(e){if(e)return A_(e)}function A_(e){for(var t in Ae.prototype)e[t]=Ae.prototype[t];return e}Ae.prototype.on=Ae.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Ae.prototype.once=function(e,t){function i(){this.off(e,i),t.apply(this,arguments)}return i.fn=t,this.on(e,i),this};Ae.prototype.off=Ae.prototype.removeListener=Ae.prototype.removeAllListeners=Ae.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+e];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var s,r=0;r<i.length;r++)if(s=i[r],s===t||s.fn===t){i.splice(r,1);break}return i.length===0&&delete this._callbacks["$"+e],this};Ae.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),i=this._callbacks["$"+e],s=1;s<arguments.length;s++)t[s-1]=arguments[s];if(i){i=i.slice(0);for(var s=0,r=i.length;s<r;++s)i[s].apply(this,t)}return this};Ae.prototype.emitReserved=Ae.prototype.emit;Ae.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Ae.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Os=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,i)=>i(t,0),ct=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),T_="arraybuffer";function Ch(e,...t){return t.reduce((i,s)=>(e.hasOwnProperty(s)&&(i[s]=e[s]),i),{})}const N_=ct.setTimeout,P_=ct.clearTimeout;function zs(e,t){t.useNativeTimers?(e.setTimeoutFn=N_.bind(ct),e.clearTimeoutFn=P_.bind(ct)):(e.setTimeoutFn=ct.setTimeout.bind(ct),e.clearTimeoutFn=ct.clearTimeout.bind(ct))}const I_=1.33;function O_(e){return typeof e=="string"?z_(e):Math.ceil((e.byteLength||e.size)*I_)}function z_(e){let t=0,i=0;for(let s=0,r=e.length;s<r;s++)t=e.charCodeAt(s),t<128?i+=1:t<2048?i+=2:t<55296||t>=57344?i+=3:(s++,i+=4);return i}function kh(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function H_(e){let t="";for(let i in e)e.hasOwnProperty(i)&&(t.length&&(t+="&"),t+=encodeURIComponent(i)+"="+encodeURIComponent(e[i]));return t}function W_(e){let t={},i=e.split("&");for(let s=0,r=i.length;s<r;s++){let n=i[s].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}class F_ extends Error{constructor(t,i,s){super(t),this.description=i,this.context=s,this.type="TransportError"}}class Jn extends Ae{constructor(t){super(),this.writable=!1,zs(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,i,s){return super.emitReserved("error",new F_(t,i,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const i=Yn(t,this.socket.binaryType);this.onPacket(i)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,i={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(i)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const i=H_(t);return i.length?"?"+i:""}}class U_ extends Jn{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const i=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||i()})),this.writable||(s++,this.once("drain",function(){--s||i()}))}else i()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const i=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};M_(t,this.socket.binaryType).forEach(i),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,L_(t,i=>{this.doWrite(i,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",i=this.query||{};return this.opts.timestampRequests!==!1&&(i[this.opts.timestampParam]=kh()),!this.supportsBinary&&!i.sid&&(i.b64=1),this.createUri(t,i)}}let Eh=!1;try{Eh=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const q_=Eh;function K_(){}class $_ extends U_{constructor(t){if(super(t),typeof location<"u"){const i=location.protocol==="https:";let s=location.port;s||(s=i?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||s!==t.port}}doWrite(t,i){const s=this.request({method:"POST",data:t});s.on("success",i),s.on("error",(r,n)=>{this.onError("xhr post error",r,n)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(i,s)=>{this.onError("xhr poll error",i,s)}),this.pollXhr=t}}class wt extends Ae{constructor(t,i,s){super(),this.createRequest=t,zs(this,s),this._opts=s,this._method=s.method||"GET",this._uri=i,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var t;const i=Ch(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");i.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(i);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&s.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var r;s.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=wt.requestsCount++,wt.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=K_,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete wt.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}wt.requestsCount=0;wt.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Za);else if(typeof addEventListener=="function"){const e="onpagehide"in ct?"pagehide":"unload";addEventListener(e,Za,!1)}}function Za(){for(let e in wt.requests)wt.requests.hasOwnProperty(e)&&wt.requests[e].abort()}const V_=(function(){const e=Bh({xdomain:!1});return e&&e.responseType!==null})();class j_ extends $_{constructor(t){super(t);const i=t&&t.forceBase64;this.supportsBinary=V_&&!i}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new wt(Bh,this.uri(),t)}}function Bh(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||q_))return new XMLHttpRequest}catch{}if(!t)try{return new ct[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Lh=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class G_ extends Jn{get name(){return"websocket"}doOpen(){const t=this.uri(),i=this.opts.protocols,s=Lh?{}:Ch(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,i,s)}catch(r){return this.emitReserved("error",r)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const s=t[i],r=i===t.length-1;Gn(s,this.supportsBinary,n=>{try{this.doWrite(s,n)}catch{}r&&Os(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",i=this.query||{};return this.opts.timestampRequests&&(i[this.opts.timestampParam]=kh()),this.supportsBinary||(i.b64=1),this.createUri(t,i)}}const Lr=ct.WebSocket||ct.MozWebSocket;class Y_ extends G_{createSocket(t,i,s){return Lh?new Lr(t,i,s):i?new Lr(t,i):new Lr(t)}doWrite(t,i){this.ws.send(i)}}class J_ extends Jn{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const i=R_(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(i).getReader(),r=D_();r.readable.pipeTo(t.writable),this._writer=r.writable.getWriter();const n=()=>{s.read().then(({done:a,value:h})=>{a||(this.onPacket(h),n())}).catch(a=>{})};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let i=0;i<t.length;i++){const s=t[i],r=i===t.length-1;this._writer.write(s).then(()=>{r&&Os(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Z_={websocket:Y_,webtransport:J_,polling:j_},X_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Q_=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function kn(e){if(e.length>8e3)throw"URI too long";const t=e,i=e.indexOf("["),s=e.indexOf("]");i!=-1&&s!=-1&&(e=e.substring(0,i)+e.substring(i,s).replace(/:/g,";")+e.substring(s,e.length));let r=X_.exec(e||""),n={},o=14;for(;o--;)n[Q_[o]]=r[o]||"";return i!=-1&&s!=-1&&(n.source=t,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=ep(n,n.path),n.queryKey=tp(n,n.query),n}function ep(e,t){const i=/\/{2,9}/g,s=t.replace(i,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&s.splice(0,1),t.slice(-1)=="/"&&s.splice(s.length-1,1),s}function tp(e,t){const i={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,r,n){r&&(i[r]=n)}),i}const En=typeof addEventListener=="function"&&typeof removeEventListener=="function",cs=[];En&&addEventListener("offline",()=>{cs.forEach(e=>e())},!1);class Kt extends Ae{constructor(t,i){if(super(),this.binaryType=T_,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(i=t,t=null),t){const s=kn(t);i.hostname=s.host,i.secure=s.protocol==="https"||s.protocol==="wss",i.port=s.port,s.query&&(i.query=s.query)}else i.host&&(i.hostname=kn(i.host).host);zs(this,i),this.secure=i.secure!=null?i.secure:typeof location<"u"&&location.protocol==="https:",i.hostname&&!i.port&&(i.port=this.secure?"443":"80"),this.hostname=i.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=i.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},i.transports.forEach(s=>{const r=s.prototype.name;this.transports.push(r),this._transportsByName[r]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},i),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=W_(this.opts.query)),En&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},cs.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const i=Object.assign({},this.opts.query);i.EIO=xh,i.transport=t,this.id&&(i.sid=this.id);const s=Object.assign({},this.opts,{query:i,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Kt.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const i=this.createTransport(t);i.open(),this.setTransport(i)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",i=>this._onClose("transport close",i))}onOpen(){this.readyState="open",Kt.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const i=new Error("server error");i.code=t.data,this._onError(i);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let i=1;for(let s=0;s<this.writeBuffer.length;s++){const r=this.writeBuffer[s].data;if(r&&(i+=O_(r)),s>0&&i>this._maxPayload)return this.writeBuffer.slice(0,s);i+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Os(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,i,s){return this._sendPacket("message",t,i,s),this}send(t,i,s){return this._sendPacket("message",t,i,s),this}_sendPacket(t,i,s,r){if(typeof i=="function"&&(r=i,i=void 0),typeof s=="function"&&(r=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const n={type:t,data:i,options:s};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),r&&this.once("flush",r),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},i=()=>{this.off("upgrade",i),this.off("upgradeError",i),t()},s=()=>{this.once("upgrade",i),this.once("upgradeError",i)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}_onError(t){if(Kt.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,i){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),En&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=cs.indexOf(this._offlineEventListener);s!==-1&&cs.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,i),this.writeBuffer=[],this._prevBufferLen=0}}}Kt.protocol=xh;class ip extends Kt{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let i=this.createTransport(t),s=!1;Kt.priorWebsocketSuccess=!1;const r=()=>{s||(i.send([{type:"ping",data:"probe"}]),i.once("packet",f=>{if(!s)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",i),!i)return;Kt.priorWebsocketSuccess=i.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(u(),this.setTransport(i),i.send([{type:"upgrade"}]),this.emitReserved("upgrade",i),i=null,this.upgrading=!1,this.flush())})}else{const c=new Error("probe error");c.transport=i.name,this.emitReserved("upgradeError",c)}}))};function n(){s||(s=!0,u(),i.close(),i=null)}const o=f=>{const c=new Error("probe error: "+f);c.transport=i.name,n(),this.emitReserved("upgradeError",c)};function a(){o("transport closed")}function h(){o("socket closed")}function l(f){i&&f.name!==i.name&&n()}const u=()=>{i.removeListener("open",r),i.removeListener("error",o),i.removeListener("close",a),this.off("close",h),this.off("upgrading",l)};i.once("open",r),i.once("error",o),i.once("close",a),this.once("close",h),this.once("upgrading",l),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{s||i.open()},200):i.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const i=[];for(let s=0;s<t.length;s++)~this.transports.indexOf(t[s])&&i.push(t[s]);return i}}let sp=class extends ip{constructor(t,i={}){const s=typeof t=="object"?t:i;(!s.transports||s.transports&&typeof s.transports[0]=="string")&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(r=>Z_[r]).filter(r=>!!r)),super(t,s)}};function rp(e,t="",i){let s=e;i=i||typeof location<"u"&&location,e==null&&(e=i.protocol+"//"+i.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=i.protocol+e:e=i.host+e),/^(https?|wss?):\/\//.test(e)||(typeof i<"u"?e=i.protocol+"//"+e:e="https://"+e),s=kn(e)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const n=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+t,s.href=s.protocol+"://"+n+(i&&i.port===s.port?"":":"+s.port),s}const np=typeof ArrayBuffer=="function",op=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Mh=Object.prototype.toString,ap=typeof Blob=="function"||typeof Blob<"u"&&Mh.call(Blob)==="[object BlobConstructor]",lp=typeof File=="function"||typeof File<"u"&&Mh.call(File)==="[object FileConstructor]";function Zn(e){return np&&(e instanceof ArrayBuffer||op(e))||ap&&e instanceof Blob||lp&&e instanceof File}function ds(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let i=0,s=e.length;i<s;i++)if(ds(e[i]))return!0;return!1}if(Zn(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return ds(e.toJSON(),!0);for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&ds(e[i]))return!0;return!1}function hp(e){const t=[],i=e.data,s=e;return s.data=Bn(i,t),s.attachments=t.length,{packet:s,buffers:t}}function Bn(e,t){if(!e)return e;if(Zn(e)){const i={_placeholder:!0,num:t.length};return t.push(e),i}else if(Array.isArray(e)){const i=new Array(e.length);for(let s=0;s<e.length;s++)i[s]=Bn(e[s],t);return i}else if(typeof e=="object"&&!(e instanceof Date)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=Bn(e[s],t));return i}return e}function cp(e,t){return e.data=Ln(e.data,t),delete e.attachments,e}function Ln(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let i=0;i<e.length;i++)e[i]=Ln(e[i],t);else if(typeof e=="object")for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(e[i]=Ln(e[i],t));return e}const dp=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var se;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(se||(se={}));class up{constructor(t){this.replacer=t}encode(t){return(t.type===se.EVENT||t.type===se.ACK)&&ds(t)?this.encodeAsBinary({type:t.type===se.EVENT?se.BINARY_EVENT:se.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let i=""+t.type;return(t.type===se.BINARY_EVENT||t.type===se.BINARY_ACK)&&(i+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(i+=t.nsp+","),t.id!=null&&(i+=t.id),t.data!=null&&(i+=JSON.stringify(t.data,this.replacer)),i}encodeAsBinary(t){const i=hp(t),s=this.encodeAsString(i.packet),r=i.buffers;return r.unshift(s),r}}class Xn extends Ae{constructor(t){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof t=="function"?{reviver:t}:t)}add(t){let i;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");i=this.decodeString(t);const s=i.type===se.BINARY_EVENT;s||i.type===se.BINARY_ACK?(i.type=s?se.EVENT:se.ACK,this.reconstructor=new fp(i),i.attachments===0&&super.emitReserved("decoded",i)):super.emitReserved("decoded",i)}else if(Zn(t)||t.base64)if(this.reconstructor)i=this.reconstructor.takeBinaryData(t),i&&(this.reconstructor=null,super.emitReserved("decoded",i));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let i=0;const s={type:Number(t.charAt(0))};if(se[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===se.BINARY_EVENT||s.type===se.BINARY_ACK){const n=i+1;for(;t.charAt(++i)!=="-"&&i!=t.length;);const o=t.substring(n,i);if(o!=Number(o)||t.charAt(i)!=="-")throw new Error("Illegal attachments");const a=Number(o);if(!_p(a)||a<0)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=a}if(t.charAt(i+1)==="/"){const n=i+1;for(;++i&&!(t.charAt(i)===","||i===t.length););s.nsp=t.substring(n,i)}else s.nsp="/";const r=t.charAt(i+1);if(r!==""&&Number(r)==r){const n=i+1;for(;++i;){const o=t.charAt(i);if(o==null||Number(o)!=o){--i;break}if(i===t.length)break}s.id=Number(t.substring(n,i+1))}if(t.charAt(++i)){const n=this.tryParse(t.substr(i));if(Xn.isPayloadValid(s.type,n))s.data=n;else throw new Error("invalid payload")}return s}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,i){switch(t){case se.CONNECT:return Xa(i);case se.DISCONNECT:return i===void 0;case se.CONNECT_ERROR:return typeof i=="string"||Xa(i);case se.EVENT:case se.BINARY_EVENT:return Array.isArray(i)&&(typeof i[0]=="number"||typeof i[0]=="string"&&dp.indexOf(i[0])===-1);case se.ACK:case se.BINARY_ACK:return Array.isArray(i)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class fp{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const i=cp(this.reconPack,this.buffers);return this.finishedReconstruction(),i}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const _p=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Xa(e){return Object.prototype.toString.call(e)==="[object Object]"}const pp=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Xn,Encoder:up,get PacketType(){return se}},Symbol.toStringTag,{value:"Module"}));function ft(e,t,i){return e.on(t,i),function(){e.off(t,i)}}const gp=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Dh extends Ae{constructor(t,i,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=i,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[ft(t,"open",this.onopen.bind(this)),ft(t,"packet",this.onpacket.bind(this)),ft(t,"error",this.onerror.bind(this)),ft(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...i){var s,r,n;if(gp.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(i.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(i),this;const o={type:se.EVENT,data:i};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof i[i.length-1]=="function"){const u=this.ids++,f=i.pop();this._registerAckCallback(u,f),o.id=u}const a=(r=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||r===void 0?void 0:r.writable,h=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!a||(h?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,i){var s;const r=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(r===void 0){this.acks[t]=i;return}const n=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);i.call(this,new Error("operation has timed out"))},r),o=(...a)=>{this.io.clearTimeoutFn(n),i.apply(this,a)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...i){return new Promise((s,r)=>{const n=(o,a)=>o?r(o):s(a);n.withError=!0,i.push(n),this.emit(t,...i)})}_addToQueue(t){let i;typeof t[t.length-1]=="function"&&(i=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((r,...n)=>(this._queue[0],r!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),i&&i(r)):(this._queue.shift(),i&&i(null,...n)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const i=this._queue[0];i.pending&&!t||(i.pending=!0,i.tryCount++,this.flags=i.flags,this.emit.apply(this,i.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:se.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,i){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,i),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(s=>String(s.id)===t)){const s=this.acks[t];delete this.acks[t],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case se.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case se.EVENT:case se.BINARY_EVENT:this.onevent(t);break;case se.ACK:case se.BINARY_ACK:this.onack(t);break;case se.DISCONNECT:this.ondisconnect();break;case se.CONNECT_ERROR:this.destroy();const s=new Error(t.data.message);s.data=t.data.data,this.emitReserved("connect_error",s);break}}onevent(t){const i=t.data||[];t.id!=null&&i.push(this.ack(t.id)),this.connected?this.emitEvent(i):this.receiveBuffer.push(Object.freeze(i))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const i=this._anyListeners.slice();for(const s of i)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const i=this;let s=!1;return function(...r){s||(s=!0,i.packet({type:se.ACK,id:t,data:r}))}}onack(t){const i=this.acks[t.id];typeof i=="function"&&(delete this.acks[t.id],i.withError&&t.data.unshift(null),i.apply(this,t.data))}onconnect(t,i){this.id=t,this.recovered=i&&this._pid===i,this._pid=i,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:se.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const i=this._anyListeners;for(let s=0;s<i.length;s++)if(t===i[s])return i.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const i=this._anyOutgoingListeners;for(let s=0;s<i.length;s++)if(t===i[s])return i.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const i=this._anyOutgoingListeners.slice();for(const s of i)s.apply(this,t.data)}}}function _i(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}_i.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),i=Math.floor(t*this.jitter*e);e=(Math.floor(t*10)&1)==0?e-i:e+i}return Math.min(e,this.max)|0};_i.prototype.reset=function(){this.attempts=0};_i.prototype.setMin=function(e){this.ms=e};_i.prototype.setMax=function(e){this.max=e};_i.prototype.setJitter=function(e){this.jitter=e};class Mn extends Ae{constructor(t,i){var s;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(i=t,t=void 0),i=i||{},i.path=i.path||"/socket.io",this.opts=i,zs(this,i),this.reconnection(i.reconnection!==!1),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor((s=i.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new _i({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(i.timeout==null?2e4:i.timeout),this._readyState="closed",this.uri=t;const r=i.parser||pp;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=i.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var i;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(i=this.backoff)===null||i===void 0||i.setMin(t),this)}randomizationFactor(t){var i;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(i=this.backoff)===null||i===void 0||i.setJitter(t),this)}reconnectionDelayMax(t){var i;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(i=this.backoff)===null||i===void 0||i.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new sp(this.uri,this.opts);const i=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=ft(i,"open",function(){s.onopen(),t&&t()}),n=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},o=ft(i,"error",n);if(this._timeout!==!1){const a=this._timeout,h=this.setTimeoutFn(()=>{r(),n(new Error("timeout")),i.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(r),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(ft(t,"ping",this.onping.bind(this)),ft(t,"data",this.ondata.bind(this)),ft(t,"error",this.onerror.bind(this)),ft(t,"close",this.onclose.bind(this)),ft(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(i){this.onclose("parse error",i)}}ondecoded(t){Os(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,i){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new Dh(this,t,i),this.nsps[t]=s),s}_destroy(t){const i=Object.keys(this.nsps);for(const s of i)if(this.nsps[s].active)return;this._close()}_packet(t){const i=this.encoder.encode(t);for(let s=0;s<i.length;s++)this.engine.write(i[s],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,i){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,i),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const i=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(r=>{r?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",r)):t.onreconnect()}))},i);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const xi={};function us(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const i=rp(e,t.path||"/socket.io"),s=i.source,r=i.id,n=i.path,o=xi[r]&&n in xi[r].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let h;return a?h=new Mn(s,t):(xi[r]||(xi[r]=new Mn(s,t)),h=xi[r]),i.query&&!t.query&&(t.query=i.queryKey),h.socket(i.path,t)}Object.assign(us,{Manager:Mn,Socket:Dh,io:us,connect:us});(function(e,t){const i=_t,s=e();for(;;)try{if(-parseInt(i(143))/1+-parseInt(i(155))/2+parseInt(i(160))/3*(parseInt(i(156))/4)+-parseInt(i(153))/5*(-parseInt(i(152))/6)+parseInt(i(162))/7+-parseInt(i(146))/8*(parseInt(i(133))/9)+parseInt(i(171))/10===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ms,132452);let Ci=null;function _t(e,t){e=e-130;const i=Ms();let s=i[e];if(_t.aFDJyD===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};_t.YAWggQ=r,_t.CbAEte={},_t.aFDJyD=!0}const n=i[0],o=e+n,a=_t.CbAEte[o];return a?s=a:(s=_t.YAWggQ(s),_t.CbAEte[o]=s),s}function Ms(){const e=["y29UBMvJDgvK","mJK0otfVrvfcv2e","AxnbCNjHEq","CMvUyw1Lu2vZC2LVBG","y2f0y2G","Bg9JywWTDwK","BM90AwzPy2f0Aw9Uu3rHDgu","A2v5CW","C2vZC2LVBKnSB3nLza","C2vZC2LVBI1Yzw5HBwvK","mZu4mZCYmfrwENfzta","ywrK","C2vZC2LVBKLK","z2v0u2vZC2LVBNm","ndqWmZDgA3vUD28","y3jLyxrLu2vZC2LVBG","zgvSzxrLu2vZC2LVBG","zgvSzxrLr3jVDxa","l2fWAs9SB2nHBc10B2TLBG","DgHLBG","zgvSzxrL","yxv0Aa","y2XLyxjoB3rPzMLJyxrPB24","zgLZy29UBMvJDa","mJiXmtCXtejcze1M","y29UBMvJDa","y3jLyxrLr3jVDxa","mJK2tKDOsK1N","zw1PDa","BM90AwzPy2f0Aw9Uq2XLyxjLza","ANnVBG","z3jVDxbZq2HHBMDLza","z2v0tM90AwzPy2f0Aw9Uu3rHDgu","mJK4mdjPELfQuLm","mJq1BvDlBKvw","D2vIC29JA2v0","mJi5mtyYEfHsy09X","ngfpDxvVBW","B2zM","CMvUyw1Lr3jVDxa","y3vYCMvUDa","mti5odmXD2PTufLr"];return Ms=function(){return e},Ms()}function mp(){const e=_t;return!Ci&&(Ci=us({transports:[e(154)],autoConnect:!1,auth:{deviceId:e(166)}}),fetch(e(137)).then(t=>t[e(149)]())[e(138)](t=>{const i=e;Ci[i(140)]={deviceId:i(166),localToken:t.localToken}})[e(165)](()=>{}).finally(()=>Ci.connect())),Ci}function vp(){const e=_t,t=mp(),[i,s]=K(t[e(161)]),[r,n]=K([]),[o,a]=K([]),[h,l]=K(()=>new Set),u=()=>{const b=e;t[b(147)](b(132),S=>n(Array[b(163)](S)?S:[])),t[b(147)]("getGroups",S=>a(Array.isArray(S)?S:[]))},f=$e(u);return f[e(159)]=u,ce(()=>{const b=e,S=()=>{const C=_t;s(!0),f[C(159)]()},D=()=>s(!1),k=()=>f[b(159)](),R=C=>{const w=b;C!=null&&C[w(131)]&&l(v=>new Set(v)[w(130)](C[w(131)]))},P=C=>l(new Set(Object[b(168)](C||{}))),A=C=>l(w=>{const v=b;if(!w.has(C))return w;const x=new Set(w);return x[v(139)](C),x}),H=()=>{const C=b;S(),t[C(147)](C(151))};return t.on("connect",H),t.on(b(142),D),t.on(b(169),k),t.on(b(150),k),t.on(b(170),k),t.on("chatNotification",R),t.on(b(167),P),t.on(b(148),A),t[b(161)]&&H(),()=>{const C=b;t[C(157)](C(144),H),t.off("disconnect",D),t[C(157)](C(169),k),t[C(157)](C(150),k),t[C(157)]("session-renamed",k),t[C(157)]("chatNotification",R),t[C(157)](C(167),P),t[C(157)](C(148),A)}},[]),{socket:t,connected:i,sessions:r,groups:o,finishedIds:h,clearFinished:b=>{const S=e;l(D=>{if(!D.has(b))return D;const k=new Set(D);return k.delete(b),k}),t[S(147)](S(141),b)},refresh:u,createSession:(b,S,D)=>t[e(147)](e(134),{groupId:b||null,name:D||null},k=>{u(),S==null||S(k)}),deleteSession:b=>t[e(147)](e(135),b,()=>u()),renameSession:(b,S)=>t[e(147)](e(164),{sessionId:b,name:S},()=>u()),createGroup:(b,S)=>t.emit(e(145),{name:b},D=>{u(),S==null||S(D)}),renameGroup:(b,S)=>t[e(147)](e(158),{groupId:b,name:S},()=>u()),deleteGroup:b=>t[e(147)](e(136),{groupId:b},()=>u())}}const Hs=Mt;(function(e,t){const i=Mt,s=e();for(;;)try{if(-parseInt(i(139))/1*(-parseInt(i(136))/2)+-parseInt(i(146))/3*(parseInt(i(141))/4)+parseInt(i(143))/5+-parseInt(i(148))/6*(parseInt(i(133))/7)+parseInt(i(134))/8+parseInt(i(142))/9*(-parseInt(i(132))/10)+parseInt(i(135))/11===t)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ds,617237);const yp=Hs(138),Mr=Hs(140),bp=400;function Mt(e,t){e=e-132;const i=Ds();let s=i[e];if(Mt.JzMCGt===void 0){var r=function(h){const l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=";let u="",f="";for(let c=0,_,p,g=0;p=h.charAt(g++);~p&&(_=c%4?_*64+p:p,c++%4)?u+=String.fromCharCode(255&_>>(-2*c&6)):0)p=l.indexOf(p);for(let c=0,_=u.length;c<_;c++)f+="%"+("00"+u.charCodeAt(c).toString(16)).slice(-2);return decodeURIComponent(f)};Mt.hvrOYY=r,Mt.lgZAaY={},Mt.JzMCGt=!0}const n=i[0],o=e+n,a=Mt.lgZAaY[o];return a?s=a:(s=Mt.hvrOYY(s),Mt.lgZAaY[o]=s),s}let ki=null,li=0,Rh=0;function Qa(){const e=Hs,t=Mr[e(144)](li)+Mr[e(144)](0,li);document[e(147)]="("+Rh+e(137)+t,li=(li+1)%Mr[e(145)]}function el(e){const t=Hs;Rh=e,e>0?!ki&&(li=0,Qa(),ki=setInterval(Qa,bp)):(ki&&(clearInterval(ki),ki=null),li=0,document[t(147)]=yp)}function Ds(){const e=["mta0mJG2mgzKsvvLqW","C2XPy2u","BgvUz3rO","nJqZotG5quvnEuT1","DgL0Bgu","nJm3nJyYu2TutgXS","mtuWz1LoCLrJ","nJnnyvLhrem","odu5mtGZmK54yKLxuq","mtC4odmWnJnSvvfRzMu","mZG5mdbuvK1Irvu","ksdWN5suia","ovjLBw90zq","mtDuvKzAwLy","ovjLBw90zsdIGkiG","mtjetuTIEuq","nJeYnZi5u0fRzhjL"];return Ds=function(){return e},Ds()}const Sp="https://docs.9remote.cc/",Qn=[{id:"connection",label:"Connection",icon:"hub",desc:"Pair devices and manage your secure tunnel"},{id:"terminals",label:"Terminals",icon:"terminal",desc:"Live terminal sessions running on this host"},{id:"logs",label:"Logs",icon:"description",desc:"Server activity and diagnostics"}],wp="connection",eo="terminals",Qi=()=>{const[e,t]=window.location.pathname.replace(/^\/+/,"").split("/"),i=Qn.some(r=>r.id===e)?e:wp,s=i===eo&&t?decodeURIComponent(t):null;return{menu:i,sessionId:s}},xp=(e,t)=>e===eo&&t?`/${e}/${encodeURIComponent(t)}`:`/${e}`,Ah=e=>({screenRecording:{label:e("remote.screenRecording"),icon:"screenshot_monitor",desc:e("remote.captureScreen")},accessibility:{label:e("remote.accessibility"),icon:"accessibility_new",desc:e("remote.controlMouseKeyboard")}});function Cp({type:e,granted:t,onRequest:i,t:s}){const r=Ah(s)[e]||{label:e,desc:""};return d("div",{className:"flex items-center gap-2 py-2",children:[d("span",{className:`material-symbols-outlined flex-shrink-0 ${t?"text-green-400":""}`,style:{fontSize:18,color:t?void 0:"var(--text-muted)"},children:t?"check_circle":"cancel"}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-xs font-medium",style:{color:t?"var(--text-main)":"var(--text-muted)"},children:r.label}),d("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:r.desc})]}),!t&&d("button",{onClick:()=>i(e),title:"Click to grant permission",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:"var(--border)",cursor:"pointer"},children:d("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]})}const kp=e=>({"30m":e("remote.sleepModes.30m"),"1h":e("remote.sleepModes.1h"),"2h":e("remote.sleepModes.2h"),"4h":e("remote.sleepModes.4h"),"24h":e("remote.sleepModes.24h"),never:e("remote.sleepModes.never")});function Ep({icon:e,label:t,desc:i,value:s,options:r,onChange:n}){return d("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:"var(--brand-400)"},children:e}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-xs font-medium",style:{color:"var(--text-main)"},children:t}),d("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:i})]}),d("select",{value:s,onChange:o=>n==null?void 0:n(o.target.value),className:"flex-shrink-0 text-xs px-2 py-1 rounded-lg",style:{background:"var(--glass-bg)",color:"var(--text-main)",border:"1px solid var(--border)",cursor:"pointer"},children:r.map(o=>d("option",{value:o.value,children:o.label},o.value))})]})}function Bp({icon:e,label:t,desc:i,value:s,onToggle:r,activeColor:n="var(--brand-500)"}){return d("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:s?"var(--brand-400)":"var(--text-muted)"},children:e}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-xs font-medium",style:{color:"var(--text-main)"},children:t}),d("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:i})]}),d("button",{onClick:r,className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:s?n:"var(--border)",cursor:"pointer"},children:d("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:s?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]})}function Lp({desktopEnabled:e,onDesktopToggle:t,permissions:i,onRequestPermission:s,autoStart:r,onAutoStartToggle:n,sleepInhibitMode:o,sleepInhibitPresets:a,onSleepInhibitChange:h,t:l}){const u=Object.entries(Ah(l)),c=!u.every(([_])=>!!(i!=null&&i[_]))&&!e;return d("div",{className:"glass-card conn-card p-4 flex flex-col gap-3",children:[d("div",{className:"flex flex-col gap-2",children:[d("div",{className:"flex items-center gap-3",children:[d("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:e?"rgba(var(--brand-rgb),0.15)":"var(--glass-bg)"},children:d("span",{className:"material-symbols-outlined",style:{fontSize:20,color:e?"var(--brand-400)":"var(--text-muted)"},children:"desktop_windows"})}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:l("remote.remoteDesktop")}),d("p",{className:"text-xs",style:{color:"var(--text-muted)"},children:l("remote.controlScreen")})]}),d("button",{onClick:c?void 0:t,disabled:c,title:c?l("dialogs.grantPermissions"):"",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:e?"var(--brand-500)":"var(--border)",opacity:c?.5:1,cursor:c?"not-allowed":"pointer"},children:d("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:e?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),d("div",{className:"grid grid-cols-2 gap-2 pl-12",children:u.map(([_])=>d(Cp,{type:_,granted:(i==null?void 0:i[_])??!1,onRequest:s,t:l},_))})]}),d("div",{className:"flex flex-col border-t pt-2",style:{borderColor:"var(--border)"},children:[d("p",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"Startup"}),d(Bp,{icon:"power_settings_new",label:"Launch on system startup",desc:r?"Runs in background when you log in":"Disabled — start manually",value:!!r,onToggle:n}),d(Ep,{icon:"bedtime_off",label:l("remote.preventSleep"),desc:l("remote.blockSleep"),value:o||"never",options:(a||[]).map(_=>({value:_,label:kp(l)[_]||_})),onChange:h})]})]})}function Mp({version:e}){return e?d("div",{className:"px-5 py-2 flex items-center gap-2 border-b",style:{background:"rgba(var(--brand-rgb),0.08)",borderColor:"rgba(var(--brand-rgb),0.2)"},children:[d("span",{className:"material-symbols-outlined text-sm flex-shrink-0",style:{color:"var(--brand-400)"},children:"system_update"}),d("span",{className:"text-xs flex-1",style:{color:"var(--brand-400)"},children:["Version ",e," available"]}),d("button",{onClick:()=>fetch("/api/update",{method:"POST"}).catch(()=>{}),className:"flex-shrink-0 text-xs px-2 py-0.5 rounded font-medium",style:{background:"rgba(var(--brand-rgb),0.15)",color:"var(--brand-400)"},children:"Update"})]}):null}const Dp=e=>[{icon:"terminal",label:e("connection.features.terminal"),desc:e("connection.features.fullShell")},{icon:"desktop_windows",label:e("connection.features.desktop"),desc:e("connection.features.remoteScreen")},{icon:"folder_open",label:e("connection.features.files"),desc:e("connection.features.browseEdit")}];function Rp(e,t,i=[]){const s=new Map;for(const a of t){if(!a.deviceId)continue;const h=s.get(a.deviceId);(!h||a.connectedAt&&a.connectedAt<h.connectedAt)&&s.set(a.deviceId,a)}const r=e.map(a=>{const h=s.get(a.deviceId);return{deviceId:a.deviceId,status:h?"online":"offline",ip:(h==null?void 0:h.ip)||null,connectedAt:(h==null?void 0:h.connectedAt)||null,approvedAt:a.approvedAt||null,label:a.label||""}}),n=i.map(a=>({deviceId:a.deviceId,status:"pending",ip:a.ip||null,connectedAt:null,approvedAt:null,rejectedAt:a.rejectedAt||null})),o={online:0,pending:1,offline:2};return[...r,...n].sort((a,h)=>o[a.status]-o[h.status])}const tl={online:{color:"#4ade80",icon:"wifi",title:"Online"},offline:{color:"var(--text-muted)",icon:"wifi_off",title:"Offline"},pending:{color:"#f59e0b",icon:"hourglass_top",title:"Pending approval"}};function Ap({client:e,onRemove:t,onApprove:i,onLabel:s}){const r=`${e.deviceId.slice(0,8)}...`,n=e.label||r,o=tl[e.status]||tl.offline,a=e.status==="online"?`Connected · ${e.connectedAt?new Date(e.connectedAt).toLocaleTimeString():""}`:e.status==="pending"?"Pending · waiting for approval":e.approvedAt?`Offline · approved ${new Date(e.approvedAt).toLocaleDateString()}`:"Offline",h=e.status==="online"?"Disconnect":"Remove";return d("div",{className:"flex items-center gap-3 py-2 border-b last:border-0",style:{borderColor:"var(--border)"},children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:o.color},title:o.title,children:o.icon}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-xs font-medium truncate flex items-center gap-1",style:{color:"var(--text-main)"},children:[n,e.ip?` · ${e.ip}`:"",e.status!=="pending"&&d("button",{onClick:()=>s==null?void 0:s(e),className:"material-symbols-outlined",style:{fontSize:14,color:"var(--text-muted)",cursor:"pointer"},title:"Rename this device",children:"edit"})]}),d("p",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:a})]}),e.status==="pending"&&d("button",{onClick:()=>i==null?void 0:i(e),className:"flex-shrink-0 text-xs px-2 py-1 rounded-lg font-medium",style:{background:"rgba(74,222,128,0.15)",color:"#4ade80"},title:"Approve this device",children:"Approve"}),d("button",{onClick:()=>t(e),className:"flex-shrink-0 text-xs px-2 py-1 rounded-lg font-medium",style:{background:"rgba(220,53,69,0.15)",color:"#dc3545"},title:"Disconnect and remove this device",children:h})]})}const il={healthy:{color:"#4ade80",label:"Healthy",dot:"bg-green-400"},unreachable:{color:"#dc3545",label:"Offline",dot:"bg-red-500"},unknown:{color:"var(--text-muted)",label:"Checking...",dot:"bg-gray-400"}};function Tp({icon:e,title:t,danger:i,onClick:s}){return d("button",{onClick:s,title:t,className:i?"btn-danger w-7 h-7 flex items-center justify-center":"glass-btn w-7 h-7 flex items-center justify-center",style:i?void 0:{color:"var(--text-muted)"},children:d("span",{className:"material-symbols-outlined text-sm",children:e})})}function Np({onStart:e,t}){const[i,s]=K(!1),r=()=>{s(!0),e==null||e()};return d("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 px-6 py-8 text-center max-w-md mx-auto w-full",children:[d("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--glass-bg)"},children:d("span",{className:"material-symbols-outlined",style:{fontSize:32,color:"var(--text-muted)"},children:"cloud_off"})}),d("div",{className:"flex flex-col gap-1",children:[d("p",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t("connection.tunnelOffline")}),d("p",{className:"text-xs leading-5",style:{color:"var(--text-muted)"},children:t("connection.startTunnel")})]}),d("button",{onClick:i?void 0:r,disabled:i,className:"btn-primary w-full py-3 flex items-center justify-center gap-2 text-sm font-semibold",style:{borderRadius:"var(--radius-brand)",opacity:i?.7:1},children:[d("span",{className:"material-symbols-outlined text-base",children:"play_arrow"}),t(i?"connection.connecting":"connection.connect")]}),d("div",{className:"grid grid-cols-3 gap-2 w-full",children:Dp(t).map(n=>d("div",{className:"dark-card flex flex-col items-center gap-1.5 py-3 px-1",children:[d("span",{className:"material-symbols-outlined",style:{fontSize:20,color:"var(--brand-400)"},children:n.icon}),d("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-main)"},children:n.label})]},n.label))})]})}function Pp({isStopped:e,onStop:t,onShutdown:i}){const{t:s,locale:r}=ti(),[n,o]=K(!1),[a,h]=K(!1),l=$e(null),u=Pr.find(c=>c.code===r)||Pr[0];ce(()=>{if(!n)return;const c=_=>{l.current&&!l.current.contains(_.target)&&o(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[n]);const f=c=>{o(!1),c==null||c()};return d("div",{ref:l,className:"relative",children:[d("button",{onClick:()=>o(c=>!c),title:s("header.settings"),className:"glass-btn w-7 h-7 flex items-center justify-center",children:d("span",{className:"material-symbols-outlined text-sm",children:"settings"})}),n&&d("div",{className:"absolute right-0 top-full mt-1 z-50 rounded-lg shadow-lg py-1 min-w-[200px]",style:{background:"var(--surface)",border:"1px solid var(--border)"},children:[d("button",{onClick:()=>f(()=>h(!0)),className:"w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 card-act",style:{color:"var(--text-main)"},children:[d("span",{className:"material-symbols-outlined text-base",children:"language"}),d("span",{className:"flex-1",children:[u.flag," ",u.label]})]}),d(Dr,{icon:"menu_book",label:s("header.documentation"),onClick:()=>f(()=>window.open(Sp,"_blank"))}),!e&&d(Dr,{icon:"restart_alt",label:s("header.resetShort"),onClick:()=>f(t)}),d(Dr,{icon:"power_settings_new",label:s("header.shutdownShort"),danger:!0,onClick:()=>f(i)})]}),a&&d(Ip,{onClose:()=>h(!1)})]})}function Ip({onClose:e}){const{t,locale:i,setLocale:s}=ti();return ce(()=>{const r=n=>{n.key==="Escape"&&e()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),d("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",style:{background:"rgba(0,0,0,0.6)"},onClick:e,children:d("div",{className:"glass-card p-5 flex flex-col gap-4 w-full max-w-lg max-h-[90vh]",onClick:r=>r.stopPropagation(),children:[d("div",{className:"flex items-center justify-between",children:[d("h3",{className:"text-base font-semibold",style:{color:"var(--text-main)"},children:t("header.language")}),d("button",{onClick:e,className:"material-symbols-outlined",style:{fontSize:20,color:"var(--text-muted)",cursor:"pointer"},children:"close"})]}),d("div",{className:"grid grid-cols-2 gap-2 overflow-y-auto",children:Pr.map(r=>d("button",{onClick:()=>{s(r.code),e()},className:"flex items-center gap-2 px-3 py-2 text-sm rounded-xl card-act",style:{background:r.code===i?"rgba(var(--brand-rgb),0.15)":"var(--glass-bg)",color:r.code===i?"var(--brand-400)":"var(--text-main)"},children:[d("span",{children:r.flag}),d("span",{className:"flex-1 text-left truncate",children:r.label}),r.code===i&&d("span",{className:"material-symbols-outlined",style:{fontSize:16},children:"check"})]},r.code))})]})})}function Dr({icon:e,label:t,danger:i,onClick:s}){return d("button",{onClick:s,className:"w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 card-act",style:{color:i?"#dc3545":"var(--text-main)"},children:[d("span",{className:"material-symbols-outlined text-base",children:e})," ",t]})}function sl({activeMenu:e,onSelect:t,version:i,isReady:s,tunnelHealth:r,onClose:n}){const{t:o}=ti(),a=h=>{t(h),n==null||n()};return d("aside",{className:"flex flex-col sidebar w-64 flex-shrink-0 h-full",children:[d("div",{className:"flex items-center gap-3 px-5 py-4",children:[d("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"var(--brand-500)"},children:d("span",{className:"material-symbols-outlined text-white text-base",children:"terminal"})}),d("div",{className:"flex flex-col leading-tight",children:[d("span",{className:"brand-text text-xs",children:"9Remote"}),i&&d("span",{className:"text-[10px]",style:{color:"var(--text-muted)"},children:["v",i]})]})]}),s&&d("div",{className:"px-4 pb-3 flex justify-center",children:d(zp,{tunnelHealth:r})}),d("nav",{className:"flex-1 px-4 py-2 space-y-0.5 overflow-y-auto select-none",children:Qn.map(h=>{const l=e===h.id;return d("button",{onClick:()=>a(h.id),className:"group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-all text-left",style:l?{background:"var(--brand-tint)",color:"var(--brand-500)"}:{color:"var(--text-muted)"},children:[d("span",{className:`material-symbols-outlined text-[18px] ${l?"fill-1":""}`,children:h.icon}),d("span",{className:"text-[13px] font-medium",children:o(`menu.${h.id}`)})]},h.id)})})]})}function Op({menu:e,isStopped:t,theme:i,onToggleTheme:s,onStop:r,onShutdown:n,onMenuClick:o}){const{t:a}=ti();return d("header",{className:"shrink-0 flex items-center justify-between gap-3 px-6 lg:px-10 pt-4 pb-3 border-b",style:{borderColor:"var(--border-subtle)"},children:[d("div",{className:"flex items-center gap-2 min-w-0",children:[d("button",{onClick:o,className:"md:hidden glass-btn w-8 h-8 flex items-center justify-center flex-shrink-0",style:{color:"var(--text-muted)"},"aria-label":"Open menu",children:d("span",{className:"material-symbols-outlined text-lg",children:"menu"})}),d("span",{className:"material-symbols-outlined text-xl",style:{color:"var(--brand-500)"},children:e==null?void 0:e.icon}),d("div",{className:"min-w-0",children:[d("h1",{className:"text-lg lg:text-xl font-semibold tracking-tight truncate",style:{color:"var(--text-main)"},children:e?a(`menu.${e.id}`):""}),e&&d("p",{className:"hidden lg:block text-xs truncate",style:{color:"var(--text-muted)"},children:a(`menu.${e.id}Desc`)})]})]}),d("div",{className:"flex items-center gap-1.5 shrink-0",children:[d(Tp,{icon:i==="dark"?"light_mode":"dark_mode",title:a(i==="dark"?"header.lightMode":"header.darkMode"),onClick:s}),d(Pp,{isStopped:t,onStop:r,onShutdown:n})]})]})}function zp({tunnelHealth:e}){const t=il[e==null?void 0:e.status]||il.unknown,i=e!=null&&e.checkedAt?new Date(e.checkedAt).toLocaleTimeString():"--:--:--";return d("div",{className:"inline-flex items-center justify-center gap-1.5 px-3 h-7 rounded-full glass-btn",title:`Tunnel ${t.label} · last check ${i}`,children:[d("span",{className:`w-1.5 h-1.5 rounded-full ${t.dot}`}),d("span",{className:"text-[11px] font-medium",style:{color:t.color},children:t.label})]})}function Hp({step:e,stepDesc:t="",healthCheck:i,tunnelHealth:s,tunnelUrl:r,oneTimeKey:n,oneTimeKeyExpiresAt:o,permanentKey:a,qrUrl:h,permissions:l,desktopEnabled:u,updateVersion:f,connections:c=[],version:_="",onRequestPermission:p,onDesktopToggle:g,onStop:y,onStart:m,onShutdown:E,onGenerateOneTimeKey:b,onRegenerateKey:S,logs:D=[],onClearLogs:k,theme:R,onToggleTheme:P,pendingDevice:A,onDeviceApprove:H,onDeviceReject:C,approvedDevices:w=[],rejectedDevices:v=[],onDeviceRemove:x,onFetchDevices:M,onDeviceApproveRejected:z,onDeviceLabel:U,autoApprove:T=!1,onAutoApproveToggle:Z,autoStart:ne=!1,onAutoStartToggle:pe,sleepInhibitMode:we="never",sleepInhibitPresets:_e=[],onSleepInhibitChange:oe,sessions:W=[],onSessionDelete:ee,onSessionRefresh:V}){var oo;const{t:de}=ti(),[re,je]=K(()=>Qi().menu),[ot,qe]=K(!1),[ie,Ie]=K(!1),[tt,$]=K(null),[ae,O]=K(null),[j,pt]=K(""),[it,si]=K(!1),[Qe,B]=K(null),[le,ve]=K([]),to=$e(null),te=vp(),io=q=>{je(q),q!==eo&&B(null)};ce(()=>{const q=()=>{const{menu:Y,sessionId:xe}=Qi();je(Y),B(xe)};return window.addEventListener("popstate",q),()=>window.removeEventListener("popstate",q)},[]);const so=$e(!1);ce(()=>{if(!so.current){if(!Qe&&Qi().sessionId)return;so.current=!0}const q=xp(re,Qe);window.location.pathname!==q&&window.history.pushState(null,"",q)},[re,Qe]),ce(()=>{Qe&&te.clearFinished(Qe)},[Qe]),ce(()=>(el(te.finishedIds.size),()=>el(0)),[te.finishedIds]);const ro=q=>{const Y=te.sessions.find($t=>$t.id===q),xe=(Y==null?void 0:Y.groupId)||null,Fs=te.sessions.filter($t=>($t.groupId||null)===xe).map($t=>$t.id);ve($t=>Array.from(new Set([...$t,...Fs,q]))),B(q)};ce(()=>{const{menu:q,sessionId:Y}=Qi();!Y||Qe||(te.sessions.some(xe=>xe.id===Y)?ro(Y):te.sessions.length&&window.history.replaceState(null,"",`/${q}`))},[te.sessions]),ce(()=>{const q=te.sessions.map(Y=>Y.id);ve(Y=>Y.filter(xe=>q.includes(xe)))},[te.sessions]),ce(()=>{const q=Y=>{Y===Qe&&B(null)};return te.socket.on("sessionClosed",q),()=>te.socket.off("sessionClosed",q)},[Qe,te.socket]);const Ws=e===5,no=e===0,Th=e>0&&e<5;ce(()=>{var q;re==="logs"&&((q=to.current)==null||q.scrollIntoView({behavior:"smooth"})),re==="connection"&&(M==null||M()),re==="terminals"&&te.refresh()},[D,re,c.length]);const pi=Rp(w,c,v),Nh=pi.filter(q=>q.status==="online").length,Ph=Qn.find(q=>q.id===re);return d("div",{className:"h-full w-full flex overflow-hidden",style:{background:"var(--bg-body)"},children:[d("div",{className:"hidden md:flex",children:d(sl,{activeMenu:re,onSelect:io,version:_,isReady:Ws,tunnelHealth:s})}),it&&d("div",{className:"fixed inset-0 z-40 bg-black/40 md:hidden",onClick:()=>si(!1)}),d("div",{className:`fixed inset-y-0 left-0 z-50 transform md:hidden transition-transform duration-300 ${it?"translate-x-0":"-translate-x-full"}`,children:d(sl,{activeMenu:re,onSelect:io,version:_,isReady:Ws,tunnelHealth:s,onClose:()=>si(!1)})}),d("main",{className:"flex-1 flex flex-col min-w-0 h-full relative dot-grid-bg isolate",children:[d("div",{className:"landing-grid absolute inset-0 pointer-events-none -z-10","aria-hidden":"true"}),d(Op,{menu:Ph,isStopped:no,theme:R,onToggleTheme:P,onStop:()=>qe(!0),onShutdown:()=>Ie(!0),onMenuClick:()=>si(!0)}),d(Mp,{version:f}),d("div",{className:"flex-1 overflow-y-auto p-6 lg:p-10",children:d("div",{className:"max-w-7xl mx-auto flex flex-col gap-4",children:[re==="connection"&&no&&d(Np,{onStart:m,t:de}),re==="connection"&&Th&&d("div",{className:"flex-1 flex flex-col gap-4 max-w-2xl mx-auto w-full",children:d(Jh,{currentStep:e,activeDesc:t,healthCheck:i,t:de})}),re==="connection"&&Ws&&d(Be,{children:d("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 items-stretch",children:[d("div",{className:"md:col-span-1",children:d(wc,{qrUrl:h,oneTimeKey:n,oneTimeKeyExpiresAt:o,permanentKey:a,tunnelUrl:r,onGenerateOneTimeKey:b,onRegenerateKey:S})}),d("div",{className:"md:col-span-2 flex flex-col gap-4",children:[d(Lp,{desktopEnabled:u,onDesktopToggle:g,permissions:l,onRequestPermission:p,autoStart:ne,onAutoStartToggle:pe,sleepInhibitMode:we,sleepInhibitPresets:_e,onSleepInhibitChange:oe,t:de}),d("div",{className:"glass-card conn-card p-4 flex flex-col gap-1",children:[d("p",{className:"text-xs font-medium uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:["Clients",pi.length>0?` (${Nh}/${pi.length} online)`:""]}),d("div",{className:"flex items-center gap-3 py-2 border-b",style:{borderColor:"var(--border)"},children:[d("span",{className:"material-symbols-outlined flex-shrink-0",style:{fontSize:18,color:T?"var(--brand-400)":"var(--text-muted)"},children:T?"lock_open":"lock"}),d("div",{className:"flex-1 min-w-0",children:[d("p",{className:"text-xs font-medium",style:{color:"var(--text-main)"},children:"Auto-approve new devices"}),d("p",{className:"text-[10px] leading-4",style:{color:"var(--text-muted)"},children:T?"Any new device connects without approval":"Require manual approval for new devices"})]}),d("button",{onClick:Z,title:T?"Disable auto-approve":"Enable auto-approve",className:"flex-shrink-0 w-11 h-6 rounded-full transition-all relative",style:{background:T?"var(--brand-500)":"var(--border)",cursor:"pointer"},children:d("span",{className:"absolute top-0.5 w-5 h-5 rounded-full bg-white transition-all",style:{left:T?"calc(100% - 22px)":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),pi.length===0?d("p",{className:"text-xs text-center py-3",style:{color:"var(--text-muted)"},children:"No clients yet"}):pi.map(q=>d(Ap,{client:q,onRemove:$,onApprove:Y=>z==null?void 0:z(Y.deviceId),onLabel:Y=>{O(Y),pt(Y.label||"")}},q.deviceId))]})]})]})}),re==="terminals"&&d(Xc,{sessions:te.sessions,groups:te.groups,connected:te.connected,finishedIds:te.finishedIds,onSelect:q=>{te.clearFinished(q.id),ro(q.id)},onCreate:q=>te.createSession(q),onCreateNamed:(q,Y)=>te.createSession(q,void 0,Y),onDelete:q=>te.deleteSession(q),onRename:(q,Y)=>te.renameSession(q,Y),onCreateGroup:(q,Y)=>te.createGroup(q,Y),onRenameGroup:(q,Y)=>te.renameGroup(q,Y),onDeleteGroup:q=>te.deleteGroup(q)}),re==="logs"&&d("div",{className:"flex-1 flex flex-col",children:[D.length>0&&d("div",{className:"flex justify-end mb-2 sticky top-0 z-10",children:d("button",{onClick:k,title:"Clear logs",className:"glass-btn flex items-center gap-1.5 px-2.5 h-7 text-xs",style:{color:"var(--text-muted)"},children:[d("span",{className:"material-symbols-outlined text-sm",children:"delete_sweep"})," Clear"]})}),D.length===0?d("p",{className:"text-xs text-center mt-8",style:{color:"var(--text-muted)"},children:"No logs yet"}):d("div",{className:"flex flex-col gap-0.5",children:[D.map((q,Y)=>d("p",{className:"text-xs font-mono leading-5 break-all",style:{color:"var(--text-muted)"},children:q},Y)),d("div",{ref:to})]})]})]})})]}),ot&&d(Ft,{message:"Reset and stop the tunnel? Remote clients will be disconnected.",confirmLabel:"Reset",onConfirm:()=>{qe(!1),y==null||y()},onCancel:()=>qe(!1)}),ie&&d(Ft,{message:"Shutdown 9Remote completely? This will stop the server, close the tunnel and quit the app.",confirmLabel:"Shutdown",confirmDanger:!0,onConfirm:()=>{Ie(!1),E==null||E()},onCancel:()=>Ie(!1)}),tt&&d(Ft,{message:tt.status==="online"?`Disconnect and remove device ${tt.deviceId.slice(0,8)}...? The client will be disconnected and need approval again next time.`:tt.status==="pending"?`Remove pending device ${tt.deviceId.slice(0,8)}...? It will need a fresh approval request to connect again.`:`Remove device ${tt.deviceId.slice(0,8)}...? It will need approval again next time.`,confirmLabel:tt.status==="online"?"Disconnect & Remove":"Remove",confirmDanger:!0,onConfirm:()=>{x==null||x(tt),$(null)},onCancel:()=>$(null)}),ae&&d(Ft,{message:`Name for device ${ae.deviceId.slice(0,8)}...`,confirmLabel:"Save",inputValue:j,inputPlaceholder:"e.g. My MacBook",onInput:pt,onConfirm:()=>{U==null||U(ae.deviceId,j.trim()),O(null)},onCancel:()=>O(null)}),A&&d("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.6)"},children:d("div",{className:"glass-card p-5 flex flex-col gap-4 w-80",children:[d("div",{className:"flex items-center gap-2",children:[d("span",{className:"material-symbols-outlined",style:{color:"var(--brand-500)",fontSize:24},children:"devices"}),d("span",{className:"text-sm font-semibold",style:{color:"var(--text-main)"},children:"New Device Connection"})]}),d("div",{className:"flex flex-col gap-1 text-xs",style:{color:"var(--text-muted)"},children:[d("span",{children:["Device: ",d("span",{style:{color:"var(--text-main)"},children:[(oo=A.deviceId)==null?void 0:oo.slice(0,8),"..."]})]}),d("span",{children:["IP: ",d("span",{style:{color:"var(--text-main)"},children:A.ip})]})]}),d("div",{className:"flex gap-2",children:[d("button",{onClick:C,className:"glass-btn flex-1 py-2 text-sm",style:{color:"var(--text-muted)"},children:"Reject"}),d("button",{onClick:H,className:"flex-1 py-2 text-sm font-semibold rounded-xl",style:{background:"var(--brand-500)",color:"#fff"},children:"Approve"})]})]})}),Qe&&d(x_,{socket:te.socket,sessions:te.sessions,openedIds:le,activeId:Qe,connected:te.connected,theme:R,groups:te.groups,finishedIds:te.finishedIds,clearFinished:te.clearFinished,onSwitch:q=>{te.clearFinished(q),B(q)},onSelectGroup:q=>{const Y=te.sessions.filter(xe=>(xe.groupId||null)===q).map(xe=>xe.id);ve(xe=>Array.from(new Set([...xe,...Y]))),Y[0]&&B(Y[0])},onCreate:q=>te.createSession(q,Y=>{Y!=null&&Y.success&&Y.sessionId&&(ve(xe=>Array.from(new Set([...xe,Y.sessionId]))),B(Y.sessionId))}),onCreateNamed:(q,Y)=>te.createSession(q,xe=>{xe!=null&&xe.success&&xe.sessionId&&(ve(Fs=>Array.from(new Set([...Fs,xe.sessionId]))),B(xe.sessionId))},Y),onRename:(q,Y)=>te.renameSession(q,Y),onDelete:q=>te.deleteSession(q),onBack:()=>B(null)})]})}const Wp=3e3,Dn={running:!1,timeoutMs:0,startedAt:null,logs:[]},Rn={status:"unknown",checkedAt:null},rl={step:0,stepDesc:"",tunnelUrl:"",oneTimeKey:"",oneTimeKeyExpiresAt:null,permanentKey:"",qrUrl:"",latency:null,uptime:null,healthCheck:Dn,tunnelHealth:Rn},Fp={screenRecording:!1,accessibility:!1},nl=200;function Up(){const[e,t]=K(rl),[i,s]=K(Fp),[r,n]=K(!1),[o,a]=K([]),[h,l]=K(null),[u,f]=K([]),[c,_]=K([]),[p,g]=K(null),[y,m]=K([]),[E,b]=K([]),[S,D]=K(!1),[k,R]=K(!1),[P,A]=K("never"),[H,C]=K([]),[w,v]=K(""),[x,M]=K(()=>localStorage.getItem("9remote-theme")||"dark");ce(()=>{document.documentElement.setAttribute("data-theme",x),localStorage.setItem("9remote-theme",x)},[x]);const z=()=>{M($=>$==="dark"?"light":"dark")};ce(()=>{fetch("/api/version").then(O=>O.json()).then(O=>v(O.version??"")).catch(()=>{}),fetch("/api/ui/state").then(O=>O.json()).then(O=>{t({step:O.step??0,stepDesc:O.stepDesc??"",tunnelUrl:O.tunnelUrl??"",oneTimeKey:O.oneTimeKey??"",oneTimeKeyExpiresAt:O.oneTimeKeyExpiresAt??null,permanentKey:O.permanentKey??"",qrUrl:O.qrUrl??"",latency:O.latency??null,uptime:O.uptime??null,healthCheck:O.healthCheck??Dn,tunnelHealth:O.tunnelHealth??Rn}),s({screenRecording:O.screenRecording??!1,accessibility:O.accessibility??!1}),O.desktopEnabled!==void 0&&n(O.desktopEnabled),O.theme&&(O.theme==="light"||O.theme==="dark")&&M(O.theme)}).catch(()=>{}),fetch("/api/logs").then(O=>O.json()).then(O=>{Array.isArray(O==null?void 0:O.logs)&&a(O.logs)}).catch(()=>{});const $=new EventSource("/api/ui/events");$.onmessage=O=>{try{const j=JSON.parse(O.data);j.type==="state"?t({step:j.step??0,stepDesc:j.stepDesc??"",tunnelUrl:j.tunnelUrl??"",oneTimeKey:j.oneTimeKey??"",oneTimeKeyExpiresAt:j.oneTimeKeyExpiresAt??null,permanentKey:j.permanentKey??"",qrUrl:j.qrUrl??"",latency:j.latency??null,uptime:j.uptime??null,healthCheck:j.healthCheck??Dn,tunnelHealth:j.tunnelHealth??Rn}):j.type==="log"?a(pt=>{const it=[...pt,j.message];return it.length>nl?it.slice(-nl):it}):j.type==="updateAvailable"?l(j.version):j.type==="permissions"?(s({screenRecording:j.screenRecording,accessibility:j.accessibility}),j.desktopEnabled!==void 0&&n(j.desktopEnabled)):j.type==="connections"?f(j.connections??[]):j.type==="deviceApproval"&&j.action==="pending"?g({socketId:j.socketId,deviceId:j.deviceId,ip:j.ip}):j.type==="deviceApproval"&&j.action==="refresh"?oe():j.type==="autostart"?R(!!j.enabled):j.type==="sleepInhibit"&&(j.mode&&A(j.mode),Array.isArray(j.presets)&&C(j.presets))}catch{}},$.onerror=()=>{},fetch("/api/device/auto-approve").then(O=>O.json()).then(O=>{D(!!(O!=null&&O.enabled))}).catch(()=>{}),fetch("/api/autostart").then(O=>O.json()).then(O=>{R(!!(O!=null&&O.enabled))}).catch(()=>{}),fetch("/api/sleep-inhibit").then(O=>O.json()).then(O=>{O!=null&&O.mode&&A(O.mode),Array.isArray(O==null?void 0:O.presets)&&C(O.presets)}).catch(()=>{});const ae=setInterval(async()=>{var O;if(!U.current)try{const j=await fetch("/api/device/pending");if(!j.ok)return;const pt=await j.json(),it=(O=pt==null?void 0:pt.pending)==null?void 0:O[0];it&&!U.current&&g({socketId:it.socketId,deviceId:it.deviceId,ip:it.ip})}catch{}},Wp);return()=>{$.close(),clearInterval(ae)}},[]);const U=$e(null);ce(()=>{U.current=p},[p]);const T=async $=>{await fetch("/api/permissions/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:$})}).catch(()=>{})},Z=()=>{fetch("/api/ui/stop",{method:"POST"}).catch(()=>{})},ne=()=>{fetch("/api/ui/start",{method:"POST"}).catch(()=>{})},pe=()=>{fetch("/api/ui/shutdown",{method:"POST"}).catch(()=>{}),t(rl)},we=async()=>{const $=await fetch("/api/key/one-time",{method:"POST"}).catch(()=>null);if(!($!=null&&$.ok))return;const ae=await $.json().catch(()=>null);ae!=null&&ae.oneTimeKey&&t(O=>({...O,oneTimeKey:ae.oneTimeKey,oneTimeKeyExpiresAt:ae.expiresAt,qrUrl:ae.qrUrl??O.qrUrl}))},_e=async()=>{const $=!r;n($),await fetch("/api/desktop/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:$})}).catch(()=>{})},oe=async()=>{try{const[$,ae]=await Promise.all([fetch("/api/device/approved"),fetch("/api/device/rejected")]);if($.ok){const O=await $.json();m(O.devices||[])}if(ae.ok){const O=await ae.json();b(O.rejected||[])}}catch{}},W=async()=>{try{const $=await fetch("/api/sessions");if($.ok){const ae=await $.json();_(ae.sessions||[])}}catch{}},ee=async $=>{await fetch("/api/sessions/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:$})}).catch(()=>{}),W()},V=async $=>{const ae=$.status==="pending"?"/api/device/clear-rejected":"/api/device/remove";await fetch(ae,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:$.deviceId})}).catch(()=>{}),oe()},de=async()=>{p&&(await fetch("/api/device/approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({socketId:p.socketId})}).catch(()=>{}),g(null),oe())},re=async()=>{p&&(await fetch("/api/device/reject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({socketId:p.socketId})}).catch(()=>{}),g(null),oe())},je=async()=>{const $=!k;R($);try{const O=await(await fetch("/api/autostart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:$})})).json().catch(()=>null);O&&typeof O.enabled=="boolean"&&R(O.enabled)}catch{R(!$)}},ot=async $=>{const ae=P;A($);try{const j=await(await fetch("/api/sleep-inhibit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:$})})).json().catch(()=>null);j!=null&&j.mode&&A(j.mode)}catch{A(ae)}},qe=async()=>{const $=!S;D($);try{const O=await(await fetch("/api/device/auto-approve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:$})})).json().catch(()=>null);O&&typeof O.enabled=="boolean"&&D(O.enabled)}catch{D(!$)}},ie=async $=>{await fetch("/api/device/approve-rejected",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:$})}).catch(()=>{}),oe()},Ie=async($,ae)=>{await fetch("/api/device/label",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceId:$,label:ae})}).catch(()=>{}),oe()},tt=async()=>{const $=await fetch("/api/key/regenerate",{method:"POST"}).catch(()=>null);if(!($!=null&&$.ok))return;const ae=await $.json().catch(()=>null);ae!=null&&ae.permanentKey&&t(O=>({...O,permanentKey:ae.permanentKey}))};return d(Hp,{step:e.step,stepDesc:e.stepDesc,healthCheck:e.healthCheck,tunnelHealth:e.tunnelHealth,tunnelUrl:e.tunnelUrl,oneTimeKey:e.oneTimeKey,oneTimeKeyExpiresAt:e.oneTimeKeyExpiresAt,permanentKey:e.permanentKey,qrUrl:e.qrUrl,permissions:i,desktopEnabled:r,updateVersion:h,connections:u,onRequestPermission:T,onDesktopToggle:_e,onStop:Z,onStart:ne,onShutdown:pe,onGenerateOneTimeKey:we,onRegenerateKey:tt,logs:o,onClearLogs:()=>a([]),version:w,theme:x,onToggleTheme:z,pendingDevice:p,onDeviceApprove:de,onDeviceReject:re,approvedDevices:y,rejectedDevices:E,onDeviceRemove:V,onFetchDevices:oe,sessions:c,onSessionRefresh:W,onSessionDelete:ee,onDeviceApproveRejected:ie,onDeviceLabel:Ie,autoApprove:S,onAutoApproveToggle:qe,autoStart:k,onAutoStartToggle:je,sleepInhibitMode:P,sleepInhibitPresets:H,onSleepInhibitChange:ot})}qh(d(Up,{}),document.getElementById("root"));
|